Changeset e0e9a0b for src/AST/Type.hpp
- Timestamp:
- Jun 27, 2019, 5:16:54 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7d0881c
- Parents:
- 6be3b7d6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Type.hpp
r6be3b7d6 re0e9a0b 33 33 34 34 namespace ast { 35 36 template< typename T > class Pass; 37 class ForallSubstitutor; 35 38 36 39 class Type : public Node { … … 266 269 /// Base type for potentially forall-qualified types 267 270 class ParameterizedType : public Type { 271 protected: 272 /// initializes forall with substitutor 273 void initWithSub( const ParameterizedType & o, Pass< ForallSubstitutor > & sub ); 268 274 public: 269 275 using ForallList = std::vector<ptr<TypeDecl>>; … … 278 284 : Type(q, std::move(as)), forall() {} 279 285 280 ParameterizedType( const ParameterizedType & o ) : Type( o ), forall() { 281 // one-level deep clone to avoid weak-reference errors 282 forall.reserve( o.forall.size() ); 283 for ( const TypeDecl * d : o.forall ) { forall.emplace_back( d->clone() ); } 284 } 286 // enforce use of ForallSubstitutor to copy parameterized type 287 ParameterizedType( const ParameterizedType & ) = delete; 285 288 286 289 ParameterizedType( ParameterizedType && ) = default; … … 312 315 : ParameterizedType(q), returns(), params(), isVarArgs(va) {} 313 316 317 FunctionType( const FunctionType & o ); 318 314 319 /// true if either the parameters or return values contain a tttype 315 320 bool isTtype() const; … … 325 330 /// base class for types that refer to types declared elsewhere (aggregates and typedefs) 326 331 class ReferenceToType : public ParameterizedType { 332 protected: 333 /// Initializes forall and parameters based on substitutor 334 void initWithSub( const ReferenceToType & o, Pass< ForallSubstitutor > & sub ); 327 335 public: 328 336 std::vector<ptr<Expr>> params; … … 330 338 bool hoistType = false; 331 339 332 ReferenceToType( const std::string& n, CV::Qualifiers q = {},333 std::vector<ptr<Attribute>> && as = {} )340 ReferenceToType( 341 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 334 342 : ParameterizedType(q, std::move(as)), params(), name(n) {} 343 344 ReferenceToType( const ReferenceToType & o ); 335 345 336 346 /// Gets aggregate declaration this type refers to … … 349 359 readonly<StructDecl> base; 350 360 351 StructInstType( const std::string& n, CV::Qualifiers q = {},352 std::vector<ptr<Attribute>> && as = {} )361 StructInstType( 362 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 353 363 : ReferenceToType( n, q, std::move(as) ), base() {} 354 StructInstType( const StructDecl * b, CV::Qualifiers q = {}, 355 std::vector<ptr<Attribute>> && as = {} ); 364 365 StructInstType( 366 const StructDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 356 367 357 368 bool isComplete() const override; … … 370 381 readonly<UnionDecl> base; 371 382 372 UnionInstType( const std::string& n, CV::Qualifiers q = {},373 std::vector<ptr<Attribute>> && as = {} )383 UnionInstType( 384 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 374 385 : ReferenceToType( n, q, std::move(as) ), base() {} 375 UnionInstType( const UnionDecl * b, CV::Qualifiers q = {}, 376 std::vector<ptr<Attribute>> && as = {} ); 386 387 UnionInstType( 388 const UnionDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 377 389 378 390 bool isComplete() const override; … … 391 403 readonly<EnumDecl> base; 392 404 393 EnumInstType( const std::string& n, CV::Qualifiers q = {},394 std::vector<ptr<Attribute>> && as = {} )405 EnumInstType( 406 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 395 407 : ReferenceToType( n, q, std::move(as) ), base() {} 396 EnumInstType( const EnumDecl * b, CV::Qualifiers q = {}, 397 std::vector<ptr<Attribute>> && as = {} ); 408 409 EnumInstType( 410 const EnumDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 398 411 399 412 bool isComplete() const override; … … 412 425 readonly<TraitDecl> base; 413 426 414 TraitInstType( const std::string& n, CV::Qualifiers q = {},415 std::vector<ptr<Attribute>> && as = {} )427 TraitInstType( 428 const std::string& n, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ) 416 429 : ReferenceToType( n, q, std::move(as) ), base() {} 417 TraitInstType( const TraitDecl * b, CV::Qualifiers q = {}, 418 std::vector<ptr<Attribute>> && as = {} ); 430 431 TraitInstType( 432 const TraitDecl * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} ); 419 433 420 434 // not meaningful for TraitInstType … … 435 449 TypeVar::Kind kind; 436 450 437 TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 451 TypeInstType( 452 const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 438 453 std::vector<ptr<Attribute>> && as = {} ) 439 454 : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {} 440 TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 455 456 TypeInstType( 457 const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 441 458 std::vector<ptr<Attribute>> && as = {} ) 442 459 : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {} 460 461 TypeInstType( const TypeInstType & o ); 443 462 444 463 /// sets `base`, updating `kind` correctly
Note: See TracChangeset
for help on using the changeset viewer.