Changes in src/SynTree/Statement.cc [ba3706f:61255ad]
- File:
-
- 1 edited
-
src/SynTree/Statement.cc (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
rba3706f r61255ad 32 32 using std::endl; 33 33 34 Statement::Statement( const std::list<Label> &labels ) : labels( labels ) {}34 Statement::Statement( std::list<Label> labels ) : labels( labels ) {} 35 35 36 36 void Statement::print( std::ostream & os, Indenter ) const { … … 46 46 Statement::~Statement() {} 47 47 48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {}48 ExprStmt::ExprStmt( std::list<Label> labels, Expression *expr ) : Statement( labels ), expr( expr ) {} 49 49 50 50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 60 60 61 61 62 AsmStmt::AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}62 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement( labels ), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {} 63 63 64 64 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { … … 96 96 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 97 97 98 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) :99 Statement( ), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {98 BranchStmt::BranchStmt( std::list<Label> labels, Label target, Type type ) throw ( SemanticError ) : 99 Statement( labels ), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) { 100 100 //actually this is a syntactic error signaled by the parser 101 101 if ( type == BranchStmt::Goto && target.empty() ) { … … 104 104 } 105 105 106 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) :107 Statement( ), computedTarget( computedTarget ), type( type ) {106 BranchStmt::BranchStmt( std::list<Label> labels, Expression *computedTarget, Type type ) throw ( SemanticError ) : 107 Statement( labels ), computedTarget( computedTarget ), type( type ) { 108 108 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { 109 109 throw SemanticError("Computed target not valid in branch statement"); … … 118 118 } 119 119 120 ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {}120 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *expr ) : Statement( labels ), expr( expr ) {} 121 121 122 122 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 135 135 } 136 136 137 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):138 Statement( ), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {}137 IfStmt::IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ): 138 Statement( labels ), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {} 139 139 140 140 IfStmt::IfStmt( const IfStmt & other ) : … … 176 176 } 177 177 178 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ):179 Statement( ), condition( condition ), statements( statements ) {178 SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, const std::list<Statement *> &statements ): 179 Statement( labels ), condition( condition ), statements( statements ) { 180 180 } 181 181 … … 201 201 } 202 202 203 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :204 Statement( ), condition( condition ), stmts( statements ), _isDefault( deflt ) {203 CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) : 204 Statement( labels ), condition( condition ), stmts( statements ), _isDefault( deflt ) { 205 205 if ( isDefault() && condition != 0 ) throw SemanticError("default case with condition: ", condition); 206 206 } … … 216 216 } 217 217 218 CaseStmt * CaseStmt::makeDefault( const std::list<Label> & labels, std::list<Statement *> stmts ) { 219 CaseStmt * stmt = new CaseStmt( nullptr, stmts, true ); 220 stmt->labels = labels; 221 return stmt; 218 CaseStmt * CaseStmt::makeDefault( std::list<Label> labels, std::list<Statement *> stmts ) { 219 return new CaseStmt( labels, 0, stmts, true ); 222 220 } 223 221 … … 235 233 } 236 234 237 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):238 Statement( ), condition( condition), body( body), isDoWhile( isDoWhile) {235 WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition, Statement *body, bool isDoWhile ): 236 Statement( labels ), condition( condition), body( body), isDoWhile( isDoWhile) { 239 237 } 240 238 … … 257 255 } 258 256 259 ForStmt::ForStmt( std::list< Statement *> initialization, Expression *condition, Expression *increment, Statement *body ):260 Statement( ), initialization( initialization ), condition( condition ), increment( increment ), body( body ) {257 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ): 258 Statement( labels ), initialization( initialization ), condition( condition ), increment( increment ), body( body ) { 261 259 } 262 260 … … 304 302 } 305 303 306 ThrowStmt::ThrowStmt( Kind kind, Expression * expr, Expression * target ) :307 Statement( ), kind(kind), expr(expr), target(target) {304 ThrowStmt::ThrowStmt( std::list<Label> labels, Kind kind, Expression * expr, Expression * target ) : 305 Statement( labels ), kind(kind), expr(expr), target(target) { 308 306 assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." ); 309 307 } … … 328 326 } 329 327 330 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :331 Statement( ), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) {328 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) : 329 Statement( labels ), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 332 330 } 333 331 … … 361 359 } 362 360 363 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) :364 Statement( ), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) {361 CatchStmt::CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, Expression *cond, Statement *body ) : 362 Statement( labels ), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { 365 363 assertf( decl, "Catch clause must have a declaration." ); 366 364 } … … 393 391 394 392 395 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) { 393 FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *block ) : Statement( labels ), block( block ) { 394 assert( labels.empty() ); // finally statement cannot be labeled 396 395 } 397 396 … … 409 408 } 410 409 411 WaitForStmt::WaitForStmt( ) : Statement() {410 WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels ) { 412 411 timeout.time = nullptr; 413 412 timeout.statement = nullptr; … … 456 455 } 457 456 458 NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) { 459 } 457 458 WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Statement( std::list<Label>() ), exprs( exprs ), stmt( stmt ) {} 459 WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) { 460 cloneAll( other.exprs, exprs ); 461 } 462 WithStmt::~WithStmt() { 463 deleteAll( exprs ); 464 delete stmt; 465 } 466 467 void WithStmt::print( std::ostream & os, Indenter indent ) const { 468 os << "With statement" << endl; 469 os << indent << "... with statement:" << endl << indent+1; 470 stmt->print( os, indent+1 ); 471 } 472 473 474 NullStmt::NullStmt( std::list<Label> labels ) : Statement( labels ) {} 475 NullStmt::NullStmt() : Statement( std::list<Label>() ) {} 460 476 461 477 void NullStmt::print( std::ostream &os, Indenter ) const { … … 463 479 } 464 480 465 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement( ), callStmt( callStmt ) {481 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement( std::list<Label>() ), callStmt( callStmt ) { 466 482 assert( callStmt ); 467 483 }
Note:
See TracChangeset
for help on using the changeset viewer.