| 168 | } |
| 169 | |
| 170 | absl::optional<cel::Expr> CelAccuVarMacroExpander( |
| 171 | cel::MacroExprFactory& factory, cel::Expr& target, |
| 172 | absl::Span<cel::Expr> args) { |
| 173 | if (!IsCelNamespace(target)) { |
| 174 | return absl::nullopt; |
| 175 | } |
| 176 | cel::Expr& depth_arg = args[0]; |
| 177 | if (!depth_arg.has_const_expr() || !depth_arg.const_expr().has_int_value() || |
| 178 | depth_arg.const_expr().int_value() < 0) { |
| 179 | return factory.ReportErrorAt( |
| 180 | depth_arg, "cel.accuVar requires two non-negative int constant args"); |
| 181 | } |
| 182 | cel::Expr& unique_arg = args[1]; |
| 183 | if (!unique_arg.has_const_expr() || |
| 184 | !unique_arg.const_expr().has_int_value() || |
| 185 | unique_arg.const_expr().int_value() < 0) { |
| 186 | return factory.ReportErrorAt( |
| 187 | unique_arg, "cel.accuVar requires two non-negative int constant args"); |
| 188 | } |
| 189 | return factory.NewIdent( |
| 190 | absl::StrCat("@ac:", depth_arg.const_expr().int_value(), ":", |
| 191 | unique_arg.const_expr().int_value())); |
| 192 | } |
| 193 | |
| 194 | absl::Status RegisterCelBlockMacros(cel::MacroRegistry& registry) { |
| 195 | CEL_ASSIGN_OR_RETURN(auto block_macro, |
nothing calls this directly
no test coverage detected