| 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('dart:uri'); | 7 #import('dart:uri'); |
| 8 | 8 |
| 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. | 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. |
| 10 #import('../../compiler.dart', prefix: 'api_e'); | 10 #import('../../compiler.dart', prefix: 'api_e'); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return token; | 240 return token; |
| 241 } | 241 } |
| 242 | 242 |
| 243 // TODO(kasperl): This is a very bad hash code for the element and | 243 // TODO(kasperl): This is a very bad hash code for the element and |
| 244 // there's no reason why two elements with the same name should have | 244 // there's no reason why two elements with the same name should have |
| 245 // the same hash code. Replace this with a simple id in the element? | 245 // the same hash code. Replace this with a simple id in the element? |
| 246 int hashCode() => name === null ? 0 : name.hashCode(); | 246 int hashCode() => name === null ? 0 : name.hashCode(); |
| 247 | 247 |
| 248 CompilationUnitElement getCompilationUnit() { | 248 CompilationUnitElement getCompilationUnit() { |
| 249 Element element = this; | 249 Element element = this; |
| 250 while (element !== null && !element.isCompilationUnit()) { | 250 while (!element.isCompilationUnit()) { |
| 251 if (element.isLibrary()) { | |
| 252 LibraryElement library = element; | |
| 253 return library.entryCompilationUnit; | |
| 254 } | |
| 255 element = element.enclosingElement; | 251 element = element.enclosingElement; |
| 256 } | 252 } |
| 257 return element; | 253 return element; |
| 258 } | 254 } |
| 259 | 255 |
| 260 LibraryElement getLibrary() => enclosingElement.getLibrary(); | 256 LibraryElement getLibrary() => enclosingElement.getLibrary(); |
| 261 | 257 |
| 262 LibraryElement getImplementationLibrary() { | 258 LibraryElement getImplementationLibrary() { |
| 263 Element element = this; | 259 Element element = this; |
| 264 while (element.kind !== ElementKind.LIBRARY) { | 260 while (element.kind !== ElementKind.LIBRARY) { |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 origin.patch = this; | 603 origin.patch = this; |
| 608 } | 604 } |
| 609 } | 605 } |
| 610 | 606 |
| 611 bool get isPatched => patch !== null; | 607 bool get isPatched => patch !== null; |
| 612 bool get isPatch => origin !== null; | 608 bool get isPatch => origin !== null; |
| 613 | 609 |
| 614 LibraryElement get declaration => super.declaration; | 610 LibraryElement get declaration => super.declaration; |
| 615 LibraryElement get implementation => super.implementation; | 611 LibraryElement get implementation => super.implementation; |
| 616 | 612 |
| 613 CompilationUnitElement getCompilationUnit() => entryCompilationUnit; |
| 614 |
| 617 void addCompilationUnit(CompilationUnitElement element) { | 615 void addCompilationUnit(CompilationUnitElement element) { |
| 618 compilationUnits = compilationUnits.prepend(element); | 616 compilationUnits = compilationUnits.prepend(element); |
| 619 } | 617 } |
| 620 | 618 |
| 621 void addTag(LibraryTag tag, DiagnosticListener listener) { | 619 void addTag(LibraryTag tag, DiagnosticListener listener) { |
| 622 tags = tags.prepend(tag); | 620 tags = tags.prepend(tag); |
| 623 } | 621 } |
| 624 | 622 |
| 625 /** | 623 /** |
| 626 * Adds [element] to the import scope of this library. | 624 * Adds [element] to the import scope of this library. |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 | 1945 |
| 1948 MetadataAnnotation ensureResolved(Compiler compiler) { | 1946 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1949 if (resolutionState == STATE_NOT_STARTED) { | 1947 if (resolutionState == STATE_NOT_STARTED) { |
| 1950 compiler.resolver.resolveMetadataAnnotation(this); | 1948 compiler.resolver.resolveMetadataAnnotation(this); |
| 1951 } | 1949 } |
| 1952 return this; | 1950 return this; |
| 1953 } | 1951 } |
| 1954 | 1952 |
| 1955 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1953 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1956 } | 1954 } |
| OLD | NEW |