本文整理汇总了C++中SubstitutionList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ SubstitutionList::empty方法的具体用法?C++ SubstitutionList::empty怎么用?C++ SubstitutionList::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubstitutionList
的用法示例。
在下文中一共展示了SubstitutionList::empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeAbstractConformanceForGenericType
SubstitutionMap GenericEnvironment::
getSubstitutionMap(SubstitutionList subs) const {
SubstitutionMap result;
for (auto depTy : getGenericSignature()->getAllDependentTypes()) {
// Map the interface type to a context type.
auto contextTy = depTy.subst(QueryInterfaceTypeSubstitutions(this),
MakeAbstractConformanceForGenericType());
auto sub = subs.front();
subs = subs.slice(1);
// Record the replacement type and its conformances.
if (auto *archetype = contextTy->getAs<ArchetypeType>()) {
result.addSubstitution(CanArchetypeType(archetype), sub.getReplacement());
for (auto conformance : sub.getConformances())
result.addConformance(CanType(archetype), conformance);
continue;
}
// FIXME: getAllDependentTypes() includes generic type parameters that
// have been made concrete.
assert(contextTy->hasError() || depTy->is<GenericTypeParamType>());
}
assert(subs.empty() && "did not use all substitutions?!");
populateParentMap(result);
return result;
}
示例2: SubstitutionMap
static SubstitutionMap
getSubstitutionsForProtocolConformance(ProtocolConformanceRef CRef) {
auto C = CRef.getConcrete();
// Walk down to the base NormalProtocolConformance.
SubstitutionList Subs;
const ProtocolConformance *ParentC = C;
while (!isa<NormalProtocolConformance>(ParentC)) {
switch (ParentC->getKind()) {
case ProtocolConformanceKind::Normal:
llvm_unreachable("should have exited the loop?!");
case ProtocolConformanceKind::Inherited:
ParentC = cast<InheritedProtocolConformance>(ParentC)
->getInheritedConformance();
break;
case ProtocolConformanceKind::Specialized: {
auto SC = cast<SpecializedProtocolConformance>(ParentC);
ParentC = SC->getGenericConformance();
assert(Subs.empty() && "multiple conformance specializations?!");
Subs = SC->getGenericSubstitutions();
break;
}
}
}
const NormalProtocolConformance *NormalC
= cast<NormalProtocolConformance>(ParentC);
// 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.
if (!NormalC->getType()->isSpecialized())
return SubstitutionMap();
if (Subs.empty()) {
auto *DC = NormalC->getDeclContext();
return NormalC->getType()
->getContextSubstitutionMap(DC->getParentModule(), DC);
}
return NormalC->getGenericSignature()->getSubstitutionMap(Subs);
}
示例3: emitBuiltinCastBitPatternFromBridgeObject
static ManagedValue emitBuiltinCastBitPatternFromBridgeObject(
SILGenFunction &SGF,
SILLocation loc,
SubstitutionList 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);
}
示例4: emitOrigToSubstValue
ManagedValue
SILGenFunction::emitClosureValue(SILLocation loc, SILDeclRef constant,
CanType expectedType,
SubstitutionList subs) {
auto closure = *constant.getAnyFunctionRef();
auto captureInfo = closure.getCaptureInfo();
auto loweredCaptureInfo = SGM.Types.getLoweredLocalCaptures(closure);
auto hasCaptures = SGM.Types.hasLoweredLocalCaptures(closure);
assert(((constant.uncurryLevel == 1 && hasCaptures) ||
(constant.uncurryLevel == 0 && !hasCaptures)) &&
"curried local functions not yet supported");
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 = getForwardingSubstitutions();
}
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));
SILType closureTy =
SILGenBuilder::getPartialApplyResultType(functionRef->getType(),
capturedArgs.size(), SGM.M,
subs,
ParameterConvention::Direct_Owned);
auto toClosure =
B.createPartialApply(loc, functionRef, functionTy,
subs, forwardedArgs, closureTy);
auto result = emitManagedRValueWithCleanup(toClosure);
// Get the lowered AST types:
// - the original type
auto origLoweredFormalType =
AbstractionPattern(constantInfo.LoweredInterfaceType);
if (hasCaptures) {
// Get the unlowered formal type of the constant, stripping off
// the first level of function application, which applies captures.
origLoweredFormalType =
AbstractionPattern(constantInfo.FormalInterfaceType)
.getFunctionResultType();
// Lower it, being careful to use the right generic signature.
origLoweredFormalType =
AbstractionPattern(
origLoweredFormalType.getGenericSignature(),
SGM.Types.getLoweredASTFunctionType(
cast<FunctionType>(origLoweredFormalType.getType()),
0, constant));
}
// - the substituted type
auto substFormalType = cast<FunctionType>(expectedType);
auto substLoweredFormalType =
SGM.Types.getLoweredASTFunctionType(substFormalType, 0, constant);
// Generalize if necessary.
result = emitOrigToSubstValue(loc, result, origLoweredFormalType,
//.........这里部分代码省略.........