Changeset 93c10de for src/AST/Type.hpp
- Timestamp:
- Nov 24, 2022, 11:01:37 AM (22 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 82a90d4
- Parents:
- 78de1e5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Type.hpp
r78de1e5 r93c10de 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jul 14 15:54:00 202113 // Update Count : 712 // Last Modified On : Thu Nov 24 9:47:00 2022 13 // Update Count : 8 14 14 // 15 15 … … 390 390 }; 391 391 392 struct TypeEnvKey; 393 392 394 /// instance of named type alias (typedef or variable) 393 395 class TypeInstType final : public BaseInstType { … … 401 403 int expr_id = 0; 402 404 403 // compact representation used for map lookups.404 struct TypeEnvKey {405 const TypeDecl * base = nullptr;406 int formal_usage = 0;407 int expr_id = 0;408 409 TypeEnvKey() = default;410 TypeEnvKey(const TypeDecl * base, int formal_usage = 0, int expr_id = 0)411 : base(base), formal_usage(formal_usage), expr_id(expr_id) {}412 TypeEnvKey(const TypeInstType & inst)413 : base(inst.base), formal_usage(inst.formal_usage), expr_id(inst.expr_id) {}414 std::string typeString() const;415 bool operator==(const TypeEnvKey & other) const;416 bool operator<(const TypeEnvKey & other) const;417 };418 419 405 bool operator==(const TypeInstType & other) const; 420 406 … … 433 419 TypeInstType( const TypeInstType & o ) = default; 434 420 435 TypeInstType( const TypeEnvKey & key ) 436 : BaseInstType(key.base->name), base(key.base), kind(key.base->kind), formal_usage(key.formal_usage), expr_id(key.expr_id) {} 421 TypeInstType( const TypeEnvKey & key ); 437 422 438 423 /// sets `base`, updating `kind` correctly … … 453 438 TypeInstType * clone() const override { return new TypeInstType{ *this }; } 454 439 MUTATE_FRIEND 440 }; 441 442 /// Compact representation of TypeInstType used for map lookups. 443 struct TypeEnvKey { 444 const TypeDecl * base = nullptr; 445 int formal_usage = 0; 446 int expr_id = 0; 447 448 TypeEnvKey() = default; 449 TypeEnvKey(const TypeDecl * base, int formal_usage = 0, int expr_id = 0) 450 : base(base), formal_usage(formal_usage), expr_id(expr_id) {} 451 TypeEnvKey(const TypeInstType & inst) 452 : base(inst.base), formal_usage(inst.formal_usage), expr_id(inst.expr_id) {} 453 std::string typeString() const; 454 bool operator==(const TypeEnvKey & other) const; 455 bool operator<(const TypeEnvKey & other) const; 455 456 }; 456 457 … … 560 561 namespace std { 561 562 template<> 562 struct hash<typename ast::Type InstType::TypeEnvKey> {563 size_t operator() (const ast::Type InstType::TypeEnvKey & x) const {563 struct hash<typename ast::TypeEnvKey> { 564 size_t operator() (const ast::TypeEnvKey & x) const { 564 565 const size_t p = 1000007; 565 566 size_t res = reinterpret_cast<size_t>(x.base);
Note: See TracChangeset
for help on using the changeset viewer.