Copy creates a deep copy of the Expr and SourceInfo values in the input AST. Copies of the Expr value are generated using an internal default ExprFactory.
(a *AST)
| 131 | // |
| 132 | // Copies of the Expr value are generated using an internal default ExprFactory. |
| 133 | func Copy(a *AST) *AST { |
| 134 | if a == nil { |
| 135 | return nil |
| 136 | } |
| 137 | e := defaultFactory.CopyExpr(a.expr) |
| 138 | if !a.IsChecked() { |
| 139 | return NewAST(e, CopySourceInfo(a.SourceInfo())) |
| 140 | } |
| 141 | typesCopy := make(map[int64]*types.Type, len(a.typeMap)) |
| 142 | for id, t := range a.typeMap { |
| 143 | typesCopy[id] = t |
| 144 | } |
| 145 | refsCopy := make(map[int64]*ReferenceInfo, len(a.refMap)) |
| 146 | for id, r := range a.refMap { |
| 147 | refsCopy[id] = r |
| 148 | } |
| 149 | return NewCheckedAST(NewAST(e, CopySourceInfo(a.SourceInfo())), typesCopy, refsCopy) |
| 150 | } |
| 151 | |
| 152 | // MaxID returns the upper-bound, non-inclusive, of ids present within the AST's Expr value. |
| 153 | func MaxID(a *AST) int64 { |