From 8f962894fd38edb47d782d303ac9ff87b3a3bb6a Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 4 Sep 2020 10:18:44 -0700 Subject: Allow mixing unspecialized and specialized existential parameters. (#1533) * Allow mixing unspecialized and specialized existential parameters. * Fixes. --- source/slang/slang-ir.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir.cpp') 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 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`. // 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(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: -- cgit v1.2.3