Changeset c0aa336 for src/SynTree/Type.h
- Timestamp:
- Feb 6, 2017, 4:19:41 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:
- b4d65c7
- Parents:
- a362f97
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Type.h
ra362f97 rc0aa336 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 13 11:46:54 201613 // Update Count : 2312 // Last Modified On : Thu Feb 2 17:43:01 2017 13 // Update Count : 33 14 14 // 15 15 … … 25 25 public: 26 26 struct Qualifiers { 27 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) , isAttribute( false ){}28 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) {}27 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {} 28 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {} 29 29 30 30 Qualifiers &operator&=( const Qualifiers &other ); … … 45 45 bool isLvalue; 46 46 bool isAtomic; 47 bool isAttribute;48 47 }; 49 48 50 Type( const Qualifiers &tq );49 Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ); 51 50 Type( const Type &other ); 52 51 virtual ~Type(); … … 58 57 bool get_isLvalue() { return tq.isLvalue; } 59 58 bool get_isAtomic() { return tq.isAtomic; } 60 bool get_isAttribute() { return tq.isAttribute; }61 59 void set_isConst( bool newValue ) { tq.isConst = newValue; } 62 60 void set_isVolatile( bool newValue ) { tq.isVolatile = newValue; } … … 64 62 void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; } 65 63 void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; } 66 void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }67 64 68 65 typedef std::list<TypeDecl *> ForallList; 69 66 ForallList& get_forall() { return forall; } 67 68 std::list< Attribute * >& get_attributes() { return attributes; } 69 const std::list< Attribute * >& get_attributes() const { return attributes; } 70 70 71 71 /// How many elemental types are represented by this type … … 83 83 Qualifiers tq; 84 84 ForallList forall; 85 std::list< Attribute * > attributes; 85 86 }; 86 87 … … 89 90 class VoidType : public Type { 90 91 public: 91 VoidType( const Type::Qualifiers &tq );92 VoidType( const Type::Qualifiers &tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 92 93 93 94 virtual unsigned size() const { return 0; }; … … 129 130 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind 130 131 131 BasicType( const Type::Qualifiers &tq, Kind bt );132 BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 132 133 133 134 Kind get_kind() { return kind; } … … 146 147 class PointerType : public Type { 147 148 public: 148 PointerType( const Type::Qualifiers &tq, Type *base );149 PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );149 PointerType( const Type::Qualifiers &tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 150 PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 150 151 PointerType( const PointerType& ); 151 152 virtual ~PointerType(); … … 175 176 class ArrayType : public Type { 176 177 public: 177 ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );178 ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 178 179 ArrayType( const ArrayType& ); 179 180 virtual ~ArrayType(); … … 203 204 class FunctionType : public Type { 204 205 public: 205 FunctionType( const Type::Qualifiers &tq, bool isVarArgs );206 FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 206 207 FunctionType( const FunctionType& ); 207 208 virtual ~FunctionType(); … … 231 232 class ReferenceToType : public Type { 232 233 public: 233 ReferenceToType( const Type::Qualifiers &tq, const std::string &name );234 ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes ); 234 235 ReferenceToType( const ReferenceToType &other ); 235 236 virtual ~ReferenceToType(); … … 253 254 typedef ReferenceToType Parent; 254 255 public: 255 StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name), baseStruct( 0 ) {}256 StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct );256 StructInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 257 StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 257 258 StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {} 258 259 … … 285 286 typedef ReferenceToType Parent; 286 287 public: 287 UnionInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseUnion( 0 ) {} 288 UnionInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 289 UnionInstType( const Type::Qualifiers &tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 288 290 UnionInstType( const UnionInstType &other ) : Parent( other ), baseUnion( other.baseUnion ) {} 289 291 290 292 UnionDecl *get_baseUnion() const { return baseUnion; } 291 void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }293 void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; } 292 294 293 295 /// Accesses generic parameters of base union (NULL if none such) 294 std::list< TypeDecl*> * get_baseParameters();296 std::list< TypeDecl * > * get_baseParameters(); 295 297 296 298 virtual bool isComplete() const; … … 316 318 typedef ReferenceToType Parent; 317 319 public: 318 EnumInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {} 319 EnumInstType( const EnumInstType &other ) : Parent( other ) {} 320 321 // xxx - enum inst does not currently contain a pointer to base, this should be fixed. 322 // virtual bool isComplete() const { return baseEnum()->hasBody(); } 320 EnumInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 321 EnumInstType( const Type::Qualifiers &tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 322 EnumInstType( const EnumInstType &other ) : Parent( other ), baseEnum( other.baseEnum ) {} 323 324 EnumDecl *get_baseEnum() const { return baseEnum; } 325 void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; } 326 327 virtual bool isComplete() const; 323 328 324 329 virtual EnumInstType *clone() const { return new EnumInstType( *this ); } … … 327 332 private: 328 333 virtual std::string typeString() const; 334 335 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 336 // where the union used in this type is actually defined 337 EnumDecl *baseEnum = nullptr; 329 338 }; 330 339 … … 332 341 typedef ReferenceToType Parent; 333 342 public: 334 TraitInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name) {}343 TraitInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 335 344 TraitInstType( const TraitInstType &other ); 336 345 ~TraitInstType(); … … 354 363 typedef ReferenceToType Parent; 355 364 public: 356 TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType );357 TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype );365 TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 366 TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 358 367 TypeInstType( const TypeInstType &other ); 359 368 ~TypeInstType(); … … 380 389 class TupleType : public Type { 381 390 public: 382 TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >() );391 TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 383 392 TupleType( const TupleType& ); 384 393 virtual ~TupleType(); … … 410 419 class TypeofType : public Type { 411 420 public: 412 TypeofType( const Type::Qualifiers &tq, Expression *expr );421 TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 413 422 TypeofType( const TypeofType& ); 414 423 virtual ~TypeofType(); … … 429 438 class AttrType : public Type { 430 439 public: 431 AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr );432 AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type );440 AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 441 AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 433 442 AttrType( const AttrType& ); 434 443 virtual ~AttrType(); … … 460 469 public: 461 470 VarArgsType(); 462 VarArgsType( Type::Qualifiers tq );471 VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 463 472 464 473 virtual bool isComplete() const{ return true; } // xxx - is this right? … … 474 483 public: 475 484 ZeroType(); 476 ZeroType( Type::Qualifiers tq );485 ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 477 486 478 487 virtual ZeroType *clone() const { return new ZeroType( *this ); } … … 486 495 public: 487 496 OneType(); 488 OneType( Type::Qualifiers tq );497 OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 489 498 490 499 virtual OneType *clone() const { return new OneType( *this ); }
Note: See TracChangeset
for help on using the changeset viewer.