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

Function CelIndexMacroExpander

conformance/service.cc:127–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127absl::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
146absl::optional<cel::Expr> CelIterVarMacroExpander(
147 cel::MacroExprFactory& factory, cel::Expr& target,

Callers

nothing calls this directly

Calls 4

IsCelNamespaceFunction · 0.85
has_const_exprMethod · 0.80
ReportErrorAtMethod · 0.45
NewIdentMethod · 0.45

Tested by

no test coverage detected