Changeset 90152a4 for src/SynTree/Statement.cc
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (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
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
rf9feab8 r90152a4 34 34 Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {} 35 35 36 void Statement::print( std::ostream & os, Indenter ) const {36 void Statement::print( std::ostream & os, Indenter indent ) const { 37 37 if ( ! labels.empty() ) { 38 os << "Labels: {";38 os << indent << "... Labels: {"; 39 39 for ( const Label & l : labels ) { 40 40 os << l << ","; … … 94 94 95 95 96 DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {} 97 98 void DirectiveStmt::print( std::ostream &os, Indenter ) const { 99 os << "GCC Directive:" << directive << endl; 100 } 101 102 96 103 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 97 104 98 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) :105 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) : 99 106 Statement(), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { 100 107 //actually this is a syntactic error signaled by the parser 101 108 if ( type == BranchStmt::Goto && target.empty() ) { 102 throw SemanticError("goto without target");103 } 104 } 105 106 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) :109 SemanticError( target.get_statement()->location, "goto without target"); 110 } 111 } 112 113 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticErrorException ) : 107 114 Statement(), computedTarget( computedTarget ), type( type ) { 108 115 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { 109 throw SemanticError("Computed target not valid in branch statement");116 SemanticError( computedTarget->location, "Computed target not valid in branch statement"); 110 117 } 111 118 } … … 201 208 } 202 209 203 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :210 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) : 204 211 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) { 205 if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition);212 if ( isDefault() && condition != 0 ) SemanticError( condition, "default case with condition: " ); 206 213 } 207 214 … … 223 230 224 231 void CaseStmt::print( std::ostream &os, Indenter indent ) const { 225 if ( isDefault() ) os << "Default ";232 if ( isDefault() ) os << indent << "Default "; 226 233 else { 227 os << "Case ";234 os << indent << "Case "; 228 235 condition->print( os, indent ); 229 236 } // if … … 231 238 232 239 for ( Statement * stmt : stmts ) { 240 os << indent+1; 233 241 stmt->print( os, indent+1 ); 234 242 } 235 243 } 236 244 237 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):238 Statement(), condition( condition), body( body), i sDoWhile( isDoWhile) {245 WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ): 246 Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) { 239 247 } 240 248 … … 452 460 void WaitForStmt::print( std::ostream &os, Indenter indent ) const { 453 461 os << "Waitfor Statement" << endl; 454 os << indent << "... with block:" << endl << indent+1; 455 // block->print( os, indent + 4 ); 462 indent += 1; 463 for( auto & clause : clauses ) { 464 os << indent << "target function :"; 465 if(clause.target.function) { clause.target.function->print(os, indent + 1); } 466 os << endl << indent << "with arguments :" << endl; 467 for( auto & thing : clause.target.arguments) { 468 if(thing) { thing->print(os, indent + 1); } 469 } 470 os << indent << " with statment :" << endl; 471 if(clause.statement) { clause.statement->print(os, indent + 1); } 472 473 os << indent << " with condition :" << endl; 474 if(clause.condition) { clause.condition->print(os, indent + 1); } 475 } 476 477 os << indent << " timeout of :" << endl; 478 if(timeout.time) { timeout.time->print(os, indent + 1); } 479 480 os << indent << " with statment :" << endl; 481 if(timeout.statement) { timeout.statement->print(os, indent + 1); } 482 483 os << indent << " with condition :" << endl; 484 if(timeout.condition) { timeout.condition->print(os, indent + 1); } 485 486 487 os << indent << " else :" << endl; 488 if(orelse.statement) { orelse.statement->print(os, indent + 1); } 489 490 os << indent << " with condition :" << endl; 491 if(orelse.condition) { orelse.condition->print(os, indent + 1); } 456 492 } 457 493 … … 468 504 void WithStmt::print( std::ostream & os, Indenter indent ) const { 469 505 os << "With statement" << endl; 506 os << indent << "... with expressions: " << endl; 507 printAll( exprs, os, indent+1 ); 470 508 os << indent << "... with statement:" << endl << indent+1; 471 509 stmt->print( os, indent+1 ); … … 476 514 } 477 515 478 void NullStmt::print( std::ostream &os, Indenter ) const {516 void NullStmt::print( std::ostream &os, Indenter indent ) const { 479 517 os << "Null Statement" << endl; 518 Statement::print( os, indent ); 480 519 } 481 520
Note:
See TracChangeset
for help on using the changeset viewer.