[51b7345] | 1 | #ifndef TYPE_H |
---|
| 2 | #define TYPE_H |
---|
| 3 | |
---|
| 4 | #include "SynTree.h" |
---|
| 5 | #include "Visitor.h" |
---|
| 6 | #include "Mutator.h" |
---|
| 7 | |
---|
| 8 | |
---|
[c8ffe20b] | 9 | class Type { |
---|
| 10 | public: |
---|
| 11 | struct Qualifiers { |
---|
[c11e31c] | 12 | Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {} |
---|
| 13 | Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {} |
---|
[51b7345] | 14 | |
---|
[c8ffe20b] | 15 | Qualifiers &operator+=( const Qualifiers &other ); |
---|
| 16 | Qualifiers &operator-=( const Qualifiers &other ); |
---|
[51b7345] | 17 | Qualifiers operator+( const Type::Qualifiers &other ); |
---|
[c8ffe20b] | 18 | bool operator==( const Qualifiers &other ); |
---|
| 19 | bool operator!=( const Qualifiers &other ); |
---|
[51b7345] | 20 | bool operator<=( const Qualifiers &other ); |
---|
| 21 | bool operator>=( const Qualifiers &other ); |
---|
| 22 | bool operator<( const Qualifiers &other ); |
---|
| 23 | bool operator>( const Qualifiers &other ); |
---|
| 24 | |
---|
| 25 | bool isConst; |
---|
| 26 | bool isVolatile; |
---|
| 27 | bool isRestrict; |
---|
| 28 | bool isLvalue; |
---|
[bdd516a] | 29 | bool isAtomic; |
---|
[c11e31c] | 30 | bool isAttribute; |
---|
[51b7345] | 31 | }; |
---|
| 32 | |
---|
| 33 | Type( const Qualifiers &tq ); |
---|
| 34 | Type( const Type &other ); |
---|
| 35 | virtual ~Type(); |
---|
| 36 | |
---|
| 37 | Qualifiers &get_qualifiers() { return tq; } |
---|
| 38 | bool get_isConst() { return tq.isConst; } |
---|
| 39 | bool get_isVolatile() { return tq.isVolatile; } |
---|
| 40 | bool get_isRestrict() { return tq.isRestrict; } |
---|
| 41 | bool get_isLvalue() { return tq.isLvalue; } |
---|
[bdd516a] | 42 | bool get_isAtomic() { return tq.isAtomic; } |
---|
[c11e31c] | 43 | bool get_isAttribute() { return tq.isAttribute; } |
---|
[51b7345] | 44 | void set_isConst( bool newValue ) { tq.isConst = newValue; } |
---|
| 45 | void set_iisVolatile( bool newValue ) { tq.isVolatile = newValue; } |
---|
| 46 | void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; } |
---|
| 47 | void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; } |
---|
[bdd516a] | 48 | void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; } |
---|
[c11e31c] | 49 | void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; } |
---|
[51b7345] | 50 | std::list<TypeDecl*>& get_forall() { return forall; } |
---|
| 51 | |
---|
| 52 | virtual Type *clone() const = 0; |
---|
| 53 | virtual void accept( Visitor &v ) = 0; |
---|
| 54 | virtual Type *acceptMutator( Mutator &m ) = 0; |
---|
| 55 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 56 | private: |
---|
[51b7345] | 57 | Qualifiers tq; |
---|
| 58 | std::list<TypeDecl*> forall; |
---|
| 59 | }; |
---|
| 60 | |
---|
[c8ffe20b] | 61 | class VoidType : public Type { |
---|
| 62 | public: |
---|
[51b7345] | 63 | VoidType( const Type::Qualifiers &tq ); |
---|
| 64 | |
---|
| 65 | virtual VoidType *clone() const { return new VoidType( *this ); } |
---|
| 66 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 67 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 68 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 69 | }; |
---|
| 70 | |
---|
[c8ffe20b] | 71 | class BasicType : public Type { |
---|
| 72 | public: |
---|
| 73 | enum Kind { |
---|
| 74 | Bool, |
---|
| 75 | Char, |
---|
| 76 | SignedChar, |
---|
| 77 | UnsignedChar, |
---|
| 78 | ShortSignedInt, |
---|
| 79 | ShortUnsignedInt, |
---|
| 80 | SignedInt, |
---|
| 81 | UnsignedInt, |
---|
| 82 | LongSignedInt, |
---|
| 83 | LongUnsignedInt, |
---|
| 84 | LongLongSignedInt, |
---|
| 85 | LongLongUnsignedInt, |
---|
| 86 | Float, |
---|
| 87 | Double, |
---|
| 88 | LongDouble, |
---|
| 89 | FloatComplex, |
---|
| 90 | DoubleComplex, |
---|
| 91 | LongDoubleComplex, |
---|
| 92 | FloatImaginary, |
---|
| 93 | DoubleImaginary, |
---|
| 94 | LongDoubleImaginary, |
---|
| 95 | NUMBER_OF_BASIC_TYPES |
---|
| 96 | }; |
---|
[51b7345] | 97 | |
---|
[17cd4eb] | 98 | static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind |
---|
| 99 | |
---|
[51b7345] | 100 | BasicType( const Type::Qualifiers &tq, Kind bt ); |
---|
| 101 | |
---|
| 102 | Kind get_kind() { return kind; } |
---|
| 103 | void set_kind( Kind newValue ) { kind = newValue; } |
---|
| 104 | |
---|
| 105 | virtual BasicType *clone() const { return new BasicType( *this ); } |
---|
| 106 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 107 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 108 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 109 | |
---|
| 110 | bool isInteger() const; |
---|
[c8ffe20b] | 111 | private: |
---|
[51b7345] | 112 | Kind kind; |
---|
| 113 | }; |
---|
| 114 | |
---|
[c8ffe20b] | 115 | class PointerType : public Type { |
---|
| 116 | public: |
---|
[51b7345] | 117 | PointerType( const Type::Qualifiers &tq, Type *base ); |
---|
| 118 | PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic ); |
---|
| 119 | PointerType( const PointerType& ); |
---|
| 120 | virtual ~PointerType(); |
---|
| 121 | |
---|
| 122 | Type *get_base() { return base; } |
---|
| 123 | void set_base( Type *newValue ) { base = newValue; } |
---|
| 124 | Expression *get_dimension() { return dimension; } |
---|
| 125 | void set_dimension( Expression *newValue ) { dimension = newValue; } |
---|
| 126 | bool get_isVarLen() { return isVarLen; } |
---|
| 127 | void set_isVarLen( bool newValue ) { isVarLen = newValue; } |
---|
| 128 | bool get_isStatic() { return isStatic; } |
---|
| 129 | void set_isStatic( bool newValue ) { isStatic = newValue; } |
---|
| 130 | |
---|
| 131 | virtual PointerType *clone() const { return new PointerType( *this ); } |
---|
| 132 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 133 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 134 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 135 | private: |
---|
[51b7345] | 136 | Type *base; |
---|
| 137 | |
---|
[c8ffe20b] | 138 | // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) |
---|
[51b7345] | 139 | Expression *dimension; |
---|
| 140 | bool isVarLen; |
---|
| 141 | bool isStatic; |
---|
| 142 | }; |
---|
| 143 | |
---|
[c8ffe20b] | 144 | class ArrayType : public Type { |
---|
| 145 | public: |
---|
[51b7345] | 146 | ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic ); |
---|
| 147 | ArrayType( const ArrayType& ); |
---|
| 148 | virtual ~ArrayType(); |
---|
| 149 | |
---|
| 150 | Type *get_base() { return base; } |
---|
| 151 | void set_base( Type *newValue ) { base = newValue; } |
---|
| 152 | Expression *get_dimension() { return dimension; } |
---|
| 153 | void set_dimension( Expression *newValue ) { dimension = newValue; } |
---|
| 154 | bool get_isVarLen() { return isVarLen; } |
---|
| 155 | void set_isVarLen( bool newValue ) { isVarLen = newValue; } |
---|
| 156 | bool get_isStatic() { return isStatic; } |
---|
| 157 | void set_isStatic( bool newValue ) { isStatic = newValue; } |
---|
| 158 | |
---|
| 159 | virtual ArrayType *clone() const { return new ArrayType( *this ); } |
---|
| 160 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 161 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 162 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 163 | private: |
---|
[51b7345] | 164 | Type *base; |
---|
| 165 | Expression *dimension; |
---|
| 166 | bool isVarLen; |
---|
| 167 | bool isStatic; |
---|
| 168 | }; |
---|
| 169 | |
---|
[c8ffe20b] | 170 | class FunctionType : public Type { |
---|
| 171 | public: |
---|
[51b7345] | 172 | FunctionType( const Type::Qualifiers &tq, bool isVarArgs ); |
---|
| 173 | FunctionType( const FunctionType& ); |
---|
| 174 | virtual ~FunctionType(); |
---|
| 175 | |
---|
| 176 | std::list<DeclarationWithType*>& get_returnVals() { return returnVals; } |
---|
| 177 | std::list<DeclarationWithType*>& get_parameters() { return parameters; } |
---|
| 178 | bool get_isVarArgs() { return isVarArgs; } |
---|
| 179 | void set_isVarArgs( bool newValue ) { isVarArgs = newValue; } |
---|
| 180 | |
---|
| 181 | virtual FunctionType *clone() const { return new FunctionType( *this ); } |
---|
| 182 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 183 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 184 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 185 | private: |
---|
[51b7345] | 186 | std::list<DeclarationWithType*> returnVals; |
---|
| 187 | std::list<DeclarationWithType*> parameters; |
---|
| 188 | |
---|
| 189 | // does the function accept a variable number of arguments following the arguments |
---|
| 190 | // specified in the parameters list. This could be because of |
---|
| 191 | // - an ellipsis in a prototype declaration |
---|
| 192 | // - an unprototyped declaration |
---|
| 193 | bool isVarArgs; |
---|
| 194 | }; |
---|
| 195 | |
---|
[c8ffe20b] | 196 | class ReferenceToType : public Type { |
---|
| 197 | public: |
---|
[51b7345] | 198 | ReferenceToType( const Type::Qualifiers &tq, const std::string &name ); |
---|
| 199 | ReferenceToType( const ReferenceToType &other ); |
---|
| 200 | virtual ~ReferenceToType(); |
---|
| 201 | |
---|
| 202 | std::string get_name() const { return name; } |
---|
| 203 | void set_name( std::string newValue ) { name = newValue; } |
---|
| 204 | std::list< Expression* >& get_parameters() { return parameters; } |
---|
| 205 | |
---|
| 206 | virtual ReferenceToType *clone() const = 0; |
---|
| 207 | virtual void accept( Visitor &v ) = 0; |
---|
| 208 | virtual Type *acceptMutator( Mutator &m ) = 0; |
---|
| 209 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 210 | protected: |
---|
[51b7345] | 211 | virtual std::string typeString() const = 0; |
---|
| 212 | std::list< Expression* > parameters; |
---|
[c8ffe20b] | 213 | private: |
---|
[51b7345] | 214 | std::string name; |
---|
| 215 | }; |
---|
| 216 | |
---|
[c8ffe20b] | 217 | class StructInstType : public ReferenceToType { |
---|
[51b7345] | 218 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 219 | public: |
---|
[51b7345] | 220 | StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {} |
---|
| 221 | StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {} |
---|
| 222 | |
---|
| 223 | StructDecl *get_baseStruct() const { return baseStruct; } |
---|
| 224 | void set_baseStruct( StructDecl *newValue ) { baseStruct = newValue; } |
---|
| 225 | |
---|
| 226 | // a utility function |
---|
| 227 | void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const; |
---|
| 228 | |
---|
| 229 | virtual StructInstType *clone() const { return new StructInstType( *this ); } |
---|
| 230 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 231 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 232 | |
---|
[c8ffe20b] | 233 | private: |
---|
[51b7345] | 234 | virtual std::string typeString() const; |
---|
| 235 | |
---|
| 236 | // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, |
---|
| 237 | // where the structure used in this type is actually defined |
---|
| 238 | StructDecl *baseStruct; |
---|
| 239 | }; |
---|
| 240 | |
---|
[c8ffe20b] | 241 | class UnionInstType : public ReferenceToType { |
---|
[51b7345] | 242 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 243 | public: |
---|
[51b7345] | 244 | UnionInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseUnion( 0 ) {} |
---|
| 245 | UnionInstType( const UnionInstType &other ) : Parent( other ), baseUnion( other.baseUnion ) {} |
---|
| 246 | |
---|
| 247 | UnionDecl *get_baseUnion() const { return baseUnion; } |
---|
| 248 | void set_baseUnion( UnionDecl *newValue ) { baseUnion = newValue; } |
---|
| 249 | |
---|
| 250 | // a utility function |
---|
| 251 | void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const; |
---|
| 252 | |
---|
| 253 | virtual UnionInstType *clone() const { return new UnionInstType( *this ); } |
---|
| 254 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 255 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
[c8ffe20b] | 256 | private: |
---|
[51b7345] | 257 | virtual std::string typeString() const; |
---|
| 258 | |
---|
| 259 | // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, |
---|
| 260 | // where the union used in this type is actually defined |
---|
| 261 | UnionDecl *baseUnion; |
---|
| 262 | }; |
---|
| 263 | |
---|
[c8ffe20b] | 264 | class EnumInstType : public ReferenceToType { |
---|
[51b7345] | 265 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 266 | public: |
---|
[51b7345] | 267 | EnumInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {} |
---|
| 268 | EnumInstType( const EnumInstType &other ) : Parent( other ) {} |
---|
| 269 | |
---|
| 270 | virtual EnumInstType *clone() const { return new EnumInstType( *this ); } |
---|
| 271 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 272 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 273 | |
---|
[c8ffe20b] | 274 | private: |
---|
[51b7345] | 275 | virtual std::string typeString() const; |
---|
| 276 | }; |
---|
| 277 | |
---|
[c8ffe20b] | 278 | class ContextInstType : public ReferenceToType { |
---|
[51b7345] | 279 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 280 | public: |
---|
[51b7345] | 281 | ContextInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {} |
---|
| 282 | ContextInstType( const ContextInstType &other ); |
---|
| 283 | ~ContextInstType(); |
---|
| 284 | |
---|
| 285 | std::list< Declaration* >& get_members() { return members; } |
---|
| 286 | |
---|
| 287 | virtual ContextInstType *clone() const { return new ContextInstType( *this ); } |
---|
| 288 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 289 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
[c8ffe20b] | 290 | private: |
---|
[51b7345] | 291 | virtual std::string typeString() const; |
---|
| 292 | |
---|
| 293 | // this member is filled in by the validate pass, which instantiates the members of the correponding |
---|
| 294 | // aggregate with the actual type parameters specified for this use of the context |
---|
| 295 | std::list< Declaration* > members; |
---|
| 296 | }; |
---|
| 297 | |
---|
[c8ffe20b] | 298 | class TypeInstType : public ReferenceToType { |
---|
[51b7345] | 299 | typedef ReferenceToType Parent; |
---|
[c8ffe20b] | 300 | public: |
---|
[51b7345] | 301 | TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType ); |
---|
| 302 | TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype ); |
---|
| 303 | TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {} |
---|
| 304 | |
---|
| 305 | TypeDecl *get_baseType() const { return baseType; } |
---|
| 306 | void set_baseType( TypeDecl *newValue ); |
---|
| 307 | bool get_isFtype() const { return isFtype; } |
---|
| 308 | void set_isFtype( bool newValue ) { isFtype = newValue; } |
---|
| 309 | |
---|
| 310 | virtual TypeInstType *clone() const { return new TypeInstType( *this ); } |
---|
| 311 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 312 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 313 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 314 | private: |
---|
[51b7345] | 315 | virtual std::string typeString() const; |
---|
| 316 | // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree, |
---|
| 317 | // where the type used here is actually defined |
---|
| 318 | TypeDecl *baseType; |
---|
| 319 | bool isFtype; |
---|
| 320 | }; |
---|
| 321 | |
---|
[c8ffe20b] | 322 | class TupleType : public Type { |
---|
| 323 | public: |
---|
[51b7345] | 324 | TupleType( const Type::Qualifiers &tq ); |
---|
| 325 | TupleType( const TupleType& ); |
---|
| 326 | virtual ~TupleType(); |
---|
| 327 | |
---|
| 328 | std::list<Type*>& get_types() { return types; } |
---|
| 329 | |
---|
| 330 | virtual TupleType *clone() const { return new TupleType( *this ); } |
---|
| 331 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 332 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 333 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 334 | private: |
---|
[51b7345] | 335 | std::list<Type*> types; |
---|
| 336 | }; |
---|
| 337 | |
---|
[c8ffe20b] | 338 | class TypeofType : public Type { |
---|
| 339 | public: |
---|
[51b7345] | 340 | TypeofType( const Type::Qualifiers &tq, Expression *expr ); |
---|
| 341 | TypeofType( const TypeofType& ); |
---|
| 342 | virtual ~TypeofType(); |
---|
| 343 | |
---|
| 344 | Expression *get_expr() const { return expr; } |
---|
| 345 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
| 346 | |
---|
| 347 | virtual TypeofType *clone() const { return new TypeofType( *this ); } |
---|
| 348 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 349 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 350 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[c8ffe20b] | 351 | private: |
---|
[51b7345] | 352 | Expression *expr; |
---|
| 353 | }; |
---|
| 354 | |
---|
[c8ffe20b] | 355 | class AttrType : public Type { |
---|
| 356 | public: |
---|
[51b7345] | 357 | AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr ); |
---|
| 358 | AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type ); |
---|
| 359 | AttrType( const AttrType& ); |
---|
| 360 | virtual ~AttrType(); |
---|
| 361 | |
---|
| 362 | std::string get_name() const { return name; } |
---|
| 363 | void set_name( const std::string &newValue ) { name = newValue; } |
---|
| 364 | Expression *get_expr() const { return expr; } |
---|
| 365 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
| 366 | Type *get_type() const { return type; } |
---|
| 367 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 368 | bool get_isType() const { return isType; } |
---|
| 369 | void set_isType( bool newValue ) { isType = newValue; } |
---|
| 370 | |
---|
| 371 | virtual AttrType *clone() const { return new AttrType( *this ); } |
---|
| 372 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 373 | virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 374 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 375 | |
---|
[c8ffe20b] | 376 | private: |
---|
[51b7345] | 377 | std::string name; |
---|
| 378 | Expression *expr; |
---|
| 379 | Type *type; |
---|
| 380 | bool isType; |
---|
| 381 | }; |
---|
| 382 | |
---|
[c8ffe20b] | 383 | inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { |
---|
[51b7345] | 384 | isConst |= other.isConst; |
---|
| 385 | isVolatile |= other.isVolatile; |
---|
| 386 | isRestrict |= other.isRestrict; |
---|
| 387 | isLvalue |= other.isLvalue; |
---|
[bdd516a] | 388 | isAtomic |= other.isAtomic; |
---|
[51b7345] | 389 | return *this; |
---|
| 390 | } |
---|
| 391 | |
---|
[c8ffe20b] | 392 | inline Type::Qualifiers &Type::Qualifiers::operator-=( const Type::Qualifiers &other ) { |
---|
| 393 | if ( other.isConst ) isConst = 0; |
---|
| 394 | if ( other.isVolatile ) isVolatile = 0; |
---|
| 395 | if ( other.isRestrict ) isRestrict = 0; |
---|
[bdd516a] | 396 | if ( other.isAtomic ) isAtomic = 0; |
---|
[51b7345] | 397 | return *this; |
---|
| 398 | } |
---|
| 399 | |
---|
[c8ffe20b] | 400 | inline Type::Qualifiers Type::Qualifiers::operator+( const Type::Qualifiers &other ) { |
---|
[51b7345] | 401 | Qualifiers q = other; |
---|
| 402 | q += *this; |
---|
| 403 | return q; |
---|
| 404 | } |
---|
| 405 | |
---|
[c8ffe20b] | 406 | inline bool Type::Qualifiers::operator==( const Qualifiers &other ) { |
---|
[51b7345] | 407 | return isConst == other.isConst |
---|
[bdd516a] | 408 | && isVolatile == other.isVolatile |
---|
| 409 | && isRestrict == other.isRestrict |
---|
| 410 | // && isLvalue == other.isLvalue |
---|
| 411 | && isAtomic == other.isAtomic; |
---|
[51b7345] | 412 | } |
---|
| 413 | |
---|
[c8ffe20b] | 414 | inline bool Type::Qualifiers::operator!=( const Qualifiers &other ) { |
---|
[51b7345] | 415 | return isConst != other.isConst |
---|
| 416 | || isVolatile != other.isVolatile |
---|
[bdd516a] | 417 | || isRestrict != other.isRestrict |
---|
| 418 | // || isLvalue != other.isLvalue |
---|
| 419 | || isAtomic != other.isAtomic; |
---|
[51b7345] | 420 | } |
---|
| 421 | |
---|
[c8ffe20b] | 422 | inline bool Type::Qualifiers::operator<=( const Type::Qualifiers &other ) { |
---|
[51b7345] | 423 | return isConst <= other.isConst |
---|
| 424 | && isVolatile <= other.isVolatile |
---|
[bdd516a] | 425 | && isRestrict <= other.isRestrict |
---|
| 426 | // && isLvalue >= other.isLvalue |
---|
| 427 | && isAtomic == other.isAtomic; |
---|
[51b7345] | 428 | } |
---|
| 429 | |
---|
[c8ffe20b] | 430 | inline bool Type::Qualifiers::operator>=( const Type::Qualifiers &other ) { |
---|
[51b7345] | 431 | return isConst >= other.isConst |
---|
| 432 | && isVolatile >= other.isVolatile |
---|
[bdd516a] | 433 | && isRestrict >= other.isRestrict |
---|
| 434 | // && isLvalue <= other.isLvalue |
---|
| 435 | && isAtomic == other.isAtomic; |
---|
[51b7345] | 436 | } |
---|
| 437 | |
---|
[c8ffe20b] | 438 | inline bool Type::Qualifiers::operator<( const Type::Qualifiers &other ) { |
---|
[51b7345] | 439 | return operator!=( other ) && operator<=( other ); |
---|
| 440 | } |
---|
| 441 | |
---|
[c8ffe20b] | 442 | inline bool Type::Qualifiers::operator>( const Type::Qualifiers &other ) { |
---|
[51b7345] | 443 | return operator!=( other ) && operator>=( other ); |
---|
| 444 | } |
---|
| 445 | |
---|
[c8ffe20b] | 446 | #endif // TYPE_H |
---|