Changeset ba3706f for src/SynTree/Statement.cc
- Timestamp:
- Nov 30, 2017, 4:43:59 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, resolv-new, with_gc
- Children:
- c50d54d
- Parents:
- 4429b04
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
r4429b04 rba3706f 32 32 using std::endl; 33 33 34 Statement::Statement( std::list<Label>labels ) : labels( labels ) {}34 Statement::Statement( const 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( std::list<Label> labels, Expression *expr ) : Statement( labels), expr( expr ) {}48 ExprStmt::ExprStmt( Expression *expr ) : Statement(), expr( expr ) {} 49 49 50 50 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 60 60 61 61 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 ) {}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 ) {} 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( std::list<Label> labels,Label target, Type type ) throw ( SemanticError ) :99 Statement( labels), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {98 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticError ) : 99 Statement(), 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( std::list<Label> labels,Expression *computedTarget, Type type ) throw ( SemanticError ) :107 Statement( labels), computedTarget( computedTarget ), type( type ) {106 BranchStmt::BranchStmt( Expression *computedTarget, Type type ) throw ( SemanticError ) : 107 Statement(), 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( std::list<Label> labels, Expression *expr ) : Statement( labels), expr( expr ) {}120 ReturnStmt::ReturnStmt( Expression *expr ) : Statement(), expr( expr ) {} 121 121 122 122 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 135 135 } 136 136 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 ) {}137 IfStmt::IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ): 138 Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {} 139 139 140 140 IfStmt::IfStmt( const IfStmt & other ) : … … 176 176 } 177 177 178 SwitchStmt::SwitchStmt( std::list<Label> labels,Expression * condition, const std::list<Statement *> &statements ):179 Statement( labels), condition( condition ), statements( statements ) {178 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> &statements ): 179 Statement(), condition( condition ), statements( statements ) { 180 180 } 181 181 … … 201 201 } 202 202 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 ) {203 CaseStmt::CaseStmt( Expression *condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) : 204 Statement(), 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( std::list<Label> labels, std::list<Statement *> stmts ) { 219 return new CaseStmt( labels, 0, stmts, true ); 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; 220 222 } 221 223 … … 233 235 } 234 236 235 WhileStmt::WhileStmt( std::list<Label> labels,Expression *condition, Statement *body, bool isDoWhile ):236 Statement( labels), condition( condition), body( body), isDoWhile( isDoWhile) {237 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ): 238 Statement(), condition( condition), body( body), isDoWhile( isDoWhile) { 237 239 } 238 240 … … 255 257 } 256 258 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 ) {259 ForStmt::ForStmt( std::list<Statement *> initialization, Expression *condition, Expression *increment, Statement *body ): 260 Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) { 259 261 } 260 262 … … 302 304 } 303 305 304 ThrowStmt::ThrowStmt( std::list<Label> labels,Kind kind, Expression * expr, Expression * target ) :305 Statement( labels), kind(kind), expr(expr), target(target) {306 ThrowStmt::ThrowStmt( Kind kind, Expression * expr, Expression * target ) : 307 Statement(), kind(kind), expr(expr), target(target) { 306 308 assertf(Resume == kind || nullptr == target, "Non-local termination throw is not accepted." ); 307 309 } … … 326 328 } 327 329 328 TryStmt::TryStmt( std::list<Label> labels,CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :329 Statement( labels), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) {330 TryStmt::TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) : 331 Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 330 332 } 331 333 … … 359 361 } 360 362 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 ) {363 CatchStmt::CatchStmt( Kind kind, Declaration *decl, Expression *cond, Statement *body ) : 364 Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { 363 365 assertf( decl, "Catch clause must have a declaration." ); 364 366 } … … 391 393 392 394 393 FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *block ) : Statement( labels ), block( block ) { 394 assert( labels.empty() ); // finally statement cannot be labeled 395 FinallyStmt::FinallyStmt( CompoundStmt *block ) : Statement(), block( block ) { 395 396 } 396 397 … … 408 409 } 409 410 410 WaitForStmt::WaitForStmt( std::list<Label> labels ) : Statement( labels) {411 WaitForStmt::WaitForStmt() : Statement() { 411 412 timeout.time = nullptr; 412 413 timeout.statement = nullptr; … … 455 456 } 456 457 457 NullStmt::NullStmt( std::list<Label> labels ) : Statement( labels ) {}458 NullStmt::NullStmt() : Statement( std::list<Label>() ) {}458 NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) { 459 } 459 460 460 461 void NullStmt::print( std::ostream &os, Indenter ) const { … … 462 463 } 463 464 464 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement( std::list<Label>()), callStmt( callStmt ) {465 ImplicitCtorDtorStmt::ImplicitCtorDtorStmt( Statement * callStmt ) : Statement(), callStmt( callStmt ) { 465 466 assert( callStmt ); 466 467 }
Note: See TracChangeset
for help on using the changeset viewer.