本文整理汇总了C++中mangle::ASTMangler::mangleBehaviorInitThunk方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTMangler::mangleBehaviorInitThunk方法的具体用法?C++ ASTMangler::mangleBehaviorInitThunk怎么用?C++ ASTMangler::mangleBehaviorInitThunk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mangle::ASTMangler
的用法示例。
在下文中一共展示了ASTMangler::mangleBehaviorInitThunk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBehaviorInitStorageFn
static SILValue getBehaviorInitStorageFn(SILGenFunction &SGF,
VarDecl *behaviorVar) {
Mangle::ASTMangler NewMangler;
std::string behaviorInitName = NewMangler.mangleBehaviorInitThunk(behaviorVar);
SILFunction *thunkFn;
// Skip out early if we already emitted this thunk.
if (auto existing = SGF.SGM.M.lookUpFunction(behaviorInitName)) {
thunkFn = existing;
} else {
auto init = behaviorVar->getBehavior()->InitStorageDecl.getDecl();
auto initFn = SGF.SGM.getFunction(SILDeclRef(init), NotForDefinition);
// Emit a thunk to inject the `self` metatype and implode tuples.
auto storageVar = behaviorVar->getBehavior()->StorageDecl;
auto selfTy = behaviorVar->getDeclContext()->getDeclaredInterfaceType();
auto initTy = SGF.getLoweredType(selfTy).getFieldType(behaviorVar,
SGF.SGM.M);
auto storageTy = SGF.getLoweredType(selfTy).getFieldType(storageVar,
SGF.SGM.M);
auto initConstantTy = initFn->getLoweredType().castTo<SILFunctionType>();
auto param = SILParameterInfo(initTy.getASTType(),
initTy.isAddress() ? ParameterConvention::Indirect_In
: ParameterConvention::Direct_Owned);
auto result = SILResultInfo(storageTy.getASTType(),
storageTy.isAddress() ? ResultConvention::Indirect
: ResultConvention::Owned);
initConstantTy = SILFunctionType::get(initConstantTy->getGenericSignature(),
initConstantTy->getExtInfo(),
SILCoroutineKind::None,
ParameterConvention::Direct_Unowned,
param,
/*yields*/ {},
result,
// TODO: throwing initializer?
None,
SGF.getASTContext());
// TODO: Generate the body of the thunk.
thunkFn = SGF.SGM.M.getOrCreateFunction(SILLocation(behaviorVar),
behaviorInitName,
SILLinkage::PrivateExternal,
initConstantTy,
IsBare, IsTransparent, IsSerialized);
}
return SGF.B.createFunctionRef(behaviorVar, thunkFn);
}