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 /// This class is a temporary work-around until we get a more powerful DartType. | 7 /// This class is a temporary work-around until we get a more powerful DartType. |
8 class SpecialType { | 8 class SpecialType { |
9 final String name; | 9 final String name; |
10 const SpecialType._(this.name); | 10 const SpecialType._(this.name); |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 * [annotationClass]. | 682 * [annotationClass]. |
683 * Returns `null` if no constraints. | 683 * Returns `null` if no constraints. |
684 */ | 684 */ |
685 static _collect(Element element, Compiler compiler, Element annotationClass, | 685 static _collect(Element element, Compiler compiler, Element annotationClass, |
686 lookup(str)) { | 686 lookup(str)) { |
687 var types = null; | 687 var types = null; |
688 for (Link<MetadataAnnotation> link = element.metadata; | 688 for (Link<MetadataAnnotation> link = element.metadata; |
689 !link.isEmpty; | 689 !link.isEmpty; |
690 link = link.tail) { | 690 link = link.tail) { |
691 MetadataAnnotation annotation = link.head.ensureResolved(compiler); | 691 MetadataAnnotation annotation = link.head.ensureResolved(compiler); |
692 ConstantValue value = annotation.constant.value; | 692 ConstantValue value = |
| 693 compiler.constants.getConstantValue(annotation.constant); |
693 if (!value.isConstructedObject) continue; | 694 if (!value.isConstructedObject) continue; |
694 ConstructedConstantValue constructedObject = value; | 695 ConstructedConstantValue constructedObject = value; |
695 if (constructedObject.type.element != annotationClass) continue; | 696 if (constructedObject.type.element != annotationClass) continue; |
696 | 697 |
697 Iterable<ConstantValue> fields = constructedObject.fields.values; | 698 Iterable<ConstantValue> fields = constructedObject.fields.values; |
698 // TODO(sra): Better validation of the constant. | 699 // TODO(sra): Better validation of the constant. |
699 if (fields.length != 1 || !fields.single.isString) { | 700 if (fields.length != 1 || !fields.single.isString) { |
700 PartialMetadataAnnotation partial = annotation; | 701 PartialMetadataAnnotation partial = annotation; |
701 compiler.internalError(annotation, | 702 compiler.internalError(annotation, |
702 'Annotations needs one string: ${partial.parseNode(compiler)}'); | 703 'Annotations needs one string: ${partial.parseNode(compiler)}'); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 MessageKind.GENERIC, | 771 MessageKind.GENERIC, |
771 {'text': "Type '$typeString' not found."}); | 772 {'text': "Type '$typeString' not found."}); |
772 return const DynamicType(); | 773 return const DynamicType(); |
773 } | 774 } |
774 | 775 |
775 static _errorNode(locationNodeOrElement, compiler) { | 776 static _errorNode(locationNodeOrElement, compiler) { |
776 if (locationNodeOrElement is Node) return locationNodeOrElement; | 777 if (locationNodeOrElement is Node) return locationNodeOrElement; |
777 return locationNodeOrElement.parseNode(compiler); | 778 return locationNodeOrElement.parseNode(compiler); |
778 } | 779 } |
779 } | 780 } |
OLD | NEW |