Changes in src/SynTree/Statement.cc [3be261a:baf7fee]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
r3be261a rbaf7fee 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Statement.cc -- 7 // Statement.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 36 36 ExprStmt::ExprStmt( std::list<Label> _labels, Expression *_expr ) : Statement( _labels ), expr( _expr ) {} 37 37 38 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 39 40 ExprStmt::~ExprStmt() { 41 delete expr; 42 } 38 ExprStmt::~ExprStmt() {} 43 39 44 40 void ExprStmt::print( std::ostream &os, int indent ) const { 45 41 os << string( indent, ' ' ) << "Expression Statement:" << endl; 46 42 expr->print( os, indent + 2 ); 47 } 43 } 48 44 49 45 50 46 AsmStmt::AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *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 ) {} 51 52 AsmStmt::AsmStmt( const AsmStmt & other ) : Statement( other ), voltile( other.voltile ), instruction( maybeClone( other.instruction ) ), gotolabels( other.gotolabels ) {53 cloneAll( other.output, output );54 cloneAll( other.input, input );55 cloneAll( other.clobber, clobber );56 }57 47 58 48 AsmStmt::~AsmStmt() { … … 70 60 os << endl << std::string( indent, ' ' ) << "output: " << endl; 71 61 printAll( output, os, indent + 2 ); 72 } // if 62 } // if 73 63 if ( ! input.empty() ) { 74 64 os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' ); … … 79 69 printAll( clobber, os, indent + 2 ); 80 70 } // if 81 } 71 } 82 72 83 73 … … 103 93 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {} 104 94 105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {}106 107 95 ReturnStmt::~ReturnStmt() { 108 96 delete expr; … … 118 106 Statement( _labels ), condition( _condition ), thenPart( _thenPart ), elsePart( _elsePart ) {} 119 107 120 IfStmt::IfStmt( const IfStmt & other ) :121 Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {}122 123 108 IfStmt::~IfStmt() {} 124 109 … … 138 123 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ): 139 124 Statement( _labels ), condition( _condition ), branches( _branches ) { 140 }141 142 SwitchStmt::SwitchStmt( const SwitchStmt & other ):143 Statement( other ), condition( maybeClone( other.condition ) ) {144 cloneAll( other.branches, branches );145 125 } 146 126 … … 165 145 } 166 146 167 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 147 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 168 148 Statement( _labels ), condition( _condition ), stmts( _statements ), _isDefault( deflt ) { 169 149 if ( isDefault() && condition != 0 ) 170 150 throw SemanticError("default with conditions"); 171 }172 173 CaseStmt::CaseStmt( const CaseStmt & other ) :174 Statement( other ), condition( maybeClone(other.condition ) ), _isDefault( other._isDefault ) {175 cloneAll( other.stmts, stmts );176 151 } 177 152 … … 206 181 } 207 182 208 ChooseStmt::ChooseStmt( const ChooseStmt & other ):209 Statement( other ), condition( maybeClone( other.condition ) ) {210 cloneAll( other.branches, branches );211 }212 213 183 ChooseStmt::~ChooseStmt() { 214 184 delete condition; … … 238 208 } 239 209 240 WhileStmt::WhileStmt( const WhileStmt & other ):241 Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) {242 }243 244 210 WhileStmt::~WhileStmt() { 245 211 delete body; … … 257 223 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ): 258 224 Statement( labels ), initialization( initialization_ ), condition( condition_ ), increment( increment_ ), body( body_ ) { 259 }260 261 ForStmt::ForStmt( const ForStmt & other ):262 Statement( other ), condition( maybeClone( other.condition ) ), increment( maybeClone( other.increment ) ), body( maybeClone( other.body ) ) {263 cloneAll( other.initialization, initialization );264 265 225 } 266 226 … … 281 241 os << string( indent, ' ' ) << "For Statement" << endl ; 282 242 283 os << string( indent + 2, ' ' ) << "initialization: \n"; 243 os << string( indent + 2, ' ' ) << "initialization: \n"; 284 244 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) { 285 245 (*it)->print( os, indent + 4 ); 286 246 } 287 247 288 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 248 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 289 249 if ( condition != 0 ) 290 250 condition->print( os, indent + 4 ); 291 251 292 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 252 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 293 253 if ( increment != 0 ) 294 254 increment->print( os, indent + 4 ); 295 255 296 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 256 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 297 257 if ( body != 0 ) 298 258 body->print( os, indent + 4 ); … … 305 265 } 306 266 307 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) { 308 cloneAll( other.handlers, handlers ); 267 TryStmt::TryStmt( const TryStmt &other ) : Statement( other.labels ) { 268 block = other.block; 269 std::copy( other.handlers.begin(), other.handlers.end(), back_inserter( handlers ) ); 270 finallyBlock = other.finallyBlock; 309 271 } 310 272 … … 332 294 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) : 333 295 Statement( labels ), decl ( _decl ), body( _body ), catchRest ( isCatchRest ) { 334 }335 336 CatchStmt::CatchStmt( const CatchStmt & other ) :337 Statement( other ), decl ( maybeClone( other.decl ) ), body( maybeClone( other.body ) ), catchRest ( other.catchRest ) {338 296 } 339 297 … … 361 319 } 362 320 363 FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) {364 }365 366 321 FinallyStmt::~FinallyStmt() { 367 322 delete block; … … 376 331 NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {} 377 332 NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {} 333 NullStmt::~NullStmt() {} 378 334 379 335 void NullStmt::print( std::ostream &os, int indent ) const {
Note: See TracChangeset
for help on using the changeset viewer.