Changeset 0f9e4403 for src/SynTree
- Timestamp:
- Apr 15, 2016, 12:03:11 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, stuck-waitfor-destruct, with_gc
- Children:
- 29ad0ac
- Parents:
- c5833e8 (diff), 37f0da8 (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. - Location:
- src/SynTree
- Files:
-
- 1 added
- 2 deleted
- 18 edited
-
AggregateDecl.cc (modified) (2 diffs)
-
CodeGenVisitor.cc (deleted)
-
CodeGenVisitor.h (deleted)
-
Constant.cc (modified) (2 diffs)
-
Constant.h (modified) (1 diff)
-
Declaration.h (modified) (2 diffs)
-
Expression.cc (modified) (6 diffs)
-
Expression.h (modified) (7 diffs)
-
Mutator.cc (modified) (6 diffs)
-
Mutator.h (modified) (5 diffs)
-
ReferenceToType.cc (modified) (2 diffs)
-
Statement.cc (modified) (16 diffs)
-
Statement.h (modified) (21 diffs)
-
SynTree.h (modified) (5 diffs)
-
Type.h (modified) (3 diffs)
-
TypeSubstitution.cc (modified) (3 diffs)
-
TypeSubstitution.h (modified) (2 diffs)
-
VarArgsType.cc (added)
-
Visitor.cc (modified) (6 diffs)
-
Visitor.h (modified) (5 diffs)
-
module.mk (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AggregateDecl.cc
rc5833e8 r0f9e4403 10 10 // Created On : Sun May 17 23:56:39 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 08:12:49 201513 // Update Count : 612 // Last Modified On : Wed Mar 2 17:28:00 2016 13 // Update Count : 7 14 14 // 15 15 … … 64 64 std::string EnumDecl::typeString() const { return "enum"; } 65 65 66 std::string ContextDecl::typeString() const { return "context"; }66 std::string TraitDecl::typeString() const { return "context"; } 67 67 68 68 // Local Variables: // -
src/SynTree/Constant.cc
rc5833e8 r0f9e4403 16 16 #include <iostream> 17 17 #include <list> 18 #include <string> 18 19 19 20 #include "Constant.h" … … 28 29 29 30 Constant::~Constant() { delete type; } 31 32 Constant Constant::from( int i ) { 33 return Constant( new BasicType( Type::Qualifiers(), BasicType::SignedInt ), std::to_string( i ) ); 34 } 35 36 Constant Constant::from( unsigned long i ) { 37 return Constant( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), std::to_string( i ) ); 38 } 39 40 Constant Constant::from( double d ) { 41 return Constant( new BasicType( Type::Qualifiers(), BasicType::Double ), std::to_string( d ) ); 42 } 30 43 31 44 Constant *Constant::clone() const { assert( false ); return 0; } -
src/SynTree/Constant.h
rc5833e8 r0f9e4403 32 32 void set_value( std::string newValue ) { value = newValue; } 33 33 34 /// generates an integer constant of the given int 35 static Constant from( int i ); 36 /// generates an integer constant of the given unsigned long int 37 static Constant from( unsigned long i ); 38 /// generates a floating point constant of the given double 39 static Constant from( double d ); 40 34 41 virtual Constant *clone() const; 35 42 virtual void accept( Visitor &v ) { v.visit( this ); } -
src/SynTree/Declaration.h
rc5833e8 r0f9e4403 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:08:22 201513 // Update Count : 3 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:28:11 2016 13 // Update Count : 33 14 14 // 15 15 … … 246 246 }; 247 247 248 class ContextDecl : public AggregateDecl {249 typedef AggregateDecl Parent; 250 public: 251 ContextDecl( const std::string &name ) : Parent( name ) {}252 ContextDecl( const ContextDecl &other ) : Parent( other ) {}253 254 virtual ContextDecl *clone() const { return new ContextDecl( *this ); }248 class TraitDecl : public AggregateDecl { 249 typedef AggregateDecl Parent; 250 public: 251 TraitDecl( const std::string &name ) : Parent( name ) {} 252 TraitDecl( const TraitDecl &other ) : Parent( other ) {} 253 254 virtual TraitDecl *clone() const { return new TraitDecl( *this ); } 255 255 virtual void accept( Visitor &v ) { v.visit( this ); } 256 256 virtual Declaration *acceptMutator( Mutator &m ) { return m.mutate( this ); } -
src/SynTree/Expression.cc
rc5833e8 r0f9e4403 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Expression.cc -- 7 // Expression.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:10:29 201513 // Update Count : 3411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 17:16:23 2016 13 // Update Count : 40 14 14 // 15 15 … … 22 22 23 23 #include "Type.h" 24 #include "Initializer.h" 24 25 #include "Expression.h" 25 26 #include "Declaration.h" … … 211 212 212 213 os << " of "; 214 215 if ( type ) { 216 type->print(os, indent + 2); 217 } else { 218 os << "<NULL>"; 219 } 220 221 os << std::endl; 222 Expression::print( os, indent ); 223 } 224 225 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 226 add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 227 } 228 229 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {} 230 231 OffsetPackExpr::~OffsetPackExpr() { delete type; } 232 233 void OffsetPackExpr::print( std::ostream &os, int indent ) const { 234 os << std::string( indent, ' ' ) << "Offset pack expression on "; 213 235 214 236 if ( type ) { … … 422 444 } 423 445 446 AsmExpr::AsmExpr( const AsmExpr & other ) : inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {} 447 448 424 449 void AsmExpr::print( std::ostream &os, int indent ) const { 425 450 os << "Asm Expression: " << std::endl; … … 429 454 } 430 455 456 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 457 458 UntypedValofExpr::~UntypedValofExpr() { delete body; } 459 431 460 void UntypedValofExpr::print( std::ostream &os, int indent ) const { 432 461 os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl; … … 434 463 get_body()->print( os, indent + 2 ); 435 464 } 465 466 467 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 468 add_result( type->clone() ); 469 } 470 471 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 472 473 CompoundLiteralExpr::~CompoundLiteralExpr() { 474 delete initializer; 475 delete type; 476 } 477 478 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 479 os << "Compound Literal Expression: " << std::endl; 480 if ( type ) type->print( os, indent + 2 ); 481 if ( initializer ) initializer->print( os, indent + 2 ); 482 } 483 436 484 437 485 std::ostream & operator<<( std::ostream & out, Expression * expr ) { -
src/SynTree/Expression.h
rc5833e8 r0f9e4403 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Expression.h -- 7 // Expression.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:10:21 201513 // Update Count : 1911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 17:18:06 2016 13 // Update Count : 21 14 14 // 15 15 … … 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: … … 359 360 Type *type; 360 361 DeclarationWithType *member; 362 }; 363 364 /// Expression representing a pack of field-offsets for a generic type 365 class OffsetPackExpr : public Expression { 366 public: 367 OffsetPackExpr( StructInstType *type_, Expression *aname_ = 0 ); 368 OffsetPackExpr( const OffsetPackExpr &other ); 369 virtual ~OffsetPackExpr(); 370 371 StructInstType *get_type() const { return type; } 372 void set_type( StructInstType *newValue ) { type = newValue; } 373 374 virtual OffsetPackExpr *clone() const { return new OffsetPackExpr( *this ); } 375 virtual void accept( Visitor &v ) { v.visit( this ); } 376 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 377 378 virtual void print( std::ostream &os, int indent = 0 ) const; 379 380 private: 381 StructInstType *type; 361 382 }; 362 383 … … 515 536 public: 516 537 AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 538 AsmExpr( const AsmExpr & other ); 517 539 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; 518 540 … … 541 563 public: 542 564 UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {} 543 virtual ~UntypedValofExpr() {} 565 UntypedValofExpr( const UntypedValofExpr & other ); 566 virtual ~UntypedValofExpr(); 544 567 545 568 Expression *get_value(); … … 552 575 private: 553 576 Statement *body; 577 }; 578 579 /// CompoundLiteralExpr represents a C99 'compound literal' 580 class CompoundLiteralExpr : public Expression { 581 public: 582 CompoundLiteralExpr( Type * type, Initializer * initializer ); 583 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 584 ~CompoundLiteralExpr(); 585 586 Type * get_type() const { return type; } 587 void set_type( Type * t ) { type = t; } 588 589 Initializer * get_initializer() const { return initializer; } 590 void set_initializer( Initializer * i ) { initializer = i; } 591 592 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 593 virtual void accept( Visitor &v ) { v.visit( this ); } 594 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 595 virtual void print( std::ostream &os, int indent = 0 ) const; 596 private: 597 Type * type; 598 Initializer * initializer; 554 599 }; 555 600 -
src/SynTree/Mutator.cc
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 25 19:21:33 201513 // Update Count : 1 112 // Last Modified On : Fri Apr 1 18:05:16 2016 13 // Update Count : 16 14 14 // 15 15 … … 63 63 } 64 64 65 Declaration *Mutator::mutate( ContextDecl *aggregateDecl ) {65 Declaration *Mutator::mutate( TraitDecl *aggregateDecl ) { 66 66 handleAggregateDecl( aggregateDecl ); 67 67 return aggregateDecl; … … 274 274 } 275 275 276 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 277 mutateAll( offsetPackExpr->get_results(), *this ); 278 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); 279 return offsetPackExpr; 280 } 281 276 282 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 277 283 mutateAll( attrExpr->get_results(), *this ); … … 336 342 } 337 343 344 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 345 mutateAll( compLitExpr->get_results(), *this ); 346 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); 347 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 348 return compLitExpr; 349 } 350 338 351 Type *Mutator::mutate( VoidType *voidType ) { 339 352 mutateAll( voidType->get_forall(), *this ); … … 387 400 } 388 401 389 Type *Mutator::mutate( ContextInstType *aggregateUseType ) {402 Type *Mutator::mutate( TraitInstType *aggregateUseType ) { 390 403 handleReferenceToType( aggregateUseType ); 391 404 mutateAll( aggregateUseType->get_members(), *this ); … … 421 434 } 422 435 436 Type *Mutator::mutate( VarArgsType *varArgsType ) { 437 mutateAll( varArgsType->get_forall(), *this ); 438 return varArgsType; 439 } 440 423 441 Initializer *Mutator::mutate( SingleInit *singleInit ) { 424 442 singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) ); -
src/SynTree/Mutator.h
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Nov 19 22:26:16 201513 // Update Count : 812 // Last Modified On : Fri Apr 1 17:26:56 2016 13 // Update Count : 10 14 14 // 15 15 #include <cassert> … … 31 31 virtual Declaration* mutate( UnionDecl *aggregateDecl ); 32 32 virtual Declaration* mutate( EnumDecl *aggregateDecl ); 33 virtual Declaration* mutate( ContextDecl *aggregateDecl );33 virtual Declaration* mutate( TraitDecl *aggregateDecl ); 34 34 virtual TypeDecl* mutate( TypeDecl *typeDecl ); 35 35 virtual Declaration* mutate( TypedefDecl *typeDecl ); … … 67 67 virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr ); 68 68 virtual Expression* mutate( OffsetofExpr *offsetofExpr ); 69 virtual Expression* mutate( OffsetPackExpr *offsetPackExpr ); 69 70 virtual Expression* mutate( AttrExpr *attrExpr ); 70 71 virtual Expression* mutate( LogicalExpr *logicalExpr ); … … 76 77 virtual Expression* mutate( AsmExpr *asmExpr ); 77 78 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 78 80 79 81 virtual Type* mutate( VoidType *basicType ); … … 85 87 virtual Type* mutate( UnionInstType *aggregateUseType ); 86 88 virtual Type* mutate( EnumInstType *aggregateUseType ); 87 virtual Type* mutate( ContextInstType *aggregateUseType );89 virtual Type* mutate( TraitInstType *aggregateUseType ); 88 90 virtual Type* mutate( TypeInstType *aggregateUseType ); 89 91 virtual Type* mutate( TupleType *tupleType ); 90 92 virtual Type* mutate( TypeofType *typeofType ); 91 93 virtual Type* mutate( AttrType *attrType ); 94 virtual Type* mutate( VarArgsType *varArgsType ); 92 95 93 96 virtual Initializer* mutate( SingleInit *singleInit ); -
src/SynTree/ReferenceToType.cc
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jun 7 08:31:48 201513 // Update Count : 412 // Last Modified On : Wed Mar 2 17:28:51 2016 13 // Update Count : 5 14 14 // 15 15 … … 83 83 std::string EnumInstType::typeString() const { return "enum"; } 84 84 85 std::string ContextInstType::typeString() const { return "context"; }85 std::string TraitInstType::typeString() const { return "context"; } 86 86 87 ContextInstType::ContextInstType( const ContextInstType &other ) : Parent( other ) {87 TraitInstType::TraitInstType( const TraitInstType &other ) : Parent( other ) { 88 88 cloneAll( other.members, members ); 89 89 } 90 90 91 ContextInstType::~ContextInstType() {91 TraitInstType::~TraitInstType() { 92 92 deleteAll( members ); 93 93 } -
src/SynTree/Statement.cc
rc5833e8 r0f9e4403 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
rc5833e8 r0f9e4403 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 -
src/SynTree/SynTree.h
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 23 23:25:04 201513 // Update Count : 312 // Last Modified On : Fri Apr 1 16:47:44 2016 13 // Update Count : 5 14 14 // 15 15 … … 30 30 class UnionDecl; 31 31 class EnumDecl; 32 class ContextDecl;32 class TraitDecl; 33 33 class NamedTypeDecl; 34 34 class TypeDecl; … … 72 72 class UntypedOffsetofExpr; 73 73 class OffsetofExpr; 74 class OffsetPackExpr; 74 75 class AttrExpr; 75 76 class LogicalExpr; … … 81 82 class AsmExpr; 82 83 class UntypedValofExpr; 84 class CompoundLiteralExpr; 83 85 84 86 class Type; … … 92 94 class UnionInstType; 93 95 class EnumInstType; 94 class ContextInstType;96 class TraitInstType; 95 97 class TypeInstType; 96 98 class TupleType; 97 99 class TypeofType; 98 100 class AttrType; 101 class VarArgsType; 99 102 100 103 class Initializer; -
src/SynTree/Type.h
rc5833e8 r0f9e4403 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Dec 18 14:46:18 201513 // Update Count : 1811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:29:08 2016 13 // Update Count : 21 14 14 // 15 15 … … 296 296 }; 297 297 298 class ContextInstType : public ReferenceToType {298 class TraitInstType : public ReferenceToType { 299 299 typedef ReferenceToType Parent; 300 300 public: 301 ContextInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}302 ContextInstType( const ContextInstType &other );303 ~ ContextInstType();301 TraitInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {} 302 TraitInstType( const TraitInstType &other ); 303 ~TraitInstType(); 304 304 305 305 std::list< Declaration* >& get_members() { return members; } 306 306 307 virtual ContextInstType *clone() const { return new ContextInstType( *this ); }307 virtual TraitInstType *clone() const { return new TraitInstType( *this ); } 308 308 virtual void accept( Visitor &v ) { v.visit( this ); } 309 309 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 400 400 }; 401 401 402 /// Represents the GCC built-in varargs type 403 class VarArgsType : public Type { 404 public: 405 VarArgsType(); 406 VarArgsType( Type::Qualifiers tq ); 407 408 virtual VarArgsType *clone() const { return new VarArgsType( *this ); } 409 virtual void accept( Visitor &v ) { v.visit( this ); } 410 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 411 virtual void print( std::ostream &os, int indent = 0 ) const; 412 }; 413 402 414 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 403 415 isConst |= other.isConst; -
src/SynTree/TypeSubstitution.cc
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 11:10:04 201513 // Update Count : 212 // Last Modified On : Wed Mar 2 17:29:15 2016 13 // Update Count : 3 14 14 // 15 15 … … 190 190 } 191 191 192 Type * TypeSubstitution::mutate( ContextInstType *aggregateUseType ) {192 Type * TypeSubstitution::mutate( TraitInstType *aggregateUseType ) { 193 193 return handleType( aggregateUseType ); 194 194 } … … 196 196 Type * TypeSubstitution::mutate( TupleType *tupleType ) { 197 197 return handleType( tupleType ); 198 } 199 200 Type * TypeSubstitution::mutate( VarArgsType *varArgsType ) { 201 return handleType( varArgsType ); 198 202 } 199 203 -
src/SynTree/TypeSubstitution.h
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 11:12:30 201513 // Update Count : 112 // Last Modified On : Wed Mar 2 17:33:19 2016 13 // Update Count : 2 14 14 // 15 15 … … 72 72 virtual Type* mutate(UnionInstType *aggregateUseType); 73 73 virtual Type* mutate(EnumInstType *aggregateUseType); 74 virtual Type* mutate( ContextInstType *aggregateUseType);74 virtual Type* mutate(TraitInstType *aggregateUseType); 75 75 virtual Type* mutate(TupleType *tupleType); 76 virtual Type* mutate(VarArgsType *varArgsType); 76 77 77 78 // TODO: worry about traversing into a forall-qualified function type or type decl with assertions -
src/SynTree/Visitor.cc
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 24 16:11:05 201513 // Update Count : 1 512 // Last Modified On : Fri Apr 1 18:05:13 2016 13 // Update Count : 18 14 14 // 15 15 … … 56 56 } 57 57 58 void Visitor::visit( ContextDecl *aggregateDecl ) {58 void Visitor::visit( TraitDecl *aggregateDecl ) { 59 59 visit( static_cast< AggregateDecl* >( aggregateDecl ) ); 60 60 } … … 230 230 } 231 231 232 void Visitor::visit( OffsetPackExpr *offsetPackExpr ) { 233 acceptAll( offsetPackExpr->get_results(), *this ); 234 maybeAccept( offsetPackExpr->get_type(), *this ); 235 } 236 232 237 void Visitor::visit( AttrExpr *attrExpr ) { 233 238 acceptAll( attrExpr->get_results(), *this ); … … 284 289 } 285 290 291 void Visitor::visit( CompoundLiteralExpr *compLitExpr ) { 292 acceptAll( compLitExpr->get_results(), *this ); 293 maybeAccept( compLitExpr->get_type(), *this ); 294 maybeAccept( compLitExpr->get_initializer(), *this ); 295 } 296 286 297 void Visitor::visit( VoidType *voidType ) { 287 298 acceptAll( voidType->get_forall(), *this ); … … 326 337 } 327 338 328 void Visitor::visit( ContextInstType *aggregateUseType ) {339 void Visitor::visit( TraitInstType *aggregateUseType ) { 329 340 visit( static_cast< ReferenceToType * >( aggregateUseType ) ); 330 341 acceptAll( aggregateUseType->get_members(), *this ); … … 355 366 } 356 367 368 void Visitor::visit( VarArgsType *varArgsType ) { 369 acceptAll( varArgsType->get_forall(), *this ); 370 } 371 357 372 void Visitor::visit( SingleInit *singleInit ) { 358 373 singleInit->get_value()->accept( *this ); -
src/SynTree/Visitor.h
rc5833e8 r0f9e4403 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 25 21:20:44201613 // Update Count : 512 // Last Modified On : Fri Apr 1 17:26:55 2016 13 // Update Count : 7 14 14 // 15 15 … … 31 31 virtual void visit( UnionDecl *aggregateDecl ); 32 32 virtual void visit( EnumDecl *aggregateDecl ); 33 virtual void visit( ContextDecl *aggregateDecl );33 virtual void visit( TraitDecl *aggregateDecl ); 34 34 virtual void visit( TypeDecl *typeDecl ); 35 35 virtual void visit( TypedefDecl *typeDecl ); … … 67 67 virtual void visit( UntypedOffsetofExpr *offsetofExpr ); 68 68 virtual void visit( OffsetofExpr *offsetofExpr ); 69 virtual void visit( OffsetPackExpr *offsetPackExpr ); 69 70 virtual void visit( AttrExpr *attrExpr ); 70 71 virtual void visit( LogicalExpr *logicalExpr ); … … 76 77 virtual void visit( AsmExpr *asmExpr ); 77 78 virtual void visit( UntypedValofExpr *valofExpr ); 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 78 80 79 81 virtual void visit( VoidType *basicType ); … … 85 87 virtual void visit( UnionInstType *aggregateUseType ); 86 88 virtual void visit( EnumInstType *aggregateUseType ); 87 virtual void visit( ContextInstType *aggregateUseType );89 virtual void visit( TraitInstType *aggregateUseType ); 88 90 virtual void visit( TypeInstType *aggregateUseType ); 89 91 virtual void visit( TupleType *tupleType ); 90 92 virtual void visit( TypeofType *typeofType ); 91 93 virtual void visit( AttrType *attrType ); 94 virtual void visit( VarArgsType *varArgsType ); 92 95 93 96 virtual void visit( SingleInit *singleInit ); -
src/SynTree/module.mk
rc5833e8 r0f9e4403 25 25 SynTree/TypeofType.cc \ 26 26 SynTree/AttrType.cc \ 27 SynTree/VarArgsType.cc \ 27 28 SynTree/Constant.cc \ 28 29 SynTree/Expression.cc \ … … 45 46 SynTree/Visitor.cc \ 46 47 SynTree/Mutator.cc \ 47 SynTree/CodeGenVisitor.cc \48 48 SynTree/TypeSubstitution.cc 49 49
Note:
See TracChangeset
for help on using the changeset viewer.