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

Method PerformSelect

eval/eval/select_step.cc:273–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273absl::StatusOr<bool> SelectStep::PerformSelect(ExecutionFrame* frame,
274 const Value& arg,
275 Value& result) const {
276 switch (arg->kind()) {
277 case ValueKind::kStruct: {
278 const auto& struct_value = arg.GetStruct();
279 CEL_ASSIGN_OR_RETURN(auto ok, struct_value.HasFieldByName(field_));
280 if (!ok) {
281 result = NullValue{};
282 return false;
283 }
284 CEL_RETURN_IF_ERROR(struct_value.GetFieldByName(
285 field_, unboxing_option_, frame->descriptor_pool(),
286 frame->message_factory(), frame->arena(), &result));
287 ABSL_DCHECK(!result.IsUnknown());
288 return true;
289 }
290 case ValueKind::kMap: {
291 CEL_ASSIGN_OR_RETURN(
292 auto found,
293 arg.GetMap().Find(field_value_, frame->descriptor_pool(),
294 frame->message_factory(), frame->arena(), &result));
295 ABSL_DCHECK(!found || !result.IsUnknown());
296 return found;
297 }
298 default:
299 // Control flow should have returned earlier.
300 return InvalidSelectTargetError();
301 }
302}
303
304class DirectSelectStep : public DirectExpressionStep {
305 public:

Callers

nothing calls this directly

Calls 10

InvalidSelectTargetErrorFunction · 0.85
kindMethod · 0.45
GetStructMethod · 0.45
GetFieldByNameMethod · 0.45
descriptor_poolMethod · 0.45
message_factoryMethod · 0.45
arenaMethod · 0.45
IsUnknownMethod · 0.45
GetMethod · 0.45
GetMapMethod · 0.45

Tested by

no test coverage detected