| 419 | } |
| 420 | |
| 421 | absl::Status MapExprFromProto(const ExprProto& proto, |
| 422 | const ExprProto::CreateStruct& map_proto, |
| 423 | Expr& expr) { |
| 424 | expr.Clear(); |
| 425 | expr.set_id(proto.id()); |
| 426 | auto& map_expr = expr.mutable_map_expr(); |
| 427 | map_expr.mutable_entries().reserve( |
| 428 | static_cast<size_t>(map_proto.entries().size())); |
| 429 | for (const auto& entry_proto : map_proto.entries()) { |
| 430 | switch (entry_proto.key_kind_case()) { |
| 431 | case StructExprProto::Entry::KEY_KIND_NOT_SET: |
| 432 | ABSL_FALLTHROUGH_INTENDED; |
| 433 | case StructExprProto::Entry::kMapKey: |
| 434 | break; |
| 435 | case StructExprProto::Entry::kFieldKey: |
| 436 | return absl::InvalidArgumentError("encountered struct field in map"); |
| 437 | default: |
| 438 | return absl::InvalidArgumentError(absl::StrCat( |
| 439 | "unexpected map entry kind: ", entry_proto.key_kind_case())); |
| 440 | } |
| 441 | auto& entry_expr = map_expr.add_entries(); |
| 442 | entry_expr.set_id(entry_proto.id()); |
| 443 | if (entry_proto.has_map_key()) { |
| 444 | Push(entry_proto.map_key(), entry_expr.mutable_key()); |
| 445 | } |
| 446 | if (entry_proto.has_value()) { |
| 447 | Push(entry_proto.value(), entry_expr.mutable_value()); |
| 448 | } |
| 449 | entry_expr.set_optional(entry_proto.optional_entry()); |
| 450 | } |
| 451 | return absl::OkStatus(); |
| 452 | } |
| 453 | |
| 454 | absl::Status ComprehensionExprFromProto( |
| 455 | const ExprProto& proto, |
nothing calls this directly
no test coverage detected