From 453683bf44f2112719802eaac2b332d49eebd640 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 19 Aug 2024 15:03:56 -0700 Subject: Tuple swizzling, concat, comparison and `countof`. (#4856) * Tuple swizzling and element access. * Update proposal status. * Cleanup. * Fix merrge error. * Address review. --- source/slang/slang-ast-builder.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ast-builder.cpp') diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index 3a2b2933d..a13e13851 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -572,9 +572,26 @@ Type* ASTBuilder::getExpandType(Type* pattern, ArrayView capturedPacks) return getOrCreate(pattern, capturedPacks); } +void flattenTypeList(ShortList& flattenedList, Type* type) +{ + if (auto typePack = as(type)) + { + for (Index i = 0; i < typePack->getTypeCount(); i++) + flattenTypeList(flattenedList, typePack->getElementType(i)); + } + else + { + flattenedList.add(type); + } +} + ConcreteTypePack* ASTBuilder::getTypePack(ArrayView types) { - return getOrCreate(types); + // Flatten all type packs in the type list. + ShortList flattenedTypes; + for (auto type : types) + flattenTypeList(flattenedTypes, type); + return getOrCreate(flattenedTypes.getArrayView().arrayView); } TypeEqualityWitness* ASTBuilder::getTypeEqualityWitness( -- cgit v1.2.3