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 #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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 } | 239 } |
| 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 if (this.isLibrary()) { | |
|
ahe
2012/10/11 07:36:05
Perhaps this method should be overridden in Librar
floitsch
2012/10/11 13:58:12
Done.
| |
| 250 LibraryElement library = this; | |
| 251 return library.entryCompilationUnit; | |
| 252 } | |
| 249 Element element = this; | 253 Element element = this; |
| 250 while (element !== null && !element.isCompilationUnit()) { | 254 while (!element.isCompilationUnit()) { |
|
ahe
2012/10/11 07:36:05
This will ensure a null error if something is setu
| |
| 251 if (element.isLibrary()) { | |
| 252 LibraryElement library = element; | |
| 253 return library.entryCompilationUnit; | |
| 254 } | |
| 255 element = element.enclosingElement; | 255 element = element.enclosingElement; |
| 256 } | 256 } |
| 257 return element; | 257 return element; |
| 258 } | 258 } |
| 259 | 259 |
| 260 LibraryElement getLibrary() => enclosingElement.getLibrary(); | 260 LibraryElement getLibrary() => enclosingElement.getLibrary(); |
| 261 | 261 |
| 262 LibraryElement getImplementationLibrary() { | 262 LibraryElement getImplementationLibrary() { |
| 263 Element element = this; | 263 Element element = this; |
| 264 while (element.kind !== ElementKind.LIBRARY) { | 264 while (element.kind !== ElementKind.LIBRARY) { |
| (...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1947 | 1947 |
| 1948 MetadataAnnotation ensureResolved(Compiler compiler) { | 1948 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1949 if (resolutionState == STATE_NOT_STARTED) { | 1949 if (resolutionState == STATE_NOT_STARTED) { |
| 1950 compiler.resolver.resolveMetadataAnnotation(this); | 1950 compiler.resolver.resolveMetadataAnnotation(this); |
| 1951 } | 1951 } |
| 1952 return this; | 1952 return this; |
| 1953 } | 1953 } |
| 1954 | 1954 |
| 1955 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1955 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1956 } | 1956 } |
| OLD | NEW |