Changeset ba3706f for src/SynTree
- 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
- Location:
- src/SynTree
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/CompoundStmt.cc
r4429b04 rba3706f 28 28 using std::endl; 29 29 30 CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels) {30 CompoundStmt::CompoundStmt() : Statement() { 31 31 } 32 32 33 CompoundStmt::CompoundStmt( std::list<Statement *> stmts ) : Statement( noLabels), kids( stmts ) {33 CompoundStmt::CompoundStmt( std::list<Statement *> stmts ) : Statement(), kids( stmts ) { 34 34 } 35 35 -
src/SynTree/DeclStmt.cc
r4429b04 rba3706f 23 23 #include "SynTree/Label.h" // for Label 24 24 25 DeclStmt::DeclStmt( std::list<Label> labels, Declaration *decl ) : Statement( labels), decl( decl ) {25 DeclStmt::DeclStmt( Declaration *decl ) : Statement(), decl( decl ) { 26 26 } 27 27 -
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 } -
src/SynTree/Statement.h
r4429b04 rba3706f 37 37 std::list<Label> labels; 38 38 39 Statement( std::list<Label> labels);39 Statement( const std::list<Label> & labels = {} ); 40 40 virtual ~Statement(); 41 41 … … 53 53 std::list<Statement*> kids; 54 54 55 CompoundStmt( std::list<Label> labels);55 CompoundStmt(); 56 56 CompoundStmt( std::list<Statement *> stmts ); 57 57 CompoundStmt( const CompoundStmt &other ); … … 70 70 class NullStmt : public Statement { 71 71 public: 72 NullStmt(); 73 NullStmt( std::list<Label> labels ); 72 NullStmt( const std::list<Label> & labels = {} ); 74 73 75 74 virtual NullStmt *clone() const override { return new NullStmt( *this ); } … … 83 82 Expression *expr; 84 83 85 ExprStmt( std::list<Label> labels,Expression *expr );84 ExprStmt( Expression *expr ); 86 85 ExprStmt( const ExprStmt &other ); 87 86 virtual ~ExprStmt(); … … 104 103 std::list<Label> gotolabels; 105 104 106 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 );105 AsmStmt( bool voltile, Expression *instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 107 106 AsmStmt( const AsmStmt &other ); 108 107 virtual ~AsmStmt(); … … 134 133 std::list<Statement *> initialization; 135 134 136 IfStmt( std::list<Label> labels,Expression *condition, Statement *thenPart, Statement *elsePart,135 IfStmt( Expression *condition, Statement *thenPart, Statement *elsePart, 137 136 std::list<Statement *> initialization = std::list<Statement *>() ); 138 137 IfStmt( const IfStmt &other ); … … 158 157 std::list<Statement *> statements; 159 158 160 SwitchStmt( std::list<Label> labels,Expression *condition, const std::list<Statement *> &statements );159 SwitchStmt( Expression *condition, const std::list<Statement *> &statements ); 161 160 SwitchStmt( const SwitchStmt &other ); 162 161 virtual ~SwitchStmt(); … … 180 179 std::list<Statement *> stmts; 181 180 182 CaseStmt( std::list<Label> labels,Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError);181 CaseStmt( Expression *conditions, const std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 183 182 CaseStmt( const CaseStmt &other ); 184 183 virtual ~CaseStmt(); 185 184 186 static CaseStmt * makeDefault( std::list<Label> labels = std::list<Label>(), std::list<Statement *> stmts = std::list<Statement *>() );185 static CaseStmt * makeDefault( const std::list<Label> & labels = {}, std::list<Statement *> stmts = std::list<Statement *>() ); 187 186 188 187 bool isDefault() const { return _isDefault; } … … 210 209 bool isDoWhile; 211 210 212 WhileStmt( std::list<Label> labels,Expression *condition,211 WhileStmt( Expression *condition, 213 212 Statement *body, bool isDoWhile = false ); 214 213 WhileStmt( const WhileStmt &other ); … … 235 234 Statement *body; 236 235 237 ForStmt( std::list< Label> labels, std::list<Statement *> initialization,236 ForStmt( std::list<Statement *> initialization, 238 237 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); 239 238 ForStmt( const ForStmt &other ); … … 264 263 Type type; 265 264 266 BranchStmt( std::list<Label> labels,Label target, Type ) throw (SemanticError);267 BranchStmt( std::list<Label> labels,Expression *computedTarget, Type ) throw (SemanticError);265 BranchStmt( Label target, Type ) throw (SemanticError); 266 BranchStmt( Expression *computedTarget, Type ) throw (SemanticError); 268 267 269 268 Label get_originalTarget() { return originalTarget; } … … 289 288 Expression *expr; 290 289 291 ReturnStmt( std::list<Label> labels,Expression *expr );290 ReturnStmt( Expression *expr ); 292 291 ReturnStmt( const ReturnStmt &other ); 293 292 virtual ~ReturnStmt(); … … 310 309 Expression * target; 311 310 312 ThrowStmt( std::list<Label> labels,Kind kind, Expression * expr, Expression * target = nullptr );311 ThrowStmt( Kind kind, Expression * expr, Expression * target = nullptr ); 313 312 ThrowStmt( const ThrowStmt &other ); 314 313 virtual ~ThrowStmt(); … … 332 331 FinallyStmt * finallyBlock; 333 332 334 TryStmt( std::list<Label> labels,CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 );333 TryStmt( CompoundStmt *tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock = 0 ); 335 334 TryStmt( const TryStmt &other ); 336 335 virtual ~TryStmt(); … … 358 357 Statement *body; 359 358 360 CatchStmt( std::list<Label> labels,Kind kind, Declaration *decl,359 CatchStmt( Kind kind, Declaration *decl, 361 360 Expression *cond, Statement *body ); 362 361 CatchStmt( const CatchStmt &other ); … … 381 380 CompoundStmt *block; 382 381 383 FinallyStmt( std::list<Label> labels,CompoundStmt *block );382 FinallyStmt( CompoundStmt *block ); 384 383 FinallyStmt( const FinallyStmt &other ); 385 384 virtual ~FinallyStmt(); … … 408 407 }; 409 408 410 WaitForStmt( std::list<Label> labels = noLabels);409 WaitForStmt(); 411 410 WaitForStmt( const WaitForStmt & ); 412 411 virtual ~WaitForStmt(); … … 438 437 Declaration *decl; 439 438 440 DeclStmt( std::list<Label> labels,Declaration *decl );439 DeclStmt( Declaration *decl ); 441 440 DeclStmt( const DeclStmt &other ); 442 441 virtual ~DeclStmt(); -
src/SynTree/TupleExpr.cc
r4429b04 rba3706f 23 23 #include "Declaration.h" // for ObjectDecl 24 24 #include "Expression.h" // for Expression, TupleExpr, TupleIndexExpr 25 #include "SynTree/Label.h" // for Label , noLabels25 #include "SynTree/Label.h" // for Label 26 26 #include "SynTree/Statement.h" // for CompoundStmt, DeclStmt, ExprStmt, Sta... 27 27 #include "Tuples/Tuples.h" // for makeTupleType … … 89 89 // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments 90 90 set_result( Tuples::makeTupleType( assigns ) ); 91 CompoundStmt * compoundStmt = new CompoundStmt( noLabels);91 CompoundStmt * compoundStmt = new CompoundStmt(); 92 92 std::list< Statement * > & stmts = compoundStmt->get_kids(); 93 93 for ( ObjectDecl * obj : tempDecls ) { 94 stmts.push_back( new DeclStmt( noLabels,obj ) );94 stmts.push_back( new DeclStmt( obj ) ); 95 95 } 96 96 TupleExpr * tupleExpr = new TupleExpr( assigns ); 97 97 assert( tupleExpr->get_result() ); 98 stmts.push_back( new ExprStmt( noLabels,tupleExpr ) );98 stmts.push_back( new ExprStmt( tupleExpr ) ); 99 99 stmtExpr = new StmtExpr( compoundStmt ); 100 100 }
Note: See TracChangeset
for help on using the changeset viewer.