From a0458266d7cd5d802b8c51e6a997b4bf0d9beb82 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 3 Nov 2017 09:38:02 -0400 Subject: in-progress work --- source/slang/syntax-base-defs.h | 54 +++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'source/slang/syntax-base-defs.h') diff --git a/source/slang/syntax-base-defs.h b/source/slang/syntax-base-defs.h index 8a22a61d2..3c7e8c5ae 100644 --- a/source/slang/syntax-base-defs.h +++ b/source/slang/syntax-base-defs.h @@ -126,31 +126,44 @@ protected: ) END_SYNTAX_CLASS() + // A substitution represents a binding of certain // type-level variables to concrete argument values -SYNTAX_CLASS(Substitutions, RefObject) +ABSTRACT_SYNTAX_CLASS(Substitutions, RefObject) + + // Any further substitutions, relating to outer generic declarations + SYNTAX_FIELD(RefPtr, outer) + + RAW( + // Apply a set of substitutions to the bindings in this substitution + virtual RefPtr SubstituteImpl(Substitutions* subst, int* ioDiff) = 0; + // Check if these are equivalent substitutiosn to another set + virtual bool Equals(Substitutions* subst) = 0; + virtual bool operator == (const Substitutions & subst) = 0; + virtual int GetHashCode() const = 0; + ) +END_SYNTAX_CLASS() + +SYNTAX_CLASS(GenericSubstitution, Substitutions) // The generic declaration that defines the // parametesr we are binding to arguments - DECL_FIELD(GenericDecl*, genericDecl) + DECL_FIELD(GenericDecl*, genericDecl) // The actual values of the arguments SYNTAX_FIELD(List>, args) - - // Any further substitutions, relating to outer generic declarations - SYNTAX_FIELD(RefPtr, outer) - + RAW( // Apply a set of substitutions to the bindings in this substitution - RefPtr SubstituteImpl(Substitutions* subst, int* ioDiff); + virtual RefPtr SubstituteImpl(Substitutions* subst, int* ioDiff) override; // Check if these are equivalent substitutiosn to another set - bool Equals(Substitutions* subst); - bool operator == (const Substitutions & subst) + virtual bool Equals(Substitutions* subst) override; + virtual bool operator == (const Substitutions & subst) override { return Equals(const_cast(&subst)); } - int GetHashCode() const + virtual int GetHashCode() const override { int rs = 0; for (auto && v : args) @@ -163,6 +176,27 @@ SYNTAX_CLASS(Substitutions, RefObject) ) END_SYNTAX_CLASS() +SYNTAX_CLASS(ThisTypeSubstitution, Substitutions) + // The actual type that provides the lookup scope for an associated type + SYNTAX_FIELD(RefPtr, sourceType) + + RAW( + // Apply a set of substitutions to the bindings in this substitution + virtual RefPtr SubstituteImpl(Substitutions* subst, int* ioDiff) override; + + // Check if these are equivalent substitutiosn to another set + virtual bool Equals(Substitutions* subst) override; + virtual bool operator == (const Substitutions & subst) override + { + return Equals(const_cast(&subst)); + } + virtual int GetHashCode() const override + { + return sourceType->GetHashCode(); + } + ) +END_SYNTAX_CLASS() + ABSTRACT_SYNTAX_CLASS(SyntaxNode, SyntaxNodeBase) END_SYNTAX_CLASS() -- cgit v1.2.3