| 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_; |