summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-09-04 10:18:44 -0700
committerGitHub <noreply@github.com>2020-09-04 10:18:44 -0700
commit8f962894fd38edb47d782d303ac9ff87b3a3bb6a (patch)
tree449d0d58ca7d90a11759372c9dc82650a565f96a /source/slang/slang-ir.cpp
parent5e10f1b4f0654515af1fcb29e8d1f35e691c8aa3 (diff)
Allow mixing unspecialized and specialized existential parameters. (#1533)
* Allow mixing unspecialized and specialized existential parameters. * Fixes.
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 2f27bbebc..37841c35f 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -2232,6 +2232,8 @@ namespace Slang
return (IRStringType*)getType(kIROp_StringType);
}
+ IRDynamicType* IRBuilder::getDynamicType() { return (IRDynamicType*)getType(kIROp_DynamicType); }
+
IRAssociatedType* IRBuilder::getAssociatedType(ArrayView<IRInterfaceType*> constraintTypes)
{
return (IRAssociatedType*)getType(kIROp_AssociatedType,
@@ -2331,6 +2333,12 @@ namespace Slang
operands);
}
+ IRExistentialBoxType* IRBuilder::getExistentialBoxType(IRType* concreteType, IRType* interfaceType)
+ {
+ IRInst* operands[] = {concreteType, interfaceType};
+ return (IRExistentialBoxType*)getType(kIROp_ExistentialBoxType, 2, operands);
+ }
+
IRArrayTypeBase* IRBuilder::getArrayTypeBase(
IROp op,
IRType* elementType,
@@ -2471,7 +2479,7 @@ namespace Slang
// so we just want to return `ExistentialBox<someConcreteType>`.
//
auto concreteType = (IRType*) slotArgs[0];
- auto ptrType = getPtrType(kIROp_ExistentialBoxType, concreteType);
+ auto ptrType = getExistentialBoxType(concreteType, (IRType*)baseType);
return ptrType;
}
}
@@ -2524,6 +2532,14 @@ namespace Slang
}
}
+ IRInst* IRBuilder::emitGetValueFromExistentialBox(IRType* type, IRInst* existentialBox)
+ {
+ auto inst =
+ createInst<IRInst>(this, kIROp_GetValueFromExistentialBox, type, 1, &existentialBox);
+ addInst(inst);
+ return inst;
+ }
+
IRUndefined* IRBuilder::emitUndefined(IRType* type)
{
@@ -5273,6 +5289,7 @@ namespace Slang
case kIROp_Specialize:
case kIROp_lookup_interface_method:
case kIROp_getAddr:
+ case kIROp_GetValueFromExistentialBox:
case kIROp_Construct:
case kIROp_makeVector:
case kIROp_MakeMatrix: