diff options
| author | Yong He <yonghe@outlook.com> | 2024-08-19 15:03:56 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-19 15:03:56 -0700 |
| commit | 453683bf44f2112719802eaac2b332d49eebd640 (patch) | |
| tree | d399db4c9cba90c11980186d3df1ffcc4d423b5a /source/slang/slang-ast-builder.cpp | |
| parent | ecf85df6eee3da76ef54b14e4ab083f22da89e46 (diff) | |
Tuple swizzling, concat, comparison and `countof`. (#4856)
* Tuple swizzling and element access.
* Update proposal status.
* Cleanup.
* Fix merrge error.
* Address review.
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
| -rw-r--r-- | source/slang/slang-ast-builder.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
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<Type*> capturedPacks) return getOrCreate<ExpandType>(pattern, capturedPacks); } +void flattenTypeList(ShortList<Type*>& flattenedList, Type* type) +{ + if (auto typePack = as<ConcreteTypePack>(type)) + { + for (Index i = 0; i < typePack->getTypeCount(); i++) + flattenTypeList(flattenedList, typePack->getElementType(i)); + } + else + { + flattenedList.add(type); + } +} + ConcreteTypePack* ASTBuilder::getTypePack(ArrayView<Type*> types) { - return getOrCreate<ConcreteTypePack>(types); + // Flatten all type packs in the type list. + ShortList<Type*> flattenedTypes; + for (auto type : types) + flattenTypeList(flattenedTypes, type); + return getOrCreate<ConcreteTypePack>(flattenedTypes.getArrayView().arrayView); } TypeEqualityWitness* ASTBuilder::getTypeEqualityWitness( |
