X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/76290368d48b584808a120dfbd415be93aef04f6..eb1b07409f0ccad9970c8a60ded9f2a56d205b9c:/src/symtab.c diff --git a/src/symtab.c b/src/symtab.c index 81a938ce..8910f09c 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -1,6 +1,6 @@ /* Symbol table manager for Bison. - Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006 Free + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -109,9 +109,9 @@ semantic_type_new (uniqstr tag) if (s->Attr) \ fprintf (f, " %s { %s }", #Attr, s->Attr) -#define SYMBOL_CODE_PRINT(Attr) \ - if (code_props_code_get (s->Attr)) \ - fprintf (f, " %s { %s }", #Attr, code_props_code_get(s->Attr)) +#define SYMBOL_CODE_PRINT(Attr) \ + if (s->Attr.code) \ + fprintf (f, " %s { %s }", #Attr, s->Attr.code) void symbol_print (symbol *s, FILE *f) @@ -176,13 +176,12 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc) `-----------------------------------------*/ void -symbol_destructor_set (symbol *sym, code_props destructor) +symbol_destructor_set (symbol *sym, code_props const *destructor) { - if (code_props_code_get (sym->destructor)) - symbol_redeclaration (sym, "%destructor", - code_props_location_get (sym->destructor), - code_props_location_get (destructor)); - sym->destructor = destructor; + if (sym->destructor.code) + symbol_redeclaration (sym, "%destructor", sym->destructor.location, + destructor->location); + sym->destructor = *destructor; } /*------------------------------------------. @@ -190,41 +189,43 @@ symbol_destructor_set (symbol *sym, code_props destructor) `------------------------------------------*/ void -semantic_type_destructor_set (semantic_type *type, code_props destructor) +semantic_type_destructor_set (semantic_type *type, + code_props const *destructor) { - if (code_props_code_get (type->destructor)) + if (type->destructor.code) semantic_type_redeclaration (type, "%destructor", - code_props_location_get (type->destructor), - code_props_location_get (destructor)); - type->destructor = destructor; + type->destructor.location, + destructor->location); + type->destructor = *destructor; } /*---------------------------------------. | Get the computed %destructor for SYM. | `---------------------------------------*/ -code_props -symbol_destructor_get (symbol *sym) +code_props const * +symbol_destructor_get (symbol const *sym) { /* Per-symbol %destructor. */ - if (code_props_code_get (sym->destructor)) - return sym->destructor; + if (sym->destructor.code) + return &sym->destructor; /* Per-type %destructor. */ if (sym->type_name) { - code_props destructor = semantic_type_get (sym->type_name)->destructor; - if (code_props_code_get (destructor)) + code_props const *destructor = + &semantic_type_get (sym->type_name)->destructor; + if (destructor->code) return destructor; } /* Apply default %destructor's only to user-defined symbols. */ if (sym->tag[0] == '$' || sym == errtoken) - return code_props_none; + return &code_props_none; if (sym->type_name) - return default_tagged_destructor; - return default_tagless_destructor; + return &default_tagged_destructor; + return &default_tagless_destructor; } /*--------------------------------------. @@ -232,13 +233,12 @@ symbol_destructor_get (symbol *sym) `--------------------------------------*/ void -symbol_printer_set (symbol *sym, code_props printer) +symbol_printer_set (symbol *sym, code_props const *printer) { - if (code_props_code_get (sym->printer)) + if (sym->printer.code) symbol_redeclaration (sym, "%printer", - code_props_location_get (sym->printer), - code_props_location_get (printer)); - sym->printer = printer; + sym->printer.location, printer->location); + sym->printer = *printer; } /*---------------------------------------. @@ -246,41 +246,40 @@ symbol_printer_set (symbol *sym, code_props printer) `---------------------------------------*/ void -semantic_type_printer_set (semantic_type *type, code_props printer) +semantic_type_printer_set (semantic_type *type, code_props const *printer) { - if (code_props_code_get (type->printer)) + if (type->printer.code) semantic_type_redeclaration (type, "%printer", - code_props_location_get (type->printer), - code_props_location_get (printer)); - type->printer = printer; + type->printer.location, printer->location); + type->printer = *printer; } /*------------------------------------. | Get the computed %printer for SYM. | `------------------------------------*/ -code_props -symbol_printer_get (symbol *sym) +code_props const * +symbol_printer_get (symbol const *sym) { /* Per-symbol %printer. */ - if (code_props_code_get (sym->printer)) - return sym->printer; + if (sym->printer.code) + return &sym->printer; /* Per-type %printer. */ if (sym->type_name) { - code_props printer = semantic_type_get (sym->type_name)->printer; - if (code_props_code_get (printer)) + code_props const *printer = &semantic_type_get (sym->type_name)->printer; + if (printer->code) return printer; } /* Apply the default %printer only to user-defined symbols. */ if (sym->tag[0] == '$' || sym == errtoken) - return code_props_none; + return &code_props_none; if (sym->type_name) - return default_tagged_printer; - return default_tagless_printer; + return &default_tagged_printer; + return &default_tagless_printer; } /*-----------------------------------------------------------------. @@ -446,22 +445,20 @@ symbol_check_alias_consistency (symbol *this) } - if (code_props_code_get (orig->destructor) - || code_props_code_get (alias->destructor)) + if (orig->destructor.code || alias->destructor.code) { - if (code_props_code_get (orig->destructor)) - symbol_destructor_set (alias, orig->destructor); + if (orig->destructor.code) + symbol_destructor_set (alias, &orig->destructor); else - symbol_destructor_set (orig, alias->destructor); + symbol_destructor_set (orig, &alias->destructor); } - if (code_props_code_get (orig->printer) - || code_props_code_get (alias->printer)) + if (orig->printer.code || alias->printer.code) { - if (code_props_code_get (orig->printer)) - symbol_printer_set (alias, orig->printer); + if (orig->printer.code) + symbol_printer_set (alias, &orig->printer); else - symbol_printer_set (orig, alias->printer); + symbol_printer_set (orig, &alias->printer); } if (alias->prec || orig->prec) @@ -890,54 +887,54 @@ symbols_pack (void) `--------------------------------------------------*/ void -default_tagged_destructor_set (code_props destructor) +default_tagged_destructor_set (code_props const *destructor) { - if (code_props_code_get (default_tagged_destructor)) + if (default_tagged_destructor.code) { - complain_at (code_props_location_get (destructor), + complain_at (destructor->location, _("redeclaration for default tagged %%destructor")); - complain_at (code_props_location_get (default_tagged_destructor), + complain_at (default_tagged_destructor.location, _("previous declaration")); } - default_tagged_destructor = destructor; + default_tagged_destructor = *destructor; } void -default_tagless_destructor_set (code_props destructor) +default_tagless_destructor_set (code_props const *destructor) { - if (code_props_code_get (default_tagless_destructor)) + if (default_tagless_destructor.code) { - complain_at (code_props_location_get (destructor), + complain_at (destructor->location, _("redeclaration for default tagless %%destructor")); - complain_at (code_props_location_get (default_tagless_destructor), + complain_at (default_tagless_destructor.location, _("previous declaration")); } - default_tagless_destructor = destructor; + default_tagless_destructor = *destructor; } void -default_tagged_printer_set (code_props printer) +default_tagged_printer_set (code_props const *printer) { - if (code_props_code_get (default_tagged_printer)) + if (default_tagged_printer.code) { - complain_at (code_props_location_get (printer), + complain_at (printer->location, _("redeclaration for default tagged %%printer")); - complain_at (code_props_location_get (default_tagged_printer), + complain_at (default_tagged_printer.location, _("previous declaration")); } - default_tagged_printer = printer; + default_tagged_printer = *printer; } void -default_tagless_printer_set (code_props printer) +default_tagless_printer_set (code_props const *printer) { - if (code_props_code_get (default_tagless_printer)) + if (default_tagless_printer.code) { - complain_at (code_props_location_get (printer), + complain_at (printer->location, _("redeclaration for default tagless %%printer")); - complain_at (code_props_location_get (default_tagless_printer), + complain_at (default_tagless_printer.location, _("previous declaration")); } - default_tagless_printer = printer; + default_tagless_printer = *printer; }