diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-01 13:16:26 -0400 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-11-01 13:16:26 -0400 |
| commit | 134354c68768c0e3530c02678e12cb02f5646e8a (patch) | |
| tree | 20a9ae10db6790ddc5032315b85efd94fc672cff /source/slang/type-defs.h | |
| parent | b623864fe609e6912cdd2e350aa70cf7e441e1d3 (diff) | |
Adding support for associated types.
Diffstat (limited to 'source/slang/type-defs.h')
| -rw-r--r-- | source/slang/type-defs.h | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/source/slang/type-defs.h b/source/slang/type-defs.h index 15dfe3e07..2052e1eb8 100644 --- a/source/slang/type-defs.h +++ b/source/slang/type-defs.h @@ -449,7 +449,6 @@ SYNTAX_CLASS(FuncType, Type) FIELD(List<RefPtr<Type>>, paramTypes) FIELD(RefPtr<Type>, resultType) - RAW( FuncType() {} @@ -495,7 +494,7 @@ END_SYNTAX_CLASS() // The "type" of an expression that references a asscoiated type decl (via 'assoctype' keyword). SYNTAX_CLASS(AssocTypeDeclRefType, Type) DECL_FIELD(DeclRef<AssocTypeDecl>, declRef) - + DECL_FIELD(RefPtr<Type>, sourceType) RAW( AssocTypeDeclRefType() {} @@ -515,4 +514,34 @@ SYNTAX_CLASS(AssocTypeDeclRefType, Type) virtual int GetHashCode() override; virtual Type* CreateCanonicalType() override; ) +END_SYNTAX_CLASS() + +// The "type" of an generic constraint, which wraps both the sub and sup (interface) type +// the sub type can be used in associated type substitution in later type evaluation +SYNTAX_CLASS(GenericConstraintDeclRefType, Type) + DECL_FIELD(RefPtr<Type>, subType) + DECL_FIELD(RefPtr<Type>, supType) +RAW( + GenericConstraintDeclRefType() + {} + GenericConstraintDeclRefType(Session* session, + RefPtr<Type> sub, + RefPtr<Type> sup) + : subType(sub), supType(sup) + { + setSession(session); + } + + + RefPtr<Type> const& GetSupType() const { return supType; } + RefPtr<Type> const& GetSubType() const { return subType; } + + virtual String ToString() override; + + protected: + virtual RefPtr<Val> SubstituteImpl(Substitutions* subst, int* ioDiff) override; + virtual bool EqualsImpl(Type * type) override; + virtual int GetHashCode() override; + virtual Type* CreateCanonicalType() override; +) END_SYNTAX_CLASS()
\ No newline at end of file |
