diff options
author | Zack Weinberg <zackw@panix.com> | 2007-03-26 21:00:20 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2007-03-26 21:00:20 +0000 |
commit | 17defa6a13ef4f317e22dcb3827b4e8ea1b37541 (patch) | |
tree | bc7cc4d9040d552a301d8fe6061ec59da8a396fe /gcc | |
parent | 95161faf6d635df17a7792840aa73600624b11fb (diff) | |
download | gcc-17defa6a13ef4f317e22dcb3827b4e8ea1b37541.zip gcc-17defa6a13ef4f317e22dcb3827b4e8ea1b37541.tar.gz gcc-17defa6a13ef4f317e22dcb3827b4e8ea1b37541.tar.bz2 |
gengtype-lex.l: Distinguish unions from structures in the token type.
* gengtype-lex.l: Distinguish unions from structures in the
token type. Don't call find_structure; return the tag as a string.
* gengtype-yacc.y: Add new token types ENT_TYPEDEF_UNION and ENT_UNION.
Type of these, ENT_TYPEDEF_STRUCT, and ENT_STRUCT is string.
Reorganize typedef_struct production accordingly.
Use create_nested_ptr_option.
* gengtype.c (create_nested_ptr_option): New function.
* gengtype.h: Declare it.
From-SVN: r123232
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/gengtype-lex.l | 8 | ||||
-rw-r--r-- | gcc/gengtype-yacc.y | 43 | ||||
-rw-r--r-- | gcc/gengtype.c | 12 | ||||
-rw-r--r-- | gcc/gengtype.h | 2 |
5 files changed, 50 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5bc2cad..3852471 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2007-03-26 Zack Weinberg <zackw@panix.com> + * gengtype-lex.l: Distinguish unions from structures in the + token type. Don't call find_structure; return the tag as a string. + * gengtype-yacc.y: Add new token types ENT_TYPEDEF_UNION and ENT_UNION. + Type of these, ENT_TYPEDEF_STRUCT, and ENT_STRUCT is string. + Reorganize typedef_struct production accordingly. + Use create_nested_ptr_option. + * gengtype.c (create_nested_ptr_option): New function. + * gengtype.h: Declare it. + * gengtype.h (struct type): Replace 'sc' with boolean, scalar_is_char. (string_type): Don't declare. (do_scalar_typedef): Declare. diff --git a/gcc/gengtype-lex.l b/gcc/gengtype-lex.l index 1d13625..baf09bc 100644 --- a/gcc/gengtype-lex.l +++ b/gcc/gengtype-lex.l @@ -171,12 +171,12 @@ ITYPE {IWORD}({WS}{IWORD})* for (taglen = 1; ISIDNUM (tagstart[taglen]); taglen++) ; - yylval.t = find_structure ((const char *) xmemdup (tagstart, taglen, - taglen + 1), - union_p); + yylval.s = (const char *) xmemdup (tagstart, taglen, taglen + 1); + BEGIN(in_struct); update_lineno (yytext, yyleng); - return typedef_p ? ENT_TYPEDEF_STRUCT : ENT_STRUCT; + return union_p ? (typedef_p ? ENT_TYPEDEF_UNION : ENT_UNION) + : (typedef_p ? ENT_TYPEDEF_STRUCT : ENT_STRUCT); } [^[:alnum:]_](extern|static){WS}/"GTY" { diff --git a/gcc/gengtype-yacc.y b/gcc/gengtype-yacc.y index 40c22ef..758bcaa 100644 --- a/gcc/gengtype-yacc.y +++ b/gcc/gengtype-yacc.y @@ -35,8 +35,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA const char *s; } -%token <t>ENT_TYPEDEF_STRUCT -%token <t>ENT_STRUCT +%token <s>ENT_TYPEDEF_STRUCT +%token <s>ENT_STRUCT +%token <s>ENT_TYPEDEF_UNION +%token <s>ENT_UNION %token ENT_EXTERNSTATIC %token GTY_TOKEN %token VEC_TOKEN @@ -68,21 +70,30 @@ start: /* empty */ typedef_struct: ENT_TYPEDEF_STRUCT options '{' struct_fields '}' ID { - new_structure ($1->u.s.tag, UNION_P ($1), &lexer_line, - $4, $2); - do_typedef ($6, $1, &lexer_line); + type_p t = new_structure ($1, false, &lexer_line, $4, $2); + do_typedef ($6, t, &lexer_line); lexer_toplevel_done = 1; } - ';' - {} + ';' + | ENT_TYPEDEF_UNION options '{' struct_fields '}' ID + { + type_p t = new_structure ($1, true, &lexer_line, $4, $2); + do_typedef ($6, t, &lexer_line); + lexer_toplevel_done = 1; + } + ';' | ENT_STRUCT options '{' struct_fields '}' { - new_structure ($1->u.s.tag, UNION_P ($1), &lexer_line, - $4, $2); + new_structure ($1, false, &lexer_line, $4, $2); lexer_toplevel_done = 1; } - ';' - {} + ';' + | ENT_UNION options '{' struct_fields '}' + { + new_structure ($1, true, &lexer_line, $4, $2); + lexer_toplevel_done = 1; + } + ';' ; externstatic: ENT_EXTERNSTATIC options lasttype ID semiequal @@ -210,15 +221,7 @@ option: ID | type_option '(' type ')' { $$ = create_option (NULL, $1, adjust_field_type ($3, NULL)); } | NESTED_PTR '(' type ',' stringseq ',' stringseq ')' - { - struct nested_ptr_data d; - - d.type = adjust_field_type ($3, NULL); - d.convert_to = $5; - d.convert_from = $7; - $$ = create_option (NULL, "nested_ptr", - xmemdup (&d, sizeof (d), sizeof (d))); - } + { $$ = create_nested_ptr_option ($3, $5, $7); } ; optionseq: option diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 6e93835..86d72d8f 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -330,6 +330,18 @@ create_option (options_p next, const char *name, const void *info) return o; } +/* Return an options structure for a "nested_ptr" option. */ +options_p +create_nested_ptr_option (type_p t, const char *to, const char *from) +{ + struct nested_ptr_data *d = XNEW (struct nested_ptr_data); + + d->type = adjust_field_type (t, 0); + d->convert_to = to; + d->convert_from = from; + return create_option (NULL, "nested_ptr", d); +} + /* Add a variable named S of type T with options O defined at POS, to `variables'. */ diff --git a/gcc/gengtype.h b/gcc/gengtype.h index 1ee9d3a..f803ad3 100644 --- a/gcc/gengtype.h +++ b/gcc/gengtype.h @@ -139,6 +139,8 @@ extern type_p create_scalar_type (const char *name); extern type_p create_pointer (type_p t); extern type_p create_array (type_p t, const char *len); extern options_p create_option (options_p, const char *name, const void *info); +extern options_p create_nested_ptr_option (type_p t, const char *from, + const char *to); extern type_p adjust_field_type (type_p, options_p); extern void note_variable (const char *s, type_p t, options_p o, struct fileloc *pos); |