summaryrefslogtreecommitdiffstats
path: root/source/slang/syntax.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-01-13 13:17:02 -0800
committerGitHub <noreply@github.com>2018-01-13 13:17:02 -0800
commitd4dab2cd3a409411c2d7caed01fc02a0fd3e8450 (patch)
tree10c92df406a82e7a5eb24b56c17d9256a7183c44 /source/slang/syntax.cpp
parentdf6eeb93c1718334779ae328db277cdf7a9d7b04 (diff)
parent4d2086f47e25aa4545df95ddfd260c8bc5aafdb2 (diff)
Merge pull request #364 from csyonghe/assoctype
Support nested generics
Diffstat (limited to 'source/slang/syntax.cpp')
-rw-r--r--source/slang/syntax.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp
index c63dfc781..2ed10e138 100644
--- a/source/slang/syntax.cpp
+++ b/source/slang/syntax.cpp
@@ -1194,6 +1194,7 @@ void Type::accept(IValVisitor* visitor, void* extra)
auto substSubst = new GenericSubstitution();
substSubst->genericDecl = genericDecl;
substSubst->args = substArgs;
+ substSubst->outer = outerSubst.As<GenericSubstitution>();
return substSubst;
}
@@ -1897,27 +1898,9 @@ void Type::accept(IValVisitor* visitor, void* extra)
SubstitutionSet substituteSubstitutions(SubstitutionSet oldSubst, SubstitutionSet subst, int * ioDiff)
{
- if (oldSubst)
- oldSubst = oldSubst.substituteImpl(subst, ioDiff);
-
- // if oldSubst does not have ThisTypeSubst (which means `this_type` is free variable)
- // and subst has a ThisTypeSubst (which means `this_type` is bound to a type),
- // then copy that ThisTypeSubst over (to bind the this_type to the specified type)
- SubstitutionSet newSubst = oldSubst;
- insertGlobalGenericSubstitutions(newSubst, subst, ioDiff);
- /*if (!hasThisTypeSubstitutions(oldSubst))
- {
- auto thisTypeSubst = findThisTypeSubst(subst);
- if (thisTypeSubst)
- {
- auto cpyThisTypeSubst = new ThisTypeSubstitution();
- cpyThisTypeSubst->sourceType = thisTypeSubst->sourceType;
- insertSubstAtBottom(newSubst, cpyThisTypeSubst);
- *ioDiff = 1;
- }
- }*/
- return newSubst;
+ return oldSubst.substituteImpl(subst, ioDiff);
}
+
bool SubstitutionSet::Equals(SubstitutionSet substSet) const
{
if (genericSubstitutions)
@@ -1951,8 +1934,8 @@ void Type::accept(IValVisitor* visitor, void* extra)
rs.globalGenParamSubstitutions = globalGenParamSubstitutions->SubstituteImpl(subst, ioDiff).As<GlobalGenericParamSubstitution>();
if (thisTypeSubstitution)
rs.thisTypeSubstitution = thisTypeSubstitution->SubstituteImpl(subst, ioDiff).As<ThisTypeSubstitution>();
- else
- rs.thisTypeSubstitution = subst.thisTypeSubstitution;
+
+ insertGlobalGenericSubstitutions(rs, subst, ioDiff);
return rs;
}
int SubstitutionSet::GetHashCode() const