Changeset 6180274
- Timestamp:
- Feb 2, 2022, 9:25:37 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 9dc08363
- Parents:
- 4e7171f
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/AST/Stmt.cpp ¶
r4e7171f r6180274 9 9 // Author : Aaron B. Moss 10 10 // Created On : Wed May 8 13:00:00 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed May 15 15:53:00 201913 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 2 19:01:20 2022 13 // Update Count : 3 14 14 // 15 15 … … 56 56 57 57 // --- BranchStmt 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) {58 BranchStmt::BranchStmt( const CodeLocation& loc, Kind kind, Label target, const 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() ); -
TabularUnified src/AST/Stmt.hpp ¶
r4e7171f r6180274 10 10 // Created On : Wed May 8 13:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 1 17:44:46202213 // Update Count : 2412 // Last Modified On : Wed Feb 2 20:06:41 2022 13 // Update Count : 34 14 14 // 15 15 … … 39 39 std::vector<Label> labels; 40 40 41 Stmt( const CodeLocation & loc, std::vector<Label> && labels = {} )41 Stmt( const CodeLocation & loc, const 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, std::list<ptr<Stmt>> && ks = {}, 58 std::vector<Label> && labels = {} ) 57 CompoundStmt(const CodeLocation & loc, const std::list<ptr<Stmt>> && ks = {}, const std::vector<Label> && labels = {} ) 59 58 : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} 60 59 … … 74 73 class NullStmt final : public Stmt { 75 74 public: 76 NullStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )75 NullStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 77 76 : Stmt(loc, std::move(labels)) {} 78 77 … … 88 87 ptr<Expr> expr; 89 88 90 ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label> && labels = {} )89 ExprStmt( const CodeLocation & loc, const Expr* e, const std::vector<Label> && labels = {} ) 91 90 : Stmt(loc, std::move(labels)), expr(e) {} 92 91 … … 107 106 108 107 AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction, 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 = {})108 const std::vector<ptr<Expr>> && output, const std::vector<ptr<Expr>> && input, 109 const std::vector<ptr<ConstantExpr>> && clobber, const std::vector<Label> && gotoLabels, 110 const std::vector<Label> && labels = {}) 112 111 : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction), 113 112 output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)), … … 144 143 145 144 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then, 146 const Stmt * else_ = nullptr, std::vector<ptr<Stmt>> && inits = {},147 std::vector<Label> && labels = {} )145 const Stmt * else_ = nullptr, const std::vector<ptr<Stmt>> && inits = {}, 146 const std::vector<Label> && labels = {} ) 148 147 : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_), 149 148 inits(std::move(inits)) {} … … 161 160 std::vector<ptr<Stmt>> stmts; 162 161 163 SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,164 std::vector<Label> && labels = {} )162 SwitchStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts, 163 const std::vector<Label> && labels = {} ) 165 164 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 166 165 … … 178 177 std::vector<ptr<Stmt>> stmts; 179 178 180 CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>> && stmts,181 std::vector<Label> && labels = {} )179 CaseStmt( const CodeLocation & loc, const Expr * cond, const std::vector<ptr<Stmt>> && stmts, 180 const std::vector<Label> && labels = {} ) 182 181 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 183 182 … … 200 199 201 200 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, 202 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false,std::vector<Label> && labels = {} )201 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} ) 203 202 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {} 204 203 205 204 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_, 206 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false,std::vector<Label> && labels = {} )205 const std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, const std::vector<Label> && labels = {} ) 207 206 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {} 208 207 … … 222 221 ptr<Stmt> else_; 223 222 224 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond,225 const Expr * inc, const Stmt * body, std::vector<Label> && label = {} )223 ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond, 224 const Expr * inc, const Stmt * body, const std::vector<Label> && label = {} ) 226 225 : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {} 227 226 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 = {} )227 ForStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond, 228 const Expr * inc, const Stmt * body, const Stmt * else_, const std::vector<Label> && labels = {} ) 230 229 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {} 231 230 … … 247 246 Kind kind; 248 247 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) {} 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) {} 255 251 256 252 const char * kindName() const { return kindNames[kind]; } … … 269 265 ptr<Expr> expr; 270 266 271 ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label> && labels = {} )267 ReturnStmt( const CodeLocation & loc, const Expr * expr, const std::vector<Label> && labels = {} ) 272 268 : Stmt(loc, std::move(labels)), expr(expr) {} 273 269 … … 288 284 ExceptionKind kind; 289 285 290 ThrowStmt( 291 const CodeLocation & loc, ExceptionKind kind, const Expr * expr, const Expr * target, 292 std::vector<Label> && labels = {} ) 286 ThrowStmt( const CodeLocation & loc, ExceptionKind kind, const Expr * expr, 287 const Expr * target, const std::vector<Label> && labels = {} ) 293 288 : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} 294 289 … … 306 301 ptr<FinallyStmt> finally; 307 302 308 TryStmt( 309 const CodeLocation & loc, const CompoundStmt * body, 310 std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, 311 std::vector<Label> && labels = {} ) 303 TryStmt( const CodeLocation & loc, const CompoundStmt * body, 304 const std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt * finally, 305 const std::vector<Label> && labels = {} ) 312 306 : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} 313 307 … … 326 320 ExceptionKind kind; 327 321 328 CatchStmt( 329 const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 330 const Stmt * body, std::vector<Label> && labels = {} ) 322 CatchStmt( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 323 const Stmt * body, const std::vector<Label> && labels = {} ) 331 324 : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} 332 325 … … 358 351 enum Type { None, Coroutine, Generator } type = None; 359 352 360 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, std::vector<Label> && labels = {} )353 SuspendStmt( const CodeLocation & loc, const CompoundStmt * then, Type type, const std::vector<Label> && labels = {} ) 361 354 : Stmt(loc, std::move(labels)), then(then), type(type) {} 362 355 … … 396 389 OrElse orElse; 397 390 398 WaitForStmt( const CodeLocation & loc, std::vector<Label> && labels = {} )391 WaitForStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 399 392 : Stmt(loc, std::move(labels)) {} 400 393 … … 410 403 ptr<Decl> decl; 411 404 412 DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label> && labels = {} )405 DeclStmt( const CodeLocation & loc, const Decl * decl, const std::vector<Label> && labels = {} ) 413 406 : Stmt(loc, std::move(labels)), decl(decl) {} 414 407 … … 441 434 442 435 MutexStmt( const CodeLocation & loc, const Stmt * stmt, 443 std::vector<ptr<Expr>> && mutexes,std::vector<Label> && labels = {} )436 const std::vector<ptr<Expr>> && mutexes, const std::vector<Label> && labels = {} ) 444 437 : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {} 445 438 -
TabularUnified src/CodeGen/CodeGenerator.cc ¶
r4e7171f r6180274 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 1 16:29:25202213 // Update Count : 54 012 // Last Modified On : Wed Feb 2 20:30:30 2022 13 // Update Count : 541 14 14 // 15 15 #include "CodeGenerator.h" … … 1020 1020 output << "fallthru"; 1021 1021 break; 1022 default: ; // prevent warning 1022 1023 } // switch 1023 1024 // print branch target for labelled break/continue/fallthru in debug mode -
TabularUnified src/ControlStruct/MLEMutator.cc ¶
r4e7171f r6180274 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 1 09:26:28202213 // Update Count : 22 512 // Last Modified On : Wed Feb 2 20:18:57 2022 13 // Update Count : 227 14 14 // 15 15 … … 136 136 } 137 137 } 138 assertf( false, "C ould not find label '%s' on statement %s",138 assertf( false, "CFA internal error: 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() ), "Control structure enclosing a case clause must be a switch, but is: %s", toCString( enclosingControlStructures.back().get_controlStructure() ) ); 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() ) ); 398 400 if ( caseStmt->isDefault() ) { 399 401 if ( enclosingControlStructures.back().isFallDefaultUsed() ) { -
TabularUnified src/ControlStruct/MultiLevelExit.cpp ¶
r4e7171f r6180274 10 10 // Created On : Mon Nov 1 13:48:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 1 18:48:47202213 // Update Count : 2912 // Last Modified On : Wed Feb 2 20:19:24 2022 13 // Update Count : 30 14 14 // 15 15 … … 206 206 } 207 207 } 208 assertf( false, "C ould not find label '%s' on statement %s",208 assertf( false, "CFA internal error: 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 ontrol structure enclosing a case clause must be a switch, but is: %s",408 "CFA internal error: 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() ) { -
TabularUnified src/Parser/StatementNode.cc ¶
r4e7171f r6180274 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 12:27:58202214 // Update Count : 42 413 // Last Modified On : Wed Feb 2 20:29:30 2022 14 // Update Count : 425 15 15 // 16 16 … … 138 138 139 139 Statement * build_case( ExpressionNode * ctl ) { 140 return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // no init140 return new CaseStmt( maybeMoveBuild< Expression >(ctl), {} ); // stmt starts empty and then added to 141 141 } // build_case 142 142 143 143 Statement * build_default() { 144 return new CaseStmt( nullptr, {}, true ); // no init144 return new CaseStmt( nullptr, {}, true ); // stmt starts empty and then added to 145 145 } // build_default 146 146 -
TabularUnified src/SynTree/Statement.cc ¶
r4e7171f r6180274 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 11:55:19202213 // Update Count : 8012 // Last Modified On : Wed Feb 2 20:19:33 2022 13 // Update Count : 90 14 14 // 15 15 … … 29 29 #include "SynTree/Label.h" // for Label, operator<< 30 30 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 {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 { 37 37 if ( ! labels.empty() ) { 38 38 os << indent << "... Labels: {"; … … 54 54 } 55 55 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 ) {}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, const 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( std::ostream & os, Indenter indent ) const {77 void AsmStmt::print( 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 d::string & directive ) : Statement(), directive( directive ) {}97 98 void DirectiveStmt::print( std::ostream & os, Indenter ) const {96 DirectiveStmt::DirectiveStmt( const string & directive ) : Statement(), directive( directive ) {} 97 98 void DirectiveStmt::print( ostream & os, Indenter ) const { 99 99 os << "GCC Directive:" << directive << endl; 100 100 } … … 120 120 } 121 121 122 void BranchStmt::print( std::ostream & os, Indenter indent ) const {123 assert (type < 5);122 void BranchStmt::print( ostream & os, Indenter indent ) const { 123 assertf(type < BranchStmts, "CFA internal error: invalid branch statement" ); 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( std::ostream & os, Indenter indent ) const {138 void ReturnStmt::print( 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_, std::list<Statement *> initialization ):147 IfStmt::IfStmt( Expression * condition, Statement * then, Statement * else_, const list<Statement *> initialization ): 148 148 Statement(), condition( condition ), then( then ), else_( else_ ), initialization( initialization ) {} 149 149 … … 160 160 } 161 161 162 void IfStmt::print( std::ostream & os, Indenter indent ) const {162 void IfStmt::print( 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 std::list<Statement *> & statements ):188 SwitchStmt::SwitchStmt( Expression * condition, const list<Statement *> & statements ): 189 189 Statement(), condition( condition ), statements( statements ) { 190 190 } … … 201 201 } 202 202 203 void SwitchStmt::print( std::ostream & os, Indenter indent ) const {203 void SwitchStmt::print( 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 std::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 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 std::list<Label> & labels, std::list<Statement *> stmts ) {228 CaseStmt * CaseStmt::makeDefault( const list<Label> & labels, 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( std::ostream & os, Indenter indent ) const {234 void CaseStmt::print( 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 std::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 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 std::list< Statement * > & initialization, bool isDoWhile ):252 WhileDoStmt::WhileDoStmt( Expression * condition, Statement * body, Statement * else_, const 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( std::ostream & os, Indenter indent ) const {265 void WhileDoStmt::print( 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( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body, Statement * else_ ):271 if ( body != nullptr ) body->print( os, indent + 1 ); 272 } 273 274 ForStmt::ForStmt( const 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( std::ostream & os, Indenter indent ) const {292 void ForStmt::print( 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( std::ostream & os, Indenter indent) const {341 void ThrowStmt::print( 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, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) :347 target->print(os, indent + 1); 348 } 349 } 350 351 TryStmt::TryStmt( CompoundStmt * tryBlock, const list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) : 352 352 Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 353 353 } … … 363 363 } 364 364 365 void TryStmt::print( std::ostream & os, Indenter indent ) const {365 void TryStmt::print( 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( std::ostream & os, Indenter indent ) const {398 void CatchStmt::print( 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( std::ostream & os, Indenter indent ) const {426 void FinallyStmt::print( 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( std::ostream & os, Indenter indent ) const {441 void SuspendStmt::print( ostream & os, Indenter indent ) const { 442 442 os << "Suspend Statement"; 443 443 switch (type) { … … 496 496 } 497 497 498 void WaitForStmt::print( std::ostream & os, Indenter indent ) const {498 void WaitForStmt::print( ostream & os, Indenter indent ) const { 499 499 os << "Waitfor Statement" << endl; 500 500 indent += 1; … … 531 531 532 532 533 WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Declaration("", noStorageClasses, LinkageSpec::Cforall), exprs( exprs ), stmt( stmt ) {}533 WithStmt::WithStmt( const 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( std::ostream & os, Indenter indent ) const {542 void WithStmt::print( 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 std::list<Label> & labels ) : Statement( labels ) {552 } 553 554 void NullStmt::print( std::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 list<Label> & labels ) : Statement( labels ) { 552 } 553 554 void NullStmt::print( 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( std::ostream & os, Indenter indent ) const {570 void ImplicitCtorDtorStmt::print( 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, std::list<Expression *> mutexObjs )577 MutexStmt::MutexStmt( Statement * stmt, const list<Expression *> mutexObjs ) 578 578 : Statement(), stmt( stmt ), mutexObjs( mutexObjs ) { } 579 579 … … 587 587 } 588 588 589 void MutexStmt::print( std::ostream & os, Indenter indent ) const {589 void MutexStmt::print( 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 -
TabularUnified src/SynTree/Statement.h ¶
r4e7171f r6180274 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 11:49:17202213 // Update Count : 9 412 // Last Modified On : Wed Feb 2 20:15:30 2022 13 // Update Count : 98 14 14 // 15 15 … … 107 107 std::list<Label> gotolabels; 108 108 109 AsmStmt( bool voltile, Expression * instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber,std::list<Label> gotolabels );109 AsmStmt( bool voltile, Expression * instruction, const std::list<Expression *> output, const std::list<Expression *> input, const std::list<ConstantExpr *> clobber, const 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 std::list<Statement *> initialization = std::list<Statement *>() );155 const 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( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr, Statement * else_ = nullptr );262 ForStmt( const 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 = 0, Break, Continue, FallThrough, FallThroughDefault};283 enum Type { Goto, Break, Continue, FallThrough, FallThroughDefault, BranchStmts }; 284 284 285 285 // originalTarget kept for error messages. … … 360 360 FinallyStmt * finallyBlock; 361 361 362 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr );362 TryStmt( CompoundStmt * tryBlock, const 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, std::list<Expression *> mutexObjs );545 MutexStmt( Statement * stmt, const std::list<Expression *> mutexObjs ); 546 546 MutexStmt( const MutexStmt & other ); 547 547 virtual ~MutexStmt();
Note: See TracChangeset
for help on using the changeset viewer.