summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-link.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-06-24 13:16:11 -0700
committerYong He <yonghe@outlook.com>2020-06-24 18:10:15 -0700
commit0ca75fe002f346f6ab9b77f40c0576d2905560f1 (patch)
treeed8a3af372900923e59f0d6da629c2d0969ee7fd /source/slang/slang-ir-link.cpp
parent3fe4f5398d524333e955ecb91be5646e86f3b2da (diff)
Dynamic dispatch for generic interface requirements.
-Lower interfaces into actual `IRInterfaceType` insts. -Lower `DeclRef<AssocTypeDecl>` into `IRAssociatedType` -Generate proper IRType for generic functions. -Add a test case exercising dynamic dispatching a generic static function through an associated type. -Bug fixes for the test case.
Diffstat (limited to 'source/slang/slang-ir-link.cpp')
-rw-r--r--source/slang/slang-ir-link.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index 3f51aa876..4e6ad74a4 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -228,6 +228,7 @@ IRInst* IRSpecContext::maybeCloneValue(IRInst* originalValue)
case kIROp_StructKey:
case kIROp_GlobalGenericParam:
case kIROp_WitnessTable:
+ case kIROp_InterfaceType:
case kIROp_TaggedUnionType:
return cloneGlobalValue(this, originalValue);
@@ -607,8 +608,7 @@ IRInterfaceType* cloneInterfaceTypeImpl(
auto clonedInterface = builder->createInterfaceType(originalInterface->getOperandCount(), nullptr);
for (UInt i = 0; i < originalInterface->getOperandCount(); i++)
{
- auto clonedKey = findClonedValue(context, originalInterface->getOperand(i));
- SLANG_ASSERT(clonedKey);
+ auto clonedKey = cloneValue(context, originalInterface->getOperand(i));
clonedInterface->setOperand(i, clonedKey);
}
cloneSimpleGlobalValueImpl(context, originalInterface, originalValues, clonedInterface);
@@ -628,6 +628,7 @@ void cloneGlobalValueWithCodeCommon(
cloneDecorations(context, clonedValue, originalValue);
cloneExtraDecorations(context, clonedValue, originalValues);
+ clonedValue->setFullType((IRType*)cloneValue(context, originalValue->getFullType()));
// We will walk through the blocks of the function, and clone each of them.
//