| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.mirrors_used; | 5 library dart2js.mirrors_used; |
| 6 | 6 |
| 7 import 'common/tasks.dart' show CompilerTask; | 7 import 'common/tasks.dart' show CompilerTask; |
| 8 import 'common.dart'; | 8 import 'common.dart'; |
| 9 import 'compile_time_constants.dart' show ConstantCompiler; | 9 import 'compile_time_constants.dart' show ConstantCompiler; |
| 10 import 'compiler.dart' show Compiler; | 10 import 'compiler.dart' show Compiler; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 List convertConstantToUsageList(ConstantValue constant, | 376 List convertConstantToUsageList(ConstantValue constant, |
| 377 {bool onlyStrings: false}) { | 377 {bool onlyStrings: false}) { |
| 378 if (constant.isNull) { | 378 if (constant.isNull) { |
| 379 return null; | 379 return null; |
| 380 } else if (constant.isList) { | 380 } else if (constant.isList) { |
| 381 ListConstantValue list = constant; | 381 ListConstantValue list = constant; |
| 382 List result = onlyStrings ? <String>[] : []; | 382 List result = onlyStrings ? <String>[] : []; |
| 383 for (ConstantValue entry in list.entries) { | 383 for (ConstantValue entry in list.entries) { |
| 384 if (entry.isString) { | 384 if (entry.isString) { |
| 385 StringConstantValue string = entry; | 385 StringConstantValue string = entry; |
| 386 result.add(string.primitiveValue.slowToString()); | 386 result.add(string.primitiveValue); |
| 387 } else if (!onlyStrings && entry.isType) { | 387 } else if (!onlyStrings && entry.isType) { |
| 388 TypeConstantValue type = entry; | 388 TypeConstantValue type = entry; |
| 389 result.add(type.representedType); | 389 result.add(type.representedType); |
| 390 } else { | 390 } else { |
| 391 Spannable node = positionOf(entry); | 391 Spannable node = positionOf(entry); |
| 392 MessageKind kind = onlyStrings | 392 MessageKind kind = onlyStrings |
| 393 ? MessageKind.MIRRORS_EXPECTED_STRING | 393 ? MessageKind.MIRRORS_EXPECTED_STRING |
| 394 : MessageKind.MIRRORS_EXPECTED_STRING_OR_TYPE; | 394 : MessageKind.MIRRORS_EXPECTED_STRING_OR_TYPE; |
| 395 reporter.reportHintMessage( | 395 reporter.reportHintMessage( |
| 396 node, kind, {'name': node, 'type': apiTypeOf(entry)}); | 396 node, kind, {'name': node, 'type': apiTypeOf(entry)}); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 return result; | 399 return result; |
| 400 } else if (!onlyStrings && constant.isType) { | 400 } else if (!onlyStrings && constant.isType) { |
| 401 TypeConstantValue type = constant; | 401 TypeConstantValue type = constant; |
| 402 return [type.representedType]; | 402 return [type.representedType]; |
| 403 } else if (constant.isString) { | 403 } else if (constant.isString) { |
| 404 StringConstantValue string = constant; | 404 StringConstantValue string = constant; |
| 405 var iterable = | 405 var iterable = string.primitiveValue.split(',').map((e) => e.trim()); |
| 406 string.primitiveValue.slowToString().split(',').map((e) => e.trim()); | |
| 407 return onlyStrings ? new List<String>.from(iterable) : iterable.toList(); | 406 return onlyStrings ? new List<String>.from(iterable) : iterable.toList(); |
| 408 } else { | 407 } else { |
| 409 Spannable node = positionOf(constant); | 408 Spannable node = positionOf(constant); |
| 410 MessageKind kind = onlyStrings | 409 MessageKind kind = onlyStrings |
| 411 ? MessageKind.MIRRORS_EXPECTED_STRING_OR_LIST | 410 ? MessageKind.MIRRORS_EXPECTED_STRING_OR_LIST |
| 412 : MessageKind.MIRRORS_EXPECTED_STRING_TYPE_OR_LIST; | 411 : MessageKind.MIRRORS_EXPECTED_STRING_TYPE_OR_LIST; |
| 413 reporter.reportHintMessage( | 412 reporter.reportHintMessage( |
| 414 node, kind, {'name': node, 'type': apiTypeOf(constant)}); | 413 node, kind, {'name': node, 'type': apiTypeOf(constant)}); |
| 415 return null; | 414 return null; |
| 416 } | 415 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // @MirrorsUsed(targets: fisk) | 566 // @MirrorsUsed(targets: fisk) |
| 568 // ^^^^ | 567 // ^^^^ |
| 569 // | 568 // |
| 570 // Instead of saying 'fisk' should pretty print the problematic constant | 569 // Instead of saying 'fisk' should pretty print the problematic constant |
| 571 // value. | 570 // value. |
| 572 return spannable; | 571 return spannable; |
| 573 } | 572 } |
| 574 return node; | 573 return node; |
| 575 } | 574 } |
| 576 } | 575 } |
| OLD | NEW |