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

Function AstRewrite

common/ast_rewrite.cc:350–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348} // namespace
349
350bool AstRewrite(Expr& expr, AstRewriter& visitor,
351 RewriteTraversalOptions options) {
352 std::stack<StackRecord> stack;
353 std::vector<const Expr*> traversal_path;
354
355 stack.push(StackRecord(&expr));
356 bool rewritten = false;
357
358 while (!stack.empty()) {
359 StackRecord& record = stack.top();
360 if (!record.visited) {
361 if (record.IsExprRecord()) {
362 traversal_path.push_back(record.expr());
363 visitor.TraversalStackUpdate(absl::MakeSpan(traversal_path));
364
365 if (visitor.PreVisitRewrite(*record.expr())) {
366 rewritten = true;
367 }
368 }
369 PreVisit(record, &visitor);
370 PushDependencies(record, stack, options);
371 record.visited = true;
372 } else {
373 PostVisit(record, &visitor);
374 if (record.IsExprRecord()) {
375 if (visitor.PostVisitRewrite(*record.expr())) {
376 rewritten = true;
377 }
378
379 traversal_path.pop_back();
380 visitor.TraversalStackUpdate(absl::MakeSpan(traversal_path));
381 }
382 stack.pop();
383 }
384 }
385
386 return rewritten;
387}
388
389} // namespace cel

Callers 2

TESTFunction · 0.70
CheckMethod · 0.50

Calls 10

StackRecordClass · 0.70
PreVisitFunction · 0.70
PushDependenciesFunction · 0.70
PostVisitFunction · 0.70
emptyMethod · 0.45
IsExprRecordMethod · 0.45
exprMethod · 0.45
TraversalStackUpdateMethod · 0.45
PreVisitRewriteMethod · 0.45
PostVisitRewriteMethod · 0.45

Tested by 1

TESTFunction · 0.56