diff options
| author | Yong He <yonghe@outlook.com> | 2023-07-07 14:26:37 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-07 14:26:37 -0700 |
| commit | 643aaa13d2c6e0c4994437aa9fba6716787608ce (patch) | |
| tree | 279794cfafecc89f0be133d2a81750d59d9ee94a /source/slang/slang-check-expr.cpp | |
| parent | fb6605c2a7bc17d3b3b79dabd07e1f05267eb33a (diff) | |
Make DeclRefBase a Val, and DeclRef<T> a helper class. (#2967)
* Make DeclRefBase a Val, and DeclRef<T> a helper class.
* Fixes.
* Workaround gcc parser issue.
* Revert NodeOperand change.
* Fix.
* Fix clang incomplete class complains.
* Fix code review.
* Small cleanups and improvements.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
| -rw-r--r-- | source/slang/slang-check-expr.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 11b560d93..6b050aa89 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -213,8 +213,8 @@ namespace Slang // to the chosen interface decl must be the first substitution on // the list (which is a linked list from the "inside" out). // - auto thisTypeSubst = as<ThisTypeSubstitution>(interfaceDeclRef.substitutions.substitutions); - if(thisTypeSubst && thisTypeSubst->interfaceDecl == interfaceDeclRef.decl) + auto thisTypeSubst = as<ThisTypeSubstitution>(interfaceDeclRef.getSubst()); + if(thisTypeSubst && thisTypeSubst->interfaceDecl == interfaceDeclRef.getDecl()) { // This isn't really an existential type, because somebody // has already filled in a this-type substitution. @@ -538,8 +538,8 @@ namespace Slang synthesizedDecl = structDecl; auto typeDef = m_astBuilder->create<TypeAliasDecl>(); typeDef->nameAndLoc.name = getName("Differential"); - auto declRef = createDefaultSubstitutionsIfNeeded(m_astBuilder, this,m_astBuilder->getSpecializedDeclRef(structDecl, nullptr)); - typeDef->type.type = m_astBuilder->getOrCreateDeclRefType(declRef.decl, declRef.substitutions); + auto declRef = createDefaultSubstitutionsIfNeeded(m_astBuilder, this, makeDeclRef(structDecl)); + typeDef->type.type = m_astBuilder->getOrCreateDeclRefType(declRef); typeDef->parentDecl = structDecl; structDecl->members.add(typeDef); } @@ -1052,7 +1052,7 @@ namespace Slang { foreachDirectOrExtensionMemberOfType<InheritanceDecl>(this, aggTypeDeclRef, [&](DeclRef<InheritanceDecl> member) { - auto subType = m_astBuilder->getOrCreateDeclRefType(member.getDecl(), nullptr); + auto subType = m_astBuilder->getOrCreateDeclRefType(member); maybeRegisterDifferentiableTypeImplRecursive(m_astBuilder, subType); }); foreachDirectOrExtensionMemberOfType<VarDeclBase>(this, aggTypeDeclRef, [&](DeclRef<VarDeclBase> member) @@ -1061,7 +1061,7 @@ namespace Slang maybeRegisterDifferentiableTypeImplRecursive(m_astBuilder, fieldType); }); } - for (auto subst = declRefType->declRef.substitutions.substitutions; subst; subst = subst->outer) + for (auto subst = declRefType->declRef.getSubst(); subst; subst = subst->outer) { if (auto genSubst = as<GenericSubstitution>(subst)) { @@ -1507,7 +1507,7 @@ namespace Slang if (isInterfaceRequirement(decl)) { - for (auto subst = declRef.substitutions.substitutions; subst; subst = subst->outer) + for (auto subst = declRef.getSubst(); subst; subst = subst->outer) { if (auto thisTypeSubst = as<ThisTypeSubstitution>(subst)) { @@ -1524,7 +1524,7 @@ namespace Slang if (!getInitExpr(m_astBuilder, declRef)) return nullptr; - ensureDecl(declRef.decl, DeclCheckState::Checked); + ensureDecl(declRef.getDecl(), DeclCheckState::Checked); ConstantFoldingCircularityInfo newCircularityInfo(decl, circularityInfo); return tryConstantFoldExpr(getInitExpr(m_astBuilder, declRef), &newCircularityInfo); } @@ -1577,9 +1577,7 @@ namespace Slang { Val* valResult = m_astBuilder->getOrCreate<GenericParamIntVal>( declRef.substitute(m_astBuilder, genericValParamRef.getDecl()->getType()), - m_astBuilder->getSpecializedDeclRef( - genericValParamRef.getDecl(), - genericValParamRef.substitutions.substitutions)); + genericValParamRef); valResult = valResult->substitute(m_astBuilder, expr.getSubsts()); return as<IntVal>(valResult); } @@ -2475,7 +2473,7 @@ namespace Slang // Get inner function DeclRef<Decl> unspecializedInnerRef = astBuilder->getSpecializedDeclRef<Decl>( getInner(baseFuncGenericDeclRef), - baseFuncGenericDeclRef.substitutions); + baseFuncGenericDeclRef.getSubst()); auto callableDeclRef = unspecializedInnerRef.as<CallableDecl>(); if (!callableDeclRef) return nullptr; |
