| Index: compiler/java/com/google/dart/compiler/resolver/Scope.java
|
| diff --git a/compiler/java/com/google/dart/compiler/resolver/Scope.java b/compiler/java/com/google/dart/compiler/resolver/Scope.java
|
| index ae4fd3c6193e527f666f6ca85e49d4d6fd5da523..fe8d9d6b4ba60141b81aac65e04099ba5fb8886c 100644
|
| --- a/compiler/java/com/google/dart/compiler/resolver/Scope.java
|
| +++ b/compiler/java/com/google/dart/compiler/resolver/Scope.java
|
| @@ -5,12 +5,16 @@
|
| package com.google.dart.compiler.resolver;
|
|
|
| import com.google.common.annotations.VisibleForTesting;
|
| +import com.google.common.collect.Sets;
|
| +import com.google.dart.compiler.ast.DartBlock;
|
| import com.google.dart.compiler.ast.DartIdentifier;
|
| +import com.google.dart.compiler.ast.DartVariableStatement;
|
|
|
| import java.util.ArrayList;
|
| import java.util.LinkedHashMap;
|
| import java.util.List;
|
| import java.util.Map;
|
| +import java.util.Set;
|
|
|
| /**
|
| * A scope used by {@link Resolver}.
|
| @@ -18,6 +22,7 @@ import java.util.Map;
|
| public class Scope {
|
|
|
| private final Map<String, Element> elements = new LinkedHashMap<String, Element>();
|
| + private final Set<String> declaredButNotReachedVariables = Sets.newHashSet();
|
| private final Scope parent;
|
| private final String name;
|
| private List<LabelElement> labels;
|
| @@ -86,6 +91,29 @@ public class Scope {
|
| public Map<String, Element> getElements() {
|
| return elements;
|
| }
|
| +
|
| + /**
|
| + * @return <code>true</code> if local variable with given name is declared in the lexical context
|
| + * of {@link DartBlock}, but corresponding {@link DartVariableStatement} is not visited
|
| + * yet. So, using this variable is error.
|
| + */
|
| + public boolean isDeclaredButNotReachedVariable(String name) {
|
| + return declaredButNotReachedVariables.contains(name);
|
| + }
|
| +
|
| + /**
|
| + * @see #isDeclaredButNotReachedVariable(String)
|
| + */
|
| + public void addDeclaredButNotReachedVariable(String name) {
|
| + declaredButNotReachedVariables.add(name);
|
| + }
|
| +
|
| + /**
|
| + * @see #isDeclaredButNotReachedVariable(String)
|
| + */
|
| + public void removeDeclaredButNotReachedVariable(String name) {
|
| + declaredButNotReachedVariables.remove(name);
|
| + }
|
|
|
| public String getName() {
|
| return name;
|
|
|