| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 299 |
| 300 /// Returns the JSName annotation string or `null` if no JSName annotation is | 300 /// Returns the JSName annotation string or `null` if no JSName annotation is |
| 301 /// present. | 301 /// present. |
| 302 String findJsNameFromAnnotation(Element element) { | 302 String findJsNameFromAnnotation(Element element) { |
| 303 String name = null; | 303 String name = null; |
| 304 ClassElement annotationClass = annotationJsNameClass; | 304 ClassElement annotationClass = annotationJsNameClass; |
| 305 for (Link<MetadataAnnotation> link = element.metadata; | 305 for (Link<MetadataAnnotation> link = element.metadata; |
| 306 !link.isEmpty; | 306 !link.isEmpty; |
| 307 link = link.tail) { | 307 link = link.tail) { |
| 308 MetadataAnnotation annotation = link.head.ensureResolved(compiler); | 308 MetadataAnnotation annotation = link.head.ensureResolved(compiler); |
| 309 Constant value = annotation.constant.value; | 309 ConstantValue value = annotation.constant.value; |
| 310 if (!value.isConstructedObject) continue; | 310 if (!value.isConstructedObject) continue; |
| 311 ConstructedConstant constructedObject = value; | 311 ConstructedConstantValue constructedObject = value; |
| 312 if (constructedObject.type.element != annotationClass) continue; | 312 if (constructedObject.type.element != annotationClass) continue; |
| 313 | 313 |
| 314 List<Constant> fields = constructedObject.fields; | 314 List<ConstantValue> fields = constructedObject.fields; |
| 315 // TODO(sra): Better validation of the constant. | 315 // TODO(sra): Better validation of the constant. |
| 316 if (fields.length != 1 || fields[0] is! StringConstant) { | 316 if (fields.length != 1 || fields[0] is! StringConstantValue) { |
| 317 PartialMetadataAnnotation partial = annotation; | 317 PartialMetadataAnnotation partial = annotation; |
| 318 compiler.internalError(annotation, | 318 compiler.internalError(annotation, |
| 319 'Annotations needs one string: ${partial.parseNode(compiler)}'); | 319 'Annotations needs one string: ${partial.parseNode(compiler)}'); |
| 320 } | 320 } |
| 321 StringConstant specStringConstant = fields[0]; | 321 StringConstantValue specStringConstant = fields[0]; |
| 322 String specString = specStringConstant.toDartString().slowToString(); | 322 String specString = specStringConstant.toDartString().slowToString(); |
| 323 if (name == null) { | 323 if (name == null) { |
| 324 name = specString; | 324 name = specString; |
| 325 } else { | 325 } else { |
| 326 PartialMetadataAnnotation partial = annotation; | 326 PartialMetadataAnnotation partial = annotation; |
| 327 compiler.internalError(annotation, | 327 compiler.internalError(annotation, |
| 328 'Too many JSName annotations: ${partial.parseNode(compiler)}'); | 328 'Too many JSName annotations: ${partial.parseNode(compiler)}'); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 return name; | 331 return name; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 superclass, | 632 superclass, |
| 633 () => <ClassElement>[]); | 633 () => <ClassElement>[]); |
| 634 directSubtypes.add(cls); | 634 directSubtypes.add(cls); |
| 635 } | 635 } |
| 636 | 636 |
| 637 void logSummary(log(message)) { | 637 void logSummary(log(message)) { |
| 638 log('Compiled ${registeredClasses.length} native classes, ' | 638 log('Compiled ${registeredClasses.length} native classes, ' |
| 639 '${unusedClasses.length} native classes omitted.'); | 639 '${unusedClasses.length} native classes omitted.'); |
| 640 } | 640 } |
| 641 } | 641 } |
| OLD | NEW |