Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r984dce6 r4040425  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 21 21:04:23 2016
    13 // Update Count     : 142
     12// Last Modified On : Wed Mar  2 17:26:24 2016
     13// Update Count     : 134
    1414//
    1515
     
    4242UniqueName DeclarationNode::anonymous( "__anonymous" );
    4343
    44 extern LinkageSpec::Type linkage;                                               // defined in parser.yy
     44extern LinkageSpec::Type linkage;               /* defined in cfa.y */
    4545
    4646DeclarationNode *DeclarationNode::clone() const {
     
    5555        newnode->linkage = linkage;
    5656        return newnode;
    57 } // DeclarationNode::clone
     57}
    5858
    5959DeclarationNode::DeclarationNode() : type( 0 ), bitfieldWidth( 0 ), initializer( 0 ), hasEllipsis( false ), linkage( ::linkage ) {
     
    117117        newnode->type->function->newStyle = newStyle;
    118118        newnode->type->function->body = body;
    119         typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );
    120119
    121120        if ( body ) {
     
    130129
    131130        return newnode;
    132 } // DeclarationNode::newFunction
     131}
    133132
    134133DeclarationNode *DeclarationNode::newQualifier( Qualifier q ) {
     
    137136        newnode->type->qualifiers.push_back( q );
    138137        return newnode;
    139 } // DeclarationNode::newQualifier
     138}
    140139
    141140DeclarationNode *DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) {
     
    143142        newnode->storageClasses.push_back( sc );
    144143        return newnode;
    145 } // DeclarationNode::newStorageClass
     144}
    146145
    147146DeclarationNode *DeclarationNode::newBasicType( BasicType bt ) {
     
    150149        newnode->type->basic->typeSpec.push_back( bt );
    151150        return newnode;
    152 } // DeclarationNode::newBasicType
     151}
    153152
    154153DeclarationNode *DeclarationNode::newBuiltinType( BuiltinType bt ) {
     
    157156        newnode->type->builtin->type = bt;
    158157        return newnode;
    159 } // DeclarationNode::newBuiltinType
     158}
    160159
    161160DeclarationNode *DeclarationNode::newModifier( Modifier mod ) {
     
    164163        newnode->type->basic->modifiers.push_back( mod );
    165164        return newnode;
    166 } // DeclarationNode::newModifier
     165}
    167166
    168167DeclarationNode *DeclarationNode::newForall( DeclarationNode *forall ) {
     
    171170        newnode->type->forall = forall;
    172171        return newnode;
    173 } // DeclarationNode::newForall
     172}
    174173
    175174DeclarationNode *DeclarationNode::newFromTypedef( std::string *name ) {
     
    180179        newnode->type->symbolic->params = 0;
    181180        return newnode;
    182 } // DeclarationNode::newFromTypedef
     181}
    183182
    184183DeclarationNode *DeclarationNode::newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields ) {
     
    189188        if ( newnode->type->aggregate->name == "" ) {           // anonymous aggregate ?
    190189                newnode->type->aggregate->name = DeclarationNode::anonymous.newName();
    191         } else if ( ! typedefTable.exists( newnode->type->aggregate->name ) ) {
    192                 // SKULLDUGGERY: Generate a typedef for the aggregate name so the aggregate does not have to be qualified by
    193                 // "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed
    194                 // if the name is explicitly used.
     190        } else {
     191                // SKULLDUGGERY: generate a typedef for the aggregate name so that the aggregate does not have to be qualified
     192                // by "struct"
    195193                typedefTable.addToEnclosingScope( newnode->type->aggregate->name, TypedefTable::TD );
    196194                DeclarationNode *typedf = new DeclarationNode;
     
    201199        newnode->type->aggregate->fields = fields;
    202200        return newnode;
    203 } // DeclarationNode::newAggregate
     201}
    204202
    205203DeclarationNode *DeclarationNode::newEnum( std::string *name, DeclarationNode *constants ) {
     
    210208        if ( newnode->type->enumeration->name == "" ) {         // anonymous enumeration ?
    211209                newnode->type->enumeration->name = DeclarationNode::anonymous.newName();
    212         } else if ( ! typedefTable.exists( newnode->type->enumeration->name ) ) {
    213                 // SKULLDUGGERY: Generate a typedef for the enumeration name so the enumeration does not have to be qualified by
    214                 // "enum". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed if
    215                 // the name is explicitly used.
     210        } else {
     211                // SKULLDUGGERY: generate a typedef for the enumeration name so that the enumeration does not have to be
     212                // qualified by "enum"
    216213                typedefTable.addToEnclosingScope( newnode->type->enumeration->name, TypedefTable::TD );
    217214                DeclarationNode *typedf = new DeclarationNode;
     
    221218        newnode->type->enumeration->constants = constants;
    222219        return newnode;
    223 } // DeclarationNode::newEnum
     220}
    224221
    225222DeclarationNode *DeclarationNode::newEnumConstant( std::string *name, ExpressionNode *constant ) {
     
    227224        newnode->name = assign_strptr( name );
    228225        newnode->enumeratorValue = constant;
    229         typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );
    230         return newnode;
    231 } // DeclarationNode::newEnumConstant
     226        return newnode;
     227}
    232228
    233229DeclarationNode *DeclarationNode::newName( std::string *name ) {
     
    235231        newnode->name = assign_strptr( name );
    236232        return newnode;
    237 } // DeclarationNode::newName
     233}
    238234
    239235DeclarationNode *DeclarationNode::newFromTypeGen( std::string *name, ExpressionNode *params ) {
     
    244240        newnode->type->symbolic->actuals = params;
    245241        return newnode;
    246 } // DeclarationNode::newFromTypeGen
     242}
    247243
    248244DeclarationNode *DeclarationNode::newTypeParam( TypeClass tc, std::string *name ) {
     
    253249        newnode->type->variable->name = newnode->name;
    254250        return newnode;
    255 } // DeclarationNode::newTypeParam
     251}
    256252
    257253DeclarationNode *DeclarationNode::newTrait( std::string *name, DeclarationNode *params, DeclarationNode *asserts ) {
     
    263259        newnode->type->aggregate->name = assign_strptr( name );
    264260        return newnode;
    265 } // DeclarationNode::newTrait
     261}
    266262
    267263DeclarationNode *DeclarationNode::newTraitUse( std::string *name, ExpressionNode *params ) {
     
    273269        newnode->type->aggInst->params = params;
    274270        return newnode;
    275 } // DeclarationNode::newTraitUse
     271}
    276272
    277273DeclarationNode *DeclarationNode::newTypeDecl( std::string *name, DeclarationNode *typeParams ) {
     
    283279        newnode->type->symbolic->name = newnode->name;
    284280        return newnode;
    285 } // DeclarationNode::newTypeDecl
     281}
    286282
    287283DeclarationNode *DeclarationNode::newPointer( DeclarationNode *qualifiers ) {
     
    289285        newnode->type = new TypeData( TypeData::Pointer );
    290286        return newnode->addQualifiers( qualifiers );
    291 } // DeclarationNode::newPointer
     287}
    292288
    293289DeclarationNode *DeclarationNode::newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic ) {
     
    302298        } // if
    303299        return newnode->addQualifiers( qualifiers );
    304 } // DeclarationNode::newArray
     300}
    305301
    306302DeclarationNode *DeclarationNode::newVarArray( DeclarationNode *qualifiers ) {
Note: See TracChangeset for help on using the changeset viewer.