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

Method PerformOptionalSelect

eval/eval/select_step.cc:432–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432absl::Status DirectSelectStep::PerformOptionalSelect(ExecutionFrameBase& frame,
433 const Value& value,
434 Value& result) const {
435 switch (value.kind()) {
436 case ValueKind::kStruct: {
437 auto struct_value = value.GetStruct();
438 CEL_ASSIGN_OR_RETURN(auto ok, struct_value.HasFieldByName(field_));
439 if (!ok) {
440 result = OptionalValue::None();
441 return absl::OkStatus();
442 }
443 CEL_RETURN_IF_ERROR(struct_value.GetFieldByName(
444 field_, unboxing_option_, frame.descriptor_pool(),
445 frame.message_factory(), frame.arena(), &result));
446 ABSL_DCHECK(!result.IsUnknown());
447 result = OptionalValue::Of(std::move(result), frame.arena());
448 return absl::OkStatus();
449 }
450 case ValueKind::kMap: {
451 CEL_ASSIGN_OR_RETURN(
452 auto found,
453 value.GetMap().Find(field_value_, frame.descriptor_pool(),
454 frame.message_factory(), frame.arena(), &result));
455 if (!found) {
456 result = OptionalValue::None();
457 return absl::OkStatus();
458 }
459 ABSL_DCHECK(!result.IsUnknown());
460 result = OptionalValue::Of(std::move(result), frame.arena());
461 return absl::OkStatus();
462 }
463 default:
464 // Control flow should have returned earlier.
465 return InvalidSelectTargetError();
466 }
467}
468
469absl::Status DirectSelectStep::PerformSelect(ExecutionFrameBase& frame,
470 const cel::Value& value,

Callers

nothing calls this directly

Calls 9

OfFunction · 0.85
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

Tested by

no test coverage detected