MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / MakeTernaryRecursive

Method MakeTernaryRecursive

eval/compiler/flat_expr_builder.cc:1098–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1096 }
1097
1098 void MakeTernaryRecursive(const cel::Expr* expr) {
1099 if (expr->call_expr().args().size() != 3) {
1100 SetProgressStatusError(absl::InvalidArgumentError(
1101 "unexpected number of args for builtin ternary"));
1102 return;
1103 }
1104
1105 const cel::Expr* condition_expr = &expr->call_expr().args()[0];
1106 const cel::Expr* left_expr = &expr->call_expr().args()[1];
1107 const cel::Expr* right_expr = &expr->call_expr().args()[2];
1108
1109 auto* condition_plan = program_builder_.GetSubexpression(condition_expr);
1110 auto* left_plan = program_builder_.GetSubexpression(left_expr);
1111 auto* right_plan = program_builder_.GetSubexpression(right_expr);
1112
1113 if (condition_plan == nullptr || !condition_plan->IsRecursive() ||
1114 left_plan == nullptr || !left_plan->IsRecursive() ||
1115 right_plan == nullptr || !right_plan->IsRecursive()) {
1116 SetProgressStatusError(FailedRecursivePlanning());
1117 return;
1118 }
1119
1120 int max_depth = std::max({0, condition_plan->recursive_program().depth,
1121 left_plan->recursive_program().depth,
1122 right_plan->recursive_program().depth});
1123
1124 SetRecursiveStep(
1125 CreateDirectTernaryStep(condition_plan->ExtractRecursiveProgram().step,
1126 left_plan->ExtractRecursiveProgram().step,
1127 right_plan->ExtractRecursiveProgram().step,
1128 expr->id(), options_.short_circuiting),
1129 max_depth + 1);
1130 }
1131
1132 void MakeShortcircuitRecursive(const cel::Expr* expr, bool is_or) {
1133 if (expr->call_expr().args().size() != 2) {

Callers 1

PostVisitMethod · 0.80

Calls 7

FailedRecursivePlanningFunction · 0.85
CreateDirectTernaryStepFunction · 0.85
argsMethod · 0.80
IsRecursiveMethod · 0.80
sizeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected