summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-com-interface.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-06-02 14:13:35 -0400
committerGitHub <noreply@github.com>2022-06-02 14:13:35 -0400
commitb39c99661b3ad482bbd419c24991ed325b5738a9 (patch)
tree0f90fecdae10e704b2c1135c48ca5eeafa60b780 /source/slang/slang-ir-com-interface.cpp
parentbc6bc56db51d06b92dc63ef9c9e0def6c9760c9e (diff)
COM interfaces with host callable (#2258)
* #include an absolute path didn't work - because paths were taken to always be relative. * Use TerminatedUnownedStringSlice for literals in output C++. * Remove Escape/Unescape functions used in slang-token-reader.cpp Add target type of 'host-cpp' etc to map to the target types. * Fix some corner cases around string encoding. * Added unit test for string escaping. Fixed some assorted escaping bugs. * Updated test output. * Added decode test. * Stop using hex output, to get around 'greedy' aspect. Use octal instead. * Added HostHostCallable Small changes to use ArtifactDesc/Info instead of large switches. * Fix C++ emit to handle arbitrary function export. * Add options handling for callable without an output being specified. * Can compile with COM interface. Added example using com interface. * Use the IR Ptr type instead of hack in C++ emit for interfaces. * Fix issue with outputting the COM call when ptr is used. * Fix crash issue on compilation failure.
Diffstat (limited to 'source/slang/slang-ir-com-interface.cpp')
-rw-r--r--source/slang/slang-ir-com-interface.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/source/slang/slang-ir-com-interface.cpp b/source/slang/slang-ir-com-interface.cpp
index 1bcf3d2b6..009d2314d 100644
--- a/source/slang/slang-ir-com-interface.cpp
+++ b/source/slang/slang-ir-com-interface.cpp
@@ -12,9 +12,9 @@ struct ComInterfaceLoweringContext
IRModule* module;
DiagnosticSink* diagnosticSink;
- SharedIRBuilder sharedBuilder;
+ ArtifactStyle artifactStyle;
- Dictionary<IRInterfaceType*, IRComPtrType*> comPtrTypes;
+ SharedIRBuilder sharedBuilder;
void replaceTypeUses(IRInst* inst, IRInst* newValue)
{
@@ -33,6 +33,7 @@ struct ComInterfaceLoweringContext
case kIROp_RTTIPointerType:
case kIROp_RTTIHandleType:
case kIROp_ComPtrType:
+ case kIROp_PtrType:
continue;
default:
break;
@@ -41,19 +42,17 @@ struct ComInterfaceLoweringContext
}
}
- IRComPtrType* processInterfaceType(IRInterfaceType* type)
+ IRType* processInterfaceType(IRInterfaceType* type)
{
if (!type->findDecoration<IRComInterfaceDecoration>())
return nullptr;
-
- IRComPtrType* result = nullptr;
-
- if (comPtrTypes.TryGetValue(type, result))
- return result;
-
+
IRBuilder builder(sharedBuilder);
builder.setInsertInto(module->getModuleInst());
- result = builder.getComPtrType(type);
+
+ IRType* result = (artifactStyle == ArtifactStyle::Kernel) ?
+ static_cast<IRType*>(builder.getPtrType(type)) :
+ static_cast<IRType*>(builder.getComPtrType(type));
replaceTypeUses(type, result);
return result;
@@ -86,11 +85,12 @@ struct ComInterfaceLoweringContext
}
};
-void lowerComInterfaces(IRModule* module, DiagnosticSink* sink)
+void lowerComInterfaces(IRModule* module, ArtifactStyle artifactStyle, DiagnosticSink* sink)
{
ComInterfaceLoweringContext context;
context.module = module;
context.diagnosticSink = sink;
+ context.artifactStyle = artifactStyle;
context.sharedBuilder.init(module);
return context.processModule();
}