| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class Scope { | 7 abstract class Scope { |
| 8 /** | 8 /** |
| 9 * Adds [element] to this scope. This operation is only allowed on mutable | 9 * Adds [element] to this scope. This operation is only allowed on mutable |
| 10 * scopes such as [MethodScope] and [BlockScope]. | 10 * scopes such as [MethodScope] and [BlockScope]. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 NestedScope(this.parent); | 28 NestedScope(this.parent); |
| 29 | 29 |
| 30 Element lookup(String name) { | 30 Element lookup(String name) { |
| 31 Element result = localLookup(name); | 31 Element result = localLookup(name); |
| 32 if (result != null) return result; | 32 if (result != null) return result; |
| 33 return parent.lookup(name); | 33 return parent.lookup(name); |
| 34 } | 34 } |
| 35 | 35 |
| 36 Element localLookup(String name); | 36 Element localLookup(String name); |
| 37 | |
| 38 static Scope buildEnclosingScope(Element element) { | |
| 39 return element.enclosingElement != null | |
| 40 ? element.enclosingElement.buildScope() : element.buildScope(); | |
| 41 } | |
| 42 } | 37 } |
| 43 | 38 |
| 44 class VariableDefinitionScope extends NestedScope { | 39 class VariableDefinitionScope extends NestedScope { |
| 45 final String variableName; | 40 final String variableName; |
| 46 bool variableReferencedInInitializer = false; | 41 bool variableReferencedInInitializer = false; |
| 47 | 42 |
| 48 VariableDefinitionScope(Scope parent, this.variableName) : super(parent); | 43 VariableDefinitionScope(Scope parent, this.variableName) : super(parent); |
| 49 | 44 |
| 50 Element localLookup(String name) { | 45 Element localLookup(String name) { |
| 51 if (name == variableName) { | 46 if (name == variableName) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 167 |
| 173 Element localLookup(String name) => library.find(name); | 168 Element localLookup(String name) => library.find(name); |
| 174 Element lookup(String name) => localLookup(name); | 169 Element lookup(String name) => localLookup(name); |
| 175 | 170 |
| 176 Element add(Element newElement) { | 171 Element add(Element newElement) { |
| 177 throw "Cannot add an element to a library scope"; | 172 throw "Cannot add an element to a library scope"; |
| 178 } | 173 } |
| 179 | 174 |
| 180 String toString() => 'LibraryScope($library)'; | 175 String toString() => 'LibraryScope($library)'; |
| 181 } | 176 } |
| OLD | NEW |