Chromium Code Reviews| Index: compiler/java/com/google/dart/compiler/resolver/Scope.java |
| =================================================================== |
| --- compiler/java/com/google/dart/compiler/resolver/Scope.java (revision 8465) |
| +++ compiler/java/com/google/dart/compiler/resolver/Scope.java (working copy) |
| @@ -7,7 +7,9 @@ |
| import com.google.common.annotations.VisibleForTesting; |
| import com.google.dart.compiler.ast.DartIdentifier; |
| +import java.util.ArrayList; |
| import java.util.LinkedHashMap; |
| +import java.util.List; |
| import java.util.Map; |
| /** |
| @@ -18,7 +20,7 @@ |
| private final Map<String, Element> elements = new LinkedHashMap<String, Element>(); |
| private final Scope parent; |
| private final String name; |
| - private LabelElement label; |
| + private List<LabelElement> labels; |
| private LibraryElement library; |
| @VisibleForTesting |
| @@ -69,9 +71,13 @@ |
| } |
| public Element findLabel(String targetName, MethodElement innermostFunction) { |
| - if (label != null && label.getName().equals(targetName) |
| - && innermostFunction == label.getEnclosingFunction()) { |
| - return label; |
| + if (labels != null) { |
| + for (LabelElement label : labels) { |
| + if (label.getName().equals(targetName) |
| + && innermostFunction == label.getEnclosingFunction()) { |
| + return label; |
| + } |
| + } |
| } |
| return parent == null ? null : |
| parent.findLabel(targetName, innermostFunction); |
| @@ -81,9 +87,9 @@ |
| return elements; |
| } |
| - public Element getLabel() { |
| - return label; |
| - } |
| +// public Element getLabel() { |
|
zundel
2012/06/08 23:13:07
remove me
Brian Wilkerson
2012/06/11 15:06:00
Done
|
| +// return label; |
| +// } |
| public String getName() { |
| return name; |
| @@ -97,8 +103,11 @@ |
| return elements.size() == 0; |
| } |
| - public void setLabel(LabelElement label) { |
| - this.label = label; |
| + public void addLabel(LabelElement label) { |
| + if (labels == null) { |
| + labels = new ArrayList<LabelElement>(); |
| + } |
| + labels.add(label); |
| } |
| @Override |