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

Method Evaluate

codelab/exercise4.cc:91–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 }
90
91 absl::StatusOr<bool> Evaluate(const CheckedExpr& expr,
92 const AttributeContext& context) {
93 Activation activation;
94 CEL_RETURN_IF_ERROR(BindProtoToActivation(&context, &arena_, &activation));
95 CEL_ASSIGN_OR_RETURN(auto plan, builder_->CreateExpression(&expr));
96 CEL_ASSIGN_OR_RETURN(CelValue result, plan->Evaluate(activation, &arena_));
97
98 if (bool value; result.GetValue(&value)) {
99 return value;
100 } else if (const CelError * value; result.GetValue(&value)) {
101 return *value;
102 } else {
103 return absl::InvalidArgumentError(
104 absl::StrCat("unexpected return type: ", result.DebugString()));
105 }
106 }
107
108 private:
109 google::protobuf::Arena arena_;

Callers 9

BM_ParseAddressFunction · 0.45
BM_ParseAddressVarFunction · 0.45
BM_ParseAddressMatcherFunction · 0.45
EvalMethod · 0.45
EvalMethod · 0.45

Calls 3

BindProtoToActivationFunction · 0.50
GetValueMethod · 0.45
DebugStringMethod · 0.45

Tested by 5

BM_ParseAddressFunction · 0.36
BM_ParseAddressVarFunction · 0.36
BM_ParseAddressMatcherFunction · 0.36