summaryrefslogtreecommitdiff
path: root/tools/slang-reflection-test
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-06-27 11:28:14 -0400
committerGitHub <noreply@github.com>2023-06-27 11:28:14 -0400
commit1b01ff909afa1eb6700c0dc947e679b9c3890880 (patch)
treeac532105009303c65c5a6ad4f3dad8041c99e362 /tools/slang-reflection-test
parent4c9e4de4b68f2612a39e8783e9da89605ecf54e0 (diff)
Pointer layout support (#2930)
* WIP looking at reflection with pointers. * Added GetPointerLayout. * Initial test via reflection with layout of ptr type. * WIP handles ptrs to types that have layout that hasn't been completed. * Move tests to ptr. * WIP try to take into account lowering correctly between AggTypeDecl and Type, but doesn't quite work. * WIP a different path to handling recursive lowering problem with Ptr. * Fix issues with reflection output. * Small tidy. * Fix for infinite recursion issue. * Lower IRPointerTypeLayout * Working with generics. Has a hack to work around Layout around Ptr in IR. The reflection around the generic - the name isn't much use, it should probably have the generic parameters, but that would require getName to do something more sophisticated. * Fix issue around calling finishOuterGenerics to early. * Remove feature/ptr test. * Fix type legalization being an infinite loop with Ptr self referencing. * Disable the pointer self reference test because produces an infintie loop on emit. * Fixed comment based on review. * Fix for issue with emit and pointers causing infinite recursion.
Diffstat (limited to 'tools/slang-reflection-test')
-rw-r--r--tools/slang-reflection-test/slang-reflection-test-main.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/slang-reflection-test/slang-reflection-test-main.cpp b/tools/slang-reflection-test/slang-reflection-test-main.cpp
index 94062cf2b..cd726eb59 100644
--- a/tools/slang-reflection-test/slang-reflection-test-main.cpp
+++ b/tools/slang-reflection-test/slang-reflection-test-main.cpp
@@ -292,6 +292,7 @@ static void emitReflectionVarBindingInfoJSON(
CASE(MIXED, mixed);
CASE(REGISTER_SPACE, registerSpace);
CASE(GENERIC, generic);
+
#undef CASE
default:
@@ -769,6 +770,16 @@ static void emitReflectionTypeInfoJSON(
emitReflectionTypeJSON(writer, arrayType->getElementType());
}
break;
+ case slang::TypeReflection::Kind::Pointer:
+ {
+ auto pointerType = type;
+ writer.maybeComma();
+ writer << "\"kind\": \"pointer\"";
+ writer.maybeComma();
+ writer << "\"targetType\": ";
+ emitReflectionTypeJSON(writer, pointerType->getElementType());
+ }
+ break;
case slang::TypeReflection::Kind::Struct:
{
@@ -888,6 +899,40 @@ static void emitReflectionTypeLayoutInfoJSON(
emitReflectionTypeInfoJSON(writer, typeLayout->getType());
break;
+ case slang::TypeReflection::Kind::Pointer:
+ {
+ auto valueTypeLayout = typeLayout->getElementTypeLayout();
+ SLANG_ASSERT(valueTypeLayout);
+
+ writer.maybeComma();
+ writer << "\"kind\": \"pointer\"";
+
+ writer.maybeComma();
+ writer << "\"valueType\": ";
+
+ auto typeName = valueTypeLayout->getType()->getName();
+
+ if (typeName && typeName[0])
+ {
+ // TODO(JS):
+ // We can't emit the type layout, because the type could contain
+ // a pointer and we end up in a recursive loop. For now we output the typename.
+ writer.writeEscapedString(UnownedStringSlice(typeName));
+ }
+ else
+ {
+ // TODO(JS): We will need to generate name that we will associate with this type
+ // as it doesn't seem to have one
+ writer.writeEscapedString(toSlice("unknown name!"));
+ SLANG_ASSERT(!"Doesn't have an associated name");
+ }
+
+ /*
+ emitReflectionTypeLayoutJSON(
+ writer,
+ valueTypeLayout); */
+ }
+ break;
case slang::TypeReflection::Kind::Array:
{
auto arrayTypeLayout = typeLayout;