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

Method PostVisitArg

eval/compiler/flat_expr_builder.cc:2165–2193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2163}
2164
2165void BinaryCondVisitor::PostVisitArg(int arg_num, const cel::Expr* expr) {
2166 if (visitor_->PlanRecursiveProgram()) {
2167 return;
2168 }
2169 if (short_circuiting_ && arg_num == 0 &&
2170 (cond_ == BinaryCond::kAnd || cond_ == BinaryCond::kOr)) {
2171 // If first branch evaluation result is enough to determine output,
2172 // jump over the second branch and provide result of the first argument as
2173 // final output.
2174 // Retain a pointer to the jump step so we can update the target after
2175 // planning the second argument.
2176 std::unique_ptr<JumpStepBase> jump_step;
2177 switch (cond_) {
2178 case BinaryCond::kAnd:
2179 jump_step = CreateCondJumpStep(false, true, {}, expr->id());
2180 break;
2181 case BinaryCond::kOr:
2182 jump_step = CreateCondJumpStep(true, true, {}, expr->id());
2183 break;
2184 default:
2185 ABSL_UNREACHABLE();
2186 }
2187 ProgramStepIndex index = visitor_->GetCurrentIndex();
2188 if (JumpStepBase* jump_step_ptr = visitor_->AddStep(std::move(jump_step));
2189 jump_step_ptr) {
2190 jump_step_ = Jump(index, jump_step_ptr);
2191 }
2192 }
2193}
2194
2195void BinaryCondVisitor::PostVisitTarget(const cel::Expr* expr) {
2196 if (visitor_->PlanRecursiveProgram()) {

Callers 2

PostVisitArgMethod · 0.45

Calls 12

CreateCondJumpStepFunction · 0.85
JumpClass · 0.85
CreateBoolCheckJumpStepFunction · 0.85
CreateJumpStepFunction · 0.85
PlanRecursiveProgramMethod · 0.80
GetCurrentIndexMethod · 0.80
ValidateOrErrorMethod · 0.80
existsMethod · 0.80
idMethod · 0.45
AddStepMethod · 0.45
set_targetMethod · 0.45

Tested by

no test coverage detected