Changeset 6f95000 for src/SynTree
- Timestamp:
- Mar 16, 2017, 6:14:27 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
- Parents:
- d6d747d
- Location:
- src/SynTree
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SynTree/Type.cc ¶
rd6d747d r6f95000 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 1 0:25:06201713 // Update Count : 2 312 // Last Modified On : Thu Mar 16 16:25:49 2017 13 // Update Count : 27 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 … … 64 65 const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 65 66 67 Type *Type::stripDeclarator() { 68 Type * type = this; 69 while ( Type * at = InitTweak::getPointerBase( type ) ) { 70 type = at; 71 } 72 return type; 73 } 74 66 75 void Type::print( std::ostream &os, int indent ) const { 67 76 if ( ! forall.empty() ) { -
TabularUnified src/SynTree/Type.h ¶
rd6d747d r6f95000 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 1 2:11:50201713 // Update Count : 1 1612 // Last Modified On : Thu Mar 16 17:44:11 2017 13 // Update Count : 135 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 #define BFCommon( BFType, N ) \ 27 29 bool operator[]( unsigned int i ) const { return val & (1 << i); } \ 28 30 bool any() const { return val != 0; } \ 31 void reset() { val = 0; } \ 32 int ffs() { return ::ffs( val ) - 1; } \ 29 33 static const char * Names[]; \ 34 BFType operator&=( BFType other ) { \ 35 val &= other.val; return *this; \ 36 } \ 37 BFType operator&( BFType other ) const { \ 38 BFType q = other; \ 39 q &= *this; \ 40 return q; \ 41 } \ 42 BFType operator|=( BFType other ) { \ 43 val |= other.val; return *this; \ 44 } \ 45 BFType operator|( BFType other ) const { \ 46 BFType q = other; \ 47 q |= *this; \ 48 return q; \ 49 } \ 50 BFType operator-=( BFType other ) { \ 51 val &= ~other.val; return *this; \ 52 } \ 30 53 void print( std::ostream & os ) const { \ 31 54 if ( (*this).any() ) { \ … … 50 73 FuncSpecifiers() : val( 0 ) {} 51 74 FuncSpecifiers( unsigned int val ) : val( val ) {} 52 CommonBF( NumFuncSpecifier ) 75 bool operator==( FuncSpecifiers other ) const { return val == other.val; } 76 bool operator!=( FuncSpecifiers other ) const { return val != other.val; } 77 BFCommon( FuncSpecifiers, NumFuncSpecifier ) 53 78 }; // FuncSpecifiers 54 79 … … 66 91 StorageClasses() : val( 0 ) {} 67 92 StorageClasses( unsigned int val ) : val( val ) {} 68 CommonBF( NumStorageClass ) 93 bool operator==( StorageClasses other ) const { return val == other.val; } 94 bool operator!=( StorageClasses other ) const { return val != other.val; } 95 BFCommon( StorageClasses, NumStorageClass ) 69 96 }; // StorageClasses 70 97 … … 92 119 bool operator<=( Qualifiers other ) const { 93 120 return isConst <= other.isConst && isVolatile <= other.isVolatile && 94 isMutex == other.isMutex && isAtomic == other.isAtomic;121 isMutex >= other.isMutex && isAtomic == other.isAtomic; 95 122 } 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 ) 123 bool operator<( Qualifiers other ) const { return *this != other && *this <= other; } 124 bool operator>=( Qualifiers other ) const { return ! (*this < other); } 125 bool operator>( Qualifiers other ) const { return *this != other && *this >= other; } 126 BFCommon( Qualifiers, NumTypeQualifier ) 121 127 }; // Qualifiers 122 128 … … 147 153 virtual bool isVoid() const { return size() == 0; } 148 154 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; } 155 156 Type *stripDeclarator(); 149 157 150 158 virtual bool isComplete() const { return true; } -
TabularUnified src/SynTree/TypeSubstitution.cc ¶
rd6d747d r6f95000 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.