| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 // TODO(ahe): This class is simply wrong. This backend should use | 7 // TODO(ahe): This class is simply wrong. This backend should use |
| 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, | 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, |
| 9 // TreeElements>] is what is needed. | 9 // TreeElements>] is what is needed. |
| 10 class ElementAst { | 10 class ElementAst { |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 nonPlatformSize += compilationUnit.script.text.length; | 498 nonPlatformSize += compilationUnit.script.text.length; |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 int percentage = compiler.assembledCode.length * 100 ~/ nonPlatformSize; | 501 int percentage = compiler.assembledCode.length * 100 ~/ nonPlatformSize; |
| 502 log('Total used non-platform files size: ${nonPlatformSize} bytes, ' | 502 log('Total used non-platform files size: ${nonPlatformSize} bytes, ' |
| 503 'bundle size: ${compiler.assembledCode.length} bytes (${percentage}%)'); | 503 'bundle size: ${compiler.assembledCode.length} bytes (${percentage}%)'); |
| 504 } | 504 } |
| 505 | 505 |
| 506 log(String message) => compiler.log('[DartBackend] $message'); | 506 log(String message) => compiler.log('[DartBackend] $message'); |
| 507 | 507 |
| 508 void onLibraryLoaded(LibraryElement library, Uri uri) { | 508 Future onLibraryLoaded(LibraryElement library, Uri uri) { |
| 509 if (useMirrorHelperLibrary && library == compiler.mirrorsLibrary) { | 509 if (useMirrorHelperLibrary && library == compiler.mirrorsLibrary) { |
| 510 mirrorHelperLibrary = compiler.scanBuiltinLibrary( | 510 return compiler.scanBuiltinLibrary( |
| 511 MirrorRenamer.MIRROR_HELPER_LIBRARY_NAME); | 511 MirrorRenamer.MIRROR_HELPER_LIBRARY_NAME). |
| 512 mirrorHelperGetNameFunction = mirrorHelperLibrary.find( | 512 then((LibraryElement element) { |
| 513 const SourceString(MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION)); | 513 mirrorHelperLibrary = element; |
| 514 mirrorHelperSymbolsMap = mirrorHelperLibrary.find( | 514 mirrorHelperGetNameFunction = mirrorHelperLibrary.find( |
| 515 const SourceString(MirrorRenamer.MIRROR_HELPER_SYMBOLS_MAP_NAME)); | 515 const SourceString(MirrorRenamer.MIRROR_HELPER_GET_NAME_FUNCTION)); |
| 516 mirrorHelperSymbolsMap = mirrorHelperLibrary.find( |
| 517 const SourceString(MirrorRenamer.MIRROR_HELPER_SYMBOLS_MAP_NAME)); |
| 518 }); |
| 516 } | 519 } |
| 520 return new Future.value(); |
| 517 } | 521 } |
| 518 | 522 |
| 519 void registerStaticSend(Element element, Node node) { | 523 void registerStaticSend(Element element, Node node) { |
| 520 if (useMirrorHelperLibrary) { | 524 if (useMirrorHelperLibrary) { |
| 521 mirrorRenamer.registerStaticSend(element, node); | 525 mirrorRenamer.registerStaticSend(element, node); |
| 522 } | 526 } |
| 523 } | 527 } |
| 524 | 528 |
| 525 void registerMirrorHelperElement(Element element, Node node) { | 529 void registerMirrorHelperElement(Element element, Node node) { |
| 526 if (mirrorHelperLibrary != null | 530 if (mirrorHelperLibrary != null |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 } | 617 } |
| 614 | 618 |
| 615 compareElements(e0, e1) { | 619 compareElements(e0, e1) { |
| 616 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); | 620 int result = compareBy((e) => e.getLibrary().canonicalUri.toString())(e0, e1); |
| 617 if (result != 0) return result; | 621 if (result != 0) return result; |
| 618 return compareBy((e) => e.position().charOffset)(e0, e1); | 622 return compareBy((e) => e.position().charOffset)(e0, e1); |
| 619 } | 623 } |
| 620 | 624 |
| 621 List<Element> sortElements(Iterable<Element> elements) => | 625 List<Element> sortElements(Iterable<Element> elements) => |
| 622 sorted(elements, compareElements); | 626 sorted(elements, compareElements); |
| OLD | NEW |