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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 if (list.length == 1 && list[0] == '*') { | 446 if (list.length == 1 && list[0] == '*') { |
447 return analyzer.wildcard; | 447 return analyzer.wildcard; |
448 } | 448 } |
449 List<Element> result = <Element>[]; | 449 List<Element> result = <Element>[]; |
450 for (var entry in list) { | 450 for (var entry in list) { |
451 if (entry is ResolutionDartType) { | 451 if (entry is ResolutionDartType) { |
452 ResolutionDartType type = entry; | 452 ResolutionDartType type = entry; |
453 result.add(type.element); | 453 result.add(type.element); |
454 } else { | 454 } else { |
455 String string = entry; | 455 String string = entry; |
456 LibraryElement libraryCandiate; | 456 LibraryElement libraryCandidate; |
457 String libraryNameCandiate; | 457 String libraryNameCandidate; |
458 for (LibraryElement l in compiler.libraryLoader.libraries) { | 458 for (LibraryElement l in compiler.libraryLoader.libraries) { |
459 if (l.hasLibraryName) { | 459 if (l.hasLibraryName) { |
460 String libraryName = l.libraryName; | 460 String libraryName = l.libraryName; |
461 if (string == libraryName) { | 461 if (string == libraryName) { |
462 // Found an exact match. | 462 // Found an exact match. |
463 libraryCandiate = l; | 463 libraryCandidate = l; |
464 libraryNameCandiate = libraryName; | 464 libraryNameCandidate = libraryName; |
465 break; | 465 break; |
466 } else if (string.startsWith('$libraryName.')) { | 466 } else if (string.startsWith('$libraryName.')) { |
467 if (libraryNameCandiate == null || | 467 if (libraryNameCandidate == null || |
468 libraryNameCandiate.length < libraryName.length) { | 468 libraryNameCandidate.length < libraryName.length) { |
469 // Found a better candiate | 469 // Found a better candidate |
470 libraryCandiate = l; | 470 libraryCandidate = l; |
471 libraryNameCandiate = libraryName; | 471 libraryNameCandidate = libraryName; |
472 } | 472 } |
473 } | 473 } |
474 } | 474 } |
475 } | 475 } |
476 Element e; | 476 Element e; |
477 if (libraryNameCandiate == string) { | 477 if (libraryNameCandidate == string) { |
478 e = libraryCandiate; | 478 e = libraryCandidate; |
479 } else if (libraryNameCandiate != null) { | 479 } else if (libraryNameCandidate != null) { |
480 e = resolveLocalExpression(libraryCandiate, | 480 e = resolveLocalExpression(libraryCandidate, |
481 string.substring(libraryNameCandiate.length + 1).split('.')); | 481 string.substring(libraryNameCandidate.length + 1).split('.')); |
482 } else { | 482 } else { |
483 e = resolveExpression(string); | 483 e = resolveExpression(string); |
484 } | 484 } |
485 if (e != null) result.add(e); | 485 if (e != null) result.add(e); |
486 } | 486 } |
487 } | 487 } |
488 return result; | 488 return result; |
489 } | 489 } |
490 | 490 |
491 /// Resolve [expression] in [enclosingLibrary]'s import scope. | 491 /// Resolve [expression] in [enclosingLibrary]'s import scope. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 // @MirrorsUsed(targets: fisk) | 567 // @MirrorsUsed(targets: fisk) |
568 // ^^^^ | 568 // ^^^^ |
569 // | 569 // |
570 // Instead of saying 'fisk' should pretty print the problematic constant | 570 // Instead of saying 'fisk' should pretty print the problematic constant |
571 // value. | 571 // value. |
572 return spannable; | 572 return spannable; |
573 } | 573 } |
574 return node; | 574 return node; |
575 } | 575 } |
576 } | 576 } |
OLD | NEW |