| 132 | } |
| 133 | |
| 134 | absl::StatusOr<bool> Evaluate(const CheckedExpr& expr, |
| 135 | const AttributeContext& context) { |
| 136 | Activation activation; |
| 137 | CEL_RETURN_IF_ERROR(BindProtoToActivation(&context, &arena_, &activation)); |
| 138 | CEL_ASSIGN_OR_RETURN(auto plan, builder_->CreateExpression(&expr)); |
| 139 | CEL_ASSIGN_OR_RETURN(CelValue result, plan->Evaluate(activation, &arena_)); |
| 140 | |
| 141 | if (bool value; result.GetValue(&value)) { |
| 142 | return value; |
| 143 | } else if (const CelError* value; result.GetValue(&value)) { |
| 144 | return *value; |
| 145 | } else { |
| 146 | return absl::InvalidArgumentError( |
| 147 | absl::StrCat("unexpected return type: ", result.DebugString())); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | private: |
| 152 | google::protobuf::Arena arena_; |
no test coverage detected