Changeset 65cdc1e for src/SynTree/Type.h
- Timestamp:
- Aug 9, 2017, 3:21:58 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:
- 0ec9229
- Parents:
- cbce272
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Type.h
rcbce272 r65cdc1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Jul 22 09:53:29201713 // Update Count : 15 111 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:25:00 2017 13 // Update Count : 152 14 14 // 15 15 … … 127 127 }; // Qualifiers 128 128 129 typedef std::list<TypeDecl *> ForallList; 130 131 Qualifiers tq; 132 ForallList forall; 133 std::list< Attribute * > attributes; 134 129 135 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 130 136 Type( const Type & other ); … … 145 151 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } 146 152 147 typedef std::list<TypeDecl *> ForallList;148 153 ForallList& get_forall() { return forall; } 149 154 … … 165 170 virtual Type *acceptMutator( Mutator & m ) = 0; 166 171 virtual void print( std::ostream & os, int indent = 0 ) const; 167 private: 168 Qualifiers tq; 169 ForallList forall; 170 std::list< Attribute * > attributes; 171 }; 172 173 extern Type::Qualifiers noQualifiers; // no qualifiers on constants 172 }; 173 174 extern const Type::FuncSpecifiers noFuncSpecifiers; 175 extern const Type::StorageClasses noStorageClasses; 176 extern const Type::Qualifiers noQualifiers; // no qualifiers on constants 174 177 175 178 class VoidType : public Type { … … 211 214 LongDoubleImaginary, 212 215 NUMBER_OF_BASIC_TYPES 213 } ;216 } kind; 214 217 215 218 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind … … 226 229 227 230 bool isInteger() const; 228 private:229 Kind kind;230 231 }; 231 232 232 233 class PointerType : public Type { 233 234 public: 235 Type *base; 236 237 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) 238 Expression *dimension; 239 bool isVarLen; 240 bool isStatic; 241 234 242 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 235 243 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 252 260 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 253 261 virtual void print( std::ostream & os, int indent = 0 ) const; 254 private: 262 }; 263 264 class ArrayType : public Type { 265 public: 255 266 Type *base; 256 257 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )258 267 Expression *dimension; 259 268 bool isVarLen; 260 269 bool isStatic; 261 }; 262 263 class ArrayType : public Type { 264 public: 270 265 271 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 266 272 ArrayType( const ArrayType& ); … … 282 288 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 283 289 virtual void print( std::ostream & os, int indent = 0 ) const; 284 private:285 Type *base;286 Expression *dimension;287 bool isVarLen;288 bool isStatic;289 290 }; 290 291 291 292 class FunctionType : public Type { 292 293 public: 294 std::list<DeclarationWithType*> returnVals; 295 std::list<DeclarationWithType*> parameters; 296 297 // Does the function accept a variable number of arguments following the arguments specified in the parameters list. 298 // This could be because of 299 // - an ellipsis in a prototype declaration 300 // - an unprototyped declaration 301 bool isVarArgs; 302 293 303 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 294 304 FunctionType( const FunctionType& ); … … 305 315 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 306 316 virtual void print( std::ostream & os, int indent = 0 ) const; 307 private:308 std::list<DeclarationWithType*> returnVals;309 std::list<DeclarationWithType*> parameters;310 311 // Does the function accept a variable number of arguments following the arguments specified in the parameters list.312 // This could be because of313 // - an ellipsis in a prototype declaration314 // - an unprototyped declaration315 bool isVarArgs;316 317 }; 317 318 318 319 class ReferenceToType : public Type { 319 320 public: 321 std::list< Expression* > parameters; 322 std::string name; 323 bool hoistType; 324 320 325 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 321 326 ReferenceToType( const ReferenceToType & other ); … … 336 341 protected: 337 342 virtual std::string typeString() const = 0; 338 std::list< Expression* > parameters;339 std::string name;340 private:341 bool hoistType;342 343 }; 343 344 … … 345 346 typedef ReferenceToType Parent; 346 347 public: 348 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, 349 // where the structure used in this type is actually defined 350 StructDecl *baseStruct; 351 347 352 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 348 353 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 368 373 private: 369 374 virtual std::string typeString() const; 370 371 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,372 // where the structure used in this type is actually defined373 StructDecl *baseStruct;374 375 }; 375 376 … … 377 378 typedef ReferenceToType Parent; 378 379 public: 380 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 381 // where the union used in this type is actually defined 382 UnionDecl *baseUnion; 383 379 384 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 380 385 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 400 405 private: 401 406 virtual std::string typeString() const; 402 407 }; 408 409 class EnumInstType : public ReferenceToType { 410 typedef ReferenceToType Parent; 411 public: 403 412 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 404 413 // where the union used in this type is actually defined 405 UnionDecl *baseUnion; 406 }; 407 408 class EnumInstType : public ReferenceToType { 409 typedef ReferenceToType Parent; 410 public: 414 EnumDecl *baseEnum = nullptr; 415 411 416 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 412 417 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 423 428 private: 424 429 virtual std::string typeString() const; 425 426 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,427 // where the union used in this type is actually defined428 EnumDecl *baseEnum = nullptr;429 430 }; 430 431 … … 432 433 typedef ReferenceToType Parent; 433 434 public: 435 // this member is filled in by the validate pass, which instantiates the members of the correponding 436 // aggregate with the actual type parameters specified for this use of the context 437 std::list< Declaration* > members; 438 434 439 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 435 440 TraitInstType( const TraitInstType & other ); … … 445 450 private: 446 451 virtual std::string typeString() const; 447 448 // this member is filled in by the validate pass, which instantiates the members of the correponding449 // aggregate with the actual type parameters specified for this use of the context450 std::list< Declaration* > members;451 452 }; 452 453 … … 454 455 typedef ReferenceToType Parent; 455 456 public: 457 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree, 458 // where the type used here is actually defined 459 TypeDecl *baseType; 460 bool isFtype; 461 456 462 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 457 463 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 472 478 private: 473 479 virtual std::string typeString() const; 474 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,475 // where the type used here is actually defined476 TypeDecl *baseType;477 bool isFtype;478 480 }; 479 481 480 482 class TupleType : public Type { 481 483 public: 484 std::list<Type *> types; 485 std::list<Declaration *> members; 486 482 487 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 483 488 TupleType( const TupleType& ); … … 508 513 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 509 514 virtual void print( std::ostream & os, int indent = 0 ) const; 510 private:511 std::list<Type *> types;512 std::list<Declaration *> members;513 515 }; 514 516 515 517 class TypeofType : public Type { 516 518 public: 519 Expression *expr; 520 517 521 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 518 522 TypeofType( const TypeofType& ); … … 528 532 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 529 533 virtual void print( std::ostream & os, int indent = 0 ) const; 530 private: 534 }; 535 536 class AttrType : public Type { 537 public: 538 std::string name; 531 539 Expression *expr; 532 }; 533 534 class AttrType : public Type { 535 public: 540 Type *type; 541 bool isType; 542 536 543 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 537 544 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 554 561 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 555 562 virtual void print( std::ostream & os, int indent = 0 ) const; 556 private:557 std::string name;558 Expression *expr;559 Type *type;560 bool isType;561 563 }; 562 564
Note: See TracChangeset
for help on using the changeset viewer.