summaryrefslogtreecommitdiffstats
path: root/source/slang/syntax.cpp
diff options
context:
space:
mode:
authorYONGH\yongh <yonghe@outlook.com>2017-11-02 19:21:15 -0400
committerYONGH\yongh <yonghe@outlook.com>2017-11-02 19:21:15 -0400
commitd5e2319c33115d0241dd9d2047c0a5f029553dde (patch)
treeb89aef27f2330e7c568b0f799f0902015fdd4f18 /source/slang/syntax.cpp
parente2b97607977977fd2dbe298c2bb4512f4715dd4c (diff)
work inprogress
Diffstat (limited to 'source/slang/syntax.cpp')
-rw-r--r--source/slang/syntax.cpp36
1 files changed, 3 insertions, 33 deletions
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<DeclRefType>())
+ auto substSourceType = sourceType->SubstituteImpl(subst, ioDiff);
+ if (auto parentDeclRefType = substSourceType.As<DeclRefType>())
{
auto parentDeclRef = parentDeclRefType->declRef;
DeclRef<AggTypeDecl> newParentDeclRef = parentDeclRef.As<AggTypeDecl>();
@@ -1045,38 +1046,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
RefPtr<Val> GenericConstraintDeclRefType::SubstituteImpl(Substitutions* subst, int* ioDiff)
{
- auto genParamDecl = subType.As<DeclRefType>()->declRef.As<GenericTypeParamDecl>();
- // 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<GenericTypeParamDecl>())
- {
- index++;
- }
- else if (auto valParam = m.As<GenericValueParamDecl>())
- {
- index++;
- }
- else
- {
- }
- }
- }
- return this;
+ return subType->SubstituteImpl(subst, ioDiff);
}
int GenericConstraintDeclRefType::GetHashCode()