Changeset 946bcca for src/SynTree
- Timestamp:
- Mar 17, 2017, 1:14:44 PM (7 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:
- 14a33790, 7c70089, 89d129c
- Parents:
- b2f5082 (diff), 615a096 (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:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/ArrayType.cc
rb2f5082 r946bcca 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 1 17:16:29201713 // Update Count : 1 212 // Last Modified On : Fri Mar 17 09:40:30 2017 13 // Update Count : 13 14 14 // 15 15 … … 21 21 ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes ) 22 22 : Type( tq, attributes ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic ) { 23 base->set_ isLvalue( false );23 base->set_lvalue( false ); 24 24 } 25 25 -
src/SynTree/Expression.cc
rb2f5082 r946bcca 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 5 14:23:56 201613 // Update Count : 4912 // Last Modified On : Fri Mar 17 09:42:04 2017 13 // Update Count : 51 14 14 // 15 15 … … 77 77 assert( var->get_type() ); 78 78 Type * type = var->get_type()->clone(); 79 type->set_ isLvalue( true );79 type->set_lvalue( true ); 80 80 set_result( type ); 81 81 } … … 352 352 sub.apply( res ); 353 353 set_result( res ); 354 get_result()->set_ isLvalue( true );354 get_result()->set_lvalue( true ); 355 355 } 356 356 -
src/SynTree/TupleExpr.cc
rb2f5082 r946bcca 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:59:19 201513 // Update Count : 112 // Last Modified On : Fri Mar 17 09:42:29 2017 13 // Update Count : 3 14 14 // 15 15 … … 60 60 assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested index %d in expr %s", type->size(), index, toString( tuple ).c_str() ); 61 61 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 62 get_result()->set_ isLvalue( type->get_isLvalue() );62 get_result()->set_lvalue( type->get_lvalue() ); 63 63 } 64 64 -
src/SynTree/Type.cc
rb2f5082 r946bcca 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 10:25:06201713 // Update Count : 2 312 // Last Modified On : Fri Mar 17 08:42:47 2017 13 // Update Count : 28 14 14 // 15 15 … … 19 19 #include "Declaration.h" 20 20 #include "Attribute.h" 21 #include "InitTweak/InitTweak.h" 21 22 #include "Common/utility.h" 22 23 … … 60 61 61 62 // 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" }; 63 const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" }; 64 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" }; 65 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 66 67 Type *Type::stripDeclarator() { 68 Type * type = this; 69 while ( Type * at = InitTweak::getPointerBase( type ) ) { 70 type = at; 71 } 72 return type; 73 } 65 74 66 75 void Type::print( std::ostream &os, int indent ) const { -
src/SynTree/Type.h
rb2f5082 r946bcca 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 12:11:50201713 // Update Count : 1 1612 // Last Modified On : Fri Mar 17 09:04:03 2017 13 // Update Count : 147 14 14 // 15 15 … … 21 21 #include "SynTree.h" 22 22 #include "Visitor.h" 23 #include <strings.h> // ffs 23 24 24 25 class Type : public BaseSyntaxNode { 25 26 public: 26 #define CommonBF( N ) \ 27 // Simulate inheritance because union does not allow it. 28 // Bug in g++-4.9 prevents static field in union 29 //static const char * Names[]; 30 #define BFCommon( BFType, N ) \ 27 31 bool operator[]( unsigned int i ) const { return val & (1 << i); } \ 28 32 bool any() const { return val != 0; } \ 29 static const char * Names[]; \ 33 void reset() { val = 0; } \ 34 int ffs() { return ::ffs( val ) - 1; } \ 35 BFType operator&=( BFType other ) { \ 36 val &= other.val; return *this; \ 37 } \ 38 BFType operator&( BFType other ) const { \ 39 BFType q = other; \ 40 q &= *this; \ 41 return q; \ 42 } \ 43 BFType operator|=( BFType other ) { \ 44 val |= other.val; return *this; \ 45 } \ 46 BFType operator|( BFType other ) const { \ 47 BFType q = other; \ 48 q |= *this; \ 49 return q; \ 50 } \ 51 BFType operator-=( BFType other ) { \ 52 val &= ~other.val; return *this; \ 53 } \ 30 54 void print( std::ostream & os ) const { \ 31 55 if ( (*this).any() ) { \ 32 56 for ( unsigned int i = 0; i < N; i += 1 ) { \ 33 57 if ( (*this)[i] ) { \ 34 os << Names[i] << ' '; \58 os << BFType##Names[i] << ' '; \ 35 59 } \ 36 60 } \ … … 41 65 42 66 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 67 static const char * FuncSpecifiersNames[]; 43 68 union FuncSpecifiers { 44 69 unsigned int val; … … 50 75 FuncSpecifiers() : val( 0 ) {} 51 76 FuncSpecifiers( unsigned int val ) : val( val ) {} 52 CommonBF( NumFuncSpecifier ) 77 // equality (==, !=) works implicitly on first field "val", relational operations are undefined. 78 BFCommon( FuncSpecifiers, NumFuncSpecifier ) 53 79 }; // FuncSpecifiers 54 80 55 81 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 82 static const char * StorageClassesNames[]; 56 83 union StorageClasses { 57 84 unsigned int val; … … 66 93 StorageClasses() : val( 0 ) {} 67 94 StorageClasses( unsigned int val ) : val( val ) {} 68 CommonBF( NumStorageClass ) 95 // equality (==, !=) works implicitly on first field "val", relational operations are undefined. 96 BFCommon( StorageClasses, NumStorageClass ) 69 97 }; // StorageClasses 70 98 71 99 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 100 static const char * QualifiersNames[]; 72 101 union Qualifiers { 73 102 enum { Mask = ~(Restrict | Lvalue) }; 74 103 unsigned int val; 75 104 struct { 76 bool is Const : 1;77 bool is Restrict : 1;78 bool is Volatile : 1;79 bool is Lvalue : 1;80 bool is Mutex : 1;81 bool is Atomic : 1;105 bool is_const : 1; 106 bool is_restrict : 1; 107 bool is_volatile : 1; 108 bool is_lvalue : 1; 109 bool is_mutex : 1; 110 bool is_atomic : 1; 82 111 }; 83 112 84 113 Qualifiers() : val( 0 ) {} 85 114 Qualifiers( unsigned int val ) : val( val ) {} 86 bool operator==( Qualifiers other ) const { 87 return (val & Mask) == (other.val & Mask); 115 // Complex comparisons provide implicit qualifier downcasting, e.g., T downcast to const T. 116 bool operator==( Qualifiers other ) const { return (val & Mask) == (other.val & Mask); } 117 bool operator!=( Qualifiers other ) const { return (val & Mask) != (other.val & Mask); } 118 bool operator<=( Qualifiers other ) const { 119 return is_const <= other.is_const && is_volatile <= other.is_volatile && 120 is_mutex >= other.is_mutex && is_atomic == other.is_atomic; 88 121 } 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 ) 122 bool operator<( Qualifiers other ) const { return *this != other && *this <= other; } 123 bool operator>=( Qualifiers other ) const { return ! (*this < other); } 124 bool operator>( Qualifiers other ) const { return *this != other && *this >= other; } 125 BFCommon( Qualifiers, NumTypeQualifier ) 121 126 }; // Qualifiers 122 127 … … 126 131 127 132 Qualifiers & get_qualifiers() { return tq; } 128 bool get_isConst() { return tq.isConst; } 129 bool get_isVolatile() { return tq.isVolatile; } 130 bool get_isRestrict() { return tq.isRestrict; } 131 bool get_isLvalue() { return tq.isLvalue; } 132 bool get_isAtomic() { return tq.isAtomic; } 133 void set_isConst( bool newValue ) { tq.isConst = newValue; } 134 void set_isVolatile( bool newValue ) { tq.isVolatile = newValue; } 135 void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; } 136 void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; } 137 void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; } 133 bool get_const() { return tq.is_const; } 134 bool get_volatile() { return tq.is_volatile; } 135 bool get_restrict() { return tq.is_restrict; } 136 bool get_lvalue() { return tq.is_lvalue; } 137 bool get_mutex() { return tq.is_mutex; } 138 bool get_atomic() { return tq.is_atomic; } 139 void set_const( bool newValue ) { tq.is_const = newValue; } 140 void set_volatile( bool newValue ) { tq.is_volatile = newValue; } 141 void set_restrict( bool newValue ) { tq.is_restrict = newValue; } 142 void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; } 143 void set_mutex( bool newValue ) { tq.is_mutex = newValue; } 144 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } 138 145 139 146 typedef std::list<TypeDecl *> ForallList; … … 147 154 virtual bool isVoid() const { return size() == 0; } 148 155 virtual Type * getComponent( unsigned i ) { assertf( size() == 1 && i == 0, "Type::getComponent was called with size %d and index %d\n", size(), i ); return this; } 156 157 Type *stripDeclarator(); 149 158 150 159 virtual bool isComplete() const { return true; } -
src/SynTree/TypeSubstitution.cc
rb2f5082 r946bcca 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 : T ue Apr 26 11:15:29 201613 // Update Count : 311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 15:54:35 2017 13 // Update Count : 4 14 14 // 15 15 … … 127 127 subCount++; 128 128 Type *newtype = i->second->clone(); 129 newtype->get_qualifiers() += inst->get_qualifiers();129 newtype->get_qualifiers() |= inst->get_qualifiers(); 130 130 delete inst; 131 131 return newtype;
Note: See TracChangeset
for help on using the changeset viewer.