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

Method Evaluate

eval/eval/regex_match_step.cc:66–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64 re2_(std::move(re2)) {}
65
66 absl::Status Evaluate(ExecutionFrame* frame) const override {
67 if (!frame->value_stack().HasEnough(kNumRegexMatchArguments)) {
68 return absl::Status(absl::StatusCode::kInternal,
69 "Insufficient arguments supplied for regular "
70 "expression match");
71 }
72 auto input_args = frame->value_stack().GetSpan(kNumRegexMatchArguments);
73 const auto& subject = input_args[kRegexMatchStepSubject];
74 if (!subject->Is<cel::StringValue>()) {
75 return absl::Status(absl::StatusCode::kInternal,
76 "First argument for regular "
77 "expression match must be a string");
78 }
79 bool match = subject.GetString().NativeValue(MatchesVisitor{*re2_});
80 frame->value_stack().Pop(kNumRegexMatchArguments);
81 frame->value_stack().Push(cel::BoolValue(match));
82 return absl::OkStatus();
83 }
84
85 private:
86 const std::shared_ptr<const RE2> re2_;

Callers 1

EvaluateMethod · 0.45

Calls 7

HasEnoughMethod · 0.80
GetSpanMethod · 0.80
BoolValueClass · 0.50
NativeValueMethod · 0.45
GetStringMethod · 0.45
PopMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected