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

Function Expand

common/expr.cc:210–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208
209namespace {
210void Expand(Expr** tail, Expr* cur) {
211 static common_internal::ExprEraseTag tag;
212 switch (cur->kind_case()) {
213 case ExprKindCase::kSelectExpr: {
214 SelectExpr& select = cur->mutable_select_expr();
215 if (select.has_operand()) {
216 select.mutable_operand().SetNext(tag, *tail);
217 *tail = &select.mutable_operand();
218 }
219 break;
220 }
221 case ExprKindCase::kCallExpr: {
222 CallExpr& call = cur->mutable_call_expr();
223 if (call.has_target()) {
224 call.mutable_target().SetNext(tag, *tail);
225 *tail = &call.mutable_target();
226 }
227 for (auto& arg : call.mutable_args()) {
228 arg.SetNext(tag, *tail);
229 *tail = &arg;
230 }
231 break;
232 }
233 case ExprKindCase::kListExpr: {
234 for (auto& arg : cur->mutable_list_expr().mutable_elements()) {
235 arg.mutable_expr().SetNext(tag, *tail);
236 *tail = &arg.mutable_expr();
237 }
238 break;
239 }
240 case ExprKindCase::kStructExpr: {
241 for (auto& field : cur->mutable_struct_expr().mutable_fields()) {
242 field.mutable_value().SetNext(tag, *tail);
243 *tail = &field.mutable_value();
244 }
245 break;
246 }
247 case ExprKindCase::kMapExpr: {
248 for (auto& entry : cur->mutable_map_expr().mutable_entries()) {
249 entry.mutable_key().SetNext(tag, *tail);
250 *tail = &entry.mutable_key();
251 entry.mutable_value().SetNext(tag, *tail);
252 *tail = &entry.mutable_value();
253 }
254 break;
255 }
256 case ExprKindCase::kComprehensionExpr: {
257 if (cur->comprehension_expr().has_accu_init()) {
258 cur->mutable_comprehension_expr().mutable_accu_init().SetNext(tag,
259 *tail);
260 *tail = &cur->mutable_comprehension_expr().mutable_accu_init();
261 }
262 if (cur->comprehension_expr().has_iter_range()) {
263 cur->mutable_comprehension_expr().mutable_iter_range().SetNext(tag,
264 *tail);
265 *tail = &cur->mutable_comprehension_expr().mutable_iter_range();
266 }
267 if (cur->comprehension_expr().has_loop_condition()) {

Callers 2

MacroClass · 0.85
FlattenedEraseMethod · 0.85

Calls 10

kind_caseMethod · 0.80
has_operandMethod · 0.80
SetNextMethod · 0.80
has_targetMethod · 0.80
mutable_valueMethod · 0.80
has_accu_initMethod · 0.80
has_iter_rangeMethod · 0.80
has_loop_conditionMethod · 0.80
has_loop_stepMethod · 0.80
has_resultMethod · 0.80

Tested by

no test coverage detected