Changes in / [9dc08363:941e14a]
- Location:
- src
- Files:
-
- 8 edited
-
AST/Stmt.cpp (modified) (2 diffs)
-
AST/Stmt.hpp (modified) (20 diffs)
-
CodeGen/CodeGenerator.cc (modified) (2 diffs)
-
ControlStruct/MLEMutator.cc (modified) (3 diffs)
-
ControlStruct/MultiLevelExit.cpp (modified) (3 diffs)
-
Parser/StatementNode.cc (modified) (2 diffs)
-
SynTree/Statement.cc (modified) (26 diffs)
-
SynTree/Statement.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Stmt.cpp
r9dc08363 r941e14a 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 8 13:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Feb 2 19:01:20 202213 // Update Count : 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed May 15 15:53:00 2019 13 // Update Count : 2 14 14 // 15 15 … … 56 56 57 57 // --- BranchStmt 58 BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, conststd::vector<Label>&& labels )59 : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) {58 BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, std::vector<Label>&& labels ) 59 : Stmt(loc, std::move(labels)), originalTarget(target), target(target), kind(kind) { 60 60 // Make sure a syntax error hasn't slipped through. 61 61 assert( Goto != kind || !target.empty() ); -
src/AST/Stmt.hpp
r9dc08363 r941e14a 10 10 // Created On : Wed May 8 13:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 20:06:41202213 // Update Count : 3412 // Last Modified On : Tue Feb 1 17:44:46 2022 13 // Update Count : 24 14 14 // 15 15 … … 39 39 std::vector<Label> labels; 40 40 41 Stmt( const CodeLocation & loc, conststd::vector<Label> && labels = {} )41 Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) 42 42 : ParseNode(loc), labels(std::move(labels)) {} 43 43 … … 55 55 std::list<ptr<Stmt>> kids; 56 56 57 CompoundStmt(const CodeLocation & loc, const std::list<ptr<Stmt>> && ks = {}, const std::vector<Label> && labels = {} ) 57 CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {}, 58 std::vector<Label> && labels = {} ) 58 59 : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} 59 60 … … 73 74 class NullStmt final : public Stmt { 74 75 public: 75 NullStmt( const CodeLocation & loc, conststd::vector<Label> && labels = {} )76 NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) 76 77 : Stmt(loc, std::move(labels)) {} 77 78 … … 87 88 ptr<Expr> expr; 88 89 89 ExprStmt( const CodeLocation & loc, const Expr* e, conststd::vector<Label> && labels = {} )90 ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label> && labels = {} ) 90 91 : Stmt(loc, std::move(labels)), expr(e) {} 91 92 … … 106 107 107 108 AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction, 108 const std::vector<ptr<Expr>> && output, conststd::vector<ptr<Expr>> && input,109 const std::vector<ptr<ConstantExpr>> && clobber, conststd::vector<Label> && gotoLabels,110 conststd::vector<Label> && labels = {})109 std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>> && input, 110 std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label> && gotoLabels, 111 std::vector<Label> && labels = {}) 111 112 : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction), 112 113 output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)), … … 143 144 144 145 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then, 145 const Stmt * else_ = nullptr, conststd::vector<ptr<Stmt>> && inits = {},146 conststd::vector<Label> && labels = {} )146 const Stmt * else_ = nullptr, std::vector<ptr<Stmt>> && inits = {}, 147 std::vector<Label> && labels = {} ) 147 148 : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_), 148 149 inits(std::move(inits)) {} … … 160 161 std::vector<ptr<Stmt>> stmts; 161 162 162 SwitchStmt( const CodeLocation & loc, const Expr * cond, conststd::vector<ptr<Stmt>> && stmts,163 conststd::vector<Label> && labels = {} )163 SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts, 164 std::vector<Label> && labels = {} ) 164 165 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 165 166 … … 177 178 std::vector<ptr<Stmt>> stmts; 178 179 179 CaseStmt( const CodeLocation & loc, const Expr * cond, conststd::vector<ptr<Stmt>> && stmts,180 conststd::vector<Label> && labels = {} )180 CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts, 181 std::vector<Label> && labels = {} ) 181 182 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 182 183 … … 199 200 200 201 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, 201 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, conststd::vector<Label> && labels = {} )202 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} ) 202 203 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {} 203 204 204 205 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_, 205 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, conststd::vector<Label> && labels = {} )206 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} ) 206 207 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {} 207 208 … … 221 222 ptr<Stmt> else_; 222 223 223 ForStmt( const CodeLocation & loc, conststd::vector<ptr<Stmt>> && inits, const Expr * cond,224 const Expr * inc, const Stmt * body, conststd::vector<Label> && label = {} )224 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond, 225 const Expr * inc, const Stmt * body, std::vector<Label> && label = {} ) 225 226 : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {} 226 227 227 ForStmt( const CodeLocation & loc, conststd::vector<ptr<Stmt>> && inits, const Expr * cond,228 const Expr * inc, const Stmt * body, const Stmt * else_, conststd::vector<Label> && labels = {} )228 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond, 229 const Expr * inc, const Stmt * body, const Stmt * else_, std::vector<Label> && labels = {} ) 229 230 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {} 230 231 … … 246 247 Kind kind; 247 248 248 BranchStmt( const CodeLocation & loc, Kind kind, Label target, const std::vector<Label> && labels = {} ); 249 BranchStmt( const CodeLocation & loc, const Expr * computedTarget, const std::vector<Label> && labels = {} ) 250 : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), computedTarget(computedTarget), kind(Goto) {} 249 BranchStmt( const CodeLocation & loc, Kind kind, Label target, 250 std::vector<Label> && labels = {} ); 251 BranchStmt( const CodeLocation & loc, const Expr * computedTarget, 252 std::vector<Label> && labels = {} ) 253 : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), 254 computedTarget(computedTarget), kind(Goto) {} 251 255 252 256 const char * kindName() const { return kindNames[kind]; } … … 265 269 ptr<Expr> expr; 266 270 267 ReturnStmt( const CodeLocation & loc, const Expr * expr, conststd::vector<Label> && labels = {} )271 ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} ) 268 272 : Stmt(loc, std::move(labels)), expr(expr) {} 269 273 … … 284 288 ExceptionKind kind; 285 289 286 ThrowStmt( const CodeLocation & loc, ExceptionKind kind, const Expr * expr, 287 const Expr * target, const std::vector<Label> && labels = {} ) 290 ThrowStmt( 291 const CodeLocation & loc, ExceptionKind kind, const Expr * expr, const Expr * target, 292 std::vector<Label> && labels = {} ) 288 293 : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} 289 294 … … 301 306 ptr<FinallyStmt> finally; 302 307 303 TryStmt( const CodeLocation & loc, const CompoundStmt * body, 304 const std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, 305 const std::vector<Label> && labels = {} ) 308 TryStmt( 309 const CodeLocation & loc, const CompoundStmt * body, 310 std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, 311 std::vector<Label> && labels = {} ) 306 312 : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} 307 313 … … 320 326 ExceptionKind kind; 321 327 322 CatchStmt( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 323 const Stmt * body, const std::vector<Label> && labels = {} ) 328 CatchStmt( 329 const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 330 const Stmt * body, std::vector<Label> && labels = {} ) 324 331 : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} 325 332 … … 351 358 enum Type { None, Coroutine, Generator } type = None; 352 359 353 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, conststd::vector<Label> && labels = {} )360 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} ) 354 361 : Stmt(loc, std::move(labels)), then(then), type(type) {} 355 362 … … 389 396 OrElse orElse; 390 397 391 WaitForStmt( const CodeLocation & loc, conststd::vector<Label> && labels = {} )398 WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} ) 392 399 : Stmt(loc, std::move(labels)) {} 393 400 … … 403 410 ptr<Decl> decl; 404 411 405 DeclStmt( const CodeLocation & loc, const Decl * decl, conststd::vector<Label> && labels = {} )412 DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} ) 406 413 : Stmt(loc, std::move(labels)), decl(decl) {} 407 414 … … 434 441 435 442 MutexStmt( const CodeLocation & loc, const Stmt * stmt, 436 const std::vector<ptr<Expr>> && mutexes, conststd::vector<Label> && labels = {} )443 std::vector<ptr<Expr>> && mutexes, std::vector<Label> && labels = {} ) 437 444 : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {} 438 445 -
src/CodeGen/CodeGenerator.cc
r9dc08363 r941e14a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 20:30:30202213 // Update Count : 54 112 // Last Modified On : Tue Feb 1 16:29:25 2022 13 // Update Count : 540 14 14 // 15 15 #include "CodeGenerator.h" … … 1020 1020 output << "fallthru"; 1021 1021 break; 1022 default: ; // prevent warning1023 1022 } // switch 1024 1023 // print branch target for labelled break/continue/fallthru in debug mode -
src/ControlStruct/MLEMutator.cc
r9dc08363 r941e14a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 20:18:57202213 // Update Count : 22 712 // Last Modified On : Tue Feb 1 09:26:28 2022 13 // Update Count : 225 14 14 // 15 15 … … 136 136 } 137 137 } 138 assertf( false, "C FA internal error: could not find label '%s' on statement %s",138 assertf( false, "Could not find label '%s' on statement %s", 139 139 originalTarget.get_name().c_str(), toString( stmt ).c_str() ); 140 140 } … … 395 395 } 396 396 assert( ! enclosingControlStructures.empty() ); 397 assertf( dynamic_cast<SwitchStmt *>( enclosingControlStructures.back().get_controlStructure() ), 398 "CFA internal error: control structure enclosing a case clause must be a switch, but is: %s", 399 toCString( enclosingControlStructures.back().get_controlStructure() ) ); 397 assertf( dynamic_cast<SwitchStmt *>( enclosingControlStructures.back().get_controlStructure() ), "Control structure enclosing a case clause must be a switch, but is: %s", toCString( enclosingControlStructures.back().get_controlStructure() ) ); 400 398 if ( caseStmt->isDefault() ) { 401 399 if ( enclosingControlStructures.back().isFallDefaultUsed() ) { -
src/ControlStruct/MultiLevelExit.cpp
r9dc08363 r941e14a 10 10 // Created On : Mon Nov 1 13:48:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 20:19:24202213 // Update Count : 3012 // Last Modified On : Tue Feb 1 18:48:47 2022 13 // Update Count : 29 14 14 // 15 15 … … 206 206 } 207 207 } 208 assertf( false, "C FA internal error: could not find label '%s' on statement %s",208 assertf( false, "Could not find label '%s' on statement %s", 209 209 originalTarget.name.c_str(), toString( stmt ).c_str() ); 210 210 } … … 406 406 Entry & entry = enclosing_control_structures.back(); 407 407 assertf( dynamic_cast< const SwitchStmt * >( entry.stmt ), 408 "C FA internal error: control structure enclosing a case clause must be a switch, but is: %s",408 "Control structure enclosing a case clause must be a switch, but is: %s", 409 409 toString( entry.stmt ).c_str() ); 410 410 if ( mutStmt->isDefault() ) { -
src/Parser/StatementNode.cc
r9dc08363 r941e14a 11 11 // Created On : Sat May 16 14:59:41 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Feb 2 20:29:30202214 // Update Count : 42 513 // Last Modified On : Wed Feb 2 12:27:58 2022 14 // Update Count : 424 15 15 // 16 16 … … 138 138 139 139 Statement * build_case( ExpressionNode * ctl ) { 140 return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // stmt starts empty and then added to140 return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // no init 141 141 } // build_case 142 142 143 143 Statement * build_default() { 144 return new CaseStmt( nullptr, {}, true ); // stmt starts empty and then added to144 return new CaseStmt( nullptr, {}, true ); // no init 145 145 } // build_default 146 146 -
src/SynTree/Statement.cc
r9dc08363 r941e14a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 20:19:33202213 // Update Count : 9012 // Last Modified On : Wed Feb 2 11:55:19 2022 13 // Update Count : 80 14 14 // 15 15 … … 29 29 #include "SynTree/Label.h" // for Label, operator<< 30 30 31 using namespace std;32 33 34 Statement::Statement( const list<Label> & labels ) : labels( labels ) {}35 36 void Statement::print( ostream & os, Indenter indent ) const {31 using std::string; 32 using std::endl; 33 34 Statement::Statement( const std::list<Label> & labels ) : labels( labels ) {} 35 36 void Statement::print( std::ostream & os, Indenter indent ) const { 37 37 if ( ! labels.empty() ) { 38 38 os << indent << "... Labels: {"; … … 54 54 } 55 55 56 void ExprStmt::print( ostream & os, Indenter indent ) const {57 os << "Expression Statement:" << endl << indent +1;58 expr->print( os, indent +1 );59 } 60 61 62 AsmStmt::AsmStmt( bool voltile, Expression * instruction, const list<Expression *> output, const list<Expression *> input, const list<ConstantExpr *> clobber, constlist<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}56 void ExprStmt::print( std::ostream & os, Indenter indent ) const { 57 os << "Expression Statement:" << endl << indent+1; 58 expr->print( os, indent+1 ); 59 } 60 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 ) {} 63 63 64 64 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) { … … 75 75 } 76 76 77 void AsmStmt::print( ostream & os, Indenter indent ) const {77 void AsmStmt::print( std::ostream & os, Indenter indent ) const { 78 78 os << "Assembler Statement:" << endl; 79 os << indent +1 << "instruction: " << endl << indent;80 instruction->print( os, indent +1 );79 os << indent+1 << "instruction: " << endl << indent; 80 instruction->print( os, indent+1 ); 81 81 if ( ! output.empty() ) { 82 os << endl << indent +1 << "output: " << endl;83 printAll( output, os, indent +1 );82 os << endl << indent+1 << "output: " << endl; 83 printAll( output, os, indent+1 ); 84 84 } // if 85 85 if ( ! input.empty() ) { 86 os << indent +1 << "input: " << endl;87 printAll( input, os, indent +1 );86 os << indent+1 << "input: " << endl; 87 printAll( input, os, indent+1 ); 88 88 } // if 89 89 if ( ! clobber.empty() ) { 90 os << indent +1 << "clobber: " << endl;91 printAll( clobber, os, indent +1 );90 os << indent+1 << "clobber: " << endl; 91 printAll( clobber, os, indent+1 ); 92 92 } // if 93 93 } 94 94 95 95 96 DirectiveStmt::DirectiveStmt( const st ring & directive ) : Statement(), directive( directive ) {}97 98 void DirectiveStmt::print( ostream & os, Indenter ) const {96 DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {} 97 98 void DirectiveStmt::print( std::ostream & os, Indenter ) const { 99 99 os << "GCC Directive:" << directive << endl; 100 100 } … … 120 120 } 121 121 122 void BranchStmt::print( ostream & os, Indenter indent ) const {123 assert f(type < BranchStmts, "CFA internal error: invalid branch statement");122 void BranchStmt::print( std::ostream & os, Indenter indent ) const { 123 assert(type < 5); 124 124 os << "Branch (" << brType[type] << ")" << endl ; 125 if ( target != "" ) os << indent +1 << "with target: " << target << endl;126 if ( originalTarget != "" ) os << indent +1 << "with original target: " << originalTarget << endl;127 if ( computedTarget != nullptr ) os << indent +1 << "with computed target: " << computedTarget << endl;125 if ( target != "" ) os << indent+1 << "with target: " << target << endl; 126 if ( originalTarget != "" ) os << indent+1 << "with original target: " << originalTarget << endl; 127 if ( computedTarget != nullptr ) os << indent+1 << "with computed target: " << computedTarget << endl; 128 128 } 129 129 … … 136 136 } 137 137 138 void ReturnStmt::print( ostream & os, Indenter indent ) const {138 void ReturnStmt::print( std::ostream & os, Indenter indent ) const { 139 139 os << "Return Statement, returning: "; 140 140 if ( expr != nullptr ) { 141 os << endl << indent +1;142 expr->print( os, indent +1 );141 os << endl << indent+1; 142 expr->print( os, indent+1 ); 143 143 } 144 144 os << endl; 145 145 } 146 146 147 IfStmt::IfStmt( Expression * condition, Statement * then, Statement * else_, constlist<Statement *> initialization ):147 IfStmt::IfStmt( Expression * condition, Statement * then, Statement * else_, std::list<Statement *> initialization ): 148 148 Statement(), condition( condition ), then( then ), else_( else_ ), initialization( initialization ) {} 149 149 … … 160 160 } 161 161 162 void IfStmt::print( ostream & os, Indenter indent ) const {162 void IfStmt::print( std::ostream & os, Indenter indent ) const { 163 163 os << "If on condition: " << endl; 164 os << indent +1;165 condition->print( os, indent +1 );164 os << indent+1; 165 condition->print( os, indent+1 ); 166 166 167 167 if ( !initialization.empty() ) { 168 168 os << indent << "... with initialization: \n"; 169 169 for ( const Statement * stmt : initialization ) { 170 os << indent +1;171 stmt->print( os, indent +1 );170 os << indent+1; 171 stmt->print( os, indent+1 ); 172 172 } 173 173 os << endl; … … 176 176 os << indent << "... then: " << endl; 177 177 178 os << indent +1;179 then->print( os, indent +1 );178 os << indent+1; 179 then->print( os, indent+1 ); 180 180 181 181 if ( else_ != nullptr ) { 182 182 os << indent << "... else: " << endl; 183 os << indent +1;184 else_->print( os, indent +1 );183 os << indent+1; 184 else_->print( os, indent+1 ); 185 185 } // if 186 186 } 187 187 188 SwitchStmt::SwitchStmt( Expression * condition, const list<Statement *> & statements ):188 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ): 189 189 Statement(), condition( condition ), statements( statements ) { 190 190 } … … 201 201 } 202 202 203 void SwitchStmt::print( ostream & os, Indenter indent ) const {203 void SwitchStmt::print( std::ostream & os, Indenter indent ) const { 204 204 os << "Switch on condition: "; 205 205 condition->print( os ); … … 207 207 208 208 for ( const Statement * stmt : statements ) { 209 stmt->print( os, indent +1 );210 } 211 } 212 213 CaseStmt::CaseStmt( Expression * condition, const list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) :214 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) {209 stmt->print( os, indent+1 ); 210 } 211 } 212 213 CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) : 214 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) { 215 215 if ( isDefault() && condition != nullptr ) SemanticError( condition, "default case with condition: " ); 216 216 } 217 217 218 218 CaseStmt::CaseStmt( const CaseStmt & other ) : 219 Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {219 Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) { 220 220 cloneAll( other.stmts, stmts ); 221 221 } … … 226 226 } 227 227 228 CaseStmt * CaseStmt::makeDefault( const list<Label> & labels,list<Statement *> stmts ) {228 CaseStmt * CaseStmt::makeDefault( const std::list<Label> & labels, std::list<Statement *> stmts ) { 229 229 CaseStmt * stmt = new CaseStmt( nullptr, stmts, true ); 230 230 stmt->labels = labels; … … 232 232 } 233 233 234 void CaseStmt::print( ostream & os, Indenter indent ) const {234 void CaseStmt::print( std::ostream & os, Indenter indent ) const { 235 235 if ( isDefault() ) os << indent << "Default "; 236 236 else { … … 241 241 242 242 for ( Statement * stmt : stmts ) { 243 os << indent +1;244 stmt->print( os, indent +1 );245 } 246 } 247 248 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, const list< Statement * > & initialization, bool isDoWhile ):243 os << indent+1; 244 stmt->print( os, indent+1 ); 245 } 246 } 247 248 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, const std::list< Statement * > & initialization, bool isDoWhile ): 249 249 Statement(), condition( condition ), body( body ), else_( nullptr ), initialization( initialization ), isDoWhile( isDoWhile) { 250 250 } 251 251 252 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const list< Statement * > & initialization, bool isDoWhile ):252 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const std::list< Statement * > & initialization, bool isDoWhile ): 253 253 Statement(), condition( condition), body( body ), else_( else_ ), initialization( initialization ), isDoWhile( isDoWhile) { 254 254 } … … 263 263 } 264 264 265 void WhileDoStmt::print( ostream & os, Indenter indent ) const {265 void WhileDoStmt::print( std::ostream & os, Indenter indent ) const { 266 266 os << "While on condition: " << endl ; 267 condition->print( os, indent +1 );267 condition->print( os, indent+1 ); 268 268 269 269 os << indent << "... with body: " << endl; 270 270 271 if ( body != nullptr ) body->print( os, indent +1 );272 } 273 274 ForStmt::ForStmt( constlist<Statement *> initialization, Expression * condition, Expression * increment, Statement * body, Statement * else_ ):271 if ( body != nullptr ) body->print( os, indent+1 ); 272 } 273 274 ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body, Statement * else_ ): 275 275 Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ), else_( else_ ) { 276 276 } … … 290 290 } 291 291 292 void ForStmt::print( ostream & os, Indenter indent ) const {292 void ForStmt::print( std::ostream & os, Indenter indent ) const { 293 293 Statement::print( os, indent ); // print labels 294 294 … … 298 298 os << indent << "... initialization: \n"; 299 299 for ( Statement * stmt : initialization ) { 300 os << indent +1;301 stmt->print( os, indent +1 );300 os << indent+1; 301 stmt->print( os, indent+1 ); 302 302 } 303 303 } 304 304 305 305 if ( condition != nullptr ) { 306 os << indent << "... condition: \n" << indent +1;307 condition->print( os, indent +1 );306 os << indent << "... condition: \n" << indent+1; 307 condition->print( os, indent+1 ); 308 308 } 309 309 310 310 if ( increment != nullptr ) { 311 os << "\n" << indent << "... increment: \n" << indent +1;312 increment->print( os, indent +1 );311 os << "\n" << indent << "... increment: \n" << indent+1; 312 increment->print( os, indent+1 ); 313 313 } 314 314 315 315 if ( body != nullptr ) { 316 os << "\n" << indent << "... with body: \n" << indent +1;317 body->print( os, indent +1 );316 os << "\n" << indent << "... with body: \n" << indent+1; 317 body->print( os, indent+1 ); 318 318 } 319 319 320 320 if ( else_ != nullptr ) { 321 os << "\n" << indent << "... with body: \n" << indent +1;322 else_->print( os, indent +1 );321 os << "\n" << indent << "... with body: \n" << indent+1; 322 else_->print( os, indent+1 ); 323 323 } 324 324 os << endl; … … 339 339 } 340 340 341 void ThrowStmt::print( ostream & os, Indenter indent) const {341 void ThrowStmt::print( std::ostream & os, Indenter indent) const { 342 342 if ( target ) os << "Non-Local "; 343 343 os << "Throw Statement, raising: "; 344 expr->print(os, indent +1);344 expr->print(os, indent+1); 345 345 if ( target ) { 346 346 os << "... at: "; 347 target->print(os, indent +1);348 } 349 } 350 351 TryStmt::TryStmt( CompoundStmt * tryBlock, constlist<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) :347 target->print(os, indent+1); 348 } 349 } 350 351 TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) : 352 352 Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 353 353 } … … 363 363 } 364 364 365 void TryStmt::print( ostream & os, Indenter indent ) const {365 void TryStmt::print( std::ostream & os, Indenter indent ) const { 366 366 os << "Try Statement" << endl; 367 os << indent << "... with block:" << endl << indent +1;368 block->print( os, indent +1 );367 os << indent << "... with block:" << endl << indent+1; 368 block->print( os, indent+1 ); 369 369 370 370 // handlers 371 371 os << indent << "... and handlers:" << endl; 372 372 for ( const CatchStmt * stmt : handlers ) { 373 os << indent +1;374 stmt->print( os, indent +1 );373 os << indent+1; 374 stmt->print( os, indent+1 ); 375 375 } 376 376 377 377 // finally block 378 378 if ( finallyBlock != nullptr ) { 379 os << indent << "... and finally:" << endl << indent +1;380 finallyBlock->print( os, indent +1 );379 os << indent << "... and finally:" << endl << indent+1; 380 finallyBlock->print( os, indent+1 ); 381 381 } // if 382 382 } … … 396 396 } 397 397 398 void CatchStmt::print( ostream & os, Indenter indent ) const {398 void CatchStmt::print( std::ostream & os, Indenter indent ) const { 399 399 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; 400 400 401 401 os << indent << "... catching: "; 402 decl->printShort( os, indent +1 );402 decl->printShort( os, indent+1 ); 403 403 os << endl; 404 404 405 405 if ( cond ) { 406 os << indent << "... with conditional:" << endl << indent +1;407 cond->print( os, indent +1 );406 os << indent << "... with conditional:" << endl << indent+1; 407 cond->print( os, indent+1 ); 408 408 } 409 409 410 410 os << indent << "... with block:" << endl; 411 os << indent +1;412 body->print( os, indent +1 );411 os << indent+1; 412 body->print( os, indent+1 ); 413 413 } 414 414 … … 424 424 } 425 425 426 void FinallyStmt::print( ostream & os, Indenter indent ) const {426 void FinallyStmt::print( std::ostream & os, Indenter indent ) const { 427 427 os << "Finally Statement" << endl; 428 os << indent << "... with block:" << endl << indent +1;429 block->print( os, indent +1 );428 os << indent << "... with block:" << endl << indent+1; 429 block->print( os, indent+1 ); 430 430 } 431 431 … … 439 439 } 440 440 441 void SuspendStmt::print( ostream & os, Indenter indent ) const {441 void SuspendStmt::print( std::ostream & os, Indenter indent ) const { 442 442 os << "Suspend Statement"; 443 443 switch (type) { … … 496 496 } 497 497 498 void WaitForStmt::print( ostream & os, Indenter indent ) const {498 void WaitForStmt::print( std::ostream & os, Indenter indent ) const { 499 499 os << "Waitfor Statement" << endl; 500 500 indent += 1; … … 531 531 532 532 533 WithStmt::WithStmt( const list< Expression * > & exprs, Statement * stmt ) : Declaration("", noStorageClasses, LinkageSpec::Cforall), exprs( exprs ), stmt( stmt ) {}533 WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Declaration("", noStorageClasses, LinkageSpec::Cforall), exprs( exprs ), stmt( stmt ) {} 534 534 WithStmt::WithStmt( const WithStmt & other ) : Declaration( other ), stmt( maybeClone( other.stmt ) ) { 535 535 cloneAll( other.exprs, exprs ); … … 540 540 } 541 541 542 void WithStmt::print( ostream & os, Indenter indent ) const {542 void WithStmt::print( std::ostream & os, Indenter indent ) const { 543 543 os << "With statement" << endl; 544 544 os << indent << "... with expressions: " << endl; 545 printAll( exprs, os, indent +1 );546 os << indent << "... with statement:" << endl << indent +1;547 stmt->print( os, indent +1 );548 } 549 550 551 NullStmt::NullStmt( const list<Label> & labels ) : Statement( labels ) {552 } 553 554 void NullStmt::print( ostream & os, Indenter indent ) const {545 printAll( exprs, os, indent+1 ); 546 os << indent << "... with statement:" << endl << indent+1; 547 stmt->print( os, indent+1 ); 548 } 549 550 551 NullStmt::NullStmt( const std::list<Label> & labels ) : Statement( labels ) { 552 } 553 554 void NullStmt::print( std::ostream & os, Indenter indent ) const { 555 555 os << "Null Statement" << endl; 556 556 Statement::print( os, indent ); … … 568 568 } 569 569 570 void ImplicitCtorDtorStmt::print( ostream & os, Indenter indent ) const {570 void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const { 571 571 os << "Implicit Ctor Dtor Statement" << endl; 572 572 os << indent << "... with Ctor/Dtor: "; 573 callStmt->print( os, indent +1);573 callStmt->print( os, indent+1); 574 574 os << endl; 575 575 } 576 576 577 MutexStmt::MutexStmt( Statement * stmt, constlist<Expression *> mutexObjs )577 MutexStmt::MutexStmt( Statement * stmt, std::list<Expression *> mutexObjs ) 578 578 : Statement(), stmt( stmt ), mutexObjs( mutexObjs ) { } 579 579 … … 587 587 } 588 588 589 void MutexStmt::print( ostream & os, Indenter indent ) const {589 void MutexStmt::print( std::ostream & os, Indenter indent ) const { 590 590 os << "Mutex Statement" << endl; 591 591 os << indent << "... with Expressions: " << endl; 592 592 for (auto * obj : mutexObjs) { 593 os << indent +1;594 obj->print( os, indent +1);593 os << indent+1; 594 obj->print( os, indent+1); 595 595 os << endl; 596 596 } 597 os << indent << "... with Statement: " << endl << indent +1;598 stmt->print( os, indent +1 );597 os << indent << "... with Statement: " << endl << indent+1; 598 stmt->print( os, indent+1 ); 599 599 } 600 600 -
src/SynTree/Statement.h
r9dc08363 r941e14a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 20:15:30202213 // Update Count : 9 812 // Last Modified On : Wed Feb 2 11:49:17 2022 13 // Update Count : 94 14 14 // 15 15 … … 107 107 std::list<Label> gotolabels; 108 108 109 AsmStmt( bool voltile, Expression * instruction, const std::list<Expression *> output, const std::list<Expression *> input, const std::list<ConstantExpr *> clobber, conststd::list<Label> gotolabels );109 AsmStmt( bool voltile, Expression * instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 110 110 AsmStmt( const AsmStmt & other ); 111 111 virtual ~AsmStmt(); … … 153 153 154 154 IfStmt( Expression * condition, Statement * then, Statement * else_, 155 conststd::list<Statement *> initialization = std::list<Statement *>() );155 std::list<Statement *> initialization = std::list<Statement *>() ); 156 156 IfStmt( const IfStmt & other ); 157 157 virtual ~IfStmt(); … … 260 260 Statement * else_; 261 261 262 ForStmt( conststd::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr );262 ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr ); 263 263 ForStmt( const ForStmt & other ); 264 264 virtual ~ForStmt(); … … 281 281 class BranchStmt : public Statement { 282 282 public: 283 enum Type { Goto , Break, Continue, FallThrough, FallThroughDefault, BranchStmts};283 enum Type { Goto = 0, Break, Continue, FallThrough, FallThroughDefault }; 284 284 285 285 // originalTarget kept for error messages. … … 360 360 FinallyStmt * finallyBlock; 361 361 362 TryStmt( CompoundStmt * tryBlock, conststd::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr );362 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr ); 363 363 TryStmt( const TryStmt & other ); 364 364 virtual ~TryStmt(); … … 543 543 std::list<Expression *> mutexObjs; // list of mutex objects to acquire 544 544 545 MutexStmt( Statement * stmt, conststd::list<Expression *> mutexObjs );545 MutexStmt( Statement * stmt, std::list<Expression *> mutexObjs ); 546 546 MutexStmt( const MutexStmt & other ); 547 547 virtual ~MutexStmt();
Note:
See TracChangeset
for help on using the changeset viewer.