Changeset 615a096 for src/SynTree
- Timestamp:
- Mar 17, 2017, 9:58:23 AM (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:
- 409433da, 946bcca
- Parents:
- 395fc37
- Location:
- src/SynTree
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SynTree/ArrayType.cc ¶
r395fc37 r615a096 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 -
TabularUnified src/SynTree/Expression.cc ¶
r395fc37 r615a096 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 -
TabularUnified src/SynTree/TupleExpr.cc ¶
r395fc37 r615a096 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 -
TabularUnified src/SynTree/Type.cc ¶
r395fc37 r615a096 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 16:25:49201713 // Update Count : 2 712 // Last Modified On : Fri Mar 17 08:42:47 2017 13 // Update Count : 28 14 14 // 15 15 … … 61 61 62 62 // These must remain in the same order as the corresponding bit fields. 63 const char * Type::FuncSpecifiers ::Names[] = { "inline", "fortran", "_Noreturn" };64 const char * Type::StorageClasses ::Names[] = { "extern", "static", "auto", "register", "_Thread_local" };65 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 66 67 67 Type *Type::stripDeclarator() { -
TabularUnified src/SynTree/Type.h ¶
r395fc37 r615a096 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 17:44:11201713 // Update Count : 1 3512 // Last Modified On : Fri Mar 17 09:04:03 2017 13 // Update Count : 147 14 14 // 15 15 … … 26 26 public: 27 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[]; 28 30 #define BFCommon( BFType, N ) \ 29 31 bool operator[]( unsigned int i ) const { return val & (1 << i); } \ … … 31 33 void reset() { val = 0; } \ 32 34 int ffs() { return ::ffs( val ) - 1; } \ 33 static const char * Names[]; \34 35 BFType operator&=( BFType other ) { \ 35 36 val &= other.val; return *this; \ … … 55 56 for ( unsigned int i = 0; i < N; i += 1 ) { \ 56 57 if ( (*this)[i] ) { \ 57 os << Names[i] << ' '; \58 os << BFType##Names[i] << ' '; \ 58 59 } \ 59 60 } \ … … 64 65 65 66 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 67 static const char * FuncSpecifiersNames[]; 66 68 union FuncSpecifiers { 67 69 unsigned int val; … … 73 75 FuncSpecifiers() : val( 0 ) {} 74 76 FuncSpecifiers( unsigned int val ) : val( val ) {} 75 bool operator==( FuncSpecifiers other ) const { return val == other.val; } 76 bool operator!=( FuncSpecifiers other ) const { return val != other.val; } 77 // equality (==, !=) works implicitly on first field "val", relational operations are undefined. 77 78 BFCommon( FuncSpecifiers, NumFuncSpecifier ) 78 79 }; // FuncSpecifiers 79 80 80 81 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 82 static const char * StorageClassesNames[]; 81 83 union StorageClasses { 82 84 unsigned int val; … … 91 93 StorageClasses() : val( 0 ) {} 92 94 StorageClasses( unsigned int val ) : val( val ) {} 93 bool operator==( StorageClasses other ) const { return val == other.val; } 94 bool operator!=( StorageClasses other ) const { return val != other.val; } 95 // equality (==, !=) works implicitly on first field "val", relational operations are undefined. 95 96 BFCommon( StorageClasses, NumStorageClass ) 96 97 }; // StorageClasses 97 98 98 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[]; 99 101 union Qualifiers { 100 102 enum { Mask = ~(Restrict | Lvalue) }; 101 103 unsigned int val; 102 104 struct { 103 bool is Const : 1;104 bool is Restrict : 1;105 bool is Volatile : 1;106 bool is Lvalue : 1;107 bool is Mutex : 1;108 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; 109 111 }; 110 112 111 113 Qualifiers() : val( 0 ) {} 112 114 Qualifiers( unsigned int val ) : val( val ) {} 113 bool operator==( Qualifiers other ) const { 114 return (val & Mask) == (other.val & Mask); 115 } 116 bool operator!=( Qualifiers other ) const { 117 return (val & Mask) != (other.val & Mask); 118 } 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); } 119 118 bool operator<=( Qualifiers other ) const { 120 return is Const <= other.isConst && isVolatile <= other.isVolatile &&121 is Mutex >= other.isMutex && isAtomic == other.isAtomic;119 return is_const <= other.is_const && is_volatile <= other.is_volatile && 120 is_mutex >= other.is_mutex && is_atomic == other.is_atomic; 122 121 } 123 122 bool operator<( Qualifiers other ) const { return *this != other && *this <= other; } … … 132 131 133 132 Qualifiers & get_qualifiers() { return tq; } 134 bool get_isConst() { return tq.isConst; } 135 bool get_isVolatile() { return tq.isVolatile; } 136 bool get_isRestrict() { return tq.isRestrict; } 137 bool get_isLvalue() { return tq.isLvalue; } 138 bool get_isAtomic() { return tq.isAtomic; } 139 void set_isConst( bool newValue ) { tq.isConst = newValue; } 140 void set_isVolatile( bool newValue ) { tq.isVolatile = newValue; } 141 void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; } 142 void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; } 143 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; } 144 145 145 146 typedef std::list<TypeDecl *> ForallList;
Note: See TracChangeset
for help on using the changeset viewer.