| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 * [annotationClass]. | 345 * [annotationClass]. |
| 346 * Returns `null` if no constraints. | 346 * Returns `null` if no constraints. |
| 347 */ | 347 */ |
| 348 static _collect(Element element, Compiler compiler, Element annotationClass, | 348 static _collect(Element element, Compiler compiler, Element annotationClass, |
| 349 lookup(str)) { | 349 lookup(str)) { |
| 350 var types = null; | 350 var types = null; |
| 351 for (Link<MetadataAnnotation> link = element.metadata; | 351 for (Link<MetadataAnnotation> link = element.metadata; |
| 352 !link.isEmpty; | 352 !link.isEmpty; |
| 353 link = link.tail) { | 353 link = link.tail) { |
| 354 MetadataAnnotation annotation = link.head.ensureResolved(compiler); | 354 MetadataAnnotation annotation = link.head.ensureResolved(compiler); |
| 355 Constant value = annotation.constant.value; | 355 ConstantValue value = annotation.constant.value; |
| 356 if (!value.isConstructedObject) continue; | 356 if (!value.isConstructedObject) continue; |
| 357 ConstructedConstant constructedObject = value; | 357 ConstructedConstantValue constructedObject = value; |
| 358 if (constructedObject.type.element != annotationClass) continue; | 358 if (constructedObject.type.element != annotationClass) continue; |
| 359 | 359 |
| 360 List<Constant> fields = constructedObject.fields; | 360 List<ConstantValue> fields = constructedObject.fields; |
| 361 // TODO(sra): Better validation of the constant. | 361 // TODO(sra): Better validation of the constant. |
| 362 if (fields.length != 1 || !fields[0].isString) { | 362 if (fields.length != 1 || !fields[0].isString) { |
| 363 PartialMetadataAnnotation partial = annotation; | 363 PartialMetadataAnnotation partial = annotation; |
| 364 compiler.internalError(annotation, | 364 compiler.internalError(annotation, |
| 365 'Annotations needs one string: ${partial.parseNode(compiler)}'); | 365 'Annotations needs one string: ${partial.parseNode(compiler)}'); |
| 366 } | 366 } |
| 367 StringConstant specStringConstant = fields[0]; | 367 StringConstantValue specStringConstant = fields[0]; |
| 368 String specString = specStringConstant.toDartString().slowToString(); | 368 String specString = specStringConstant.toDartString().slowToString(); |
| 369 for (final typeString in specString.split('|')) { | 369 for (final typeString in specString.split('|')) { |
| 370 var type = _parseType(typeString, compiler, lookup, annotation); | 370 var type = _parseType(typeString, compiler, lookup, annotation); |
| 371 if (types == null) types = []; | 371 if (types == null) types = []; |
| 372 types.add(type); | 372 types.add(type); |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 return types; | 375 return types; |
| 376 } | 376 } |
| 377 | 377 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 compiler.internalError( | 429 compiler.internalError( |
| 430 _errorNode(locationNodeOrElement, compiler), | 430 _errorNode(locationNodeOrElement, compiler), |
| 431 "Type '$typeString' not found."); | 431 "Type '$typeString' not found."); |
| 432 } | 432 } |
| 433 | 433 |
| 434 static _errorNode(locationNodeOrElement, compiler) { | 434 static _errorNode(locationNodeOrElement, compiler) { |
| 435 if (locationNodeOrElement is Node) return locationNodeOrElement; | 435 if (locationNodeOrElement is Node) return locationNodeOrElement; |
| 436 return locationNodeOrElement.parseNode(compiler); | 436 return locationNodeOrElement.parseNode(compiler); |
| 437 } | 437 } |
| 438 } | 438 } |
| OLD | NEW |