Ignore:
Timestamp:
Apr 21, 2022, 9:03:39 AM (2 years ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
94d91e17
Parents:
3c79ea9 (diff), f6e6a55 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r3c79ea9 r4c530a5  
    253253} // DeclarationNode::newAggregate
    254254
    255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool typed) {
     255DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body) {
    256256        DeclarationNode * newnode = new DeclarationNode;
    257257        newnode->type = new TypeData( TypeData::Enum );
     
    272272} // DeclarationNode::newName
    273273
    274 DeclarationNode * DeclarationNode::newEnumConstant( const string * name, ExpressionNode * constant ) { // Marker
     274DeclarationNode * DeclarationNode::newEnumConstant( const string * name, ExpressionNode * constant ) {
    275275        DeclarationNode * newnode = newName( name );
    276276        newnode->enumeratorValue.reset( constant );
    277277        return newnode;
    278278} // DeclarationNode::newEnumConstant
     279
     280DeclarationNode * DeclarationNode::newEnumValueGeneric( const string * name, InitializerNode * init ) {
     281        if ( init ) { // list init {} or a singleInit
     282                if ( init->get_expression() ) { // singleInit
     283                        return newEnumConstant( name, init->get_expression() );
     284                } else { // TODO: listInit
     285                        DeclarationNode * newnode = newName( name );
     286                        newnode->initializer = init;
     287                        return newnode;
     288                } // if
     289        } else {
     290                return newName( name ); // Not explicitly inited enum value;
     291        } // if
     292} // DeclarationNode::newEnumGeneric
    279293
    280294DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) {
Note: See TracChangeset for help on using the changeset viewer.