| 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. */ |
| 304 Element find(SourceString elementName) { | 307 Element find(SourceString elementName) { |
| 305 return elements[elementName]; | 308 return elements[elementName]; |
| 306 } | 309 } |
| 307 | 310 |
| 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 |
| 308 void forEachExport(f(Element element)) { | 319 void forEachExport(f(Element element)) { |
| 309 elements.forEach((SourceString _, Element e) { | 320 elements.forEach((SourceString _, Element e) { |
| 310 if (this === e.getLibrary() | 321 if (this === e.getLibrary() |
| 311 && e.kind !== ElementKind.PREFIX | 322 && e.kind !== ElementKind.PREFIX |
| 312 && e.kind !== ElementKind.FOREIGN) { | 323 && e.kind !== ElementKind.FOREIGN) { |
| 313 if (!e.name.isPrivate()) f(e); | 324 if (!e.name.isPrivate()) f(e); |
| 314 } | 325 } |
| 315 }); | 326 }); |
| 316 } | 327 } |
| 317 | 328 |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 final Node node; | 1057 final Node node; |
| 1047 Type bound; | 1058 Type bound; |
| 1048 Type type; | 1059 Type type; |
| 1049 TypeVariableElement(name, Element enclosing, this.node, this.type, | 1060 TypeVariableElement(name, Element enclosing, this.node, this.type, |
| 1050 [this.bound]) | 1061 [this.bound]) |
| 1051 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 1062 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 1052 Type computeType(compiler) => type; | 1063 Type computeType(compiler) => type; |
| 1053 Node parseNode(compiler) => node; | 1064 Node parseNode(compiler) => node; |
| 1054 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; | 1065 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; |
| 1055 } | 1066 } |
| OLD | NEW |