lang: ast: Add a util function for node map copying

This commit is contained in:
James Shubin
2024-01-22 13:04:23 -05:00
parent 16dfb7b5f5
commit f8077d9fc4
2 changed files with 10 additions and 9 deletions

View File

@@ -265,3 +265,12 @@ func CollectFiles(ast interfaces.Stmt) ([]string, error) {
}
return fileList, nil
}
// CopyNodeMapping copies the map of string to node and is used in Ordering.
func CopyNodeMapping(in map[string]interfaces.Node) map[string]interfaces.Node {
out := make(map[string]interfaces.Node)
for k, v := range in {
out[k] = v // copy the map, not the Node's
}
return out
}