当前位置: 首页>>代码示例>>C++>>正文


C++ ProtocolConformanceRef::getRequirement方法代码示例

本文整理汇总了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);
}
开发者ID:XLsn0wKit,项目名称:swift,代码行数:33,代码来源:ProtocolConformance.cpp

示例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);
}
开发者ID:herculesjr,项目名称:swift,代码行数:20,代码来源:Devirtualize.cpp

示例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);
}
开发者ID:frsoares,项目名称:swift,代码行数:22,代码来源:Devirtualize.cpp


注:本文中的ProtocolConformanceRef::getRequirement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。