Changeset 1fbab5a for src/SynTree
- Timestamp:
- Mar 16, 2017, 4:50:08 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 395fc37, 64ac636, ef42b143
- Parents:
- 2f26687a (diff), d6d747d (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:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AggregateDecl.cc
r2f26687a r1fbab5a 10 10 // Created On : Sun May 17 23:56:39 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 7 07:31:47 201713 // Update Count : 1912 // Last Modified On : Thu Mar 16 07:49:07 2017 13 // Update Count : 20 14 14 // 15 15 … … 20 20 21 21 22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, Type::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) { 23 23 } 24 24 -
src/SynTree/Declaration.cc
r2f26687a r1fbab5a 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 Mar 7 07:31:11201713 // Update Count : 2 312 // Last Modified On : Thu Mar 16 07:49:18 2017 13 // Update Count : 24 14 14 // 15 15 … … 27 27 static IdMapType idMap; 28 28 29 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage )29 Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) 30 30 : name( name ), storageClasses( scs ), linkage( linkage ), uniqueId( 0 ) { 31 31 } … … 66 66 67 67 68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) { 69 69 } 70 70 -
src/SynTree/Declaration.h
r2f26687a r1fbab5a 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 Mar 7 07:40:42201713 // Update Count : 11 312 // Last Modified On : Thu Mar 16 08:34:11 2017 13 // Update Count : 118 14 14 // 15 15 … … 28 28 class Declaration : public BaseSyntaxNode { 29 29 public: 30 Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage );30 Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); 31 31 Declaration( const Declaration &other ); 32 32 virtual ~Declaration(); … … 35 35 void set_name( std::string newValue ) { name = newValue; } 36 36 37 DeclarationNode::StorageClasses get_storageClasses() const { return storageClasses; }37 Type::StorageClasses get_storageClasses() const { return storageClasses; } 38 38 39 39 LinkageSpec::Spec get_linkage() const { return linkage; } … … 56 56 private: 57 57 std::string name; 58 DeclarationNode::StorageClasses storageClasses;58 Type::StorageClasses storageClasses; 59 59 LinkageSpec::Spec linkage; 60 60 UniqueId uniqueId; … … 64 64 class DeclarationWithType : public Declaration { 65 65 public: 66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs );66 DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs ); 67 67 DeclarationWithType( const DeclarationWithType &other ); 68 68 virtual ~DeclarationWithType(); … … 82 82 const std::list< Attribute * >& get_attributes() const { return attributes; } 83 83 84 DeclarationNode::FuncSpecifiers get_funcSpec() const { return fs; }85 //void set_functionSpecifiers( DeclarationNode::FuncSpecifiers newValue ) { fs = newValue; }84 Type::FuncSpecifiers get_funcSpec() const { return fs; } 85 //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; } 86 86 87 87 virtual DeclarationWithType *clone() const = 0; … … 98 98 ConstantExpr *asmName; 99 99 std::list< Attribute * > attributes; 100 DeclarationNode::FuncSpecifiers fs;100 Type::FuncSpecifiers fs; 101 101 }; 102 102 … … 104 104 typedef DeclarationWithType Parent; 105 105 public: 106 ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,107 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );106 ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, 107 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 108 108 ObjectDecl( const ObjectDecl &other ); 109 109 virtual ~ObjectDecl(); … … 132 132 typedef DeclarationWithType Parent; 133 133 public: 134 FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,135 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );134 FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, 135 const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); 136 136 FunctionDecl( const FunctionDecl &other ); 137 137 virtual ~FunctionDecl(); … … 158 158 typedef Declaration Parent; 159 159 public: 160 NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type );160 NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); 161 161 NamedTypeDecl( const NamedTypeDecl &other ); 162 162 virtual ~NamedTypeDecl(); … … 193 193 }; 194 194 195 TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind );195 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ); 196 196 TypeDecl( const TypeDecl &other ); 197 197 … … 214 214 typedef NamedTypeDecl Parent; 215 215 public: 216 TypedefDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}216 TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {} 217 217 TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} 218 218 -
src/SynTree/DeclarationWithType.cc
r2f26687a r1fbab5a 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 Mar 7 07:32:14201713 // Update Count : 2 312 // Last Modified On : Thu Mar 16 08:34:35 2017 13 // Update Count : 25 14 14 // 15 15 … … 19 19 #include "Common/utility.h" 20 20 21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs )21 DeclarationWithType::DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs ) 22 22 : Declaration( name, scs, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) { 23 23 } -
src/SynTree/FunctionDecl.cc
r2f26687a r1fbab5a 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 Mar 7 07:54:58201713 // Update Count : 6812 // Last Modified On : Thu Mar 16 08:33:41 2017 13 // Update Count : 74 14 14 // 15 15 … … 26 26 extern bool translation_unit_nomain; 27 27 28 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )28 FunctionDecl::FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, Type::FuncSpecifiers fs ) 29 29 : Parent( name, scs, linkage, attributes, fs ), type( type ), statements( statements ) { 30 30 // hack forcing the function "main" to have Cforall linkage to replace main even if it is inside an extern … … 65 65 printAll( get_attributes(), os, indent ); 66 66 67 DeclarationNode::print_StorageClass( os, get_storageClasses());68 DeclarationNode::print_FuncSpec( os, get_funcSpec());67 get_storageClasses().print( os ); 68 get_funcSpec().print( os ); 69 69 70 70 if ( get_type() ) { … … 91 91 // xxx - should printShort print attributes? 92 92 93 DeclarationNode::print_StorageClass( os, get_storageClasses());94 DeclarationNode::print_FuncSpec( os, get_funcSpec());93 get_storageClasses().print( os ); 94 get_funcSpec().print( os ); 95 95 96 96 if ( get_type() ) { -
src/SynTree/NamedTypeDecl.cc
r2f26687a r1fbab5a 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 Mar 7 07:39:41201713 // Update Count : 1 012 // Last Modified On : Thu Mar 16 07:49:44 2017 13 // Update Count : 13 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *base )20 NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base ) 21 21 : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {} 22 22 … … 39 39 os << get_name() << ": "; 40 40 } // if 41 DeclarationNode::print_StorageClass( os, get_storageClasses());41 get_storageClasses().print( os ); 42 42 os << typeString(); 43 43 if ( base ) { … … 61 61 os << get_name() << ": "; 62 62 } // if 63 DeclarationNode::print_StorageClass( os, get_storageClasses());63 get_storageClasses().print( os ); 64 64 os << typeString(); 65 65 if ( base ) { -
src/SynTree/ObjectDecl.cc
r2f26687a r1fbab5a 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 Mar 7 07:55:24201713 // Update Count : 5 412 // Last Modified On : Thu Mar 16 08:34:27 2017 13 // Update Count : 59 14 14 // 15 15 … … 22 22 #include "Statement.h" 23 23 24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )24 ObjectDecl::ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, Type::FuncSpecifiers fs ) 25 25 : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 26 26 } … … 47 47 printAll( get_attributes(), os, indent ); 48 48 49 DeclarationNode::print_StorageClass( os, get_storageClasses());49 get_storageClasses().print( os ); 50 50 51 51 if ( get_type() ) { … … 81 81 // xxx - should printShort print attributes? 82 82 83 DeclarationNode::print_StorageClass( os, get_storageClasses());83 get_storageClasses().print( os ); 84 84 85 85 if ( get_type() ) { -
src/SynTree/Type.cc
r2f26687a r1fbab5a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:26:24201713 // Update Count : 1212 // Last Modified On : Thu Mar 16 10:25:06 2017 13 // Update Count : 23 14 14 // 15 15 … … 59 59 } 60 60 61 void Type::Qualifiers::print( std::ostream &os, int indent ) const { 62 if ( isConst ) { 63 os << "const "; 64 } // if 65 if ( isVolatile ) { 66 os << "volatile "; 67 } // if 68 if ( isRestrict ) { 69 os << "restrict "; 70 } // if 71 if ( isLvalue ) { 72 os << "lvalue "; 73 } // if 74 if ( isAtomic ) { 75 os << "_Atomic "; 76 } // if 77 } 61 // These must remain in the same order as the corresponding bit fields. 62 const char * Type::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn" }; 63 const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" }; 64 const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 78 65 79 66 void Type::print( std::ostream &os, int indent ) const { … … 89 76 } // if 90 77 91 tq.print( os , indent);78 tq.print( os ); 92 79 } 93 80 -
src/SynTree/Type.h
r2f26687a r1fbab5a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 1 09:11:45201713 // Update Count : 4112 // Last Modified On : Thu Mar 16 12:11:50 2017 13 // Update Count : 116 14 14 // 15 15 … … 24 24 class Type : public BaseSyntaxNode { 25 25 public: 26 struct Qualifiers { 27 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isMutex( false ) {} 28 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isMutex ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isMutex( isMutex ) {} 29 30 Qualifiers &operator&=( const Qualifiers &other ); 31 Qualifiers &operator+=( const Qualifiers &other ); 32 Qualifiers &operator-=( const Qualifiers &other ); 33 Qualifiers operator+( const Type::Qualifiers &other ); 34 bool operator==( const Qualifiers &other ); 35 bool operator!=( const Qualifiers &other ); 36 bool operator<=( const Qualifiers &other ); 37 bool operator>=( const Qualifiers &other ); 38 bool operator<( const Qualifiers &other ); 39 bool operator>( const Qualifiers &other ); 40 void print( std::ostream &os, int indent = 0 ) const; 41 42 bool isConst; 43 bool isVolatile; 44 bool isRestrict; 45 bool isLvalue; 46 bool isAtomic; 47 bool isMutex; 48 }; 49 50 Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ); 51 Type( const Type &other ); 26 #define CommonBF( N ) \ 27 bool operator[]( unsigned int i ) const { return val & (1 << i); } \ 28 bool any() const { return val != 0; } \ 29 static const char * Names[]; \ 30 void print( std::ostream & os ) const { \ 31 if ( (*this).any() ) { \ 32 for ( unsigned int i = 0; i < N; i += 1 ) { \ 33 if ( (*this)[i] ) { \ 34 os << Names[i] << ' '; \ 35 } \ 36 } \ 37 } \ 38 } 39 40 // enum must remain in the same order as the corresponding bit fields. 41 42 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 43 union FuncSpecifiers { 44 unsigned int val; 45 struct { 46 bool is_inline : 1; 47 bool is_noreturn : 1; 48 bool is_fortran : 1; 49 }; 50 FuncSpecifiers() : val( 0 ) {} 51 FuncSpecifiers( unsigned int val ) : val( val ) {} 52 CommonBF( NumFuncSpecifier ) 53 }; // FuncSpecifiers 54 55 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 56 union StorageClasses { 57 unsigned int val; 58 struct { 59 bool is_extern : 1; 60 bool is_static : 1; 61 bool is_auto : 1; 62 bool is_register : 1; 63 bool is_threadlocal : 1; 64 }; 65 66 StorageClasses() : val( 0 ) {} 67 StorageClasses( unsigned int val ) : val( val ) {} 68 CommonBF( NumStorageClass ) 69 }; // StorageClasses 70 71 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 72 union Qualifiers { 73 enum { Mask = ~(Restrict | Lvalue) }; 74 unsigned int val; 75 struct { 76 bool isConst : 1; 77 bool isRestrict : 1; 78 bool isVolatile : 1; 79 bool isLvalue : 1; 80 bool isMutex : 1; 81 bool isAtomic : 1; 82 }; 83 84 Qualifiers() : val( 0 ) {} 85 Qualifiers( unsigned int val ) : val( val ) {} 86 bool operator==( Qualifiers other ) const { 87 return (val & Mask) == (other.val & Mask); 88 } 89 bool operator!=( Qualifiers other ) const { 90 return (val & Mask) != (other.val & Mask); 91 } 92 bool operator<=( Qualifiers other ) const { 93 return isConst <= other.isConst && isVolatile <= other.isVolatile && 94 isMutex == other.isMutex && isAtomic == other.isAtomic; 95 } 96 bool operator>=( Qualifiers other ) const { 97 return isConst >= other.isConst && isVolatile >= other.isVolatile && 98 isMutex == other.isMutex && isAtomic == other.isAtomic; 99 } 100 bool operator<( Qualifiers other ) const { 101 return *this != other && *this <= other; 102 } 103 bool operator>( Qualifiers other ) const { 104 return *this != other && *this >= other; 105 } 106 Qualifiers operator&=( Type::Qualifiers other ) { 107 val &= other.val; return *this; 108 } 109 Qualifiers operator+=( Qualifiers other ) { 110 val |= other.val; return *this; 111 } 112 Qualifiers operator-=( Qualifiers other ) { 113 val &= ~other.val; return *this; 114 } 115 Qualifiers operator+( Qualifiers other ) const { 116 Qualifiers q = other; 117 q += *this; 118 return q; 119 } 120 CommonBF( NumTypeQualifier ) 121 }; // Qualifiers 122 123 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 124 Type( const Type & other ); 52 125 virtual ~Type(); 53 126 54 Qualifiers & get_qualifiers() { return tq; }127 Qualifiers & get_qualifiers() { return tq; } 55 128 bool get_isConst() { return tq.isConst; } 56 129 bool get_isVolatile() { return tq.isVolatile; } … … 78 151 79 152 virtual Type *clone() const = 0; 80 virtual void accept( Visitor & v ) = 0;81 virtual Type *acceptMutator( Mutator & m ) = 0;82 virtual void print( std::ostream & os, int indent = 0 ) const;153 virtual void accept( Visitor & v ) = 0; 154 virtual Type *acceptMutator( Mutator & m ) = 0; 155 virtual void print( std::ostream & os, int indent = 0 ) const; 83 156 private: 84 157 Qualifiers tq; … … 91 164 class VoidType : public Type { 92 165 public: 93 VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );166 VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 94 167 95 168 virtual unsigned size() const { return 0; }; … … 97 170 98 171 virtual VoidType *clone() const { return new VoidType( *this ); } 99 virtual void accept( Visitor & v ) { v.visit( this ); }100 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }101 virtual void print( std::ostream & os, int indent = 0 ) const;172 virtual void accept( Visitor & v ) { v.visit( this ); } 173 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 174 virtual void print( std::ostream & os, int indent = 0 ) const; 102 175 }; 103 176 … … 131 204 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind 132 205 133 BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );206 BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 134 207 135 208 Kind get_kind() { return kind; } … … 137 210 138 211 virtual BasicType *clone() const { return new BasicType( *this ); } 139 virtual void accept( Visitor & v ) { v.visit( this ); }140 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }141 virtual void print( std::ostream & os, int indent = 0 ) const;212 virtual void accept( Visitor & v ) { v.visit( this ); } 213 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 214 virtual void print( std::ostream & os, int indent = 0 ) const; 142 215 143 216 bool isInteger() const; … … 148 221 class PointerType : public Type { 149 222 public: 150 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );151 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );223 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 224 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 152 225 PointerType( const PointerType& ); 153 226 virtual ~PointerType(); … … 163 236 164 237 virtual PointerType *clone() const { return new PointerType( *this ); } 165 virtual void accept( Visitor & v ) { v.visit( this ); }166 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }167 virtual void print( std::ostream & os, int indent = 0 ) const;238 virtual void accept( Visitor & v ) { v.visit( this ); } 239 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 240 virtual void print( std::ostream & os, int indent = 0 ) const; 168 241 private: 169 242 Type *base; … … 177 250 class ArrayType : public Type { 178 251 public: 179 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );252 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 180 253 ArrayType( const ArrayType& ); 181 254 virtual ~ArrayType(); … … 193 266 194 267 virtual ArrayType *clone() const { return new ArrayType( *this ); } 195 virtual void accept( Visitor & v ) { v.visit( this ); }196 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }197 virtual void print( std::ostream & os, int indent = 0 ) const;268 virtual void accept( Visitor & v ) { v.visit( this ); } 269 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 270 virtual void print( std::ostream & os, int indent = 0 ) const; 198 271 private: 199 272 Type *base; … … 205 278 class FunctionType : public Type { 206 279 public: 207 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );280 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 208 281 FunctionType( const FunctionType& ); 209 282 virtual ~FunctionType(); … … 216 289 217 290 virtual FunctionType *clone() const { return new FunctionType( *this ); } 218 virtual void accept( Visitor & v ) { v.visit( this ); }219 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }220 virtual void print( std::ostream & os, int indent = 0 ) const;291 virtual void accept( Visitor & v ) { v.visit( this ); } 292 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 293 virtual void print( std::ostream & os, int indent = 0 ) const; 221 294 private: 222 295 std::list<DeclarationWithType*> returnVals; … … 232 305 class ReferenceToType : public Type { 233 306 public: 234 ReferenceToType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes );235 ReferenceToType( const ReferenceToType & other );307 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 308 ReferenceToType( const ReferenceToType & other ); 236 309 virtual ~ReferenceToType(); 237 310 238 const std::string & get_name() const { return name; }311 const std::string & get_name() const { return name; } 239 312 void set_name( std::string newValue ) { name = newValue; } 240 313 std::list< Expression* >& get_parameters() { return parameters; } … … 243 316 244 317 virtual ReferenceToType *clone() const = 0; 245 virtual void accept( Visitor & v ) = 0;246 virtual Type *acceptMutator( Mutator & m ) = 0;247 virtual void print( std::ostream & os, int indent = 0 ) const;318 virtual void accept( Visitor & v ) = 0; 319 virtual Type *acceptMutator( Mutator & m ) = 0; 320 virtual void print( std::ostream & os, int indent = 0 ) const; 248 321 protected: 249 322 virtual std::string typeString() const = 0; … … 257 330 typedef ReferenceToType Parent; 258 331 public: 259 StructInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}260 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() );261 StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}332 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 333 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 334 StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {} 262 335 263 336 StructDecl *get_baseStruct() const { return baseStruct; } … … 271 344 /// Looks up the members of this struct named "name" and places them into "foundDecls". 272 345 /// Clones declarations into "foundDecls", caller responsible for freeing 273 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;346 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 274 347 275 348 virtual StructInstType *clone() const { return new StructInstType( *this ); } 276 virtual void accept( Visitor & v ) { v.visit( this ); }277 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }278 279 virtual void print( std::ostream & os, int indent = 0 ) const;349 virtual void accept( Visitor & v ) { v.visit( this ); } 350 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 351 352 virtual void print( std::ostream & os, int indent = 0 ) const; 280 353 private: 281 354 virtual std::string typeString() const; … … 289 362 typedef ReferenceToType Parent; 290 363 public: 291 UnionInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}292 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() );293 UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}364 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 365 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 366 UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {} 294 367 295 368 UnionDecl *get_baseUnion() const { return baseUnion; } … … 303 376 /// looks up the members of this union named "name" and places them into "foundDecls" 304 377 /// Clones declarations into "foundDecls", caller responsible for freeing 305 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;378 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 306 379 307 380 virtual UnionInstType *clone() const { return new UnionInstType( *this ); } 308 virtual void accept( Visitor & v ) { v.visit( this ); }309 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }310 311 virtual void print( std::ostream & os, int indent = 0 ) const;381 virtual void accept( Visitor & v ) { v.visit( this ); } 382 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 383 384 virtual void print( std::ostream & os, int indent = 0 ) const; 312 385 private: 313 386 virtual std::string typeString() const; … … 321 394 typedef ReferenceToType Parent; 322 395 public: 323 EnumInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}324 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() );325 EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}396 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 397 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 398 EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {} 326 399 327 400 EnumDecl *get_baseEnum() const { return baseEnum; } … … 331 404 332 405 virtual EnumInstType *clone() const { return new EnumInstType( *this ); } 333 virtual void accept( Visitor & v ) { v.visit( this ); }334 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }406 virtual void accept( Visitor & v ) { v.visit( this ); } 407 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 335 408 private: 336 409 virtual std::string typeString() const; … … 344 417 typedef ReferenceToType Parent; 345 418 public: 346 TraitInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}347 TraitInstType( const TraitInstType & other );419 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 420 TraitInstType( const TraitInstType & other ); 348 421 ~TraitInstType(); 349 422 … … 353 426 354 427 virtual TraitInstType *clone() const { return new TraitInstType( *this ); } 355 virtual void accept( Visitor & v ) { v.visit( this ); }356 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }428 virtual void accept( Visitor & v ) { v.visit( this ); } 429 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 357 430 private: 358 431 virtual std::string typeString() const; … … 366 439 typedef ReferenceToType Parent; 367 440 public: 368 TypeInstType( const Type::Qualifiers & tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() );369 TypeInstType( const Type::Qualifiers & tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() );370 TypeInstType( const TypeInstType & other );441 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 442 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 443 TypeInstType( const TypeInstType & other ); 371 444 ~TypeInstType(); 372 445 … … 379 452 380 453 virtual TypeInstType *clone() const { return new TypeInstType( *this ); } 381 virtual void accept( Visitor & v ) { v.visit( this ); }382 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }383 virtual void print( std::ostream & os, int indent = 0 ) const;454 virtual void accept( Visitor & v ) { v.visit( this ); } 455 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 456 virtual void print( std::ostream & os, int indent = 0 ) const; 384 457 private: 385 458 virtual std::string typeString() const; … … 392 465 class TupleType : public Type { 393 466 public: 394 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() );467 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 395 468 TupleType( const TupleType& ); 396 469 virtual ~TupleType(); … … 413 486 414 487 virtual TupleType *clone() const { return new TupleType( *this ); } 415 virtual void accept( Visitor & v ) { v.visit( this ); }416 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }417 virtual void print( std::ostream & os, int indent = 0 ) const;488 virtual void accept( Visitor & v ) { v.visit( this ); } 489 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 490 virtual void print( std::ostream & os, int indent = 0 ) const; 418 491 private: 419 492 std::list<Type*> types; … … 422 495 class TypeofType : public Type { 423 496 public: 424 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );497 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 425 498 TypeofType( const TypeofType& ); 426 499 virtual ~TypeofType(); … … 432 505 433 506 virtual TypeofType *clone() const { return new TypeofType( *this ); } 434 virtual void accept( Visitor & v ) { v.visit( this ); }435 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }436 virtual void print( std::ostream & os, int indent = 0 ) const;507 virtual void accept( Visitor & v ) { v.visit( this ); } 508 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 509 virtual void print( std::ostream & os, int indent = 0 ) const; 437 510 private: 438 511 Expression *expr; … … 441 514 class AttrType : public Type { 442 515 public: 443 AttrType( const Type::Qualifiers & tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );444 AttrType( const Type::Qualifiers & tq, const std::string &name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() );516 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 517 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 445 518 AttrType( const AttrType& ); 446 519 virtual ~AttrType(); 447 520 448 const std::string & get_name() const { return name; }449 void set_name( const std::string & newValue ) { name = newValue; }521 const std::string & get_name() const { return name; } 522 void set_name( const std::string & newValue ) { name = newValue; } 450 523 Expression *get_expr() const { return expr; } 451 524 void set_expr( Expression *newValue ) { expr = newValue; } … … 458 531 459 532 virtual AttrType *clone() const { return new AttrType( *this ); } 460 virtual void accept( Visitor & v ) { v.visit( this ); }461 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }462 virtual void print( std::ostream & os, int indent = 0 ) const;533 virtual void accept( Visitor & v ) { v.visit( this ); } 534 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 535 virtual void print( std::ostream & os, int indent = 0 ) const; 463 536 private: 464 537 std::string name; … … 477 550 478 551 virtual VarArgsType *clone() const { return new VarArgsType( *this ); } 479 virtual void accept( Visitor & v ) { v.visit( this ); }480 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }481 virtual void print( std::ostream & os, int indent = 0 ) const;552 virtual void accept( Visitor & v ) { v.visit( this ); } 553 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 554 virtual void print( std::ostream & os, int indent = 0 ) const; 482 555 }; 483 556 … … 489 562 490 563 virtual ZeroType *clone() const { return new ZeroType( *this ); } 491 virtual void accept( Visitor & v ) { v.visit( this ); }492 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }493 virtual void print( std::ostream & os, int indent = 0 ) const;564 virtual void accept( Visitor & v ) { v.visit( this ); } 565 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 566 virtual void print( std::ostream & os, int indent = 0 ) const; 494 567 }; 495 568 … … 501 574 502 575 virtual OneType *clone() const { return new OneType( *this ); } 503 virtual void accept( Visitor &v ) { v.visit( this ); } 504 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 505 virtual void print( std::ostream &os, int indent = 0 ) const; 506 }; 507 508 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) { 509 isConst &= other.isConst; 510 isVolatile &= other.isVolatile; 511 isRestrict &= other.isRestrict; 512 isLvalue &= other.isLvalue; 513 isAtomic &= other.isAtomic; 514 isMutex &= other.isMutex; 515 return *this; 516 } 517 518 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 519 isConst |= other.isConst; 520 isVolatile |= other.isVolatile; 521 isRestrict |= other.isRestrict; 522 isLvalue |= other.isLvalue; 523 isAtomic |= other.isAtomic; 524 isMutex |= other.isMutex; 525 return *this; 526 } 527 528 inline Type::Qualifiers &Type::Qualifiers::operator-=( const Type::Qualifiers &other ) { 529 if ( other.isConst ) isConst = 0; 530 if ( other.isVolatile ) isVolatile = 0; 531 if ( other.isRestrict ) isRestrict = 0; 532 if ( other.isAtomic ) isAtomic = 0; 533 if ( other.isMutex ) isMutex = 0; 534 return *this; 535 } 536 537 inline Type::Qualifiers Type::Qualifiers::operator+( const Type::Qualifiers &other ) { 538 Qualifiers q = other; 539 q += *this; 540 return q; 541 } 542 543 inline bool Type::Qualifiers::operator==( const Qualifiers &other ) { 544 return isConst == other.isConst 545 && isVolatile == other.isVolatile 546 // && isRestrict == other.isRestrict 547 // && isLvalue == other.isLvalue 548 && isAtomic == other.isAtomic; 549 } 550 551 inline bool Type::Qualifiers::operator!=( const Qualifiers &other ) { 552 return isConst != other.isConst 553 || isVolatile != other.isVolatile 554 // || isRestrict != other.isRestrict 555 // || isLvalue != other.isLvalue 556 || isAtomic != other.isAtomic; 557 } 558 559 inline bool Type::Qualifiers::operator<=( const Type::Qualifiers &other ) { 560 return isConst <= other.isConst 561 && isVolatile <= other.isVolatile 562 // && isRestrict <= other.isRestrict 563 // && isLvalue >= other.isLvalue 564 && isAtomic == other.isAtomic; 565 } 566 567 inline bool Type::Qualifiers::operator>=( const Type::Qualifiers &other ) { 568 return isConst >= other.isConst 569 && isVolatile >= other.isVolatile 570 // && isRestrict >= other.isRestrict 571 // && isLvalue <= other.isLvalue 572 && isAtomic == other.isAtomic; 573 } 574 575 inline bool Type::Qualifiers::operator<( const Type::Qualifiers &other ) { 576 return operator!=( other ) && operator<=( other ); 577 } 578 579 inline bool Type::Qualifiers::operator>( const Type::Qualifiers &other ) { 580 return operator!=( other ) && operator>=( other ); 581 } 576 virtual void accept( Visitor & v ) { v.visit( this ); } 577 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 578 virtual void print( std::ostream & os, int indent = 0 ) const; 579 }; 582 580 583 581 std::ostream & operator<<( std::ostream & out, const Type * type ); -
src/SynTree/TypeDecl.cc
r2f26687a r1fbab5a 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 Mar 7 07:39:09201713 // Update Count : 412 // Last Modified On : Thu Mar 16 07:49:58 2017 13 // Update Count : 5 14 14 // 15 15 … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) { 21 21 } 22 22
Note: See TracChangeset
for help on using the changeset viewer.