本文整理汇总了C++中SILGenFunction::emitRValueForDecl方法的典型用法代码示例。如果您正苦于以下问题:C++ SILGenFunction::emitRValueForDecl方法的具体用法?C++ SILGenFunction::emitRValueForDecl怎么用?C++ SILGenFunction::emitRValueForDecl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SILGenFunction
的用法示例。
在下文中一共展示了SILGenFunction::emitRValueForDecl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitSelfForMemberInit
static ManagedValue emitSelfForMemberInit(SILGenFunction &SGF, SILLocation loc,
VarDecl *selfDecl) {
CanType selfFormalType = selfDecl->getType()->getCanonicalType();
if (selfFormalType->hasReferenceSemantics())
return SGF.emitRValueForDecl(loc, selfDecl, selfFormalType,
AccessSemantics::DirectToStorage,
SGFContext::AllowImmediatePlusZero)
.getAsSingleValue(SGF, loc);
else
return SGF.emitAddressOfLocalVarDecl(loc, selfDecl, selfFormalType,
SGFAccessKind::Write);
}
示例2: emitMemberInit
/// Emit a member initialization for the members described in the
/// given pattern from the given source value.
static void emitMemberInit(SILGenFunction &SGF, VarDecl *selfDecl,
Pattern *pattern, RValue &&src) {
switch (pattern->getKind()) {
case PatternKind::Paren:
return emitMemberInit(SGF, selfDecl,
cast<ParenPattern>(pattern)->getSubPattern(),
std::move(src));
case PatternKind::Tuple: {
auto tuple = cast<TuplePattern>(pattern);
auto fields = tuple->getElements();
SmallVector<RValue, 4> elements;
std::move(src).extractElements(elements);
for (unsigned i = 0, n = fields.size(); i != n; ++i) {
emitMemberInit(SGF, selfDecl, fields[i].getPattern(),
std::move(elements[i]));
}
break;
}
case PatternKind::Named: {
auto named = cast<NamedPattern>(pattern);
// Form the lvalue referencing this member.
WritebackScope scope(SGF);
SILLocation loc = pattern;
ManagedValue self;
CanType selfFormalType = selfDecl->getType()
->getInOutObjectType()->getCanonicalType();
if (selfFormalType->hasReferenceSemantics())
self = SGF.emitRValueForDecl(loc, selfDecl, selfDecl->getType(),
AccessSemantics::DirectToStorage,
SGFContext::AllowImmediatePlusZero)
.getAsSingleValue(SGF, loc);
else
self = SGF.emitLValueForDecl(loc, selfDecl,
src.getType()->getCanonicalType(),
AccessKind::Write,
AccessSemantics::DirectToStorage);
LValue memberRef =
SGF.emitPropertyLValue(loc, self, selfFormalType, named->getDecl(),
AccessKind::Write,
AccessSemantics::DirectToStorage);
// Assign to it.
SGF.emitAssignToLValue(loc, std::move(src), std::move(memberRef));
return;
}
case PatternKind::Any:
return;
case PatternKind::Typed:
return emitMemberInit(SGF, selfDecl,
cast<TypedPattern>(pattern)->getSubPattern(),
std::move(src));
case PatternKind::Var:
return emitMemberInit(SGF, selfDecl,
cast<VarPattern>(pattern)->getSubPattern(),
std::move(src));
#define PATTERN(Name, Parent)
#define REFUTABLE_PATTERN(Name, Parent) case PatternKind::Name:
#include "swift/AST/PatternNodes.def"
llvm_unreachable("Refutable pattern in pattern binding");
}
}