MCPcopy Create free account
hub / github.com/cel-expr/cel-go / CopyAST

Method CopyAST

cel/optimizer.go:282–289  ·  view source on GitHub ↗

CopyAST creates a renumbered copy of `Expr` and `SourceInfo` values of the input AST, where the renumbering uses the same scheme as the core optimizer logic ensuring there are no collisions between copies. Use this method before attempting to merge the expression from AST into another.

(a *ast.AST)

Source from the content-addressed store, hash-verified

280//
281// Use this method before attempting to merge the expression from AST into another.
282func (opt *optimizerExprFactory) CopyAST(a *ast.AST) (ast.Expr, *ast.SourceInfo) {
283 idGen := newIDGenerator(opt.nextID())
284 defer func() { opt.seed = idGen.nextID() }()
285 copyExpr := opt.fac.CopyExpr(a.Expr())
286 copyInfo := ast.CopySourceInfo(a.SourceInfo())
287 normalizeIDs(idGen.renumberStable, copyExpr, copyInfo)
288 return copyExpr, copyInfo
289}
290
291// CopyASTAndMetadata copies the input AST and propagates the macro metadata into the AST being
292// optimized.

Callers 1

CopyASTAndMetadataMethod · 0.95

Calls 7

CopySourceInfoFunction · 0.92
newIDGeneratorFunction · 0.85
normalizeIDsFunction · 0.85
CopyExprMethod · 0.65
ExprMethod · 0.65
nextIDMethod · 0.45
SourceInfoMethod · 0.45

Tested by

no test coverage detected