Changeset 3be261a
- Timestamp:
- Feb 25, 2016, 4:45:19 PM (9 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, string, with_gc
- Children:
- 41a2620
- Parents:
- 6ce67ce
- Location:
- src/SynTree
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r6ce67ce r3be261a 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Expression.cc -- 7 // Expression.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 422 422 } 423 423 424 AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {} 425 426 424 427 void AsmExpr::print( std::ostream &os, int indent ) const { 425 428 os << "Asm Expression: " << std::endl; … … 429 432 } 430 433 434 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 435 436 UntypedValofExpr::~UntypedValofExpr() { delete body; } 437 431 438 void UntypedValofExpr::print( std::ostream &os, int indent ) const { 432 439 os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl; … … 434 441 get_body()->print( os, indent + 2 ); 435 442 } 443 444 436 445 437 446 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
r6ce67ce r3be261a 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Expression.h -- 7 // Expression.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 155 155 }; 156 156 157 // xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack 157 158 class LabelAddressExpr : public Expression { 158 159 public: 159 160 LabelAddressExpr( Expression *arg ); 160 LabelAddressExpr( const AddressExpr &other );161 LabelAddressExpr( const LabelAddressExpr &other ); 161 162 virtual ~LabelAddressExpr(); 162 163 … … 251 252 }; 252 253 253 /// ConstantExpr represents an expression that simply refers to the value of a constant 254 /// ConstantExpr represents an expression that simply refers to the value of a constant 254 255 class ConstantExpr : public Expression { 255 256 public: … … 515 516 public: 516 517 AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 518 AsmExpr( const AsmExpr & other ); 517 519 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; 518 520 … … 541 543 public: 542 544 UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {} 543 virtual ~UntypedValofExpr() {} 545 UntypedValofExpr( const UntypedValofExpr & other ); 546 virtual ~UntypedValofExpr(); 544 547 545 548 Expression *get_value(); -
src/SynTree/Statement.cc
r6ce67ce r3be261a 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 { -
src/SynTree/Statement.h
r6ce67ce r3be261a 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Statement.h -- 7 // Statement.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 57 57 public: 58 58 ExprStmt( std::list<Label> labels, Expression *expr ); 59 ExprStmt( const ExprStmt &other ); 59 60 virtual ~ExprStmt(); 60 61 … … 73 74 public: 74 75 AsmStmt( std::list<Label> labels, bool voltile, ConstantExpr *instruction, std::list<Expression *> input, std::list<Expression *> output, std::list<ConstantExpr *> clobber, std::list<Label> gotolabels ); 76 AsmStmt( const AsmStmt &other ); 75 77 virtual ~AsmStmt(); 76 78 … … 103 105 public: 104 106 IfStmt( std::list<Label> labels, Expression *condition, Statement *thenPart, Statement *elsePart ); 107 IfStmt( const IfStmt &other ); 105 108 virtual ~IfStmt(); 106 109 … … 111 114 Statement *get_elsePart() { return elsePart; } 112 115 void set_elsePart( Statement *newValue ) { elsePart = newValue; } 113 116 114 117 virtual IfStmt *clone() const { return new IfStmt( *this ); } 115 118 virtual void accept( Visitor &v ) { v.visit( this ); } … … 125 128 public: 126 129 SwitchStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches ); 130 SwitchStmt( const SwitchStmt &other ); 127 131 virtual ~SwitchStmt(); 128 132 … … 146 150 public: 147 151 ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches ); 152 ChooseStmt( const ChooseStmt &other ); 148 153 virtual ~ChooseStmt(); 149 154 … … 177 182 class CaseStmt : public Statement { 178 183 public: 179 CaseStmt( std::list<Label> labels, Expression *conditions, 184 CaseStmt( std::list<Label> labels, Expression *conditions, 180 185 std::list<Statement *> &stmts, bool isdef = false ) throw(SemanticError); 186 CaseStmt( const CaseStmt &other ); 181 187 virtual ~CaseStmt(); 182 188 … … 192 198 std::list<Statement *> &get_statements() { return stmts; } 193 199 void set_statements( std::list<Statement *> &newValue ) { stmts = newValue; } 194 200 195 201 virtual void accept( Visitor &v ) { v.visit( this ); } 196 202 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 208 214 WhileStmt( std::list<Label> labels, Expression *condition, 209 215 Statement *body, bool isDoWhile = false ); 216 WhileStmt( const WhileStmt &other ); 210 217 virtual ~WhileStmt(); 211 218 … … 216 223 bool get_isDoWhile() { return isDoWhile; } 217 224 void set_isDoWhile( bool newValue ) { isDoWhile = newValue; } 218 225 219 226 virtual WhileStmt *clone() const { return new WhileStmt( *this ); } 220 227 virtual void accept( Visitor &v ) { v.visit( this ); } … … 231 238 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 232 239 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); 240 ForStmt( const ForStmt &other ); 233 241 virtual ~ForStmt(); 234 242 … … 241 249 Statement *get_body() { return body; } 242 250 void set_body( Statement *newValue ) { body = newValue; } 243 251 244 252 virtual ForStmt *clone() const { return new ForStmt( *this ); } 245 253 virtual void accept( Visitor &v ) { v.visit( this ); } … … 259 267 BranchStmt( std::list<Label> labels, Label target, Type ) throw (SemanticError); 260 268 BranchStmt( std::list<Label> labels, Expression *computedTarget, Type ) throw (SemanticError); 261 virtual ~BranchStmt() {}262 269 263 270 Label get_originalTarget() { return originalTarget; } 264 271 Label get_target() { return target; } 265 272 void set_target( Label newValue ) { target = newValue; } 266 273 267 274 Expression *get_computedTarget() { return computedTarget; } 268 275 void set_target( Expression * newValue ) { computedTarget = newValue; } … … 286 293 public: 287 294 ReturnStmt( std::list<Label> labels, Expression *expr, bool throwP = false ); 295 ReturnStmt( const ReturnStmt &other ); 288 296 virtual ~ReturnStmt(); 289 297 290 298 Expression *get_expr() { return expr; } 291 299 void set_expr( Expression *newValue ) { expr = newValue; } 292 300 293 301 virtual ReturnStmt *clone() const { return new ReturnStmt( *this ); } 294 302 virtual void accept( Visitor &v ) { v.visit( this ); } … … 305 313 NullStmt(); 306 314 NullStmt( std::list<Label> labels ); 307 virtual ~NullStmt();308 315 309 316 virtual NullStmt *clone() const { return new NullStmt( *this ); } … … 311 318 virtual NullStmt *acceptMutator( Mutator &m ) { return m.mutate( this ); } 312 319 virtual void print( std::ostream &os, int indent = 0 ) const; 313 314 private: 315 }; 316 317 class TryStmt : public Statement { 320 321 private: 322 }; 323 324 class TryStmt : public Statement { 318 325 public: 319 326 TryStmt( std::list<Label> labels, CompoundStmt *tryBlock, std::list<Statement *> &handlers, FinallyStmt *finallyBlock = 0 ); … … 332 339 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 333 340 virtual void print( std::ostream &os, int indent = 0 ) const; 334 341 335 342 private: 336 343 CompoundStmt *block; 337 344 std::list<Statement *> handlers; 338 345 FinallyStmt *finallyBlock; 339 }; 346 }; 340 347 341 348 class CatchStmt : public Statement { 342 349 public: 343 350 CatchStmt( std::list<Label> labels, Declaration *decl, Statement *body, bool isCatchRest = false ); 351 CatchStmt( const CatchStmt &other ); 344 352 virtual ~CatchStmt(); 345 353 … … 349 357 Statement *get_body() { return body; } 350 358 void set_body( Statement *newValue ) { body = newValue; } 351 359 352 360 virtual CatchStmt *clone() const { return new CatchStmt( *this ); } 353 361 virtual void accept( Visitor &v ) { v.visit( this ); } 354 362 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); } 355 363 virtual void print( std::ostream &os, int indent = 0 ) const; 356 364 357 365 private: 358 366 Declaration *decl; … … 361 369 }; 362 370 363 class FinallyStmt : public Statement { 371 class FinallyStmt : public Statement { 364 372 public: 365 373 FinallyStmt( std::list<Label> labels, CompoundStmt *block ); 374 FinallyStmt( const FinallyStmt &other ); 366 375 virtual ~FinallyStmt(); 367 376 368 377 CompoundStmt *get_block() const { return block; } 369 378 void set_block( CompoundStmt *newValue ) { block = newValue; } 370 379 371 380 virtual FinallyStmt *clone() const { return new FinallyStmt( *this ); } 372 381 virtual void accept( Visitor &v ) { v.visit( this ); } … … 375 384 private: 376 385 CompoundStmt *block; 377 }; 386 }; 378 387 379 388
Note: See TracChangeset
for help on using the changeset viewer.