OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of native; | 5 part of native; |
6 | 6 |
7 /** | 7 /** |
8 * This could be an abstract class but we use it as a stub for the dart_backend. | 8 * This could be an abstract class but we use it as a stub for the dart_backend. |
9 */ | 9 */ |
10 class NativeEnqueuer { | 10 class NativeEnqueuer { |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 _annotationCreatesClass = find('Creates'); | 307 _annotationCreatesClass = find('Creates'); |
308 _annotationReturnsClass = find('Returns'); | 308 _annotationReturnsClass = find('Returns'); |
309 _annotationJsNameClass = find('JSName'); | 309 _annotationJsNameClass = find('JSName'); |
310 } | 310 } |
311 | 311 |
312 /// Returns the JSName annotation string or `null` if no JSName annotation is | 312 /// Returns the JSName annotation string or `null` if no JSName annotation is |
313 /// present. | 313 /// present. |
314 String findJsNameFromAnnotation(Element element) { | 314 String findJsNameFromAnnotation(Element element) { |
315 String name = null; | 315 String name = null; |
316 ClassElement annotationClass = annotationJsNameClass; | 316 ClassElement annotationClass = annotationJsNameClass; |
317 for (Link<MetadataAnnotation> link = element.metadata; | 317 for (MetadataAnnotation annotation in element.implementation.metadata) { |
318 !link.isEmpty; | 318 annotation.ensureResolved(compiler); |
319 link = link.tail) { | |
320 MetadataAnnotation annotation = link.head.ensureResolved(compiler); | |
321 ConstantValue value = | 319 ConstantValue value = |
322 compiler.constants.getConstantValue(annotation.constant); | 320 compiler.constants.getConstantValue(annotation.constant); |
323 if (!value.isConstructedObject) continue; | 321 if (!value.isConstructedObject) continue; |
324 ConstructedConstantValue constructedObject = value; | 322 ConstructedConstantValue constructedObject = value; |
325 if (constructedObject.type.element != annotationClass) continue; | 323 if (constructedObject.type.element != annotationClass) continue; |
326 | 324 |
327 Iterable<ConstantValue> fields = constructedObject.fields.values; | 325 Iterable<ConstantValue> fields = constructedObject.fields.values; |
328 // TODO(sra): Better validation of the constant. | 326 // TODO(sra): Better validation of the constant. |
329 if (fields.length != 1 || fields.single is! StringConstantValue) { | 327 if (fields.length != 1 || fields.single is! StringConstantValue) { |
330 PartialMetadataAnnotation partial = annotation; | 328 PartialMetadataAnnotation partial = annotation; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 superclass, | 686 superclass, |
689 () => <ClassElement>[]); | 687 () => <ClassElement>[]); |
690 directSubtypes.add(cls); | 688 directSubtypes.add(cls); |
691 } | 689 } |
692 | 690 |
693 void logSummary(log(message)) { | 691 void logSummary(log(message)) { |
694 log('Compiled ${registeredClasses.length} native classes, ' | 692 log('Compiled ${registeredClasses.length} native classes, ' |
695 '${unusedClasses.length} native classes omitted.'); | 693 '${unusedClasses.length} native classes omitted.'); |
696 } | 694 } |
697 } | 695 } |
OLD | NEW |