- Timestamp:
- Jan 10, 2020, 3:15:10 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- a21dec4
- Parents:
- 4737d8e
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
r4737d8e r0608e007 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Sep 3 20:46:44 201713 // Update Count : 6812 // Last Modified On : Fri Jan 10 14:20:47 2020 13 // Update Count : 70 14 14 // 15 15 … … 46 46 Statement::~Statement() {} 47 47 48 ExprStmt::ExprStmt( Expression * expr ) : Statement(), expr( expr ) {}49 50 ExprStmt::ExprStmt( const ExprStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {}48 ExprStmt::ExprStmt( Expression * expr ) : Statement(), expr( expr ) {} 49 50 ExprStmt::ExprStmt( const ExprStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 51 51 52 52 ExprStmt::~ExprStmt() { … … 54 54 } 55 55 56 void ExprStmt::print( std::ostream & os, Indenter indent ) const {56 void ExprStmt::print( std::ostream & os, Indenter indent ) const { 57 57 os << "Expression Statement:" << endl << indent+1; 58 58 expr->print( os, indent+1 ); … … 60 60 61 61 62 AsmStmt::AsmStmt( bool voltile, Expression * instruction, std::list<Expression *> output, std::list<Expression *> input, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ) : Statement(), voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ), gotolabels( gotolabels ) {}62 AsmStmt::AsmStmt( 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( std::ostream & os, Indenter indent ) const {77 void AsmStmt::print( std::ostream & os, Indenter indent ) const { 78 78 os << "Assembler Statement:" << endl; 79 79 os << indent+1 << "instruction: " << endl << indent; … … 96 96 DirectiveStmt::DirectiveStmt( const std::string & directive ) : Statement(), directive( directive ) {} 97 97 98 void DirectiveStmt::print( std::ostream & os, Indenter ) const {98 void DirectiveStmt::print( std::ostream & os, Indenter ) const { 99 99 os << "GCC Directive:" << directive << endl; 100 100 } 101 101 102 102 103 const char * BranchStmt::brType[] = { "Goto", "Break", "Continue" };103 const char * BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 104 104 105 105 BranchStmt::BranchStmt( Label target, Type type ) throw ( SemanticErrorException ) : … … 111 111 } 112 112 113 BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ) :113 BranchStmt::BranchStmt( Expression * computedTarget, Type type ) throw ( SemanticErrorException ) : 114 114 Statement(), computedTarget( computedTarget ), type( type ) { 115 115 if ( type != BranchStmt::Goto || computedTarget == nullptr ) { … … 118 118 } 119 119 120 void BranchStmt::print( std::ostream & os, Indenter indent ) const {120 void BranchStmt::print( std::ostream & os, Indenter indent ) const { 121 121 os << "Branch (" << brType[type] << ")" << endl ; 122 122 if ( target != "" ) os << indent+1 << "with target: " << target << endl; … … 125 125 } 126 126 127 ReturnStmt::ReturnStmt( Expression * expr ) : Statement(), expr( expr ) {}127 ReturnStmt::ReturnStmt( Expression * expr ) : Statement(), expr( expr ) {} 128 128 129 129 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 133 133 } 134 134 135 void ReturnStmt::print( std::ostream & os, Indenter indent ) const {135 void ReturnStmt::print( std::ostream & os, Indenter indent ) const { 136 136 os << "Return Statement, returning: "; 137 137 if ( expr != nullptr ) { … … 142 142 } 143 143 144 IfStmt::IfStmt( Expression * condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization ):144 IfStmt::IfStmt( Expression * condition, Statement * thenPart, Statement * elsePart, std::list<Statement *> initialization ): 145 145 Statement(), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization ) {} 146 146 … … 157 157 } 158 158 159 void IfStmt::print( std::ostream & os, Indenter indent ) const {159 void IfStmt::print( std::ostream & os, Indenter indent ) const { 160 160 os << "If on condition: " << endl; 161 161 os << indent+1; … … 176 176 thenPart->print( os, indent+1 ); 177 177 178 if ( elsePart != 0) {178 if ( elsePart != nullptr ) { 179 179 os << indent << "... else: " << endl; 180 180 os << indent+1; … … 183 183 } 184 184 185 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ):185 SwitchStmt::SwitchStmt( Expression * condition, const std::list<Statement *> & statements ): 186 186 Statement(), condition( condition ), statements( statements ) { 187 187 } … … 198 198 } 199 199 200 void SwitchStmt::print( std::ostream & os, Indenter indent ) const {200 void SwitchStmt::print( std::ostream & os, Indenter indent ) const { 201 201 os << "Switch on condition: "; 202 202 condition->print( os ); … … 208 208 } 209 209 210 CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> &statements, bool deflt ) throw ( SemanticErrorException ) :210 CaseStmt::CaseStmt( Expression * condition, const std::list<Statement *> & statements, bool deflt ) throw ( SemanticErrorException ) : 211 211 Statement(), condition( condition ), stmts( statements ), _isDefault( deflt ) { 212 if ( isDefault() && condition != 0) SemanticError( condition, "default case with condition: " );212 if ( isDefault() && condition != nullptr ) SemanticError( condition, "default case with condition: " ); 213 213 } 214 214 … … 229 229 } 230 230 231 void CaseStmt::print( std::ostream & os, Indenter indent ) const {231 void CaseStmt::print( std::ostream & os, Indenter indent ) const { 232 232 if ( isDefault() ) os << indent << "Default "; 233 233 else { … … 243 243 } 244 244 245 WhileStmt::WhileStmt( Expression * condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):245 WhileStmt::WhileStmt( Expression * condition, Statement * body, std::list< Statement * > & initialization, bool isDoWhile ): 246 246 Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) { 247 247 } … … 256 256 } 257 257 258 void WhileStmt::print( std::ostream & os, Indenter indent ) const {258 void WhileStmt::print( std::ostream & os, Indenter indent ) const { 259 259 os << "While on condition: " << endl ; 260 260 condition->print( os, indent+1 ); … … 262 262 os << indent << "... with body: " << endl; 263 263 264 if ( body != 0) body->print( os, indent+1 );265 } 266 267 ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression *increment, Statement *body ):264 if ( body != nullptr ) body->print( os, indent+1 ); 265 } 266 267 ForStmt::ForStmt( std::list<Statement *> initialization, Expression * condition, Expression * increment, Statement * body ): 268 268 Statement(), initialization( initialization ), condition( condition ), increment( increment ), body( body ) { 269 269 } … … 282 282 } 283 283 284 void ForStmt::print( std::ostream & os, Indenter indent ) const {284 void ForStmt::print( std::ostream & os, Indenter indent ) const { 285 285 Statement::print( os, indent ); // print labels 286 286 … … 305 305 } 306 306 307 if ( body != 0) {307 if ( body != nullptr ) { 308 308 os << "\n" << indent << "... with body: \n" << indent+1; 309 309 body->print( os, indent+1 ); … … 317 317 } 318 318 319 ThrowStmt::ThrowStmt( const ThrowStmt & other ) :319 ThrowStmt::ThrowStmt( const ThrowStmt & other ) : 320 320 Statement ( other ), kind( other.kind ), expr( maybeClone( other.expr ) ), target( maybeClone( other.target ) ) { 321 321 } … … 326 326 } 327 327 328 void ThrowStmt::print( std::ostream & os, Indenter indent) const {328 void ThrowStmt::print( std::ostream & os, Indenter indent) const { 329 329 if ( target ) os << "Non-Local "; 330 330 os << "Throw Statement, raising: "; … … 336 336 } 337 337 338 TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> &handlers, FinallyStmt *finallyBlock ) :338 TryStmt::TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock ) : 339 339 Statement(), block( tryBlock ), handlers( handlers ), finallyBlock( finallyBlock ) { 340 340 } 341 341 342 TryStmt::TryStmt( const TryStmt & other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) {342 TryStmt::TryStmt( const TryStmt & other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) { 343 343 cloneAll( other.handlers, handlers ); 344 344 } … … 350 350 } 351 351 352 void TryStmt::print( std::ostream & os, Indenter indent ) const {352 void TryStmt::print( std::ostream & os, Indenter indent ) const { 353 353 os << "Try Statement" << endl; 354 354 os << indent << "... with block:" << endl << indent+1; … … 363 363 364 364 // finally block 365 if ( finallyBlock != 0) {365 if ( finallyBlock != nullptr ) { 366 366 os << indent << "... and finally:" << endl << indent+1; 367 367 finallyBlock->print( os, indent+1 ); … … 369 369 } 370 370 371 CatchStmt::CatchStmt( Kind kind, Declaration * decl, Expression *cond, Statement *body ) :371 CatchStmt::CatchStmt( Kind kind, Declaration * decl, Expression * cond, Statement * body ) : 372 372 Statement(), kind ( kind ), decl ( decl ), cond ( cond ), body( body ) { 373 373 assertf( decl, "Catch clause must have a declaration." ); … … 383 383 } 384 384 385 void CatchStmt::print( std::ostream & os, Indenter indent ) const {385 void CatchStmt::print( std::ostream & os, Indenter indent ) const { 386 386 os << "Catch " << ((Terminate == kind) ? "Terminate" : "Resume") << " Statement" << endl; 387 387 … … 401 401 402 402 403 FinallyStmt::FinallyStmt( CompoundStmt * block ) : Statement(), block( block ) {403 FinallyStmt::FinallyStmt( CompoundStmt * block ) : Statement(), block( block ) { 404 404 } 405 405 … … 411 411 } 412 412 413 void FinallyStmt::print( std::ostream & os, Indenter indent ) const {413 void FinallyStmt::print( std::ostream & os, Indenter indent ) const { 414 414 os << "Finally Statement" << endl; 415 415 os << indent << "... with block:" << endl << indent+1; … … 458 458 } 459 459 460 void WaitForStmt::print( std::ostream & os, Indenter indent ) const {460 void WaitForStmt::print( std::ostream & os, Indenter indent ) const { 461 461 os << "Waitfor Statement" << endl; 462 462 indent += 1; … … 514 514 } 515 515 516 void NullStmt::print( std::ostream & os, Indenter indent ) const {516 void NullStmt::print( std::ostream & os, Indenter indent ) const { 517 517 os << "Null Statement" << endl; 518 518 Statement::print( os, indent ); … … 530 530 } 531 531 532 void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const {532 void ImplicitCtorDtorStmt::print( std::ostream & os, Indenter indent ) const { 533 533 os << "Implicit Ctor Dtor Statement" << endl; 534 534 os << indent << "... with Ctor/Dtor: "; -
src/SynTree/Statement.h
r4737d8e r0608e007 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 12 09:01:53 201913 // Update Count : 8 312 // Last Modified On : Fri Jan 10 14:13:24 2020 13 // Update Count : 85 14 14 // 15 15 … … 257 257 Statement * body; 258 258 259 ForStmt( std::list<Statement *> initialization, Expression * condition = 0, Expression * increment = 0, Statement * body = 0);259 ForStmt( std::list<Statement *> initialization, Expression * condition = nullptr, Expression * increment = nullptr, Statement * body = nullptr ); 260 260 ForStmt( const ForStmt & other ); 261 261 virtual ~ForStmt(); … … 357 357 FinallyStmt * finallyBlock; 358 358 359 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = 0);359 TryStmt( CompoundStmt * tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt * finallyBlock = nullptr ); 360 360 TryStmt( const TryStmt & other ); 361 361 virtual ~TryStmt();
Note: See TracChangeset
for help on using the changeset viewer.