| 319 | enable_optional_types_(enable_optional_types) {} |
| 320 | |
| 321 | absl::Status Evaluate(ExecutionFrameBase& frame, Value& result, |
| 322 | AttributeTrail& attribute) const override { |
| 323 | CEL_RETURN_IF_ERROR(operand_->Evaluate(frame, result, attribute)); |
| 324 | |
| 325 | if (result.IsError() || result.IsUnknown()) { |
| 326 | // Just forward. |
| 327 | return absl::OkStatus(); |
| 328 | } |
| 329 | |
| 330 | if (frame.attribute_tracking_enabled()) { |
| 331 | attribute = attribute.Step(&field_); |
| 332 | absl::optional<Value> value = CheckForMarkedAttributes(attribute, frame); |
| 333 | if (value.has_value()) { |
| 334 | result = std::move(value).value(); |
| 335 | return absl::OkStatus(); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | absl::optional<OptionalValue> optional_arg; |
| 340 | |
| 341 | if (enable_optional_types_ && result.IsOptional()) { |
| 342 | optional_arg = result.GetOptional(); |
| 343 | } |
| 344 | |
| 345 | switch (result.kind()) { |
| 346 | case ValueKind::kStruct: |
| 347 | case ValueKind::kMap: |
| 348 | break; |
| 349 | default: |
| 350 | if (optional_arg) { |
| 351 | break; |
| 352 | } |
| 353 | result = cel::ErrorValue(InvalidSelectTargetError()); |
| 354 | return absl::OkStatus(); |
| 355 | } |
| 356 | |
| 357 | if (test_only_) { |
| 358 | if (optional_arg) { |
| 359 | if (!optional_arg->HasValue()) { |
| 360 | result = cel::BoolValue{false}; |
| 361 | return absl::OkStatus(); |
| 362 | } |
| 363 | Value value; |
| 364 | optional_arg->Value(&value); |
| 365 | PerformTestOnlySelect(frame, value, result); |
| 366 | return absl::OkStatus(); |
| 367 | } |
| 368 | PerformTestOnlySelect(frame, result, result); |
| 369 | return absl::OkStatus(); |
| 370 | } |
| 371 | |
| 372 | if (optional_arg) { |
| 373 | if (!optional_arg->HasValue()) { |
| 374 | // result is still buffer for the container. just return. |
| 375 | return absl::OkStatus(); |
| 376 | } |
| 377 | Value value; |
| 378 | optional_arg->Value(&value); |
nothing calls this directly
no test coverage detected