MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / ResolveLazy

Function ResolveLazy

eval/eval/function_step.cc:305–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305absl::StatusOr<ResolveResult> ResolveLazy(
306 absl::Span<const cel::Value> input_args, absl::string_view name,
307 bool receiver_style,
308 absl::Span<const cel::FunctionRegistry::LazyOverload> providers,
309 const ExecutionFrameBase& frame) {
310 ResolveResult result = absl::nullopt;
311
312 std::vector<cel::Kind> arg_types(input_args.size());
313
314 std::transform(
315 input_args.begin(), input_args.end(), arg_types.begin(),
316 [](const cel::Value& value) { return ValueKindToKind(value->kind()); });
317
318 cel::FunctionDescriptor matcher{name, receiver_style, arg_types};
319
320 const cel::ActivationInterface& activation = frame.activation();
321 for (auto provider : providers) {
322 // The LazyFunctionStep has so far only resolved by function shape, check
323 // that the runtime argument kinds agree with the specific descriptor for
324 // the provider candidates.
325 if (!ArgumentKindsMatch(provider.descriptor, input_args)) {
326 continue;
327 }
328
329 CEL_ASSIGN_OR_RETURN(auto overload,
330 provider.provider.GetFunction(matcher, activation));
331 if (overload.has_value()) {
332 // More than one overload matches our arguments.
333 if (result.has_value()) {
334 return absl::Status(absl::StatusCode::kInternal,
335 "Cannot resolve overloads");
336 }
337
338 result.emplace(overload.value());
339 }
340 }
341
342 return result;
343}
344
345class EagerFunctionStep : public AbstractFunctionStep {
346 public:

Callers 2

ResolveFunctionMethod · 0.85
ResolveMethod · 0.85

Calls 8

ValueKindToKindFunction · 0.85
ArgumentKindsMatchFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
kindMethod · 0.45
has_valueMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected