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

Method Evaluate

eval/eval/logic_step.cc:103–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101};
102
103absl::Status ExhaustiveDirectLogicStep::Evaluate(
104 ExecutionFrameBase& frame, cel::Value& result,
105 AttributeTrail& attribute_trail) const {
106 CEL_RETURN_IF_ERROR(lhs_->Evaluate(frame, result, attribute_trail));
107 ValueKind lhs_kind = result.kind();
108
109 Value rhs_result;
110 AttributeTrail rhs_attr;
111 CEL_RETURN_IF_ERROR(rhs_->Evaluate(frame, rhs_result, attribute_trail));
112
113 ValueKind rhs_kind = rhs_result.kind();
114 if (lhs_kind == ValueKind::kBool) {
115 bool lhs_bool = Cast<BoolValue>(result).NativeValue();
116 if ((op_type_ == OpType::kOr && lhs_bool) ||
117 (op_type_ == OpType::kAnd && !lhs_bool)) {
118 return absl::OkStatus();
119 }
120 }
121
122 if (rhs_kind == ValueKind::kBool) {
123 bool rhs_bool = Cast<BoolValue>(rhs_result).NativeValue();
124 if ((op_type_ == OpType::kOr && rhs_bool) ||
125 (op_type_ == OpType::kAnd && !rhs_bool)) {
126 result = std::move(rhs_result);
127 attribute_trail = std::move(rhs_attr);
128 return absl::OkStatus();
129 }
130 }
131
132 return ReturnLogicResult(frame, op_type_, result, rhs_result, attribute_trail,
133 rhs_attr);
134}
135
136class DirectLogicStep : public DirectExpressionStep {
137 public:

Callers

nothing calls this directly

Calls 15

ReturnLogicResultFunction · 0.85
ErrorValueFunction · 0.85
HasEnoughMethod · 0.80
GetSpanMethod · 0.80
PopAndPushMethod · 0.80
attributeMethod · 0.80
BoolValueClass · 0.50
kindMethod · 0.45
NativeValueMethod · 0.45

Tested by

no test coverage detected