Changes in src/Parser/InitializerNode.cc [c468150:374cb117]
- File:
-
- 1 edited
-
src/Parser/InitializerNode.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/InitializerNode.cc
rc468150 r374cb117 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:20:24 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Apr 4 11:18:00 202313 // Update Count : 2 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 28 23:27:20 2017 13 // Update Count : 26 14 14 // 15 16 #include "InitializerNode.h"17 15 18 16 #include <iostream> // for operator<<, ostream, basic_ostream … … 20 18 #include <string> // for operator<<, string 21 19 22 #include "AST/Expr.hpp" // for Expr 23 #include "AST/Init.hpp" // for Designator, Init, ListInit, Sing... 20 using namespace std; 21 24 22 #include "Common/SemanticError.h" // for SemanticError 25 23 #include "Common/utility.h" // for maybeBuild 26 #include "ExpressionNode.h" // for ExpressionNode 27 #include "DeclarationNode.h" // for buildList 28 29 using namespace std; 30 31 static ast::ConstructFlag toConstructFlag( bool maybeConstructed ) { 32 return maybeConstructed ? ast::MaybeConstruct : ast::NoConstruct; 33 } 24 #include "ParseNode.h" // for InitializerNode, ExpressionNode 25 #include "SynTree/Expression.h" // for Expression 26 #include "SynTree/Initializer.h" // for Initializer, ListInit, SingleInit 34 27 35 28 InitializerNode::InitializerNode( ExpressionNode * _expr, bool aggrp, ExpressionNode * des ) … … 40 33 if ( kids ) 41 34 set_last( nullptr ); 42 } // InitializerNode::InitializerNode 35 } // InitializerNode::InitializerNode 43 36 44 37 InitializerNode::InitializerNode( InitializerNode * init, bool aggrp, ExpressionNode * des ) … … 92 85 } // InitializerNode::printOneLine 93 86 94 ast::Init* InitializerNode::build() const {87 Initializer * InitializerNode::build() const { 95 88 assertf( ! isDelete, "Should not build delete stmt InitializerNode" ); 96 89 if ( aggregate ) { 97 90 // steal designators from children 98 std:: vector<ast::ptr<ast::Designation>> designlist;91 std::list< Designation * > designlist; 99 92 InitializerNode * child = next_init(); 100 for ( ; child != nullptr ; child = dynamic_cast< InitializerNode * >( child->get_next() ) ) { 101 std::deque<ast::ptr<ast::Expr>> desList; 102 buildList( child->designator, desList ); 103 designlist.push_back( 104 new ast::Designation( location, std::move( desList ) ) ); 93 for ( ; child != nullptr; child = dynamic_cast< InitializerNode * >( child->get_next() ) ) { 94 std::list< Expression * > desList; 95 buildList< Expression, ExpressionNode >( child->designator, desList ); 96 designlist.push_back( new Designation( desList ) ); 105 97 } // for 106 std::vector<ast::ptr<ast::Init>> initlist; 107 buildList( next_init(), initlist ); 108 return new ast::ListInit( location, 109 std::move( initlist ), 110 std::move( designlist ), 111 toConstructFlag( maybeConstructed ) 112 ); 113 } else if ( get_expression() ) { 114 assertf( get_expression()->expr, "The expression of initializer must have value" ); 115 return new ast::SingleInit( location, 116 maybeBuild( get_expression() ), 117 toConstructFlag( maybeConstructed ) 118 ); 98 std::list< Initializer * > initlist; 99 buildList< Initializer, InitializerNode >( next_init(), initlist ); 100 return new ListInit( initlist, designlist, maybeConstructed ); 101 } else { 102 if ( get_expression() ) { 103 assertf( get_expression()->expr, "The expression of initializer must have value" ); 104 return new SingleInit( maybeBuild< Expression >( get_expression() ), maybeConstructed ); 105 } // if 119 106 } // if 120 107 return nullptr;
Note:
See TracChangeset
for help on using the changeset viewer.