Changeset b29f8f3 for src/SynTree
- Timestamp:
- Jul 29, 2015, 12:07:38 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, string, with_gc
- Children:
- 093f1a0
- Parents:
- 1e8f143 (diff), 51b986f (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:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.cc
r1e8f143 rb29f8f3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 08:07:20201513 // Update Count : 912 // Last Modified On : Mon Jul 13 17:58:38 2015 13 // Update Count : 10 14 14 // 15 15 … … 27 27 28 28 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage ) 29 : name( name ), storageClass( sc ), linkage( linkage ), uniqueId( 0 ) {29 : name( name ), storageClass( sc ), linkage( linkage ), isInline( false ), isNoreturn( false ), uniqueId( 0 ) { 30 30 } 31 31 32 32 Declaration::Declaration( const Declaration &other ) 33 : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage), uniqueId( other.uniqueId ) {33 : name( other.name ), storageClass( other.storageClass ), linkage( other.linkage ), isInline( other.isInline ), isNoreturn( other.isNoreturn ), uniqueId( other.uniqueId ) { 34 34 } 35 35 -
src/SynTree/Declaration.h
r1e8f143 rb29f8f3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 09:10:31201513 // Update Count : 2 512 // Last Modified On : Mon Jul 13 18:15:59 2015 13 // Update Count : 28 14 14 // 15 15 … … 35 35 LinkageSpec::Type get_linkage() const { return linkage; } 36 36 void set_linkage( LinkageSpec::Type newValue ) { linkage = newValue; } 37 bool get_isInline() const { return isInline; } 38 void set_isInline( bool newValue ) { isInline = newValue; } 39 bool get_isNoreturn() const { return isNoreturn; } 40 void set_isNoreturn( bool newValue ) { isNoreturn = newValue; } 37 41 UniqueId get_uniqueId() const { return uniqueId; } 38 42 … … 50 54 DeclarationNode::StorageClass storageClass; 51 55 LinkageSpec::Type linkage; 56 bool isInline, isNoreturn; 52 57 UniqueId uniqueId; 53 58 }; … … 75 80 typedef DeclarationWithType Parent; 76 81 public: 77 ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init );82 ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline = false, bool isNoreturn = false ); 78 83 ObjectDecl( const ObjectDecl &other ); 79 84 virtual ~ObjectDecl(); … … 89 94 virtual ObjectDecl *clone() const { return new ObjectDecl( *this ); } 90 95 virtual void accept( Visitor &v ) { v.visit( this ); } 91 virtual ObjectDecl*acceptMutator( Mutator &m ) { return m.mutate( this ); }96 virtual DeclarationWithType *acceptMutator( Mutator &m ) { return m.mutate( this ); } 92 97 virtual void print( std::ostream &os, int indent = 0 ) const; 93 98 virtual void printShort( std::ostream &os, int indent = 0 ) const; … … 112 117 CompoundStmt *get_statements() const { return statements; } 113 118 void set_statements( CompoundStmt *newValue ) { statements = newValue; } 114 bool get_isInline() const { return isInline; }115 bool get_isNoreturn() const { return isNoreturn; }116 119 std::list< std::string >& get_oldIdents() { return oldIdents; } 117 120 std::list< Declaration* >& get_oldDecls() { return oldDecls; } … … 125 128 FunctionType *type; 126 129 CompoundStmt *statements; 127 bool isInline, isNoreturn;128 130 std::list< std::string > oldIdents; 129 131 std::list< Declaration* > oldDecls; -
src/SynTree/FunctionDecl.cc
r1e8f143 rb29f8f3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 09:10:32201513 // Update Count : 1 612 // Last Modified On : Mon Jul 13 18:11:44 2015 13 // Update Count : 19 14 14 // 15 15 … … 22 22 23 23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn ) 24 : Parent( name, sc, linkage ), type( type ), statements( statements ), isInline( isInline ), isNoreturn( isNoreturn ) { 24 : Parent( name, sc, linkage ), type( type ), statements( statements ) { 25 set_isInline( isInline ); 26 set_isNoreturn( isNoreturn ); 25 27 // this is a brazen hack to force the function "main" to have C linkage 26 28 if ( name == "main" ) { … … 30 32 31 33 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 32 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) , isInline( other.isInline ), isNoreturn( other.isNoreturn ){34 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 33 35 } 34 36 … … 57 59 os << LinkageSpec::toString( get_linkage() ) << " "; 58 60 } // if 59 if ( isInline) {61 if ( get_isInline() ) { 60 62 os << "inline "; 61 63 } // if 62 if ( isNoreturn) {64 if ( get_isNoreturn() ) { 63 65 os << "_Noreturn "; 64 66 } // if … … 96 98 os << get_name() << ": "; 97 99 } // if 98 if ( isInline) {100 if ( get_isInline() ) { 99 101 os << "inline "; 100 102 } // if 101 if ( isNoreturn) {103 if ( get_isNoreturn() ) { 102 104 os << "_Noreturn "; 103 105 } // if -
src/SynTree/Mutator.cc
r1e8f143 rb29f8f3 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 10:10:46201513 // Update Count : 112 // Last Modified On : Thu Jul 16 16:10:54 2015 13 // Update Count : 3 14 14 // 15 15 … … 28 28 Mutator::~Mutator() {} 29 29 30 ObjectDecl*Mutator::mutate( ObjectDecl *objectDecl ) {30 DeclarationWithType *Mutator::mutate( ObjectDecl *objectDecl ) { 31 31 objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) ); 32 32 objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) ); … … 109 109 110 110 Statement *Mutator::mutate( ForStmt *forStmt ) { 111 forStmt->set_initialization( maybeMutate( forStmt->get_initialization(), *this ));111 mutateAll( forStmt->get_initialization(), *this ); 112 112 forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) ); 113 113 forStmt->set_increment( maybeMutate( forStmt->get_increment(), *this ) ); -
src/SynTree/Mutator.h
r1e8f143 rb29f8f3 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 May 29 16:34:08201513 // Update Count : 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 13 18:14:47 2015 13 // Update Count : 5 14 14 // 15 15 #include <cassert> … … 26 26 virtual ~Mutator(); 27 27 public: 28 virtual ObjectDecl* mutate( ObjectDecl *objectDecl );28 virtual DeclarationWithType* mutate( ObjectDecl *objectDecl ); 29 29 virtual DeclarationWithType* mutate( FunctionDecl *functionDecl ); 30 30 virtual Declaration* mutate( StructDecl *aggregateDecl ); -
src/SynTree/ObjectDecl.cc
r1e8f143 rb29f8f3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 08:10:16201513 // Update Count : 1 512 // Last Modified On : Mon Jul 13 18:08:27 2015 13 // Update Count : 16 14 14 // 15 15 … … 20 20 #include "utility.h" 21 21 22 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init )22 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn ) 23 23 : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 24 set_isInline( isInline ); 25 set_isNoreturn( isNoreturn ); 24 26 } 25 27 -
src/SynTree/Statement.cc
r1e8f143 rb29f8f3 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 Jun 29 17:37:10 201513 // Update Count : 2 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jul 15 14:57:40 2015 13 // Update Count : 27 14 14 // 15 15 … … 192 192 } 193 193 194 ForStmt::ForStmt( std::list<Label> labels, Statement *initialization_, Expression *condition_, Expression *increment_, Statement *body_ ):194 ForStmt::ForStmt( std::list<Label> labels, std::list<Statement *> initialization_, Expression *condition_, Expression *increment_, Statement *body_ ): 195 195 Statement( labels ), initialization( initialization_ ), condition( condition_ ), increment( increment_ ), body( body_ ) { 196 196 } 197 197 198 198 ForStmt::~ForStmt() { 199 delete initialization;199 deleteAll( initialization ); 200 200 delete condition; 201 201 delete increment; … … 213 213 214 214 os << string( indent + 2, ' ' ) << "initialization: \n"; 215 if ( initialization != 0 ) 216 initialization->print( os, indent + 4 ); 215 for ( std::list<Statement *>::const_iterator it = initialization.begin(); it != initialization.end(); ++it ) { 216 (*it)->print( os, indent + 4 ); 217 } 217 218 218 219 os << "\n" << string( indent + 2, ' ' ) << "condition: \n"; -
src/SynTree/Statement.h
r1e8f143 rb29f8f3 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 Ju n 23 11:44:27201513 // Update Count : 2 011 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jul 14 12:14:54 2015 13 // Update Count : 24 14 14 // 15 15 … … 199 199 class ForStmt : public Statement { 200 200 public: 201 ForStmt( std::list<Label> labels, Statement *initialization = 0,201 ForStmt( std::list<Label> labels, std::list<Statement *> initialization, 202 202 Expression *condition = 0, Expression *increment = 0, Statement *body = 0 ); 203 203 virtual ~ForStmt(); 204 204 205 Statement *get_initialization() { return initialization; }206 void set_initialization( Statement *newValue ) { initialization = newValue; }205 std::list<Statement *> &get_initialization() { return initialization; } 206 void set_initialization( std::list<Statement *> newValue ) { initialization = newValue; } 207 207 Expression *get_condition() { return condition; } 208 208 void set_condition( Expression *newValue ) { condition = newValue; } … … 217 217 virtual void print( std::ostream &os, int indent = 0 ) const; 218 218 private: 219 Statement *initialization;219 std::list<Statement *> initialization; 220 220 Expression *condition; 221 221 Expression *increment; -
src/SynTree/Type.cc
r1e8f143 rb29f8f3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue May 19 16:52:27201513 // Update Count : 212 // Last Modified On : Thu Jul 9 16:45:13 2015 13 // Update Count : 3 14 14 // 15 15 … … 75 75 os << "_Atomic "; 76 76 } // if 77 if ( tq.isAttribute ) { 78 os << "__attribute(( )) "; 79 } // if 77 80 } 78 81 -
src/SynTree/Type.h
r1e8f143 rb29f8f3 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 26 16:47:54201513 // Update Count : 1 312 // Last Modified On : Thu Jul 9 16:46:15 2015 13 // Update Count : 14 14 14 // 15 15 … … 25 25 struct Qualifiers { 26 26 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {} 27 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}27 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {} 28 28 29 29 Qualifiers &operator+=( const Qualifiers &other ); -
src/SynTree/Visitor.cc
r1e8f143 rb29f8f3 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 11:14:51201513 // Update Count : 211 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jul 14 12:31:03 2015 13 // Update Count : 3 14 14 // 15 15 … … 94 94 95 95 void Visitor::visit( ForStmt *forStmt ) { 96 // ForStmt still needs to be fixed 97 maybeAccept( forStmt->get_initialization(), *this ); 96 acceptAll( forStmt->get_initialization(), *this ); 98 97 maybeAccept( forStmt->get_condition(), *this ); 99 98 maybeAccept( forStmt->get_increment(), *this );
Note:
See TracChangeset
for help on using the changeset viewer.