From d5e2319c33115d0241dd9d2047c0a5f029553dde Mon Sep 17 00:00:00 2001 From: "YONGH\\yongh" Date: Thu, 2 Nov 2017 19:21:15 -0400 Subject: work inprogress --- source/slang/syntax.cpp | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) (limited to 'source/slang/syntax.cpp') diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index fd7fc0e14..3e38955ba 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -961,7 +961,8 @@ void Type::accept(IValVisitor* visitor, void* extra) { if (!sourceType) return this; - if (auto parentDeclRefType = sourceType->As()) + auto substSourceType = sourceType->SubstituteImpl(subst, ioDiff); + if (auto parentDeclRefType = substSourceType.As()) { auto parentDeclRef = parentDeclRefType->declRef; DeclRef newParentDeclRef = parentDeclRef.As(); @@ -1045,38 +1046,7 @@ void Type::accept(IValVisitor* visitor, void* extra) RefPtr GenericConstraintDeclRefType::SubstituteImpl(Substitutions* subst, int* ioDiff) { - auto genParamDecl = subType.As()->declRef.As(); - // search for a substitution that might apply to us - for (auto s = subst; s; s = s->outer.Ptr()) - { - // the generic decl associated with the substitution list must be - // the generic decl that declared this parameter - auto genericDecl = s->genericDecl; - if (genericDecl != genParamDecl.getDecl()->ParentDecl) - continue; - int index = 0; - for (auto m : genericDecl->Members) - { - if (m.Ptr() == genParamDecl.getDecl()) - { - // We've found it, so return the corresponding specialization argument - (*ioDiff)++; - return s->args[index]; - } - else if (auto typeParam = m.As()) - { - index++; - } - else if (auto valParam = m.As()) - { - index++; - } - else - { - } - } - } - return this; + return subType->SubstituteImpl(subst, ioDiff); } int GenericConstraintDeclRefType::GetHashCode() -- cgit v1.2.3