| 125 | } |
| 126 | |
| 127 | absl::optional<cel::Expr> CelIndexMacroExpander(cel::MacroExprFactory& factory, |
| 128 | cel::Expr& target, |
| 129 | absl::Span<cel::Expr> args) { |
| 130 | if (!IsCelNamespace(target)) { |
| 131 | return absl::nullopt; |
| 132 | } |
| 133 | cel::Expr& index_arg = args[0]; |
| 134 | if (!index_arg.has_const_expr() || !index_arg.const_expr().has_int_value()) { |
| 135 | return factory.ReportErrorAt( |
| 136 | index_arg, "cel.index requires a single non-negative int constant arg"); |
| 137 | } |
| 138 | int64_t index = index_arg.const_expr().int_value(); |
| 139 | if (index < 0) { |
| 140 | return factory.ReportErrorAt( |
| 141 | index_arg, "cel.index requires a single non-negative int constant arg"); |
| 142 | } |
| 143 | return factory.NewIdent(absl::StrCat("@index", index)); |
| 144 | } |
| 145 | |
| 146 | absl::optional<cel::Expr> CelIterVarMacroExpander( |
| 147 | cel::MacroExprFactory& factory, cel::Expr& target, |
nothing calls this directly
no test coverage detected