Changeset 0720e049 for src/SynTree/Type.h
- Timestamp:
- Aug 11, 2017, 10:33:37 AM (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:
- 54cd58b0
- Parents:
- 3d4b23fa (diff), 59a75cb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Type.h
r3d4b23fa r0720e049 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 : Thu Mar 23 16:16:36201713 // Update Count : 1 4911 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Aug 9 14:25:00 2017 13 // Update Count : 152 14 14 // 15 15 16 #ifndef TYPE_H 17 #define TYPE_H 16 #pragma once 18 17 19 18 #include "BaseSyntaxNode.h" … … 128 127 }; // Qualifiers 129 128 129 typedef std::list<TypeDecl *> ForallList; 130 131 Qualifiers tq; 132 ForallList forall; 133 std::list< Attribute * > attributes; 134 130 135 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 131 136 Type( const Type & other ); … … 146 151 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } 147 152 148 typedef std::list<TypeDecl *> ForallList;149 153 ForallList& get_forall() { return forall; } 150 154 … … 166 170 virtual Type *acceptMutator( Mutator & m ) = 0; 167 171 virtual void print( std::ostream & os, int indent = 0 ) const; 168 private: 169 Qualifiers tq; 170 ForallList forall; 171 std::list< Attribute * > attributes; 172 }; 173 174 extern Type::Qualifiers emptyQualifiers; // 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 175 177 176 178 class VoidType : public Type { … … 212 214 LongDoubleImaginary, 213 215 NUMBER_OF_BASIC_TYPES 214 } ;216 } kind; 215 217 216 218 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind … … 227 229 228 230 bool isInteger() const; 229 private:230 Kind kind;231 231 }; 232 232 233 233 class PointerType : public Type { 234 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 235 242 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 236 243 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 253 260 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 254 261 virtual void print( std::ostream & os, int indent = 0 ) const; 255 private: 262 }; 263 264 class ArrayType : public Type { 265 public: 256 266 Type *base; 257 258 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )259 267 Expression *dimension; 260 268 bool isVarLen; 261 269 bool isStatic; 262 }; 263 264 class ArrayType : public Type { 265 public: 270 266 271 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 267 272 ArrayType( const ArrayType& ); … … 283 288 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 284 289 virtual void print( std::ostream & os, int indent = 0 ) const; 285 private:286 Type *base;287 Expression *dimension;288 bool isVarLen;289 bool isStatic;290 290 }; 291 291 292 292 class FunctionType : public Type { 293 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 294 303 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 295 304 FunctionType( const FunctionType& ); … … 306 315 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 307 316 virtual void print( std::ostream & os, int indent = 0 ) const; 308 private:309 std::list<DeclarationWithType*> returnVals;310 std::list<DeclarationWithType*> parameters;311 312 // Does the function accept a variable number of arguments following the arguments specified in the parameters list.313 // This could be because of314 // - an ellipsis in a prototype declaration315 // - an unprototyped declaration316 bool isVarArgs;317 317 }; 318 318 319 319 class ReferenceToType : public Type { 320 320 public: 321 std::list< Expression* > parameters; 322 std::string name; 323 bool hoistType; 324 321 325 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 322 326 ReferenceToType( const ReferenceToType & other ); … … 337 341 protected: 338 342 virtual std::string typeString() const = 0; 339 std::list< Expression* > parameters;340 std::string name;341 private:342 bool hoistType;343 343 }; 344 344 … … 346 346 typedef ReferenceToType Parent; 347 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 348 352 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 349 353 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 369 373 private: 370 374 virtual std::string typeString() const; 371 372 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,373 // where the structure used in this type is actually defined374 StructDecl *baseStruct;375 375 }; 376 376 … … 378 378 typedef ReferenceToType Parent; 379 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 380 384 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 381 385 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 401 405 private: 402 406 virtual std::string typeString() const; 403 407 }; 408 409 class EnumInstType : public ReferenceToType { 410 typedef ReferenceToType Parent; 411 public: 404 412 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 405 413 // where the union used in this type is actually defined 406 UnionDecl *baseUnion; 407 }; 408 409 class EnumInstType : public ReferenceToType { 410 typedef ReferenceToType Parent; 411 public: 414 EnumDecl *baseEnum = nullptr; 415 412 416 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 413 417 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 424 428 private: 425 429 virtual std::string typeString() const; 426 427 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,428 // where the union used in this type is actually defined429 EnumDecl *baseEnum = nullptr;430 430 }; 431 431 … … 433 433 typedef ReferenceToType Parent; 434 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 435 439 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 436 440 TraitInstType( const TraitInstType & other ); … … 446 450 private: 447 451 virtual std::string typeString() const; 448 449 // this member is filled in by the validate pass, which instantiates the members of the correponding450 // aggregate with the actual type parameters specified for this use of the context451 std::list< Declaration* > members;452 452 }; 453 453 … … 455 455 typedef ReferenceToType Parent; 456 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 457 462 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 458 463 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 473 478 private: 474 479 virtual std::string typeString() const; 475 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,476 // where the type used here is actually defined477 TypeDecl *baseType;478 bool isFtype;479 480 }; 480 481 481 482 class TupleType : public Type { 482 483 public: 484 std::list<Type *> types; 485 std::list<Declaration *> members; 486 483 487 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 484 488 TupleType( const TupleType& ); … … 509 513 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 510 514 virtual void print( std::ostream & os, int indent = 0 ) const; 511 private:512 std::list<Type *> types;513 std::list<Declaration *> members;514 515 }; 515 516 516 517 class TypeofType : public Type { 517 518 public: 519 Expression *expr; 520 518 521 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 519 522 TypeofType( const TypeofType& ); … … 529 532 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 530 533 virtual void print( std::ostream & os, int indent = 0 ) const; 531 private: 534 }; 535 536 class AttrType : public Type { 537 public: 538 std::string name; 532 539 Expression *expr; 533 }; 534 535 class AttrType : public Type { 536 public: 540 Type *type; 541 bool isType; 542 537 543 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 538 544 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 555 561 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 556 562 virtual void print( std::ostream & os, int indent = 0 ) const; 557 private:558 std::string name;559 Expression *expr;560 Type *type;561 bool isType;562 563 }; 563 564 … … 601 602 602 603 std::ostream & operator<<( std::ostream & out, const Type * type ); 603 604 #endif // TYPE_H605 604 606 605 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.