From 8daafcc2e4bf7b2dfb66d7a3b7ac60c86b2d926c Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 9 Jan 2018 10:50:44 -0800 Subject: bruteforce implementation of witness table resolution for associated (#358) --- source/slang/decl-defs.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'source/slang/decl-defs.h') diff --git a/source/slang/decl-defs.h b/source/slang/decl-defs.h index 7cb9ffc0f..fb35e327a 100644 --- a/source/slang/decl-defs.h +++ b/source/slang/decl-defs.h @@ -90,21 +90,30 @@ SIMPLE_SYNTAX_CLASS(ClassDecl, AggTypeDecl) // An interface which other types can conform to SIMPLE_SYNTAX_CLASS(InterfaceDecl, AggTypeDecl) +ABSTRACT_SYNTAX_CLASS(TypeConstraintDecl, Decl) + RAW( + virtual TypeExp& getSup() = 0; + ) +END_SYNTAX_CLASS() + // A kind of pseudo-member that represents an explicit // or implicit inheritance relationship. // -SYNTAX_CLASS(InheritanceDecl, Decl) - // The type expression as written +SYNTAX_CLASS(InheritanceDecl, TypeConstraintDecl) +// The type expression as written SYNTAX_FIELD(TypeExp, base) -RAW( + RAW( // After checking, this dictionary will map members // required by the base type to their concrete // implementations in the type that contains // this inheritance declaration. - Dictionary, Decl*> requirementWitnesses; -) - + Dictionary, DeclRef> requirementWitnesses; + virtual TypeExp& getSup() override + { + return base; + } + ) END_SYNTAX_CLASS() // TODO: may eventually need sub-classes for explicit/direct vs. implicit/indirect inheritance @@ -216,13 +225,19 @@ SYNTAX_CLASS(GenericTypeParamDecl, SimpleTypeDecl) END_SYNTAX_CLASS() // A constraint placed as part of a generic declaration -SYNTAX_CLASS(GenericTypeConstraintDecl, Decl) +SYNTAX_CLASS(GenericTypeConstraintDecl, TypeConstraintDecl) // A type constraint like `T : U` is constraining `T` to be "below" `U` // on a lattice of types. This may not be a subtyping relationship // per se, but it makes sense to use that terminology here, so we // think of these fields as the sub-type and sup-ertype, respectively. SYNTAX_FIELD(TypeExp, sub) SYNTAX_FIELD(TypeExp, sup) + RAW( + virtual TypeExp& getSup() override + { + return sup; + } + ) END_SYNTAX_CLASS() SIMPLE_SYNTAX_CLASS(GenericValueParamDecl, VarDeclBase) -- cgit v1.2.3