Changeset a5a71d0 for src/SynTree
- Timestamp:
- Apr 6, 2016, 5:11:32 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:
- eab39cd
- Parents:
- 39786813 (diff), 3aba311 (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:
-
- 2 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AggregateDecl.cc
r39786813 ra5a71d0 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/CommaExpr.cc
r39786813 ra5a71d0 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // CommaExpr.cc -- 7 // CommaExpr.cc -- 8 8 // 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 : Mon May 18 08:09:58 201511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Apr 06 17:07:54 2016 13 13 // Update Count : 1 14 14 // … … 20 20 CommaExpr::CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname ) 21 21 : Expression( _aname ), arg1( arg1 ), arg2( arg2 ) { 22 // xxx - result of a comma expression is never an lvalue, so should set lvalue 23 // to false on all result types 22 24 cloneAll( arg2->get_results(), get_results() ); 23 25 } -
src/SynTree/CompoundStmt.cc
r39786813 ra5a71d0 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // XXX.cc -- 7 // XXX.cc -- 8 8 // 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 : Tue Jun 23 11:37:49 201511 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Apr 06 14:35:37 2016 13 13 // Update Count : 3 14 14 // … … 18 18 #include <algorithm> 19 19 #include <functional> 20 #include "Expression.h" 21 #include "Declaration.h" 20 22 21 23 using std::string; 22 24 using std::endl; 25 26 class VarExprReplacer : public Visitor { 27 public: 28 typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap; 29 private: 30 const DeclMap & declMap; 31 public: 32 VarExprReplacer( const DeclMap & declMap ) : declMap( declMap ) {} 33 34 // replace variable with new node from decl map 35 virtual void visit( VariableExpr * varExpr ) { 36 if ( declMap.count( varExpr->get_var() ) ) { 37 varExpr->set_var( declMap.at( varExpr->get_var() ) ); 38 } 39 } 40 }; 41 23 42 24 43 CompoundStmt::CompoundStmt( std::list<Label> labels ) : Statement( labels ) { … … 27 46 CompoundStmt::CompoundStmt( const CompoundStmt &other ) : Statement( other ) { 28 47 cloneAll( other.kids, kids ); 48 49 // when cloning a compound statement, we may end up cloning declarations which 50 // are referred to by VariableExprs throughout the block. Cloning a VariableExpr 51 // does a shallow copy, so the VariableExpr will end up pointing to the original 52 // declaration. If the original declaration is deleted, e.g. because the original 53 // CompoundStmt is deleted, then we have a dangling pointer. To avoid this case, 54 // find all DeclarationWithType nodes (since a VariableExpr must point to a 55 // DeclarationWithType) in the original CompoundStmt and map them to the cloned 56 // node in the new CompoundStmt ('this'), then replace the Declarations referred to 57 // by each VariableExpr according to the constructed map. Note that only the declarations 58 // in the current level are collected into the map, because child CompoundStmts will 59 // recursively execute this routine. There may be more efficient ways of doing 60 // this. 61 VarExprReplacer::DeclMap declMap; 62 std::list< Statement * >::const_iterator origit = other.kids.begin(); 63 for ( Statement * s : kids ) { 64 assert( origit != other.kids.end() ); 65 if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) { 66 DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( *origit ); 67 assert( origDeclStmt ); 68 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) { 69 DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ); 70 assert( origdwt ); 71 declMap[ origdwt ] = dwt; 72 } 73 } 74 } 75 if ( ! declMap.empty() ) { 76 VarExprReplacer replacer( declMap ); 77 accept( replacer ); 78 } 29 79 } 30 80 -
src/SynTree/Constant.cc
r39786813 ra5a71d0 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
r39786813 ra5a71d0 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
r39786813 ra5a71d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 16:11:49201612 // Last Modified On : Mon Apr 04 17:14:00 2016 13 13 // Update Count : 36 14 14 // … … 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/Initializer.cc
r39786813 ra5a71d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Mar 30 13:58:32 201612 // Last Modified On : Wed Apr 06 16:15:32 2016 13 13 // Update Count : 28 14 14 // … … 35 35 } 36 36 37 SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( other.value) {37 SingleInit::SingleInit( const SingleInit &other ) : Initializer(other), value ( maybeClone( other.value ) ) { 38 38 cloneAll(other.designators, designators ); 39 39 } -
src/SynTree/Mutator.cc
r39786813 ra5a71d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:32:29201612 // Last Modified On : Mon Apr 04 17:14:20 2016 13 13 // Update Count : 15 14 14 // … … 63 63 } 64 64 65 Declaration *Mutator::mutate( ContextDecl *aggregateDecl ) {65 Declaration *Mutator::mutate( TraitDecl *aggregateDecl ) { 66 66 handleAggregateDecl( aggregateDecl ); 67 67 return aggregateDecl; … … 387 387 } 388 388 389 Type *Mutator::mutate( ContextInstType *aggregateUseType ) {389 Type *Mutator::mutate( TraitInstType *aggregateUseType ) { 390 390 handleReferenceToType( aggregateUseType ); 391 391 mutateAll( aggregateUseType->get_members(), *this ); -
src/SynTree/Mutator.h
r39786813 ra5a71d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:24:26201612 // Last Modified On : Mon Apr 04 17:14:44 2016 13 13 // Update Count : 9 14 14 // … … 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 ); … … 85 85 virtual Type* mutate( UnionInstType *aggregateUseType ); 86 86 virtual Type* mutate( EnumInstType *aggregateUseType ); 87 virtual Type* mutate( ContextInstType *aggregateUseType );87 virtual Type* mutate( TraitInstType *aggregateUseType ); 88 88 virtual Type* mutate( TypeInstType *aggregateUseType ); 89 89 virtual Type* mutate( TupleType *tupleType ); -
src/SynTree/ReferenceToType.cc
r39786813 ra5a71d0 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/SynTree.h
r39786813 ra5a71d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:28:41201612 // Last Modified On : Mon Apr 04 17:16:09 2016 13 13 // Update Count : 4 14 14 // … … 30 30 class UnionDecl; 31 31 class EnumDecl; 32 class ContextDecl;32 class TraitDecl; 33 33 class NamedTypeDecl; 34 34 class TypeDecl; … … 92 92 class UnionInstType; 93 93 class EnumInstType; 94 class ContextInstType;94 class TraitInstType; 95 95 class TypeInstType; 96 96 class TupleType; -
src/SynTree/Type.h
r39786813 ra5a71d0 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 ); } … … 402 402 /// Represents the GCC built-in varargs type 403 403 class VarArgsType : public Type { 404 public: 404 405 VarArgsType(); 406 VarArgsType( Type::Qualifiers tq ); 405 407 406 408 virtual VarArgsType *clone() const { return new VarArgsType( *this ); } -
src/SynTree/TypeSubstitution.cc
r39786813 ra5a71d0 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 } -
src/SynTree/TypeSubstitution.h
r39786813 ra5a71d0 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 76 virtual Type* mutate(VarArgsType *varArgsType); -
src/SynTree/VarArgsType.cc
r39786813 ra5a71d0 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu Feb 25 16:34:00 2016 11 // Last Modified By : Aaron B. Moss12 // Last Modified On : Thu Feb 25 16:34:00 201613 // Update Count : 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 2 17:10:40 2016 13 // Update Count : 2 14 14 // 15 15 … … 17 17 18 18 VarArgsType::VarArgsType() : Type( Type::Qualifiers() ) {} 19 20 VarArgsType::VarArgsType( Type::Qualifiers tq ) : Type( tq ) {} 19 21 20 22 void VarArgsType::print( std::ostream &os, int indent ) const { -
src/SynTree/Visitor.cc
r39786813 ra5a71d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 15:27:23201612 // Last Modified On : Mon Apr 04 17:16:25 2016 13 13 // Update Count : 18 14 14 // … … 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 } … … 326 326 } 327 327 328 void Visitor::visit( ContextInstType *aggregateUseType ) {328 void Visitor::visit( TraitInstType *aggregateUseType ) { 329 329 visit( static_cast< ReferenceToType * >( aggregateUseType ) ); 330 330 acceptAll( aggregateUseType->get_members(), *this ); -
src/SynTree/Visitor.h
r39786813 ra5a71d0 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Feb 09 13:20:48201612 // Last Modified On : Mon Apr 04 17:16:36 2016 13 13 // Update Count : 6 14 14 // … … 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 ); … … 85 85 virtual void visit( UnionInstType *aggregateUseType ); 86 86 virtual void visit( EnumInstType *aggregateUseType ); 87 virtual void visit( ContextInstType *aggregateUseType );87 virtual void visit( TraitInstType *aggregateUseType ); 88 88 virtual void visit( TypeInstType *aggregateUseType ); 89 89 virtual void visit( TupleType *tupleType ); -
src/SynTree/module.mk
r39786813 ra5a71d0 46 46 SynTree/Visitor.cc \ 47 47 SynTree/Mutator.cc \ 48 SynTree/CodeGenVisitor.cc \49 48 SynTree/TypeSubstitution.cc 50 49
Note:
See TracChangeset
for help on using the changeset viewer.