Changeset f80e0218 for src/Parser/StatementNode.cc
- Timestamp:
- Jun 30, 2016, 4:32:56 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ea29e73
- Parents:
- 1b5c81ed (diff), 84d4d6f (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. - File:
-
- 1 edited
-
src/Parser/StatementNode.cc (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/StatementNode.cc
r1b5c81ed rf80e0218 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // StatementNode.cc -- 7 // StatementNode.cc -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Ju l 30 14:39:39 201513 // Update Count : 13 012 // Last Modified On : Thu Jun 9 14:18:46 2016 13 // Update Count : 132 14 14 // 15 15 … … 27 27 28 28 const char *StatementNode::StType[] = { 29 "Exp", "If", "Switch", "Case", "Default", "Choose", "Fallthru", 30 "While", "Do", "For", 29 "Exp", "If", "Switch", "Case", "Default", "Choose", "Fallthru", 30 "While", "Do", "For", 31 31 "Goto", "Continue", "Break", "Return", "Throw", 32 32 "Try", "Catch", "Finally", "Asm", … … 62 62 StatementNode::StatementNode( Type t, ExpressionNode *ctrl_label, StatementNode *block ) : type( t ), control( ctrl_label ), block( block ), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) { 63 63 this->control = ( t == Default ) ? 0 : control; 64 } 64 } 65 65 66 66 StatementNode::StatementNode( Type t, string *target ) : type( t ), control( 0 ), block( 0 ), labels( 0 ), target( target ), decl( 0 ), isCatchRest ( false ) {} … … 74 74 75 75 StatementNode * StatementNode::newCatchStmt( DeclarationNode *d, StatementNode *s, bool catchRestP ) { 76 StatementNode *ret = new StatementNode( StatementNode::Catch, 0, s ); 76 StatementNode *ret = new StatementNode( StatementNode::Catch, 0, s ); 77 77 ret->addDeclaration( d ); 78 78 ret->setCatchRest( catchRestP ); … … 101 101 StatementNode *StatementNode::add_label( const std::string *l ) { 102 102 if ( l != 0 ) { 103 labels.push_front( *l ); 103 labels.push_front( *l ); 104 104 delete l; 105 105 } // if … … 156 156 control->print( os, indent ); 157 157 os << endl; 158 } else 158 } else 159 159 os << string( indent, ' ' ) << "Null Statement" << endl; 160 160 break; … … 177 177 if ( block ) { 178 178 os << string( indent + ParseNode::indent_by, ' ' ) << "Branches of execution: " << endl; 179 block->printList( os, indent + 2 * ParseNode::indent_by ); 179 block->printList( os, indent + 2 * ParseNode::indent_by ); 180 180 } // if 181 181 if ( target ) { … … 222 222 branches.pop_front(); 223 223 } // if 224 return new IfStmt( labs, notZeroExpr( get_control()->build() ), thenb, elseb );224 return new IfStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), thenb, elseb ); 225 225 } 226 226 case While: 227 227 assert( branches.size() == 1 ); 228 return new WhileStmt( labs, notZeroExpr( get_control()->build() ), branches.front() );228 return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front() ); 229 229 case Do: 230 230 assert( branches.size() == 1 ); 231 return new WhileStmt( labs, notZeroExpr( get_control()->build() ), branches.front(), true );231 return new WhileStmt( labs, notZeroExpr( maybeBuild<Expression>(get_control()) ), branches.front(), true ); 232 232 case For: 233 233 { … … 244 244 Expression *cond = 0; 245 245 if ( ctl->get_condition() != 0 ) 246 cond = notZeroExpr( ctl->get_condition()->build() );246 cond = notZeroExpr( maybeBuild<Expression>(ctl->get_condition()) ); 247 247 248 248 Expression *incr = 0; 249 249 if ( ctl->get_change() != 0 ) 250 incr = ctl->get_change()->build();250 incr = maybeBuild<Expression>(ctl->get_change()); 251 251 252 252 return new ForStmt( labs, init, cond, incr, branches.front() ); 253 253 } 254 254 case Switch: 255 return new SwitchStmt( labs, get_control()->build(), branches );255 return new SwitchStmt( labs, maybeBuild<Expression>(get_control()), branches ); 256 256 case Choose: 257 return new ChooseStmt( labs, get_control()->build(), branches );257 return new ChooseStmt( labs, maybeBuild<Expression>(get_control()), branches ); 258 258 case Fallthru: 259 259 return new FallthruStmt( labs ); 260 case Case: 261 return new CaseStmt( labs, get_control()->build(), branches );260 case Case: 261 return new CaseStmt( labs, maybeBuild<Expression>(get_control()), branches ); 262 262 case Default: 263 263 return new CaseStmt( labs, 0, branches, true ); … … 266 266 if ( get_target() == "" ) { // computed goto 267 267 assert( get_control() != 0 ); 268 return new BranchStmt( labs, get_control()->build(), BranchStmt::Goto );268 return new BranchStmt( labs, maybeBuild<Expression>(get_control()), BranchStmt::Goto ); 269 269 } // if 270 270 … … 394 394 os << string( indent + ParseNode::indent_by, ' ' ) << "Goto Labels:" << endl; 395 395 os << string( indent + 2 * ParseNode::indent_by, ' ' ); 396 for ( std::list< std::string>::const_iterator i = gotolabels.begin();; ) {396 for ( std::list<Label>::const_iterator i = gotolabels.begin();; ) { 397 397 os << *i; 398 398 i++; … … 426 426 } 427 427 428 Statement *NullStmtNode::build() const { 428 Statement *NullStmtNode::build() const { 429 429 return new NullStmt; 430 430 }
Note:
See TracChangeset
for help on using the changeset viewer.