MCPcopy Create free account
hub / github.com/bytedance/bolt / resolveFunction

Method resolveFunction

bolt/expression/SimpleFunctionRegistry.cpp:114–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114std::optional<SimpleFunctionRegistry::ResolvedSimpleFunction>
115SimpleFunctionRegistry::resolveFunction(
116 const std::string& name,
117 const std::vector<TypePtr>& argTypes) const {
118 const FunctionEntry* selectedCandidate = nullptr;
119 TypePtr selectedCandidateType = nullptr;
120 registeredFunctions_.withRLock([&](const auto& map) {
121 if (const auto* signatureMap = getSignatureMap(name, map)) {
122 for (const auto& [candidateSignature, functionEntry] : *signatureMap) {
123 SignatureBinder binder(candidateSignature, argTypes);
124 if (binder.tryBind()) {
125 auto* currentCandidate = functionEntry.get();
126 if (!selectedCandidate ||
127 currentCandidate->getMetadata().priority() <
128 selectedCandidate->getMetadata().priority()) {
129 selectedCandidate = currentCandidate;
130 selectedCandidateType = binder.tryResolveReturnType();
131 }
132 }
133 }
134 }
135 });
136
137 BOLT_DCHECK(!selectedCandidate || selectedCandidateType);
138
139 return selectedCandidate
140 ? std::optional<ResolvedSimpleFunction>(
141 ResolvedSimpleFunction(*selectedCandidate, selectedCandidateType))
142 : std::nullopt;
143}
144
145} // namespace bytedance::bolt::exec

Callers 6

TEST_FFunction · 0.80
resolveSimpleFunctionFunction · 0.80
testVariadicArgReuseFunction · 0.80
TEST_FFunction · 0.80
isDeterministicFunction · 0.80

Calls 7

getSignatureMapFunction · 0.85
getMetadataMethod · 0.80
tryBindMethod · 0.45
getMethod · 0.45
priorityMethod · 0.45
tryResolveReturnTypeMethod · 0.45

Tested by 3

TEST_FFunction · 0.64
testVariadicArgReuseFunction · 0.64
TEST_FFunction · 0.64