Changeset d6d747d for src/SynTree
- Timestamp:
- Mar 16, 2017, 12:17:46 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:
- 1fbab5a, 6f95000
- Parents:
- fb04321
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SynTree/Type.cc ¶
rfb04321 rd6d747d 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 08:32:44201713 // Update Count : 2 212 // Last Modified On : Thu Mar 16 10:25:06 2017 13 // Update Count : 23 14 14 // 15 15 … … 76 76 } // if 77 77 78 tq.print( os , indent);78 tq.print( os ); 79 79 } 80 80 -
TabularUnified src/SynTree/Type.h ¶
rfb04321 rd6d747d 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 08:28:02201713 // Update Count : 9112 // 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 #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 26 40 // enum must remain in the same order as the corresponding bit fields. 27 41 28 42 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 29 43 union FuncSpecifiers { 30 static const char * Names[];31 44 unsigned int val; 32 45 struct { … … 37 50 FuncSpecifiers() : val( 0 ) {} 38 51 FuncSpecifiers( unsigned int val ) : val( val ) {} 39 bool operator[]( unsigned int i ) const { return val & (1 << i); } 40 bool any() const { return val != 0; } 41 void print( std::ostream & os ) const { 42 if ( (*this).any() ) { // any function specifiers ? 43 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) { 44 if ( (*this)[i] ) { 45 os << FuncSpecifiers::Names[i] << ' '; 46 } // if 47 } // for 48 } // if 49 } 52 CommonBF( NumFuncSpecifier ) 50 53 }; // FuncSpecifiers 51 54 52 55 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 53 56 union StorageClasses { 54 static const char * Names[];55 57 unsigned int val; 56 58 struct { … … 64 66 StorageClasses() : val( 0 ) {} 65 67 StorageClasses( unsigned int val ) : val( val ) {} 66 bool operator[]( unsigned int i ) const { return val & (1 << i); } 67 bool any() const { return val != 0; } 68 void print( std::ostream & os ) const { 69 if ( (*this).any() ) { // any storage classes ? 70 for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { 71 if ( (*this)[i] ) { 72 os << StorageClasses::Names[i] << ' '; 73 } // if 74 } // for 75 } // if 76 } 68 CommonBF( NumStorageClass ) 77 69 }; // StorageClasses 78 70 79 71 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 80 72 union Qualifiers { 81 static const char * Names[];82 73 enum { Mask = ~(Restrict | Lvalue) }; 83 74 unsigned int val; … … 93 84 Qualifiers() : val( 0 ) {} 94 85 Qualifiers( unsigned int val ) : val( val ) {} 95 bool operator[]( unsigned int i ) const { return val & (1 << i); } 96 bool any() const { return val != 0; } 97 bool operator==( const Qualifiers other ) const { 86 bool operator==( Qualifiers other ) const { 98 87 return (val & Mask) == (other.val & Mask); 99 88 } 100 bool operator!=( constQualifiers other ) const {89 bool operator!=( Qualifiers other ) const { 101 90 return (val & Mask) != (other.val & Mask); 102 91 } 103 bool operator<=( constQualifiers other ) const {92 bool operator<=( Qualifiers other ) const { 104 93 return isConst <= other.isConst && isVolatile <= other.isVolatile && 105 94 isMutex == other.isMutex && isAtomic == other.isAtomic; 106 95 } 107 bool operator>=( constQualifiers other ) const {96 bool operator>=( Qualifiers other ) const { 108 97 return isConst >= other.isConst && isVolatile >= other.isVolatile && 109 98 isMutex == other.isMutex && isAtomic == other.isAtomic; 110 99 } 111 bool operator<( constQualifiers other ) const {100 bool operator<( Qualifiers other ) const { 112 101 return *this != other && *this <= other; 113 102 } 114 bool operator>( constQualifiers other ) const {103 bool operator>( Qualifiers other ) const { 115 104 return *this != other && *this >= other; 116 105 } 117 Qualifiers operator&=( constType::Qualifiers other ) {106 Qualifiers operator&=( Type::Qualifiers other ) { 118 107 val &= other.val; return *this; 119 108 } 120 Qualifiers operator+=( constQualifiers other ) {109 Qualifiers operator+=( Qualifiers other ) { 121 110 val |= other.val; return *this; 122 111 } 123 Qualifiers operator-=( constQualifiers other ) {112 Qualifiers operator-=( Qualifiers other ) { 124 113 val &= ~other.val; return *this; 125 114 } 126 Qualifiers operator+( constQualifiers other ) const {115 Qualifiers operator+( Qualifiers other ) const { 127 116 Qualifiers q = other; 128 117 q += *this; 129 118 return q; 130 119 } 131 void print( std::ostream & os, int indent = 0 ) const { 132 if ( (*this).any() ) { // any type qualifiers ? 133 for ( unsigned int i = 0; i < NumTypeQualifier; i += 1 ) { 134 if ( (*this)[i] ) { 135 os << Names[i] << ' '; 136 } // if 137 } // for 138 } // if 139 } 120 CommonBF( NumTypeQualifier ) 140 121 }; // Qualifiers 141 122
Note: See TracChangeset
for help on using the changeset viewer.