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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 ClassElement annotationClass = annotationJsNameClass; | 317 ClassElement annotationClass = annotationJsNameClass; |
318 for (Link<MetadataAnnotation> link = element.metadata; | 318 for (Link<MetadataAnnotation> link = element.metadata; |
319 !link.isEmpty; | 319 !link.isEmpty; |
320 link = link.tail) { | 320 link = link.tail) { |
321 MetadataAnnotation annotation = link.head.ensureResolved(compiler); | 321 MetadataAnnotation annotation = link.head.ensureResolved(compiler); |
322 ConstantValue value = annotation.constant.value; | 322 ConstantValue value = annotation.constant.value; |
323 if (!value.isConstructedObject) continue; | 323 if (!value.isConstructedObject) continue; |
324 ConstructedConstantValue constructedObject = value; | 324 ConstructedConstantValue constructedObject = value; |
325 if (constructedObject.type.element != annotationClass) continue; | 325 if (constructedObject.type.element != annotationClass) continue; |
326 | 326 |
327 List<ConstantValue> fields = constructedObject.fields; | 327 Iterable<ConstantValue> fields = constructedObject.fields.values; |
328 // TODO(sra): Better validation of the constant. | 328 // TODO(sra): Better validation of the constant. |
329 if (fields.length != 1 || fields[0] is! StringConstantValue) { | 329 if (fields.length != 1 || fields.single is! StringConstantValue) { |
330 PartialMetadataAnnotation partial = annotation; | 330 PartialMetadataAnnotation partial = annotation; |
331 compiler.internalError(annotation, | 331 compiler.internalError(annotation, |
332 'Annotations needs one string: ${partial.parseNode(compiler)}'); | 332 'Annotations needs one string: ${partial.parseNode(compiler)}'); |
333 } | 333 } |
334 StringConstantValue specStringConstant = fields[0]; | 334 StringConstantValue specStringConstant = fields.single; |
335 String specString = specStringConstant.toDartString().slowToString(); | 335 String specString = specStringConstant.toDartString().slowToString(); |
336 if (name == null) { | 336 if (name == null) { |
337 name = specString; | 337 name = specString; |
338 } else { | 338 } else { |
339 PartialMetadataAnnotation partial = annotation; | 339 PartialMetadataAnnotation partial = annotation; |
340 compiler.internalError(annotation, | 340 compiler.internalError(annotation, |
341 'Too many JSName annotations: ${partial.parseNode(compiler)}'); | 341 'Too many JSName annotations: ${partial.parseNode(compiler)}'); |
342 } | 342 } |
343 } | 343 } |
344 return name; | 344 return name; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 superclass, | 683 superclass, |
684 () => <ClassElement>[]); | 684 () => <ClassElement>[]); |
685 directSubtypes.add(cls); | 685 directSubtypes.add(cls); |
686 } | 686 } |
687 | 687 |
688 void logSummary(log(message)) { | 688 void logSummary(log(message)) { |
689 log('Compiled ${registeredClasses.length} native classes, ' | 689 log('Compiled ${registeredClasses.length} native classes, ' |
690 '${unusedClasses.length} native classes omitted.'); | 690 '${unusedClasses.length} native classes omitted.'); |
691 } | 691 } |
692 } | 692 } |
OLD | NEW |