本文整理汇总了C++中SubstitutionMap::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ SubstitutionMap::empty方法的具体用法?C++ SubstitutionMap::empty怎么用?C++ SubstitutionMap::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubstitutionMap
的用法示例。
在下文中一共展示了SubstitutionMap::empty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConcreteDeclRef
Witness::Witness(ValueDecl *decl, SubstitutionMap substitutions,
GenericEnvironment *syntheticEnv,
SubstitutionMap reqToSynthesizedEnvSubs) {
if (!syntheticEnv && substitutions.empty() &&
reqToSynthesizedEnvSubs.empty()) {
storage = decl;
return;
}
auto &ctx = decl->getASTContext();
auto declRef = ConcreteDeclRef(decl, substitutions);
auto storedMem = ctx.Allocate(sizeof(StoredWitness), alignof(StoredWitness));
auto stored = new (storedMem) StoredWitness{declRef, syntheticEnv,
reqToSynthesizedEnvSubs};
storage = stored;
}
示例2: emitBuiltinClassifyBridgeObject
static ManagedValue emitBuiltinClassifyBridgeObject(SILGenFunction &SGF,
SILLocation loc,
SubstitutionMap subs,
ArrayRef<ManagedValue> args,
SGFContext C) {
assert(args.size() == 1 && "classify should have one argument");
assert(subs.empty() && "classify should not have subs");
SILValue result = SGF.B.createClassifyBridgeObject(loc, args[0].getValue());
return ManagedValue::forUnmanaged(result);
}
示例3: getSubstitutions
SubstitutionMap ProtocolConformance::getSubstitutions(ModuleDecl *M) const {
// Walk down to the base NormalProtocolConformance.
SubstitutionMap subMap;
const ProtocolConformance *parent = this;
while (!isa<NormalProtocolConformance>(parent)) {
switch (parent->getKind()) {
case ProtocolConformanceKind::Normal:
llvm_unreachable("should have exited the loop?!");
case ProtocolConformanceKind::Inherited:
parent =
cast<InheritedProtocolConformance>(parent)->getInheritedConformance();
break;
case ProtocolConformanceKind::Specialized: {
auto SC = cast<SpecializedProtocolConformance>(parent);
parent = SC->getGenericConformance();
assert(subMap.empty() && "multiple conformance specializations?!");
subMap = SC->getSubstitutionMap();
break;
}
}
}
// Found something; we're done!
if (!subMap.empty())
return subMap;
// If the normal conformance is for a generic type, and we didn't hit a
// specialized conformance, collect the substitutions from the generic type.
// FIXME: The AST should do this for us.
const NormalProtocolConformance *normalC =
cast<NormalProtocolConformance>(parent);
if (!normalC->getType()->isSpecialized())
return SubstitutionMap();
auto *DC = normalC->getDeclContext();
return normalC->getType()->getContextSubstitutionMap(M, DC);
}
示例4: emitBuiltinCastBitPatternFromBridgeObject
static ManagedValue emitBuiltinCastBitPatternFromBridgeObject(
SILGenFunction &SGF,
SILLocation loc,
SubstitutionMap subs,
ArrayRef<ManagedValue> args,
SGFContext C) {
assert(args.size() == 1 && "cast should have one argument");
assert(subs.empty() && "cast should not have subs");
SILType wordType = SILType::getBuiltinWordType(SGF.getASTContext());
SILValue result = SGF.B.createBridgeObjectToWord(loc, args[0].getValue(),
wordType);
return ManagedValue::forUnmanaged(result);
}
示例5: getPartialApplyResultType
SILType SILBuilder::getPartialApplyResultType(SILType origTy, unsigned argCount,
SILModule &M,
SubstitutionMap subs,
ParameterConvention calleeConvention,
PartialApplyInst::OnStackKind onStack) {
CanSILFunctionType FTI = origTy.castTo<SILFunctionType>();
if (!subs.empty())
FTI = FTI->substGenericArgs(M, subs);
assert(!FTI->isPolymorphic()
&& "must provide substitutions for generic partial_apply");
auto params = FTI->getParameters();
auto newParams = params.slice(0, params.size() - argCount);
auto extInfo = FTI->getExtInfo()
.withRepresentation(SILFunctionType::Representation::Thick)
.withIsPseudogeneric(false);
if (onStack)
extInfo = extInfo.withNoEscape();
// If the original method has an @unowned_inner_pointer return, the partial
// application thunk will lifetime-extend 'self' for us, converting the
// return value to @unowned.
//
// If the original method has an @autoreleased return, the partial application
// thunk will retain it for us, converting the return value to @owned.
SmallVector<SILResultInfo, 4> results;
results.append(FTI->getResults().begin(), FTI->getResults().end());
for (auto &result : results) {
if (result.getConvention() == ResultConvention::UnownedInnerPointer)
result = SILResultInfo(result.getType(), ResultConvention::Unowned);
else if (result.getConvention() == ResultConvention::Autoreleased)
result = SILResultInfo(result.getType(), ResultConvention::Owned);
}
auto appliedFnType = SILFunctionType::get(nullptr, extInfo,
FTI->getCoroutineKind(),
calleeConvention,
newParams,
FTI->getYields(),
results,
FTI->getOptionalErrorResult(),
M.getASTContext());
return SILType::getPrimitiveObjectType(appliedFnType);
}
示例6: emitBuiltinEndUnpairedAccess
/// Specialized emitter for Builtin.endUnpairedAccessModifyAccess.
static ManagedValue emitBuiltinEndUnpairedAccess(SILGenFunction &SGF,
SILLocation loc,
SubstitutionMap substitutions,
ArrayRef<ManagedValue> args,
SGFContext C) {
assert(substitutions.empty() &&
"Builtin.endUnpairedAccess should have no substitutions");
assert(args.size() == 1 &&
"endUnpairedAccess should be given one argument");
SILType valueBufferTy =
SGF.getLoweredType(SGF.getASTContext().TheUnsafeValueBufferType);
SILValue buffer = SGF.B.createPointerToAddress(loc,
args[0].getUnmanagedValue(),
valueBufferTy.getAddressType(),
/*strict*/ true,
/*invariant*/ false);
SGF.B.createEndUnpairedAccess(loc, buffer, SILAccessEnforcement::Dynamic,
/*aborted*/ false,
/*fromBuiltin*/ true);
return ManagedValue::forUnmanaged(SGF.emitEmptyTuple(loc));
}
示例7: emitOrigToSubstValue
ManagedValue
SILGenFunction::emitClosureValue(SILLocation loc, SILDeclRef constant,
CanType expectedType,
SubstitutionMap subs) {
auto closure = *constant.getAnyFunctionRef();
auto captureInfo = closure.getCaptureInfo();
auto loweredCaptureInfo = SGM.Types.getLoweredLocalCaptures(closure);
auto hasCaptures = SGM.Types.hasLoweredLocalCaptures(closure);
auto constantInfo = getConstantInfo(constant);
SILValue functionRef = emitGlobalFunctionRef(loc, constant, constantInfo);
SILType functionTy = functionRef->getType();
// Apply substitutions.
auto pft = constantInfo.SILFnType;
auto *dc = closure.getAsDeclContext()->getParent();
if (dc->isLocalContext() && !loweredCaptureInfo.hasGenericParamCaptures()) {
// If the lowered function type is not polymorphic but we were given
// substitutions, we have a closure in a generic context which does not
// capture generic parameters. Just drop the substitutions.
subs = { };
} else if (closure.getAbstractClosureExpr()) {
// If we have a closure expression in generic context, Sema won't give
// us substitutions, so we just use the forwarding substitutions from
// context.
subs = getForwardingSubstitutionMap();
}
bool wasSpecialized = false;
if (!subs.empty()) {
auto specialized = pft->substGenericArgs(F.getModule(), subs);
functionTy = SILType::getPrimitiveObjectType(specialized);
wasSpecialized = true;
}
// If we're in top-level code, we don't need to physically capture script
// globals, but we still need to mark them as escaping so that DI can flag
// uninitialized uses.
if (this == SGM.TopLevelSGF) {
SGM.emitMarkFunctionEscapeForTopLevelCodeGlobals(
loc, captureInfo);
}
if (!hasCaptures && !wasSpecialized) {
auto result = ManagedValue::forUnmanaged(functionRef);
return emitOrigToSubstValue(loc, result,
AbstractionPattern(expectedType),
expectedType);
}
SmallVector<ManagedValue, 4> capturedArgs;
emitCaptures(loc, closure, CaptureEmission::PartialApplication,
capturedArgs);
// The partial application takes ownership of the context parameters.
SmallVector<SILValue, 4> forwardedArgs;
for (auto capture : capturedArgs)
forwardedArgs.push_back(capture.forward(*this));
auto calleeConvention = ParameterConvention::Direct_Guaranteed;
SILType closureTy = SILGenBuilder::getPartialApplyResultType(
functionRef->getType(), capturedArgs.size(), SGM.M, subs,
calleeConvention);
auto toClosure =
B.createPartialApply(loc, functionRef, functionTy,
subs, forwardedArgs, closureTy);
auto result = emitManagedRValueWithCleanup(toClosure);
// Get the lowered AST types:
// - the original type
auto origFormalType = AbstractionPattern(constantInfo.LoweredType);
// - the substituted type
auto substFormalType = expectedType;
// Generalize if necessary.
result = emitOrigToSubstValue(loc, result, origFormalType,
substFormalType);
return result;
}