diff options
| author | Yong He <yonghe@outlook.com> | 2024-08-18 21:57:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-18 21:57:24 -0700 |
| commit | ecf85df6eee3da76ef54b14e4ab083f22da89e46 (patch) | |
| tree | 4656f9c11a1f7f40550d469fecbcd7a16c541f52 /source/slang/slang-ast-builder.cpp | |
| parent | ca5d303748517889a5d5849224671fa8945e1c6d (diff) | |
Variadic Generics Part 2: IR lowering and specialization. (#4849)
* Variadic Generics Part 2: IR lowering and specialization.
* Update design doc status.
* Update design doc.
* Resolve review comments.
Diffstat (limited to 'source/slang/slang-ast-builder.cpp')
| -rw-r--r-- | source/slang/slang-ast-builder.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index faf15470f..3a2b2933d 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -525,7 +525,19 @@ FuncType* ASTBuilder::getFuncType(ArrayView<Type*> parameters, Type* result, Typ TupleType* ASTBuilder::getTupleType(List<Type*>& types) { - return getOrCreate<TupleType>(types.getArrayView()); + // The canonical form of a tuple type is always a DeclRefType(GenAppDeclRef(TupleDecl, ConcreteTypePack(types...))). + // If `types` is already a single ConcreteTypePack, then we can use that directly. + if (types.getCount() == 1) + { + if (isTypePack(types[0])) + { + return as<TupleType>(getSpecializedBuiltinType(types[0], "TupleType")); + } + } + + // Otherwise, we need to create a ConcreteTypePack to hold the types. + auto typePack = getTypePack(types.getArrayView()); + return as<TupleType>(getSpecializedBuiltinType(typePack, "TupleType")); } TypeType* ASTBuilder::getTypeType(Type* type) |
