From 8c6e02bd094bbc0c9afb141265be9675f99ddb61 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 17 Jun 2020 22:41:56 -0700 Subject: Dynamic dipatch non-static functions. --- source/slang/slang-emit-cpp.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/slang/slang-emit-cpp.h') diff --git a/source/slang/slang-emit-cpp.h b/source/slang/slang-emit-cpp.h index b8afc6a76..47ba03d70 100644 --- a/source/slang/slang-emit-cpp.h +++ b/source/slang/slang-emit-cpp.h @@ -71,6 +71,7 @@ protected: virtual bool tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOuterPrec) SLANG_OVERRIDE; virtual void emitPreprocessorDirectivesImpl() SLANG_OVERRIDE; virtual void emitSimpleValueImpl(IRInst* value) SLANG_OVERRIDE; + virtual void emitSimpleFuncParamImpl(IRParam* param) SLANG_OVERRIDE; virtual void emitModuleImpl(IRModule* module) SLANG_OVERRIDE; virtual void emitSimpleFuncImpl(IRFunc* func) SLANG_OVERRIDE; virtual void emitOperandImpl(IRInst* inst, EmitOpInfo const& outerPrec) SLANG_OVERRIDE; @@ -117,6 +118,10 @@ protected: UnownedStringSlice _getFuncName(const HLSLIntrinsic* specOp); + // Returns a StringSlice representing the mangled name of a witness table + // wrapper function. + UnownedStringSlice _getWitnessTableWrapperFuncName(IRFunc* func); + UnownedStringSlice _getTypeName(IRType* type); SlangResult _calcCPPTextureTypeName(IRTextureTypeBase* texType, StringBuilder& outName); @@ -134,12 +139,20 @@ protected: // of all the witness table objects in `pendingWitnessTableDefinitions`. void _emitWitnessTableDefinitions(); + // Emit wrapper functions that are referenced in witness tables. + // Wrapper functions wraps the actual member function, and takes a `void*` + // as the `this` parameter instead of the actual object type, so that + // their signature is agnostic to the object type. + void _emitWitnessTableWrappers(); + HLSLIntrinsic* _addIntrinsic(HLSLIntrinsic::Op op, IRType* returnType, IRType*const* argTypes, Index argTypeCount); static bool _isVariable(IROp op); Dictionary m_typeNameMap; Dictionary m_intrinsicNameMap; + Dictionary m_witnessTableWrapperFuncNameMap; + IRTypeSet m_typeSet; RefPtr m_opLookup; -- cgit v1.2.3