Changeset ee3c93d for src/Parser
- Timestamp:
- Jun 4, 2018, 12:40:46 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 2ad4b49
- Parents:
- b429026
- git-author:
- Rob Schluntz <rschlunt@…> (06/04/18 12:40:38)
- git-committer:
- Rob Schluntz <rschlunt@…> (06/04/18 12:40:46)
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
rb429026 ree3c93d 403 403 }; 404 404 405 Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init ); 405 406 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ); 406 407 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ); -
src/Parser/StatementNode.cc
rb429026 ree3c93d 80 80 } 81 81 82 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) { 83 Statement * thenb, * elseb = 0; 84 std::list< Statement * > branches; 85 buildMoveList< Statement, StatementNode >( then_stmt, branches ); 86 assert( branches.size() == 1 ); 87 thenb = branches.front(); 88 89 if ( else_stmt ) { 90 std::list< Statement * > branches; 91 buildMoveList< Statement, StatementNode >( else_stmt, branches ); 92 assert( branches.size() == 1 ); 93 elseb = branches.front(); 94 } // if 95 96 std::list< Statement * > init; 82 Expression * build_if_control( IfCtl * ctl, std::list< Statement * > & init ) { 97 83 if ( ctl->init != 0 ) { 98 84 buildMoveList( ctl->init, init ); … … 102 88 if ( ctl->condition ) { 103 89 // compare the provided condition against 0 104 cond = 90 cond = notZeroExpr( maybeMoveBuild< Expression >(ctl->condition) ); 105 91 } else { 106 92 for ( Statement * stmt : init ) { … … 113 99 } 114 100 delete ctl; 101 return cond; 102 } 103 104 Statement * build_if( IfCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) { 105 Statement * thenb, * elseb = 0; 106 std::list< Statement * > branches; 107 buildMoveList< Statement, StatementNode >( then_stmt, branches ); 108 assert( branches.size() == 1 ); 109 thenb = branches.front(); 110 111 if ( else_stmt ) { 112 std::list< Statement * > branches; 113 buildMoveList< Statement, StatementNode >( else_stmt, branches ); 114 assert( branches.size() == 1 ); 115 elseb = branches.front(); 116 } // if 117 118 std::list< Statement * > init; 119 Expression * cond = build_if_control( ctl, init ); 115 120 return new IfStmt( cond, thenb, elseb, init ); 116 121 } … … 144 149 buildMoveList< Statement, StatementNode >( stmt, branches ); 145 150 assert( branches.size() == 1 ); 146 return new WhileStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind ); 151 152 std::list< Statement * > init; 153 return new WhileStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), init, kind ); 147 154 } 148 155
Note:
See TracChangeset
for help on using the changeset viewer.