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

Function CelIterVarMacroExpander

conformance/service.cc:146–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146absl::optional<cel::Expr> CelIterVarMacroExpander(
147 cel::MacroExprFactory& factory, cel::Expr& target,
148 absl::Span<cel::Expr> args) {
149 if (!IsCelNamespace(target)) {
150 return absl::nullopt;
151 }
152 cel::Expr& depth_arg = args[0];
153 if (!depth_arg.has_const_expr() || !depth_arg.const_expr().has_int_value() ||
154 depth_arg.const_expr().int_value() < 0) {
155 return factory.ReportErrorAt(
156 depth_arg, "cel.iterVar requires two non-negative int constant args");
157 }
158 cel::Expr& unique_arg = args[1];
159 if (!unique_arg.has_const_expr() ||
160 !unique_arg.const_expr().has_int_value() ||
161 unique_arg.const_expr().int_value() < 0) {
162 return factory.ReportErrorAt(
163 unique_arg, "cel.iterVar requires two non-negative int constant args");
164 }
165 return factory.NewIdent(
166 absl::StrCat("@it:", depth_arg.const_expr().int_value(), ":",
167 unique_arg.const_expr().int_value()));
168}
169
170absl::optional<cel::Expr> CelAccuVarMacroExpander(
171 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