summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
m---------external/vulkan0
-rw-r--r--source/slang/slang-ast-decl-ref.cpp77
-rw-r--r--tests/diagnostics/mismatching-types.slang.expected6
-rw-r--r--tools/slang-unit-test/unit-test-decl-tree-reflection.cpp7
4 files changed, 85 insertions, 5 deletions
diff --git a/external/vulkan b/external/vulkan
-Subproject 577baa05033cf1d9236b3d078ca4b3269ed87a2
+Subproject f864bc6dfe6229a399566e979c16795386d0f30
diff --git a/source/slang/slang-ast-decl-ref.cpp b/source/slang/slang-ast-decl-ref.cpp
index b2cc99ae4..29ab7f86e 100644
--- a/source/slang/slang-ast-decl-ref.cpp
+++ b/source/slang/slang-ast-decl-ref.cpp
@@ -312,7 +312,82 @@ DeclRefBase* DeclRefBase::getBase()
}
void DeclRefBase::toText(StringBuilder& out)
{
- SLANG_AST_NODE_VIRTUAL_CALL(DeclRefBase, toText, (out));
+ if (auto lookupDeclRef = as<LookupDeclRef>(this))
+ {
+ lookupDeclRef->_toTextOverride(out);
+ return;
+ }
+
+ if (as<GenericTypeParamDecl>(this->getDecl()))
+ {
+ SLANG_ASSERT(as<DirectDeclRef>(this));
+ out << this->getDecl()->getName()->text;
+ return;
+ }
+ else if (as<GenericValueParamDecl>(this->getDecl()))
+ {
+ SLANG_ASSERT(as<DirectDeclRef>(this));
+ out << this->getDecl()->getName()->text;
+ return;
+ }
+
+ SubstitutionSet substSet(this);
+
+ List<Decl*> decls;
+ for (auto dd = getDecl(); dd; dd = dd->parentDecl)
+ {
+ // Skip the top-level decl.
+ if (as<ModuleDecl>(dd))
+ continue;
+
+ // Skip base decls in generic containers. We will handle them when we handle the generic
+ // decl.
+ //
+ if (dd->parentDecl && as<GenericDecl>(dd->parentDecl))
+ continue;
+
+ decls.add(dd);
+ }
+
+ decls.reverse();
+
+ bool first = true;
+ for (auto decl : decls)
+ {
+ if (!first)
+ out << ".";
+ first = false;
+
+ if (auto name = decl->getName())
+ {
+ out << name->text;
+
+ // If there are any specializations for this decl, emit them here:
+ if (auto genericDecl = as<GenericDecl>(decl))
+ {
+ if (auto genericAppDeclRef = substSet.findGenericAppDeclRef(genericDecl))
+ {
+ Index paramCount = 0;
+ for (auto member : genericDecl->members)
+ if (as<GenericTypeParamDeclBase>(member) ||
+ as<GenericValueParamDecl>(member))
+ paramCount++;
+ out << "<";
+ auto args = genericAppDeclRef->getArgs();
+ Index argCount = args.getCount();
+ for (Index aa = 0; aa < Math::Min(paramCount, argCount); ++aa)
+ {
+ if (aa != 0)
+ out << ", ";
+ args[aa]->toText(out);
+ }
+ out << ">";
+ }
+ }
+
+ // TODO: What do we do about extensions?
+ }
+ }
}
Name* DeclRefBase::getName() const
diff --git a/tests/diagnostics/mismatching-types.slang.expected b/tests/diagnostics/mismatching-types.slang.expected
index 3bbab624d..65a6df32e 100644
--- a/tests/diagnostics/mismatching-types.slang.expected
+++ b/tests/diagnostics/mismatching-types.slang.expected
@@ -15,13 +15,13 @@ tests/diagnostics/mismatching-types.slang(57): error 30019: expected an expressi
tests/diagnostics/mismatching-types.slang(59): error 30019: expected an expression of type 'GenericOuter<int>.NonGenericInner', got 'GenericOuter<float>.NonGenericInner'
a.ng = b.ng;
^~
-tests/diagnostics/mismatching-types.slang(61): error 30019: expected an expression of type 'GenericInner<int>', got 'int'
+tests/diagnostics/mismatching-types.slang(61): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'int'
c.i = 0;
^
-tests/diagnostics/mismatching-types.slang(63): error 30019: expected an expression of type 'GenericInner<int>', got 'GenericInner<float>'
+tests/diagnostics/mismatching-types.slang(63): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>', got 'NonGenericOuter.GenericInner<float>'
c.i = c.f;
^
-tests/diagnostics/mismatching-types.slang(65): error 30019: expected an expression of type 'GenericInner<int>.ReallyNested', got 'int'
+tests/diagnostics/mismatching-types.slang(65): error 30019: expected an expression of type 'NonGenericOuter.GenericInner<int>.ReallyNested', got 'int'
c.i.n = 0;
^
tests/diagnostics/mismatching-types.slang(74): error 30019: expected an expression of type 'Texture1D<int>', got 'Texture1D<float>'
diff --git a/tools/slang-unit-test/unit-test-decl-tree-reflection.cpp b/tools/slang-unit-test/unit-test-decl-tree-reflection.cpp
index c8bd9cd02..2ceb9981b 100644
--- a/tools/slang-unit-test/unit-test-decl-tree-reflection.cpp
+++ b/tools/slang-unit-test/unit-test-decl-tree-reflection.cpp
@@ -242,7 +242,6 @@ SLANG_UNIT_TEST(declTreeReflection)
{
auto type = compositeProgram->getLayout()->findTypeByName("MyGenericType<half>");
SLANG_CHECK(type != nullptr);
- // SLANG_CHECK(type->getKind() == slang::DeclReflection::Kind::Struct);
SLANG_CHECK(getTypeFullName(type) == "MyGenericType<half>");
auto funcReflection = compositeProgram->getLayout()->findFunctionByNameInType(type, "g");
SLANG_CHECK(funcReflection != nullptr);
@@ -485,6 +484,12 @@ SLANG_UNIT_TEST(declTreeReflection)
SLANG_CHECK(getTypeFullName(specializedMethodWithFloat->getReturnType()) == "float");
}
+ // Check getTypeFullName() on nested objects.
+ {
+ auto structType = compositeProgram->getLayout()->findTypeByName("MyNamespace::MyStruct");
+ SLANG_CHECK(getTypeFullName(structType) == "MyNamespace.MyStruct");
+ }
+
// Check iterators
{
unsigned int count = 0;