summaryrefslogtreecommitdiff
path: root/source/slang/syntax.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2017-11-21 19:26:17 -0500
committerYong He <yonghe@outlook.com>2017-11-21 19:26:17 -0500
commit64108c88836ed6b0335b000d4d127113f6840010 (patch)
tree7baedf8883d9a07a9b3ce7cc25563dc20a921066 /source/slang/syntax.cpp
parentab49ac3dfe696d549c61dc6883225586a2aa88d6 (diff)
Add logic to propagate GlobalGenericParamSubstitution
Diffstat (limited to 'source/slang/syntax.cpp')
-rw-r--r--source/slang/syntax.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp
index badfaea4f..2c214a332 100644
--- a/source/slang/syntax.cpp
+++ b/source/slang/syntax.cpp
@@ -1309,9 +1309,39 @@ void Type::accept(IValVisitor* visitor, void* extra)
UNREACHABLE_RETURN(expr);
}
+ bool hasGlobalGenericSubst(Substitutions * destSubst, GlobalGenericParamSubstitution * genSubst)
+ {
+ while (destSubst)
+ {
+ if (auto globalParamSubst = dynamic_cast<GlobalGenericParamSubstitution*>(destSubst))
+ {
+ if (globalParamSubst->paramDecl == genSubst->paramDecl)
+ return true;
+ }
+ destSubst = destSubst->outer;
+ }
+ return false;
+ }
+ void insertGlobalGenericSubstitutions(RefPtr<Substitutions> & destSubst, Substitutions * srcSubst)
+ {
+ while (srcSubst)
+ {
+ if (auto globalGenSubst = dynamic_cast<GlobalGenericParamSubstitution*>(srcSubst))
+ {
+ if (!hasGlobalGenericSubst(destSubst, globalGenSubst))
+ {
+ RefPtr<GlobalGenericParamSubstitution> cpyGlobalGenSubst = new GlobalGenericParamSubstitution(*globalGenSubst);
+ cpyGlobalGenSubst->outer = nullptr;
+ insertSubstAtBottom(destSubst, cpyGlobalGenSubst);
+ }
+ }
+ srcSubst = srcSubst->outer;
+ }
+ }
DeclRefBase DeclRefBase::SubstituteImpl(Substitutions* subst, int* ioDiff)
{
+ insertGlobalGenericSubstitutions(substitutions, subst);
if (!substitutions) return *this;
int diff = 0;