summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-type-layout.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-12-18 11:33:55 -0800
committerGitHub <noreply@github.com>2024-12-18 11:33:55 -0800
commitae04e604d43d169bcba7f24c8c23a0fdf4cbb483 (patch)
tree899c872ec5cc5c6ccc27930ef6971a0baf018569 /source/slang/slang-type-layout.cpp
parent41c627fd420a644f0ae86e36f4752e820e2d683c (diff)
Allow `Optional`, `Tuple` and `bool` to be used in varying input/output. (#5889)
* Allow `Optional` and `Tuple` to be used in varying input/output. * Fix. * format code * Fix. * Fix test. * Fix. * enhance test. * Fix. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-type-layout.cpp')
-rw-r--r--source/slang/slang-type-layout.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index b54f813dd..17f1ae677 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -4785,10 +4785,18 @@ static TypeLayoutResult _createTypeLayout(TypeLayoutContext& context, Type* type
type,
rules);
}
+ else if (auto optionalType = as<OptionalType>(type))
+ {
+ // OptionalType should be laid out the same way as Tuple<T, bool>.
+ Array<Type*, 2> types =
+ makeArray(optionalType->getValueType(), context.astBuilder->getBoolType());
+ auto tupleType = context.astBuilder->getTupleType(types.getView());
+ return _createTypeLayout(context, tupleType);
+ }
else if (auto tupleType = as<TupleType>(type))
{
// A `Tuple` type is laid out exactly the same way as a `struct` type,
- // except that we want have a declref to the field.
+ // except that we won't have a declref to the field.
StructTypeLayoutBuilder typeLayoutBuilder;
StructTypeLayoutBuilder pendingDataTypeLayoutBuilder;