| 2163 | } |
| 2164 | |
| 2165 | void 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 | |
| 2195 | void BinaryCondVisitor::PostVisitTarget(const cel::Expr* expr) { |
| 2196 | if (visitor_->PlanRecursiveProgram()) { |
no test coverage detected