Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 } | 34 } |
| 35 | 35 |
| 36 Element localLookup(SourceString name); | 36 Element localLookup(SourceString name); |
| 37 | 37 |
| 38 static Scope buildEnclosingScope(Element element) { | 38 static Scope buildEnclosingScope(Element element) { |
| 39 return element.enclosingElement != null | 39 return element.enclosingElement != null |
| 40 ? element.enclosingElement.buildScope() : element.buildScope(); | 40 ? element.enclosingElement.buildScope() : element.buildScope(); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 class VariableDefinitionScope extends NestedScope { | |
| 45 final SourceString variableName; | |
| 46 bool variableReferencedInInitializer = false; | |
| 47 | |
| 48 VariableDefinitionScope(Scope parent, this.variableName) : super(parent); | |
| 49 | |
| 50 Element localLookup(SourceString name) { | |
| 51 if (name == variableName) { | |
| 52 variableReferencedInInitializer = true; | |
| 53 } | |
| 54 return null; | |
| 55 } | |
| 56 | |
| 57 Element add(Element newElement) { | |
| 58 throw "Cannot add element to TypeDeclarationScope"; | |
|
ngeoffray
2013/09/10 11:39:48
TypeDeclarationScope -> VariableDefinitionScope
karlklose
2013/09/10 11:45:53
Done.
| |
| 59 } | |
| 60 } | |
| 61 | |
| 44 /** | 62 /** |
| 45 * [TypeDeclarationScope] defines the outer scope of a type declaration in | 63 * [TypeDeclarationScope] defines the outer scope of a type declaration in |
| 46 * which the declared type variables and the entities in the enclosing scope are | 64 * which the declared type variables and the entities in the enclosing scope are |
| 47 * available but where declared and inherited members are not available. This | 65 * available but where declared and inherited members are not available. This |
| 48 * scope is only used for class declarations during resolution of the | 66 * scope is only used for class declarations during resolution of the |
| 49 * class hierarchy. In all other cases [ClassScope] is used. | 67 * class hierarchy. In all other cases [ClassScope] is used. |
| 50 */ | 68 */ |
| 51 class TypeDeclarationScope extends NestedScope { | 69 class TypeDeclarationScope extends NestedScope { |
| 52 final TypeDeclarationElement element; | 70 final TypeDeclarationElement element; |
| 53 | 71 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 | 172 |
| 155 Element localLookup(SourceString name) => library.find(name); | 173 Element localLookup(SourceString name) => library.find(name); |
| 156 Element lookup(SourceString name) => localLookup(name); | 174 Element lookup(SourceString name) => localLookup(name); |
| 157 | 175 |
| 158 Element add(Element newElement) { | 176 Element add(Element newElement) { |
| 159 throw "Cannot add an element to a library scope"; | 177 throw "Cannot add an element to a library scope"; |
| 160 } | 178 } |
| 161 | 179 |
| 162 String toString() => 'LibraryScope($library)'; | 180 String toString() => 'LibraryScope($library)'; |
| 163 } | 181 } |
| OLD | NEW |