summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-print.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-04 15:47:39 -0700
committerGitHub <noreply@github.com>2023-08-04 15:47:39 -0700
commita2d90fb275962da84611160f8ddd74d934a68dbd (patch)
tree066084537b9f4fe1f367de100ed6638a88a028c1 /source/slang/slang-ast-print.cpp
parent17da4f0dec2b86ba3a4bdaf8a2ae112047d23623 (diff)
Redesign `DeclRef` and systematic `Val` deduplication (#3049)
* Redesign DeclRef + Deduplicate Val. * Update project files * Fix warning. * Fix. * Fix. * Remove `Val::_equalsImplOverride`. * Rmove `Val::_getHashCodeOverride`. * Remove `semanticVisitor` param from `resolve`. * Cleanups. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ast-print.cpp')
-rw-r--r--source/slang/slang-ast-print.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/source/slang/slang-ast-print.cpp b/source/slang/slang-ast-print.cpp
index 84c521108..b80afeee1 100644
--- a/source/slang/slang-ast-print.cpp
+++ b/source/slang/slang-ast-print.cpp
@@ -36,12 +36,12 @@ void ASTPrinter::addType(Type* type)
{
if (auto vectorType = as<VectorExpressionType>(type))
{
- if (as<BasicExpressionType>(vectorType->elementType))
+ if (as<BasicExpressionType>(vectorType->getElementType()))
{
- vectorType->elementType->toText(m_builder);
- if (as<ConstantIntVal>(vectorType->elementCount))
+ vectorType->getElementType()->toText(m_builder);
+ if (as<ConstantIntVal>(vectorType->getElementCount()))
{
- m_builder << vectorType->elementCount;
+ m_builder << vectorType->getElementCount();
return;
}
}
@@ -107,14 +107,14 @@ void ASTPrinter::_addDeclPathRec(const DeclRef<Decl>& declRef, Index depth)
auto& sb = m_builder;
// Find the parent declaration
- auto parentDeclRef = declRef.getParent(m_astBuilder);
+ auto parentDeclRef = declRef.getParent();
// If the immediate parent is a generic, then we probably
// want the declaration above that...
auto parentGenericDeclRef = parentDeclRef.as<GenericDecl>();
if (parentGenericDeclRef)
{
- parentDeclRef = parentGenericDeclRef.getParent(m_astBuilder);
+ parentDeclRef = parentGenericDeclRef.getParent();
}
// Depending on what the parent is, we may want to format things specially
@@ -172,12 +172,9 @@ void ASTPrinter::_addDeclPathRec(const DeclRef<Decl>& declRef, Index depth)
!declRef.as<GenericValueParamDecl>() &&
!declRef.as<GenericTypeParamDecl>())
{
- auto genSubst = as<GenericSubstitution>(declRef.getSubst());
- if (genSubst)
+ auto substArgs = tryGetGenericArguments(SubstitutionSet(declRef), parentGenericDeclRef.getDecl());
+ if (substArgs.getCount())
{
- SLANG_RELEASE_ASSERT(genSubst);
- SLANG_RELEASE_ASSERT(genSubst->getGenericDecl() == parentGenericDeclRef.getDecl());
-
// If the name we printed previously was an operator
// that ends with `<`, then immediately printing the
// generic arguments inside `<...>` may cause it to
@@ -193,7 +190,7 @@ void ASTPrinter::_addDeclPathRec(const DeclRef<Decl>& declRef, Index depth)
sb << "<";
bool first = true;
- for (auto arg : genSubst->getArgs())
+ for (auto arg : substArgs)
{
// When printing the representation of a specialized
// generic declaration we don't want to include the
@@ -331,7 +328,7 @@ void ASTPrinter::addDeclParams(const DeclRef<Decl>& declRef, List<Range<Index>>*
{
addGenericParams(genericDeclRef);
- addDeclParams(m_astBuilder->getSpecializedDeclRef<Decl>(getInner(genericDeclRef), genericDeclRef.getSubst()), outParamRange);
+ addDeclParams(m_astBuilder->getMemberDeclRef(genericDeclRef, genericDeclRef.getDecl()->inner), outParamRange);
}
else
{
@@ -443,7 +440,7 @@ void ASTPrinter::addDeclResultType(const DeclRef<Decl>& inDeclRef)
DeclRef<Decl> declRef = inDeclRef;
if (auto genericDeclRef = declRef.as<GenericDecl>())
{
- declRef = m_astBuilder->getSpecializedDeclRef<Decl>(getInner(genericDeclRef), genericDeclRef.getSubst());
+ declRef = m_astBuilder->getMemberDeclRef<Decl>(genericDeclRef, genericDeclRef.getDecl()->inner);
}
if (declRef.as<ConstructorDecl>())