Ignore:
Timestamp:
Jun 20, 2017, 1:19:53 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
579263a
Parents:
c6d2e93
git-author:
Rob Schluntz <rschlunt@…> (06/20/17 13:16:13)
git-committer:
Rob Schluntz <rschlunt@…> (06/20/17 13:19:53)
Message:

major effort on designations, works in many cases

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/InitializerNode.cc

    rc6d2e93 re4d829b  
    7474
    7575        InitializerNode *moreInit;
    76         if  ( get_next() != 0 && ((moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) != 0) )
     76        if ( (moreInit = dynamic_cast< InitializerNode * >( get_next() ) ) ) {
    7777                moreInit->printOneLine( os );
     78        }
    7879}
    7980
    8081Initializer *InitializerNode::build() const {
    8182        if ( aggregate ) {
     83                // steal designators from children
     84                std::list< Designation * > designlist;
     85                InitializerNode * child = next_init();
     86                for ( ; child != nullptr; child = dynamic_cast< InitializerNode * >( child->get_next() ) ) {
     87                        std::list< Expression * > desList;
     88                        buildList< Expression, ExpressionNode >( child->designator, desList );
     89                        designlist.push_back( new Designation( desList ) );
     90                } // for
    8291                std::list< Initializer * > initlist;
    8392                buildList< Initializer, InitializerNode >( next_init(), initlist );
    84 
    85                 std::list< Expression * > designlist;
    86 
    87                 if ( designator != 0 ) {
    88                         buildList< Expression, ExpressionNode >( designator, designlist );
    89                 } // if
    90 
    9193                return new ListInit( initlist, designlist, maybeConstructed );
    9294        } else {
    93                 std::list< Expression * > designators;
    94 
    95                 if ( designator != 0 )
    96                         buildList< Expression, ExpressionNode >( designator, designators );
    97 
    98                 if ( get_expression() != 0)
    99                         return new SingleInit( maybeBuild< Expression >( get_expression() ), designators, maybeConstructed );
     95                if ( get_expression() != 0) {
     96                        return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed );
     97                }
    10098        } // if
    101 
    10299        return 0;
    103100}
Note: See TracChangeset for help on using the changeset viewer.