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)
| 280 | // |
| 281 | // Use this method before attempting to merge the expression from AST into another. |
| 282 | func (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. |
no test coverage detected