Starlark AST: use a list of bindings instead of a map in load statements
- The map was not useful: all we want to do is to iterate on the bindings
- Using Identifier as a key is not well defined (we shouldn't compare them and they shouldn't be hashable in the first place)
- Using Identifier instead of String for the original name allows us to preserve the location in the AST
RELNOTES: None.
PiperOrigin-RevId: 220860272
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
index d7e30dd..42e798e 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/Eval.java
@@ -17,7 +17,6 @@
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import java.util.function.Function;
/**
@@ -145,10 +144,10 @@
}
void execLoad(LoadStatement node) throws EvalException, InterruptedException {
- for (Map.Entry<Identifier, String> entry : node.getSymbolMap().entrySet()) {
+ for (LoadStatement.Binding binding : node.getBindings()) {
try {
- Identifier name = entry.getKey();
- Identifier declared = Identifier.of(entry.getValue());
+ Identifier name = binding.getLocalName();
+ Identifier declared = binding.getOriginalName();
if (declared.isPrivate()) {
throw new EvalException(