| 268 | } |
| 269 | |
| 270 | absl::StatusOr<Value> ApplyQualifier( |
| 271 | const Value& operand, const SelectQualifier& qualifier, |
| 272 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
| 273 | google::protobuf::MessageFactory* absl_nonnull message_factory, |
| 274 | google::protobuf::Arena* absl_nonnull arena) { |
| 275 | return absl::visit( |
| 276 | absl::Overload( |
| 277 | [&](const FieldSpecifier& field_specifier) -> absl::StatusOr<Value> { |
| 278 | if (!operand.Is<StructValue>()) { |
| 279 | return cel::ErrorValue( |
| 280 | cel::runtime_internal::CreateNoMatchingOverloadError( |
| 281 | "<select>")); |
| 282 | } |
| 283 | return operand.GetStruct().GetFieldByName( |
| 284 | field_specifier.name, descriptor_pool, message_factory, arena); |
| 285 | }, |
| 286 | [&](const AttributeQualifier& qualifier) -> absl::StatusOr<Value> { |
| 287 | if (operand.Is<ListValue>()) { |
| 288 | auto index_or = ListIndexFromQualifier(qualifier); |
| 289 | if (!index_or.ok()) { |
| 290 | return cel::ErrorValue(index_or.status()); |
| 291 | } |
| 292 | return operand.GetList().Get(*index_or, descriptor_pool, |
| 293 | message_factory, arena); |
| 294 | } else if (operand.Is<MapValue>()) { |
| 295 | auto key_or = MapKeyFromQualifier(qualifier, arena); |
| 296 | if (!key_or.ok()) { |
| 297 | return cel::ErrorValue(key_or.status()); |
| 298 | } |
| 299 | return operand.GetMap().Get(*key_or, descriptor_pool, |
| 300 | message_factory, arena); |
| 301 | } |
| 302 | return cel::ErrorValue( |
| 303 | cel::runtime_internal::CreateNoMatchingOverloadError( |
| 304 | cel::builtin::kIndex)); |
| 305 | }), |
| 306 | qualifier); |
| 307 | } |
| 308 | |
| 309 | absl::StatusOr<Value> FallbackSelect( |
| 310 | const Value& root, absl::Span<const SelectQualifier> select_path, |
no test coverage detected