Changeset 3b0bc16 for src/Parser/StatementNode.cc
- Timestamp:
- Feb 1, 2022, 8:22:12 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- fde0a58
- Parents:
- 729c991
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r729c991 r3b0bc16 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jan 29 09:45:51202213 // Update Count : 3 8412 // Last Modified On : Tue Feb 1 18:39:00 2022 13 // Update Count : 395 14 14 // 15 15 … … 145 145 } // build_default 146 146 147 Statement * build_while( CondCtl * ctl, StatementNode * stmt ) { 148 std::list< Statement * > branches; 149 buildMoveList< Statement, StatementNode >( stmt, branches ); 150 assert( branches.size() == 1 ); 151 147 Statement * build_while( CondCtl * ctl, StatementNode * stmt, StatementNode * else_ ) { 152 148 std::list< Statement * > init; 153 149 Expression * cond = build_if_control( ctl, init ); 154 return new WhileStmt( cond, branches.front(), init, false ); 150 151 std::list< Statement * > aststmt; 152 buildMoveList< Statement, StatementNode >( stmt, aststmt ); 153 assert( aststmt.size() == 1 ); 154 155 std::list< Statement * > astelse; 156 buildMoveList< Statement, StatementNode >( else_, astelse ); 157 158 return new WhileDoStmt( cond, aststmt.front(), astelse.front(), init, false ); 155 159 } // build_while 156 160 157 Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt ) { 158 std::list< Statement * > branches; 159 buildMoveList< Statement, StatementNode >( stmt, branches ); 160 assert( branches.size() == 1 ); 161 Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ ) { 162 std::list< Statement * > aststmt; 163 buildMoveList< Statement, StatementNode >( stmt, aststmt ); 164 assert( aststmt.size() == 1 ); 165 166 std::list< Statement * > astelse; 167 buildMoveList< Statement, StatementNode >( else_, astelse ); 161 168 162 169 std::list< Statement * > init; 163 return new While Stmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), init, true );170 return new WhileDoStmt( notZeroExpr( maybeMoveBuild< Expression >(ctl) ), aststmt.front(), astelse.front(), init, true ); 164 171 } // build_do_while 165 172 166 Statement * build_for( ForCtrl * forctl, StatementNode * stmt ) { 167 std::list< Statement * > branches; 168 buildMoveList< Statement, StatementNode >( stmt, branches ); 169 assert( branches.size() == 1 ); 170 173 Statement * build_for( ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ ) { 171 174 std::list< Statement * > init; 172 if ( forctl->init != 0) {175 if ( forctl->init != nullptr ) { 173 176 buildMoveList( forctl->init, init ); 174 177 } // if 175 178 176 Expression * cond = 0;177 if ( forctl->condition != 0)179 Expression * cond = nullptr; 180 if ( forctl->condition != nullptr ) 178 181 cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) ); 179 182 180 Expression * incr = 0;181 if ( forctl->change != 0)183 Expression * incr = nullptr; 184 if ( forctl->change != nullptr ) 182 185 incr = maybeMoveBuild< Expression >(forctl->change); 183 186 187 std::list< Statement * > aststmt; 188 buildMoveList< Statement, StatementNode >( stmt, aststmt ); 189 assert( aststmt.size() == 1 ); 190 191 std::list< Statement * > astelse; 192 buildMoveList< Statement, StatementNode >( else_, astelse ); 193 184 194 delete forctl; 185 return new ForStmt( init, cond, incr, branches.front() );195 return new ForStmt( init, cond, incr, aststmt.front(), astelse.front() ); 186 196 } // build_for 187 197
Note: See TracChangeset
for help on using the changeset viewer.