summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ast-type.cpp
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-05-29 16:36:49 -0700
committerGitHub <noreply@github.com>2025-05-29 16:36:49 -0700
commit984d7f22f8a0909dc870c65bb927094c54f55402 (patch)
treeab255bf44e14f6cbaa09522f90b12464f1c6a339 /source/slang/slang-ast-type.cpp
parentf4d7954e088966c2ae8618b1cc17aac4d64ef013 (diff)
Implement MapElement for CoopMat (#7159)
With this PR, MapElement works for the following signatures: - CoopMat<...>::MapElement(functype(...)); - CoopMat<...>::MapElement(capturing-lambda); - CoopMat<...>::MapElement(not-capturing-lambda); - Tuple<CoopMat<...>,...>::MapElement(functype(...)); - Tuple<CoopMat<...>,...>::MapElement(capturing-lambda); - Tuple<CoopMat<...>,...>::MapElement(not-capturing-lambda);
Diffstat (limited to 'source/slang/slang-ast-type.cpp')
-rw-r--r--source/slang/slang-ast-type.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp
index 18f3f90bc..7cfc6a67a 100644
--- a/source/slang/slang-ast-type.cpp
+++ b/source/slang/slang-ast-type.cpp
@@ -578,7 +578,19 @@ Val* FuncType::_substituteImplOverride(ASTBuilder* astBuilder, SubstitutionSet s
List<Type*> substParamTypes;
for (Index pp = 0; pp < getParamCount(); pp++)
{
- substParamTypes.add(as<Type>(getParamType(pp)->substituteImpl(astBuilder, subst, &diff)));
+ auto substParamType = as<Type>(getParamType(pp)->substituteImpl(astBuilder, subst, &diff));
+ if (auto typePack = as<ConcreteTypePack>(substParamType))
+ {
+ // Unwrap the ConcreteTypePack and add each element as a parameter
+ for (Index i = 0; i < typePack->getTypeCount(); ++i)
+ {
+ substParamTypes.add(typePack->getElementType(i));
+ }
+ }
+ else
+ {
+ substParamTypes.add(substParamType);
+ }
}
// early exit for no change...
@@ -774,7 +786,18 @@ Val* ConcreteTypePack::_substituteImplOverride(
for (Index i = 0; i < getTypeCount(); i++)
{
auto substType = as<Type>(getElementType(i)->substituteImpl(astBuilder, subst, &diff));
- substElementTypes.add(substType);
+ if (auto typePack = as<ConcreteTypePack>(substType))
+ {
+ // Unwrap the ConcreteTypePack and add each element as a parameter
+ for (Index j = 0; j < typePack->getTypeCount(); ++j)
+ {
+ substElementTypes.add(typePack->getElementType(j));
+ }
+ }
+ else
+ {
+ substElementTypes.add(substType);
+ }
}
if (!diff)
return this;