Changeset 9236060 for src/SynTree/Type.h
- Timestamp:
- Aug 14, 2017, 2:03:39 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:
- 74b007ba
- Parents:
- fd344aa (diff), 54cd58b (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
rfd344aa r9236060 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 … … 172 176 virtual Type *acceptMutator( Mutator & m ) = 0; 173 177 virtual void print( std::ostream & os, int indent = 0 ) const; 174 private: 175 Qualifiers tq; 176 ForallList forall; 177 std::list< Attribute * > attributes; 178 }; 179 180 extern Type::Qualifiers emptyQualifiers; // no qualifiers on constants 178 }; 179 180 extern const Type::FuncSpecifiers noFuncSpecifiers; 181 extern const Type::StorageClasses noStorageClasses; 182 extern const Type::Qualifiers noQualifiers; // no qualifiers on constants 181 183 182 184 class VoidType : public Type { … … 218 220 LongDoubleImaginary, 219 221 NUMBER_OF_BASIC_TYPES 220 } ;222 } kind; 221 223 222 224 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind … … 233 235 234 236 bool isInteger() const; 235 private:236 Kind kind;237 237 }; 238 238 239 239 class PointerType : public Type { 240 240 public: 241 Type *base; 242 243 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) 244 Expression *dimension; 245 bool isVarLen; 246 bool isStatic; 247 241 248 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 242 249 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 261 268 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 262 269 virtual void print( std::ostream & os, int indent = 0 ) const; 263 private: 270 }; 271 272 class ArrayType : public Type { 273 public: 264 274 Type *base; 265 266 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )267 275 Expression *dimension; 268 276 bool isVarLen; 269 277 bool isStatic; 270 }; 271 272 class ArrayType : public Type { 273 public: 278 274 279 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 275 280 ArrayType( const ArrayType& ); … … 291 296 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 292 297 virtual void print( std::ostream & os, int indent = 0 ) const; 293 private:294 Type *base;295 Expression *dimension;296 bool isVarLen;297 bool isStatic;298 298 }; 299 299 300 300 class ReferenceType : public Type { 301 301 public: 302 Type *base; 303 302 304 ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 303 305 ReferenceType( const ReferenceType & ); … … 313 315 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 314 316 virtual void print( std::ostream & os, int indent = 0 ) const; 315 private:316 Type *base;317 317 }; 318 318 319 319 class FunctionType : public Type { 320 320 public: 321 std::list<DeclarationWithType*> returnVals; 322 std::list<DeclarationWithType*> parameters; 323 324 // Does the function accept a variable number of arguments following the arguments specified in the parameters list. 325 // This could be because of 326 // - an ellipsis in a prototype declaration 327 // - an unprototyped declaration 328 bool isVarArgs; 329 321 330 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 322 331 FunctionType( const FunctionType& ); … … 333 342 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 334 343 virtual void print( std::ostream & os, int indent = 0 ) const; 335 private:336 std::list<DeclarationWithType*> returnVals;337 std::list<DeclarationWithType*> parameters;338 339 // Does the function accept a variable number of arguments following the arguments specified in the parameters list.340 // This could be because of341 // - an ellipsis in a prototype declaration342 // - an unprototyped declaration343 bool isVarArgs;344 344 }; 345 345 346 346 class ReferenceToType : public Type { 347 347 public: 348 std::list< Expression* > parameters; 349 std::string name; 350 bool hoistType; 351 348 352 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 349 353 ReferenceToType( const ReferenceToType & other ); … … 364 368 protected: 365 369 virtual std::string typeString() const = 0; 366 std::list< Expression* > parameters;367 std::string name;368 private:369 bool hoistType;370 370 }; 371 371 … … 373 373 typedef ReferenceToType Parent; 374 374 public: 375 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, 376 // where the structure used in this type is actually defined 377 StructDecl *baseStruct; 378 375 379 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 376 380 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 396 400 private: 397 401 virtual std::string typeString() const; 398 399 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,400 // where the structure used in this type is actually defined401 StructDecl *baseStruct;402 402 }; 403 403 … … 405 405 typedef ReferenceToType Parent; 406 406 public: 407 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 408 // where the union used in this type is actually defined 409 UnionDecl *baseUnion; 410 407 411 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 408 412 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 428 432 private: 429 433 virtual std::string typeString() const; 430 434 }; 435 436 class EnumInstType : public ReferenceToType { 437 typedef ReferenceToType Parent; 438 public: 431 439 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 432 440 // where the union used in this type is actually defined 433 UnionDecl *baseUnion; 434 }; 435 436 class EnumInstType : public ReferenceToType { 437 typedef ReferenceToType Parent; 438 public: 441 EnumDecl *baseEnum = nullptr; 442 439 443 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 440 444 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 451 455 private: 452 456 virtual std::string typeString() const; 453 454 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,455 // where the union used in this type is actually defined456 EnumDecl *baseEnum = nullptr;457 457 }; 458 458 … … 460 460 typedef ReferenceToType Parent; 461 461 public: 462 // this member is filled in by the validate pass, which instantiates the members of the correponding 463 // aggregate with the actual type parameters specified for this use of the context 464 std::list< Declaration* > members; 465 462 466 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 463 467 TraitInstType( const TraitInstType & other ); … … 473 477 private: 474 478 virtual std::string typeString() const; 475 476 // this member is filled in by the validate pass, which instantiates the members of the correponding477 // aggregate with the actual type parameters specified for this use of the context478 std::list< Declaration* > members;479 479 }; 480 480 … … 482 482 typedef ReferenceToType Parent; 483 483 public: 484 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree, 485 // where the type used here is actually defined 486 TypeDecl *baseType; 487 bool isFtype; 488 484 489 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 485 490 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 500 505 private: 501 506 virtual std::string typeString() const; 502 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,503 // where the type used here is actually defined504 TypeDecl *baseType;505 bool isFtype;506 507 }; 507 508 508 509 class TupleType : public Type { 509 510 public: 511 std::list<Type *> types; 512 std::list<Declaration *> members; 513 510 514 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 511 515 TupleType( const TupleType& ); … … 536 540 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 537 541 virtual void print( std::ostream & os, int indent = 0 ) const; 538 private:539 std::list<Type *> types;540 std::list<Declaration *> members;541 542 }; 542 543 543 544 class TypeofType : public Type { 544 545 public: 546 Expression *expr; 547 545 548 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 546 549 TypeofType( const TypeofType& ); … … 556 559 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 557 560 virtual void print( std::ostream & os, int indent = 0 ) const; 558 private: 561 }; 562 563 class AttrType : public Type { 564 public: 565 std::string name; 559 566 Expression *expr; 560 }; 561 562 class AttrType : public Type { 563 public: 567 Type *type; 568 bool isType; 569 564 570 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 565 571 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 582 588 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 583 589 virtual void print( std::ostream & os, int indent = 0 ) const; 584 private:585 std::string name;586 Expression *expr;587 Type *type;588 bool isType;589 590 }; 590 591 … … 628 629 629 630 std::ostream & operator<<( std::ostream & out, const Type * type ); 630 631 #endif // TYPE_H632 631 633 632 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.