本文整理汇总了C++中ProtocolConformanceRef::getRequirement方法的典型用法代码示例。如果您正苦于以下问题:C++ ProtocolConformanceRef::getRequirement方法的具体用法?C++ ProtocolConformanceRef::getRequirement怎么用?C++ ProtocolConformanceRef::getRequirement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtocolConformanceRef
的用法示例。
在下文中一共展示了ProtocolConformanceRef::getRequirement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
Type
ProtocolConformanceRef::getTypeWitnessByName(Type type,
ProtocolConformanceRef conformance,
Identifier name,
LazyResolver *resolver) {
// For an archetype, retrieve the nested type with the appropriate
// name. There are no conformance tables.
if (auto archetype = type->getAs<ArchetypeType>()) {
return archetype->getNestedType(name);
}
// Find the named requirement.
AssociatedTypeDecl *assocType = nullptr;
auto members = conformance.getRequirement()->lookupDirect(name);
for (auto member : members) {
assocType = dyn_cast<AssociatedTypeDecl>(member);
if (assocType)
break;
}
// FIXME: Shouldn't this be a hard error?
if (!assocType)
return nullptr;
if (conformance.isAbstract())
return DependentMemberType::get(type, assocType);
auto concrete = conformance.getConcrete();
if (!concrete->hasTypeWitness(assocType, resolver)) {
return nullptr;
}
return concrete->getTypeWitness(assocType, resolver);
}
示例2: getWitnessMethodSubstitutions
static void getWitnessMethodSubstitutions(ApplySite AI, SILFunction *F,
ProtocolConformanceRef CRef,
SmallVectorImpl<Substitution> &NewSubs) {
auto &Module = AI.getModule();
auto requirementSig = AI.getOrigCalleeType()->getGenericSignature();
auto witnessThunkSig = F->getLoweredFunctionType()->getGenericSignature();
SubstitutionList origSubs = AI.getSubstitutions();
bool isDefaultWitness =
F->getLoweredFunctionType()->getRepresentation()
== SILFunctionTypeRepresentation::WitnessMethod &&
F->getLoweredFunctionType()->getDefaultWitnessMethodProtocol(
*Module.getSwiftModule())
== CRef.getRequirement();
getWitnessMethodSubstitutions(Module, CRef, requirementSig, witnessThunkSig,
origSubs, isDefaultWitness, NewSubs);
}
示例3: getWitnessMethodSubstitutions
static SubstitutionMap
getWitnessMethodSubstitutions(SILModule &Module, ApplySite AI, SILFunction *F,
ProtocolConformanceRef CRef) {
auto witnessFnTy = F->getLoweredFunctionType();
assert(witnessFnTy->getRepresentation() ==
SILFunctionTypeRepresentation::WitnessMethod);
auto requirementSig = AI.getOrigCalleeType()->getGenericSignature();
auto witnessThunkSig = witnessFnTy->getGenericSignature();
SubstitutionMap origSubs = AI.getSubstitutionMap();
auto *mod = Module.getSwiftModule();
bool isDefaultWitness =
(witnessFnTy->getDefaultWitnessMethodProtocol()
== CRef.getRequirement());
auto *classWitness = witnessFnTy->getWitnessMethodClass(*mod);
return getWitnessMethodSubstitutions(
mod, CRef, requirementSig, witnessThunkSig,
origSubs, isDefaultWitness, classWitness);
}