AppendList will append the elements in value2 to value1. This call will only be invoked within comprehensions where `value1` is an intermediate result which cannot be directly assigned or co-mingled with a user-provided list.
| 84 | // intermediate result which cannot be directly assigned or co-mingled with a |
| 85 | // user-provided list. |
| 86 | absl::StatusOr<ListValue> AppendList(ListValue value1, const Value& value2) { |
| 87 | // The `value1` object cannot be directly addressed and is an intermediate |
| 88 | // variable. Once the comprehension completes this value will in effect be |
| 89 | // treated as immutable. |
| 90 | if (auto mutable_list_value = |
| 91 | cel::common_internal::AsMutableListValue(value1); |
| 92 | mutable_list_value) { |
| 93 | CEL_RETURN_IF_ERROR(mutable_list_value->Append(value2)); |
| 94 | return value1; |
| 95 | } |
| 96 | return absl::InvalidArgumentError("Unexpected call to runtime list append."); |
| 97 | } |
| 98 | } // namespace |
| 99 | |
| 100 | absl::Status RegisterContainerFunctions(FunctionRegistry& registry, |