| 55 | using ::google::protobuf::Arena; |
| 56 | |
| 57 | absl::StatusOr<ExecutionPath> CreateStackMachineProgram( |
| 58 | const std::vector<std::pair<CelValue, CelValue>>& values, |
| 59 | Activation& activation) { |
| 60 | ExecutionPath path; |
| 61 | |
| 62 | Expr expr1; |
| 63 | Expr expr0; |
| 64 | |
| 65 | std::vector<Expr> exprs; |
| 66 | exprs.reserve(values.size() * 2); |
| 67 | int index = 0; |
| 68 | |
| 69 | auto& create_struct = expr1.mutable_struct_expr(); |
| 70 | for (const auto& item : values) { |
| 71 | std::string key_name = absl::StrCat("key", index); |
| 72 | std::string value_name = absl::StrCat("value", index); |
| 73 | |
| 74 | CEL_ASSIGN_OR_RETURN(auto step_key, |
| 75 | CreateIdentStep(key_name, /*expr_id=*/-1)); |
| 76 | |
| 77 | CEL_ASSIGN_OR_RETURN(auto step_value, |
| 78 | CreateIdentStep(value_name, /*expr _id=*/-1)); |
| 79 | |
| 80 | path.push_back(std::move(step_key)); |
| 81 | path.push_back(std::move(step_value)); |
| 82 | |
| 83 | activation.InsertValue(key_name, item.first); |
| 84 | activation.InsertValue(value_name, item.second); |
| 85 | |
| 86 | create_struct.mutable_fields().emplace_back(); |
| 87 | index++; |
| 88 | } |
| 89 | |
| 90 | CEL_ASSIGN_OR_RETURN( |
| 91 | auto step1, CreateCreateStructStepForMap(values.size(), {}, expr1.id())); |
| 92 | path.push_back(std::move(step1)); |
| 93 | return path; |
| 94 | } |
| 95 | |
| 96 | absl::StatusOr<ExecutionPath> CreateRecursiveProgram( |
| 97 | const std::vector<std::pair<CelValue, CelValue>>& values, |
no test coverage detected