Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r2871210 rde62360d  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  3 12:35:02 2015
    13 // Update Count     : 108
     12// Last Modified On : Wed Jun 24 15:29:19 2015
     13// Update Count     : 86
    1414//
    1515
     
    173173}
    174174
    175 DeclarationNode *DeclarationNode::newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields ) {
     175DeclarationNode *DeclarationNode::newAggregate( Aggregate kind, std::string *name, DeclarationNode *formals, 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 == "" ) {           // anonymous aggregate ?
     180        if ( newnode->type->aggregate->name == "" ) {
    181181                newnode->type->aggregate->name = DeclarationNode::anonymous.newName();
    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
     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;
    190192        newnode->type->aggregate->actuals = actuals;
    191         newnode->type->aggregate->fields = fields;
     193        newnode->type->aggregate->members = fields;
    192194        return newnode;
    193195}
     
    198200        newnode->type = new TypeData( TypeData::Enum );
    199201        newnode->type->enumeration->name = newnode->name;
    200         if ( newnode->type->enumeration->name == "" ) {         // anonymous enumeration ?
     202        if ( newnode->type->enumeration->name == "" ) {
    201203                newnode->type->enumeration->name = DeclarationNode::anonymous.newName();
    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
     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
    210213        newnode->type->enumeration->constants = constants;
    211214        return newnode;
     
    248251        newnode->type->aggregate->kind = Context;
    249252        newnode->type->aggregate->params = params;
    250         newnode->type->aggregate->fields = asserts;
     253        newnode->type->aggregate->members = asserts;
    251254        newnode->type->aggregate->name = assign_strptr( name );
    252255        return newnode;
     
    368371                                        if ( type->kind == TypeData::Aggregate ) {
    369372                                                type->aggregate->params = q->type->forall;
    370                                                 // change implicit typedef from TYPEDEFname to TYPEGENname
    371                                                 typedefTable.changeKind( type->aggregate->name, TypedefTable::TG );
    372373                                        } else {
    373374                                                type->forall = q->type->forall;
     
    406407                                src = 0;
    407408                                break;
     409
    408410                          case TypeData::Basic:
    409411                                dst->qualifiers.splice( dst->qualifiers.end(), src->qualifiers );
     
    414416                                } // if
    415417                                break;
     418
    416419                          default:
    417420                                switch ( src->kind ) {
     
    426429                                        src = 0;
    427430                                        break;
     431
    428432                                  default:
    429433                                        if ( dst->forall ) {
     
    680684                } else {
    681685                        assert( newnode->type->aggInst->aggregate->kind == TypeData::Aggregate );
    682                         delete newnode->type->aggInst->aggregate->aggregate->fields;
    683                         newnode->type->aggInst->aggregate->aggregate->fields = 0;
     686                        delete newnode->type->aggInst->aggregate->aggregate->members;
     687                        newnode->type->aggInst->aggregate->aggregate->members = 0;
    684688                } // if
    685689        } // if
     
    706710                                } else {
    707711                                        assert( newType->aggInst->aggregate->kind == TypeData::Aggregate );
    708                                         delete newType->aggInst->aggregate->aggregate->fields;
    709                                         newType->aggInst->aggregate->aggregate->fields = 0;
     712                                        delete newType->aggInst->aggregate->aggregate->members;
     713                                        newType->aggInst->aggregate->aggregate->members = 0;
    710714                                } // if
    711715                        } // if
Note: See TracChangeset for help on using the changeset viewer.