| 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('elements'); | 5 #library('elements'); |
| 6 | 6 |
| 7 #import('../tree/tree.dart'); | 7 #import('../tree/tree.dart'); |
| 8 #import('../scanner/scannerlib.dart'); | 8 #import('../scanner/scannerlib.dart'); |
| 9 #import('../leg.dart'); // TODO(karlklose): we only need type. | 9 #import('../leg.dart'); // TODO(karlklose): we only need type. |
| 10 #import('../util/util.dart'); | 10 #import('../util/util.dart'); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 addGetterOrSetter(element, elements[element.name], listener); | 294 addGetterOrSetter(element, elements[element.name], listener); |
| 295 } else { | 295 } else { |
| 296 Element existing = elements.putIfAbsent(element.name, () => element); | 296 Element existing = elements.putIfAbsent(element.name, () => element); |
| 297 if (existing !== element) { | 297 if (existing !== element) { |
| 298 listener.cancel('duplicate definition', token: element.position()); | 298 listener.cancel('duplicate definition', token: element.position()); |
| 299 listener.cancel('existing definition', token: existing.position()); | 299 listener.cancel('existing definition', token: existing.position()); |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 /** Look up a top-level element in this library. The element could | |
| 305 * potentially have been imported from another library. Returns | |
| 306 * null if no such element exist. */ | |
| 307 Element find(SourceString elementName) { | 304 Element find(SourceString elementName) { |
| 308 return elements[elementName]; | 305 return elements[elementName]; |
| 309 } | 306 } |
| 310 | 307 |
| 311 /** Look up a top-level element in this library, but only look for | |
| 312 * non-imported elements. Returns null if no such element exist. */ | |
| 313 Element findLocal(SourceString elementName) { | |
| 314 Element result = elements[elementName]; | |
| 315 if (result === null || result.getLibrary() != this) return null; | |
| 316 return result; | |
| 317 } | |
| 318 | |
| 319 void forEachExport(f(Element element)) { | 308 void forEachExport(f(Element element)) { |
| 320 elements.forEach((SourceString _, Element e) { | 309 elements.forEach((SourceString _, Element e) { |
| 321 if (this === e.getLibrary() | 310 if (this === e.getLibrary() |
| 322 && e.kind !== ElementKind.PREFIX | 311 && e.kind !== ElementKind.PREFIX |
| 323 && e.kind !== ElementKind.FOREIGN) { | 312 && e.kind !== ElementKind.FOREIGN) { |
| 324 if (!e.name.isPrivate()) f(e); | 313 if (!e.name.isPrivate()) f(e); |
| 325 } | 314 } |
| 326 }); | 315 }); |
| 327 } | 316 } |
| 328 | 317 |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 final Node node; | 1046 final Node node; |
| 1058 Type bound; | 1047 Type bound; |
| 1059 Type type; | 1048 Type type; |
| 1060 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1049 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1061 [this.bound]) | 1050 [this.bound]) |
| 1062 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1051 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1063 Type computeType(compiler) => type; | 1052 Type computeType(compiler) => type; |
| 1064 Node parseNode(compiler) => node; | 1053 Node parseNode(compiler) => node; |
| 1065 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1054 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1066 } | 1055 } |
| OLD | NEW |