本文整理汇总了C++中SubstitutionList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ SubstitutionList::begin方法的具体用法?C++ SubstitutionList::begin怎么用?C++ SubstitutionList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubstitutionList
的用法示例。
在下文中一共展示了SubstitutionList::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getWitnessMethodSubstitutions
/// Compute substitutions for making a direct call to a SIL function with
/// @convention(witness_method) convention.
///
/// Such functions have a substituted generic signature where the
/// abstract `Self` parameter from the original type of the protocol
/// requirement is replaced by a concrete type.
///
/// Thus, the original substitutions of the apply instruction that
/// are written in terms of the requirement's generic signature need
/// to be remapped to substitutions suitable for the witness signature.
///
/// \param conformanceRef The (possibly-specialized) conformance
/// \param requirementSig The generic signature of the requirement
/// \param witnessThunkSig The generic signature of the witness method
/// \param origSubs The substitutions from the call instruction
/// \param newSubs New substitutions are stored here
static void getWitnessMethodSubstitutions(
SILModule &M,
ProtocolConformanceRef conformanceRef,
GenericSignature *requirementSig,
GenericSignature *witnessThunkSig,
SubstitutionList origSubs,
bool isDefaultWitness,
SmallVectorImpl<Substitution> &newSubs) {
if (witnessThunkSig == nullptr)
return;
if (isDefaultWitness) {
newSubs.append(origSubs.begin(), origSubs.end());
return;
}
assert(!conformanceRef.isAbstract());
auto conformance = conformanceRef.getConcrete();
// If `Self` maps to a bound generic type, this gives us the
// substitutions for the concrete type's generic parameters.
auto baseSubMap = getSubstitutionsForProtocolConformance(conformanceRef);
unsigned baseDepth = 0;
auto *rootConformance = conformance->getRootNormalConformance();
if (auto *witnessSig = rootConformance->getGenericSignature())
baseDepth = witnessSig->getGenericParams().back()->getDepth() + 1;
auto origDepth = 1;
auto origSubMap = requirementSig->getSubstitutionMap(origSubs);
auto subMap =
SubstitutionMap::combineSubstitutionMaps(baseSubMap,
origSubMap,
CombineSubstitutionMaps::AtDepth,
baseDepth,
origDepth,
witnessThunkSig);
witnessThunkSig->getSubstitutions(subMap, newSubs);
}
示例2: substituteVariablesWithConst
int Specialization::substituteVariablesWithConst(SgNode* node, ConstReporter* constReporter) {
typedef pair<SgExpression*,int> SubstitutionPair;
typedef list<SubstitutionPair > SubstitutionList;
SubstitutionList substitutionList;
RoseAst ast(node);
for(RoseAst::iterator i=ast.begin();i!=ast.end();++i) {
if(constReporter->isConst(*i)) {
int varIntValue=constReporter->getConstInt();
SgVarRefExp* varRefExp=constReporter->getVarRefExp();
SubstitutionPair p=make_pair(varRefExp,varIntValue);
substitutionList.push_back(p);
}
}
for(SubstitutionList::iterator i=substitutionList.begin(); i!=substitutionList.end(); ++i) {
// buildSignedIntType()
// buildFloatType()
// buildDoubleType()
// SgIntVal* buildIntVal(int)
SgNodeHelper::replaceExpression((*i).first,SageBuilder::buildIntVal((*i).second),false);
}
return (int)substitutionList.size();
}