diff options
| author | Yong He <yonghe@outlook.com> | 2017-11-08 12:55:08 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-08 12:55:08 -0500 |
| commit | da58c702d8be302f8d4ccc9ba27252759398d4d6 (patch) | |
| tree | cffe8ed0c6d2a884c5e7ff00035ae956ce917e56 | |
| parent | 97569db1f4caac84ad03b38647c12fc97e9864c1 (diff) | |
| parent | d4aaa6cda39b338e77d861eb321dc1a677287b75 (diff) | |
Merge branch 'master' into work
| -rw-r--r-- | source/slang/check.cpp | 9 | ||||
| -rw-r--r-- | source/slang/syntax.cpp | 73 |
2 files changed, 41 insertions, 41 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index 320b22bdb..233a82eef 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -1609,6 +1609,15 @@ namespace Slang else return false; } + else if (auto genValMbr = genMbr.As<GenericValueParamDecl>()) + { + if (auto requiredGenValMbr = requiredGenMbr.As<GenericValueParamDecl>()) + { + return genValMbr->type->Equals(requiredGenValMbr->type); + } + else + return false; + } else if (auto genTypeConstraintMbr = genMbr.As<GenericTypeConstraintDecl>()) { if (auto requiredTypeConstraintMbr = requiredGenMbr.As<GenericTypeConstraintDecl>()) diff --git a/source/slang/syntax.cpp b/source/slang/syntax.cpp index 4e1778e6e..81df49713 100644 --- a/source/slang/syntax.cpp +++ b/source/slang/syntax.cpp @@ -1529,57 +1529,48 @@ void Type::accept(IValVisitor* visitor, void* extra) RefPtr<Val> DeclaredSubtypeWitness::SubstituteImpl(Substitutions* subst, int * ioDiff) { - DeclRef<GenericTypeParamDecl> genParamDeclRef; - if (auto subDeclRefType = this->sub.As<DeclRefType>()) + if (auto genConstraintDecl = declRef.As<GenericTypeConstraintDecl>()) { - genParamDeclRef = subDeclRefType->declRef.As<GenericTypeParamDecl>(); - } - if (!genParamDeclRef) - return this; - auto genParamDecl = genParamDeclRef.getDecl(); - // search for a substitution that might apply to us - for (auto s = subst; s; s = s->outer.Ptr()) - { - if (auto genericSubst = dynamic_cast<GenericSubstitution*>(s)) + // 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 = genericSubst->genericDecl; - if (genericDecl != genParamDecl->ParentDecl) - continue; - bool found = false; - int index = 0; - for (auto m : genericDecl->Members) + if (auto genericSubst = dynamic_cast<GenericSubstitution*>(s)) { - if (m.Ptr() == genParamDecl) - { - // We've found it, so return the corresponding specialization argument - (*ioDiff)++; - found = true; - break; - } - else if (auto typeParam = m.As<GenericTypeParamDecl>()) - { - index++; - } - else if (auto valParam = m.As<GenericValueParamDecl>()) + // the generic decl associated with the substitution list must be + // the generic decl that declared this parameter + auto genericDecl = genericSubst->genericDecl; + if (genericDecl != genConstraintDecl.getDecl()->ParentDecl) + continue; + bool found = false; + UInt index = 0; + for (auto m : genericDecl->Members) { - index++; + if (auto constraintParam = m.As<GenericTypeConstraintDecl>()) + { + if (constraintParam.Ptr() == declRef.getDecl()) + { + found = true; + break; + } + index++; + } } - else + if (found) { + (*ioDiff)++; + auto ordinaryParamCount = genericDecl->getMembersOfType<GenericTypeParamDecl>().Count() + + genericDecl->getMembersOfType<GenericValueParamDecl>().Count(); + SLANG_ASSERT(index + ordinaryParamCount < genericSubst->args.Count()); + return genericSubst->args[index + ordinaryParamCount]; } } - if (found) - { - auto ordinaryParamCount = genericDecl->getMembersOfType<GenericTypeParamDecl>().Count() + - genericDecl->getMembersOfType<GenericValueParamDecl>().Count(); - SLANG_ASSERT(ordinaryParamCount + index < genericSubst->args.Count()); - return genericSubst->args[ordinaryParamCount + index]; - } } } - return this; + RefPtr<DeclaredSubtypeWitness> rs = new DeclaredSubtypeWitness(); + rs->sub = sub->SubstituteImpl(subst, ioDiff).As<Type>(); + rs->sup = sup->SubstituteImpl(subst, ioDiff).As<Type>(); + rs->declRef = declRef.SubstituteImpl(subst, ioDiff); + return rs; } String DeclaredSubtypeWitness::ToString() |
