本文整理汇总了C++中IRGenModule::getSwiftModule方法的典型用法代码示例。如果您正苦于以下问题:C++ IRGenModule::getSwiftModule方法的具体用法?C++ IRGenModule::getSwiftModule怎么用?C++ IRGenModule::getSwiftModule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRGenModule
的用法示例。
在下文中一共展示了IRGenModule::getSwiftModule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: searchNominalTypeMetadata
bool FulfillmentMap::searchNominalTypeMetadata(IRGenModule &IGM,
CanType type,
MetadataState metadataState,
unsigned source,
MetadataPath &&path,
const InterestingKeysCallback &keys) {
// Objective-C generics don't preserve their generic parameters at runtime,
// so they aren't able to fulfill type metadata requirements.
if (type.getAnyNominal()->hasClangNode()) {
return false;
}
auto *nominal = type.getAnyNominal();
if (!nominal->isGenericContext() || isa<ProtocolDecl>(nominal)) {
return false;
}
bool hadFulfillment = false;
GenericTypeRequirements requirements(IGM, nominal);
requirements.enumerateFulfillments(
IGM, type->getContextSubstitutionMap(IGM.getSwiftModule(), nominal),
[&](unsigned reqtIndex, CanType arg,
Optional<ProtocolConformanceRef> conf) {
// Skip uninteresting type arguments.
if (!keys.hasInterestingType(arg))
return;
// If the fulfilled value is type metadata, refine the path.
if (!conf) {
auto argState = getPresumedMetadataStateForTypeArgument(metadataState);
MetadataPath argPath = path;
argPath.addNominalTypeArgumentComponent(reqtIndex);
hadFulfillment |=
searchTypeMetadata(IGM, arg, IsExact, argState, source,
std::move(argPath), keys);
return;
}
// Otherwise, it's a conformance.
// Ignore it unless the type itself is interesting.
if (!keys.isInterestingType(arg))
return;
// Refine the path.
MetadataPath argPath = path;
argPath.addNominalTypeArgumentConformanceComponent(reqtIndex);
hadFulfillment |= searchWitnessTable(IGM, arg, conf->getRequirement(),
source, std::move(argPath), keys);
});
return hadFulfillment;
}
示例2: searchBoundGenericTypeMetadata
bool FulfillmentMap::searchBoundGenericTypeMetadata(IRGenModule &IGM,
CanBoundGenericType type,
unsigned source,
MetadataPath &&path,
const InterestingKeysCallback &keys) {
if (type->getDecl()->hasClangNode())
return false;
bool hadFulfillment = false;
GenericTypeRequirements requirements(IGM, type->getDecl());
requirements.enumerateFulfillments(IGM,
type->getSubstitutions(IGM.getSwiftModule(), nullptr),
[&](unsigned reqtIndex, CanType arg,
Optional<ProtocolConformanceRef> conf) {
// Skip uninteresting type arguments.
if (!keys.hasInterestingType(arg))
return;
// If the fulfilled value is type metadata, refine the path.
if (!conf) {
MetadataPath argPath = path;
argPath.addNominalTypeArgumentComponent(reqtIndex);
hadFulfillment |=
searchTypeMetadata(IGM, arg, IsExact, source, std::move(argPath), keys);
return;
}
// Otherwise, it's a conformance.
// Ignore it unless the type itself is interesting.
if (!keys.isInterestingType(arg))
return;
// Refine the path.
MetadataPath argPath = path;
argPath.addNominalTypeArgumentConformanceComponent(reqtIndex);
llvm::SmallPtrSet<ProtocolDecl*, 4> interestingConformancesBuffer;
llvm::SmallPtrSetImpl<ProtocolDecl*> *interestingConformances = nullptr;
// If the interesting-keys set is limiting the set of interesting
// conformances, collect that filter.
if (keys.hasLimitedInterestingConformances(arg)) {
// Bail out immediately if the set is empty.
auto requiredConformances = keys.getInterestingConformances(arg);
if (requiredConformances.empty()) return;
interestingConformancesBuffer.insert(requiredConformances.begin(),
requiredConformances.end());
interestingConformances = &interestingConformancesBuffer;
}
hadFulfillment |=
searchWitnessTable(IGM, arg, conf->getRequirement(), source,
std::move(argPath), keys, interestingConformances);
});
// Also match against the parent. The polymorphic type
// will start with any arguments from the parent.
hadFulfillment |= searchParentTypeMetadata(IGM, type->getDecl(),
type.getParent(),
source, std::move(path), keys);
return hadFulfillment;
}