Changes in src/SynTree/Statement.cc [6d49ea3:ea6332d]
- File:
-
- 1 edited
-
src/SynTree/Statement.cc (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
r6d49ea3 rea6332d 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Aug 17 16:17:20 201713 // Update Count : 6 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Aug 14 12:26:00 2017 13 // Update Count : 65 14 14 // 15 15 … … 32 32 using std::endl; 33 33 34 Statement::Statement( std::list<Label> labels ) : labels(labels ) {}34 Statement::Statement( std::list<Label> _labels ) : labels( _labels ) {} 35 35 36 36 void Statement::print( __attribute__((unused)) std::ostream &, __attribute__((unused)) int indent ) const {} … … 38 38 Statement::~Statement() {} 39 39 40 ExprStmt::ExprStmt( std::list<Label> labels, Expression *expr ) : Statement( labels ), expr(expr ) {}40 ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ) : Statement( _labels ), expr( _expr ) {} 41 41 42 42 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 88 88 const char *BranchStmt::brType[] = { "Goto", "Break", "Continue" }; 89 89 90 BranchStmt::BranchStmt( std::list<Label> labels, Label target, Typetype ) throw ( SemanticError ) :91 Statement( labels ), originalTarget( target ), target( target ), computedTarget( NULL ), type(type ) {90 BranchStmt::BranchStmt( std::list<Label> labels, Label _target, Type _type ) throw ( SemanticError ) : 91 Statement( labels ), originalTarget( _target ), target( _target ), computedTarget( NULL ), type( _type ) { 92 92 //actually this is a syntactic error signaled by the parser 93 93 if ( type == BranchStmt::Goto && target.empty() ) … … 95 95 } 96 96 97 BranchStmt::BranchStmt( std::list<Label> labels, Expression * computedTarget, Typetype ) throw ( SemanticError ) :98 Statement( labels ), computedTarget( computedTarget ), type(type ) {97 BranchStmt::BranchStmt( std::list<Label> labels, Expression *_computedTarget, Type _type ) throw ( SemanticError ) : 98 Statement( labels ), computedTarget( _computedTarget ), type( _type ) { 99 99 if ( type != BranchStmt::Goto || computedTarget == 0 ) 100 100 throw SemanticError("Computed target not valid in branch statement"); … … 105 105 } 106 106 107 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression * expr ) : Statement( labels ), expr(expr ) {}107 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr ) : Statement( labels ), expr( _expr ) {} 108 108 109 109 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} … … 122 122 } 123 123 124 IfStmt::IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart, std::list<Statement *> initialization):125 Statement( labels ), condition( condition ), thenPart( thenPart ), elsePart( elsePart ), initialization( initialization) {}124 IfStmt::IfStmt( std::list<Label> _labels, Expression *_condition, Statement *_thenPart, Statement *_elsePart ): 125 Statement( _labels ), condition( _condition ), thenPart( _thenPart ), elsePart( _elsePart ) {} 126 126 127 127 IfStmt::IfStmt( const IfStmt & other ) : 128 Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) { 129 cloneAll( other.initialization, initialization ); 130 } 128 Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {} 131 129 132 130 IfStmt::~IfStmt() { 133 deleteAll( initialization );134 131 delete condition; 135 132 delete thenPart; … … 142 139 condition->print( os, indent + 4 ); 143 140 144 if ( !initialization.empty() ) {145 os << string( indent + 2, ' ' ) << "initialization: \n";146 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) {147 os << string( indent + 4, ' ' );148 (*it)->print( os, indent + 4 );149 }150 os << endl;151 }152 153 141 os << string( indent+2, ' ' ) << "... then: " << endl; 154 142 … … 163 151 } 164 152 165 SwitchStmt::SwitchStmt( std::list<Label> labels, Expression * condition, std::list<Statement *> &statements ):166 Statement( labels ), condition( condition ), statements(statements ) {153 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_statements ): 154 Statement( _labels ), condition( _condition ), statements( _statements ) { 167 155 } 168 156 … … 191 179 } 192 180 193 CaseStmt::CaseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &statements, bool deflt ) throw ( SemanticError ) :194 Statement( labels ), condition( condition ), stmts(statements ), _isDefault( deflt ) {181 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 182 Statement( _labels ), condition( _condition ), stmts( _statements ), _isDefault( deflt ) { 195 183 if ( isDefault() && condition != 0 ) 196 184 throw SemanticError("default with conditions"); … … 228 216 } 229 217 230 WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition , Statement *body, bool isDoWhile):231 Statement( labels ), condition( condition ), body( body), isDoWhile( isDoWhile) {218 WhileStmt::WhileStmt( std::list<Label> labels, Expression *condition_, Statement *body_, bool isDoWhile_ ): 219 Statement( labels ), condition( condition_), body( body_), isDoWhile( isDoWhile_) { 232 220 } 233 221 … … 250 238 } 251 239 252 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization , Expression *condition, Expression *increment, Statement *body):253 Statement( labels ), initialization( initialization ), condition( condition ), increment( increment ), body( body) {240 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ): 241 Statement( labels ), initialization( initialization_ ), condition( condition_ ), increment( increment_ ), body( body_ ) { 254 242 } 255 243 … … 329 317 } 330 318 331 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> & handlers, FinallyStmt *finallyBlock ) :332 Statement( labels ), block( tryBlock ), handlers( handlers ), finallyBlock(finallyBlock ) {319 TryStmt::TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<CatchStmt *> &_handlers, FinallyStmt *_finallyBlock ) : 320 Statement( labels ), block( tryBlock ), handlers( _handlers ), finallyBlock( _finallyBlock ) { 333 321 } 334 322 … … 363 351 } 364 352 365 CatchStmt::CatchStmt( std::list<Label> labels, Kind kind, Declaration *decl, Expression *cond, Statement *body ) :366 Statement( labels ), kind ( kind ), decl ( decl ), cond ( cond ), body(body ) {353 CatchStmt::CatchStmt( std::list<Label> labels, Kind _kind, Declaration *_decl, Expression *_cond, Statement *_body ) : 354 Statement( labels ), kind ( _kind ), decl ( _decl ), cond ( _cond ), body( _body ) { 367 355 } 368 356 … … 401 389 402 390 403 FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt * block ) : Statement( labels ), block(block ) {391 FinallyStmt::FinallyStmt( std::list<Label> labels, CompoundStmt *_block ) : Statement( labels ), block( _block ) { 404 392 assert( labels.empty() ); // finally statement cannot be labeled 405 393 }
Note:
See TracChangeset
for help on using the changeset viewer.