CopySourceInfo creates a deep copy of the MacroCalls within the input SourceInfo. Copies of macro Expr values are generated using an internal default ExprFactory.
(info *SourceInfo)
| 220 | // |
| 221 | // Copies of macro Expr values are generated using an internal default ExprFactory. |
| 222 | func CopySourceInfo(info *SourceInfo) *SourceInfo { |
| 223 | if info == nil { |
| 224 | return nil |
| 225 | } |
| 226 | rangesCopy := make(map[int64]OffsetRange, len(info.offsetRanges)) |
| 227 | for id, off := range info.offsetRanges { |
| 228 | rangesCopy[id] = off |
| 229 | } |
| 230 | callsCopy := make(map[int64]Expr, len(info.macroCalls)) |
| 231 | for id, call := range info.macroCalls { |
| 232 | callsCopy[id] = defaultFactory.CopyExpr(call) |
| 233 | } |
| 234 | var extCopy []Extension |
| 235 | if len(info.extensions) > 0 { |
| 236 | extCopy = make([]Extension, len(info.extensions)) |
| 237 | copy(extCopy, info.extensions) |
| 238 | } |
| 239 | return &SourceInfo{ |
| 240 | syntax: info.syntax, |
| 241 | desc: info.desc, |
| 242 | lines: info.lines, |
| 243 | baseLine: info.baseLine, |
| 244 | baseCol: info.baseCol, |
| 245 | offsetRanges: rangesCopy, |
| 246 | macroCalls: callsCopy, |
| 247 | extensions: extCopy, |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | // SourceInfo records basic information about the expression as a textual input and |
| 252 | // as a parsed expression value. |