Changeset c14cff1 for src/SynTree/Statement.cc
- Timestamp:
- Feb 25, 2016, 5:16:15 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 071a31a
- Parents:
- a9a259c (diff), ac1ed49 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Statement.cc
ra9a259c rc14cff1 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() {} 38 ExprStmt::ExprStmt( const ExprStmt &other ) : Statement( other ), expr( maybeClone( other.expr ) ) {} 39 40 ExprStmt::~ExprStmt() { 41 delete expr; 42 } 39 43 40 44 void ExprStmt::print( std::ostream &os, int indent ) const { 41 45 os << string( indent, ' ' ) << "Expression Statement:" << endl; 42 46 expr->print( os, indent + 2 ); 43 } 47 } 44 48 45 49 46 50 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 } 47 57 48 58 AsmStmt::~AsmStmt() { … … 60 70 os << endl << std::string( indent, ' ' ) << "output: " << endl; 61 71 printAll( output, os, indent + 2 ); 62 } // if 72 } // if 63 73 if ( ! input.empty() ) { 64 74 os << std::string( indent, ' ' ) << "input: " << endl << std::string( indent, ' ' ); … … 69 79 printAll( clobber, os, indent + 2 ); 70 80 } // if 71 } 81 } 72 82 73 83 … … 93 103 ReturnStmt::ReturnStmt( std::list<Label> labels, Expression *_expr, bool throwP ) : Statement( labels ), expr( _expr ), isThrow( throwP ) {} 94 104 105 ReturnStmt::ReturnStmt( const ReturnStmt & other ) : Statement( other ), expr( maybeClone( other.expr ) ), isThrow( other.isThrow ) {} 106 95 107 ReturnStmt::~ReturnStmt() { 96 108 delete expr; … … 106 118 Statement( _labels ), condition( _condition ), thenPart( _thenPart ), elsePart( _elsePart ) {} 107 119 120 IfStmt::IfStmt( const IfStmt & other ) : 121 Statement( other ), condition( maybeClone( other.condition ) ), thenPart( maybeClone( other.thenPart ) ), elsePart( maybeClone( other.elsePart ) ) {} 122 108 123 IfStmt::~IfStmt() {} 109 124 … … 123 138 SwitchStmt::SwitchStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ): 124 139 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 ); 125 145 } 126 146 … … 145 165 } 146 166 147 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 167 CaseStmt::CaseStmt( std::list<Label> _labels, Expression *_condition, std::list<Statement *> &_statements, bool deflt ) throw ( SemanticError ) : 148 168 Statement( _labels ), condition( _condition ), stmts( _statements ), _isDefault( deflt ) { 149 169 if ( isDefault() && condition != 0 ) 150 170 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 ); 151 176 } 152 177 … … 181 206 } 182 207 208 ChooseStmt::ChooseStmt( const ChooseStmt & other ): 209 Statement( other ), condition( maybeClone( other.condition ) ) { 210 cloneAll( other.branches, branches ); 211 } 212 183 213 ChooseStmt::~ChooseStmt() { 184 214 delete condition; … … 208 238 } 209 239 240 WhileStmt::WhileStmt( const WhileStmt & other ): 241 Statement( other ), condition( maybeClone( other.condition ) ), body( maybeClone( other.body ) ), isDoWhile( other.isDoWhile ) { 242 } 243 210 244 WhileStmt::~WhileStmt() { 211 245 delete body; … … 223 257 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ): 224 258 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 225 265 } 226 266 … … 241 281 os << string( indent, ' ' ) << "For Statement" << endl ; 242 282 243 os << string( indent + 2, ' ' ) << "initialization: \n"; 283 os << string( indent + 2, ' ' ) << "initialization: \n"; 244 284 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) { 245 285 (*it)->print( os, indent + 4 ); 246 286 } 247 287 248 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 288 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; 249 289 if ( condition != 0 ) 250 290 condition->print( os, indent + 4 ); 251 291 252 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 292 os << "\n" << string( indent + 2, ' ' ) << "increment: \n"; 253 293 if ( increment != 0 ) 254 294 increment->print( os, indent + 4 ); 255 295 256 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 296 os << "\n" << string( indent + 2, ' ' ) << "statement block: \n"; 257 297 if ( body != 0 ) 258 298 body->print( os, indent + 4 ); … … 265 305 } 266 306 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; 307 TryStmt::TryStmt( const TryStmt &other ) : Statement( other ), block( maybeClone( other.block ) ), finallyBlock( maybeClone( other.finallyBlock ) ) { 308 cloneAll( other.handlers, handlers ); 271 309 } 272 310 … … 294 332 CatchStmt::CatchStmt( std::list<Label> labels, Declaration *_decl, Statement *_body, bool isCatchRest ) : 295 333 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 ) { 296 338 } 297 339 … … 319 361 } 320 362 363 FinallyStmt::FinallyStmt( const FinallyStmt & other ) : Statement( other ), block( maybeClone( other.block ) ) { 364 } 365 321 366 FinallyStmt::~FinallyStmt() { 322 367 delete block; … … 331 376 NullStmt::NullStmt( std::list<Label> labels ) : CompoundStmt( labels ) {} 332 377 NullStmt::NullStmt() : CompoundStmt( std::list<Label>() ) {} 333 NullStmt::~NullStmt() {}334 378 335 379 void NullStmt::print( std::ostream &os, int indent ) const {
Note:
See TracChangeset
for help on using the changeset viewer.