Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rde62360d r2871210  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 24 15:29:19 2015
    13 // Update Count     : 86
     12// Last Modified On : Fri Jul  3 12:35:02 2015
     13// Update Count     : 108
    1414//
    1515
     
    173173}
    174174
    175 DeclarationNode *DeclarationNode::newAggregate( Aggregate kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields ) {
     175DeclarationNode *DeclarationNode::newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields ) {
    176176        DeclarationNode *newnode = new DeclarationNode;
    177177        newnode->type = new TypeData( TypeData::Aggregate );
    178178        newnode->type->aggregate->kind = kind;
    179179        newnode->type->aggregate->name = assign_strptr( name );
    180         if ( newnode->type->aggregate->name == "" ) {
     180        if ( newnode->type->aggregate->name == "" ) {           // anonymous aggregate ?
    181181                newnode->type->aggregate->name = DeclarationNode::anonymous.newName();
    182         } // if
    183 
    184         // SKULLDUGGERY: generate a typedef for the aggregate name so that the aggregate does not have to be qualified by
    185         // "struct"
    186         typedefTable.addToEnclosingScope( newnode->type->aggregate->name, TypedefTable::TD );
    187         DeclarationNode *typedf = new DeclarationNode;
    188         typedf->name = newnode->type->aggregate->name;
    189         newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() );
    190 
    191         newnode->type->aggregate->params = formals;
     182        } else {
     183                // SKULLDUGGERY: generate a typedef for the aggregate name so that the aggregate does not have to be qualified
     184                // by "struct"
     185                typedefTable.addToEnclosingScope( newnode->type->aggregate->name, TypedefTable::TD );
     186                DeclarationNode *typedf = new DeclarationNode;
     187                typedf->name = newnode->type->aggregate->name;
     188                newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() );
     189        } // if
    192190        newnode->type->aggregate->actuals = actuals;
    193         newnode->type->aggregate->members = fields;
     191        newnode->type->aggregate->fields = fields;
    194192        return newnode;
    195193}
     
    200198        newnode->type = new TypeData( TypeData::Enum );
    201199        newnode->type->enumeration->name = newnode->name;
    202         if ( newnode->type->enumeration->name == "" ) {
     200        if ( newnode->type->enumeration->name == "" ) {         // anonymous enumeration ?
    203201                newnode->type->enumeration->name = DeclarationNode::anonymous.newName();
    204         } // if
    205 
    206         // SKULLDUGGERY: generate a typedef for the enumeration name so that the enumeration does not have to be qualified
    207         // by "enum"
    208         typedefTable.addToEnclosingScope( newnode->type->enumeration->name, TypedefTable::TD );
    209         DeclarationNode *typedf = new DeclarationNode;
    210         typedf->name = newnode->type->enumeration->name;
    211         newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() );
    212 
     202        } else {
     203                // SKULLDUGGERY: generate a typedef for the enumeration name so that the enumeration does not have to be
     204                // qualified by "enum"
     205                typedefTable.addToEnclosingScope( newnode->type->enumeration->name, TypedefTable::TD );
     206                DeclarationNode *typedf = new DeclarationNode;
     207                typedf->name = newnode->type->enumeration->name;
     208                newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() );
     209        } // if
    213210        newnode->type->enumeration->constants = constants;
    214211        return newnode;
     
    251248        newnode->type->aggregate->kind = Context;
    252249        newnode->type->aggregate->params = params;
    253         newnode->type->aggregate->members = asserts;
     250        newnode->type->aggregate->fields = asserts;
    254251        newnode->type->aggregate->name = assign_strptr( name );
    255252        return newnode;
     
    371368                                        if ( type->kind == TypeData::Aggregate ) {
    372369                                                type->aggregate->params = q->type->forall;
     370                                                // change implicit typedef from TYPEDEFname to TYPEGENname
     371                                                typedefTable.changeKind( type->aggregate->name, TypedefTable::TG );
    373372                                        } else {
    374373                                                type->forall = q->type->forall;
     
    407406                                src = 0;
    408407                                break;
    409 
    410408                          case TypeData::Basic:
    411409                                dst->qualifiers.splice( dst->qualifiers.end(), src->qualifiers );
     
    416414                                } // if
    417415                                break;
    418 
    419416                          default:
    420417                                switch ( src->kind ) {
     
    429426                                        src = 0;
    430427                                        break;
    431 
    432428                                  default:
    433429                                        if ( dst->forall ) {
     
    684680                } else {
    685681                        assert( newnode->type->aggInst->aggregate->kind == TypeData::Aggregate );
    686                         delete newnode->type->aggInst->aggregate->aggregate->members;
    687                         newnode->type->aggInst->aggregate->aggregate->members = 0;
     682                        delete newnode->type->aggInst->aggregate->aggregate->fields;
     683                        newnode->type->aggInst->aggregate->aggregate->fields = 0;
    688684                } // if
    689685        } // if
     
    710706                                } else {
    711707                                        assert( newType->aggInst->aggregate->kind == TypeData::Aggregate );
    712                                         delete newType->aggInst->aggregate->aggregate->members;
    713                                         newType->aggInst->aggregate->aggregate->members = 0;
     708                                        delete newType->aggInst->aggregate->aggregate->fields;
     709                                        newType->aggInst->aggregate->aggregate->fields = 0;
    714710                                } // if
    715711                        } // if
Note: See TracChangeset for help on using the changeset viewer.