本文整理汇总了C++中SILGenFunction::emitDynamicMethodRef方法的典型用法代码示例。如果您正苦于以下问题:C++ SILGenFunction::emitDynamicMethodRef方法的具体用法?C++ SILGenFunction::emitDynamicMethodRef怎么用?C++ SILGenFunction::emitDynamicMethodRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SILGenFunction
的用法示例。
在下文中一共展示了SILGenFunction::emitDynamicMethodRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SILDeclRef
static std::pair<ManagedValue, SILDeclRef>
getNextUncurryLevelRef(SILGenFunction &SGF, SILLocation loc, SILDeclRef thunk,
ManagedValue selfArg, SubstitutionMap curriedSubs) {
auto *vd = thunk.getDecl();
// Reference the next uncurrying level of the function.
SILDeclRef next = SILDeclRef(vd, thunk.kind);
assert(!next.isCurried);
auto constantInfo = SGF.SGM.Types.getConstantInfo(next);
// If the function is natively foreign, reference its foreign entry point.
if (requiresForeignToNativeThunk(vd))
return {ManagedValue::forUnmanaged(SGF.emitGlobalFunctionRef(loc, next)),
next};
// If the thunk is a curry thunk for a direct method reference, we are
// doing a direct dispatch (eg, a fragile 'super.foo()' call).
if (thunk.isDirectReference)
return {ManagedValue::forUnmanaged(SGF.emitGlobalFunctionRef(loc, next)),
next};
if (auto *func = dyn_cast<AbstractFunctionDecl>(vd)) {
if (getMethodDispatch(func) == MethodDispatch::Class) {
// Use the dynamic thunk if dynamic.
if (vd->isObjCDynamic()) {
return {SGF.emitDynamicMethodRef(loc, next, constantInfo.SILFnType),
next};
}
auto methodTy = SGF.SGM.Types.getConstantOverrideType(next);
SILValue result =
SGF.emitClassMethodRef(loc, selfArg.getValue(), next, methodTy);
return {ManagedValue::forUnmanaged(result),
next.getOverriddenVTableEntry()};
}
// If the fully-uncurried reference is to a generic method, look up the
// witness.
if (constantInfo.SILFnType->getRepresentation()
== SILFunctionTypeRepresentation::WitnessMethod) {
auto protocol = func->getDeclContext()->getSelfProtocolDecl();
auto origSelfType = protocol->getSelfInterfaceType()->getCanonicalType();
auto substSelfType = origSelfType.subst(curriedSubs)->getCanonicalType();
auto conformance = curriedSubs.lookupConformance(origSelfType, protocol);
auto result = SGF.B.createWitnessMethod(loc, substSelfType, *conformance,
next, constantInfo.getSILType());
return {ManagedValue::forUnmanaged(result), next};
}
}
// Otherwise, emit a direct call.
return {ManagedValue::forUnmanaged(SGF.emitGlobalFunctionRef(loc, next)),
next};
}