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 library dart2js.resolution.scope; | 5 library dart2js.resolution.scope; |
6 | 6 |
7 import '../elements/resolution_types.dart'; | 7 import '../elements/resolution_types.dart'; |
8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
9 | 9 |
10 abstract class Scope { | 10 abstract class Scope { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 TypeDeclarationScope(Scope parent, this.element) : super(parent); | 104 TypeDeclarationScope(Scope parent, this.element) : super(parent); |
105 | 105 |
106 String toString() => 'TypeDeclarationScope($element)'; | 106 String toString() => 'TypeDeclarationScope($element)'; |
107 } | 107 } |
108 | 108 |
109 abstract class MutableScope extends NestedScope { | 109 abstract class MutableScope extends NestedScope { |
110 final Map<String, Element> elements; | 110 final Map<String, Element> elements; |
111 | 111 |
112 MutableScope(Scope parent) | 112 MutableScope(Scope parent) |
113 : super(parent), | 113 : this.elements = new Map<String, Element>(), |
114 this.elements = new Map<String, Element>() { | 114 super(parent) { |
115 assert(parent != null); | 115 assert(parent != null); |
116 } | 116 } |
117 | 117 |
118 Element add(Element newElement) { | 118 Element add(Element newElement) { |
119 if (elements.containsKey(newElement.name)) { | 119 if (elements.containsKey(newElement.name)) { |
120 return elements[newElement.name]; | 120 return elements[newElement.name]; |
121 } | 121 } |
122 elements[newElement.name] = newElement; | 122 elements[newElement.name] = newElement; |
123 return newElement; | 123 return newElement; |
124 } | 124 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 Element localLookup(String name) => library.find(name); | 222 Element localLookup(String name) => library.find(name); |
223 Element lookup(String name) => localLookup(name); | 223 Element lookup(String name) => localLookup(name); |
224 | 224 |
225 Element add(Element newElement) { | 225 Element add(Element newElement) { |
226 throw "Cannot add an element to a library scope"; | 226 throw "Cannot add an element to a library scope"; |
227 } | 227 } |
228 | 228 |
229 String toString() => 'LibraryScope($library)'; | 229 String toString() => 'LibraryScope($library)'; |
230 } | 230 } |
OLD | NEW |