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)
| 228 | // |
| 229 | // Copies of macro Expr values are generated using an internal default ExprFactory. |
| 230 | func CopySourceInfo(info *SourceInfo) *SourceInfo { |
| 231 | if info == nil { |
| 232 | return nil |
| 233 | } |
| 234 | rangesCopy := make(map[int64]OffsetRange, len(info.offsetRanges)) |
| 235 | for id, off := range info.offsetRanges { |
| 236 | rangesCopy[id] = off |
| 237 | } |
| 238 | callsCopy := make(map[int64]Expr, len(info.macroCalls)) |
| 239 | for id, call := range info.macroCalls { |
| 240 | callsCopy[id] = defaultFactory.CopyExpr(call) |
| 241 | } |
| 242 | var extCopy []Extension |
| 243 | if len(info.extensions) > 0 { |
| 244 | extCopy = make([]Extension, len(info.extensions)) |
| 245 | copy(extCopy, info.extensions) |
| 246 | } |
| 247 | return &SourceInfo{ |
| 248 | syntax: info.syntax, |
| 249 | desc: info.desc, |
| 250 | lines: info.lines, |
| 251 | baseLine: info.baseLine, |
| 252 | baseCol: info.baseCol, |
| 253 | offsetRanges: rangesCopy, |
| 254 | macroCalls: callsCopy, |
| 255 | extensions: extCopy, |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | // SourceInfo records basic information about the expression as a textual input and |
| 260 | // as a parsed expression value. |