Changeset 246c245 for src/AST/Type.hpp
- Timestamp:
- May 16, 2019, 6:51:18 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 8ff178d, d66e7b7
- Parents:
- 9b4f329 (diff), 6f8e87d (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/AST/Type.hpp
r9b4f329 r246c245 30 30 31 31 // Must be included in *all* AST classes; should be #undef'd at the end of the file 32 #define MUTATE_FRIEND template<typename node_t> friend automutate(const node_t * node);32 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node); 33 33 34 34 namespace ast { … … 37 37 public: 38 38 CV::Qualifiers qualifiers; 39 39 40 40 Type( CV::Qualifiers q = {} ) : qualifiers(q) {} 41 41 … … 80 80 public: 81 81 VoidType( CV::Qualifiers q = {} ) : Type( q ) {} 82 82 83 83 unsigned size() const override { return 0; } 84 84 bool isVoid() const override { return true; } … … 171 171 172 172 PointerType( const Type * b, CV::Qualifiers q = {} ) : Type(q), base(b), dimension() {} 173 PointerType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 173 PointerType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 174 174 CV::Qualifiers q = {} ) : Type(q), base(b), dimension(d), isVarLen(vl), isStatic(s) {} 175 175 … … 193 193 DimensionFlag isStatic; 194 194 195 ArrayType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 195 ArrayType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 196 196 CV::Qualifiers q = {} ) : Type(q), base(b), dimension(d), isVarLen(vl), isStatic(s) {} 197 197 … … 233 233 ptr<Type> child; 234 234 235 QualifiedType( const Type * p, const Type * c, CV::Qualifiers q = {} ) 235 QualifiedType( const Type * p, const Type * c, CV::Qualifiers q = {} ) 236 236 : Type(q), parent(p), child(c) {} 237 237 … … 249 249 ForallList forall; 250 250 251 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {} ) 251 ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {} ) 252 252 : Type(q), forall(std::move(fs)) {} 253 253 ParameterizedType( CV::Qualifiers q ) : Type(q), forall() {} … … 267 267 std::vector<ptr<DeclWithType>> params; 268 268 269 /// Does the function accept a variable number of arguments following the arguments specified 269 /// Does the function accept a variable number of arguments following the arguments specified 270 270 /// in the parameters list. 271 271 /// This could be because of … … 296 296 bool hoistType = false; 297 297 298 ReferenceToType( const std::string& n, CV::Qualifiers q = {}, 298 ReferenceToType( const std::string& n, CV::Qualifiers q = {}, 299 299 std::vector<ptr<Attribute>> && as = {} ) 300 300 : ParameterizedType(q), params(), attributes(std::move(as)), name(n) {} … … 319 319 readonly<StructDecl> base; 320 320 321 StructInstType( const std::string& n, CV::Qualifiers q = {}, 321 StructInstType( const std::string& n, CV::Qualifiers q = {}, 322 322 std::vector<ptr<Attribute>> && as = {} ) 323 323 : ReferenceToType( n, q, std::move(as) ), base() {} 324 StructInstType( const StructDecl * b, CV::Qualifiers q = {}, 324 StructInstType( const StructDecl * b, CV::Qualifiers q = {}, 325 325 std::vector<ptr<Attribute>> && as = {} ); 326 326 327 327 bool isComplete() const override; 328 328 … … 342 342 readonly<UnionDecl> base; 343 343 344 UnionInstType( const std::string& n, CV::Qualifiers q = {}, 344 UnionInstType( const std::string& n, CV::Qualifiers q = {}, 345 345 std::vector<ptr<Attribute>> && as = {} ) 346 346 : ReferenceToType( n, q, std::move(as) ), base() {} 347 UnionInstType( const UnionDecl * b, CV::Qualifiers q = {}, 347 UnionInstType( const UnionDecl * b, CV::Qualifiers q = {}, 348 348 std::vector<ptr<Attribute>> && as = {} ); 349 349 350 350 bool isComplete() const override; 351 351 … … 365 365 readonly<EnumDecl> base; 366 366 367 EnumInstType( const std::string& n, CV::Qualifiers q = {}, 367 EnumInstType( const std::string& n, CV::Qualifiers q = {}, 368 368 std::vector<ptr<Attribute>> && as = {} ) 369 369 : ReferenceToType( n, q, std::move(as) ), base() {} 370 EnumInstType( const EnumDecl * b, CV::Qualifiers q = {}, 370 EnumInstType( const EnumDecl * b, CV::Qualifiers q = {}, 371 371 std::vector<ptr<Attribute>> && as = {} ); 372 372 373 373 bool isComplete() const override; 374 374 … … 388 388 readonly<TraitDecl> base; 389 389 390 TraitInstType( const std::string& n, CV::Qualifiers q = {}, 390 TraitInstType( const std::string& n, CV::Qualifiers q = {}, 391 391 std::vector<ptr<Attribute>> && as = {} ) 392 392 : ReferenceToType( n, q, std::move(as) ), base() {} 393 TraitInstType( const TraitDecl * b, CV::Qualifiers q = {}, 393 TraitInstType( const TraitDecl * b, CV::Qualifiers q = {}, 394 394 std::vector<ptr<Attribute>> && as = {} ); 395 395 396 396 // not meaningful for TraitInstType 397 397 bool isComplete() const override { assert(false); } … … 413 413 TypeVar::Kind kind; 414 414 415 TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 415 TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 416 416 std::vector<ptr<Attribute>> && as = {} ) 417 417 : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 418 TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 418 TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 419 419 std::vector<ptr<Attribute>> && as = {} ) 420 420 : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {} … … 448 448 iterator begin() const { return types.begin(); } 449 449 iterator end() const { return types.end(); } 450 450 451 451 unsigned size() const override { return types.size(); } 452 452 453 453 const Type * getComponent( unsigned i ) override { 454 assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", 454 assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", 455 455 i, size() ); 456 456 return *(begin()+i); … … 469 469 enum Kind { Typeof, Basetypeof } kind; 470 470 471 TypeofType( const Expr * e, Kind k = Typeof, CV::Qualifiers q = {} ) 471 TypeofType( const Expr * e, Kind k = Typeof, CV::Qualifiers q = {} ) 472 472 : Type(q), expr(e), kind(k) {} 473 473 … … 482 482 public: 483 483 VarArgsType( CV::Qualifiers q = {} ) : Type( q ) {} 484 484 485 485 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 486 486 private: … … 493 493 public: 494 494 ZeroType( CV::Qualifiers q = {} ) : Type( q ) {} 495 495 496 496 const Type * accept( Visitor & v ) const override { return v.visit( this ); } 497 497 private: … … 521 521 MUTATE_FRIEND 522 522 }; 523 524 //=================================================================================================525 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency526 /// remove only if there is a better solution.527 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with528 /// forward declarations529 inline void increment( const class Type * node, Node::ref_type ref ) { node->increment( ref ); }530 inline void decrement( const class Type * node, Node::ref_type ref ) { node->decrement( ref ); }531 inline void increment( const class VoidType * node, Node::ref_type ref ) { node->increment( ref ); }532 inline void decrement( const class VoidType * node, Node::ref_type ref ) { node->decrement( ref ); }533 inline void increment( const class BasicType * node, Node::ref_type ref ) { node->increment( ref ); }534 inline void decrement( const class BasicType * node, Node::ref_type ref ) { node->decrement( ref ); }535 inline void increment( const class PointerType * node, Node::ref_type ref ) { node->increment( ref ); }536 inline void decrement( const class PointerType * node, Node::ref_type ref ) { node->decrement( ref ); }537 inline void increment( const class ArrayType * node, Node::ref_type ref ) { node->increment( ref ); }538 inline void decrement( const class ArrayType * node, Node::ref_type ref ) { node->decrement( ref ); }539 inline void increment( const class ReferenceType * node, Node::ref_type ref ) { node->increment( ref ); }540 inline void decrement( const class ReferenceType * node, Node::ref_type ref ) { node->decrement( ref ); }541 inline void increment( const class QualifiedType * node, Node::ref_type ref ) { node->increment( ref ); }542 inline void decrement( const class QualifiedType * node, Node::ref_type ref ) { node->decrement( ref ); }543 inline void increment( const class FunctionType * node, Node::ref_type ref ) { node->increment( ref ); }544 inline void decrement( const class FunctionType * node, Node::ref_type ref ) { node->decrement( ref ); }545 inline void increment( const class ReferenceToType * node, Node::ref_type ref ) { node->increment( ref ); }546 inline void decrement( const class ReferenceToType * node, Node::ref_type ref ) { node->decrement( ref ); }547 inline void increment( const class StructInstType * node, Node::ref_type ref ) { node->increment( ref ); }548 inline void decrement( const class StructInstType * node, Node::ref_type ref ) { node->decrement( ref ); }549 inline void increment( const class UnionInstType * node, Node::ref_type ref ) { node->increment( ref ); }550 inline void decrement( const class UnionInstType * node, Node::ref_type ref ) { node->decrement( ref ); }551 inline void increment( const class EnumInstType * node, Node::ref_type ref ) { node->increment( ref ); }552 inline void decrement( const class EnumInstType * node, Node::ref_type ref ) { node->decrement( ref ); }553 inline void increment( const class TraitInstType * node, Node::ref_type ref ) { node->increment( ref ); }554 inline void decrement( const class TraitInstType * node, Node::ref_type ref ) { node->decrement( ref ); }555 inline void increment( const class TypeInstType * node, Node::ref_type ref ) { node->increment( ref ); }556 inline void decrement( const class TypeInstType * node, Node::ref_type ref ) { node->decrement( ref ); }557 inline void increment( const class TupleType * node, Node::ref_type ref ) { node->increment( ref ); }558 inline void decrement( const class TupleType * node, Node::ref_type ref ) { node->decrement( ref ); }559 inline void increment( const class TypeofType * node, Node::ref_type ref ) { node->increment( ref ); }560 inline void decrement( const class TypeofType * node, Node::ref_type ref ) { node->decrement( ref ); }561 inline void increment( const class VarArgsType * node, Node::ref_type ref ) { node->increment( ref ); }562 inline void decrement( const class VarArgsType * node, Node::ref_type ref ) { node->decrement( ref ); }563 inline void increment( const class ZeroType * node, Node::ref_type ref ) { node->increment( ref ); }564 inline void decrement( const class ZeroType * node, Node::ref_type ref ) { node->decrement( ref ); }565 inline void increment( const class OneType * node, Node::ref_type ref ) { node->increment( ref ); }566 inline void decrement( const class OneType * node, Node::ref_type ref ) { node->decrement( ref ); }567 inline void increment( const class GlobalScopeType * node, Node::ref_type ref ) { node->increment( ref ); }568 inline void decrement( const class GlobalScopeType * node, Node::ref_type ref ) { node->decrement( ref ); }569 523 570 524 }
Note: See TracChangeset
for help on using the changeset viewer.