| 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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 | 7 |
| 8 class OldEmitter implements Emitter { | 8 class OldEmitter implements Emitter { |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 final CodeEmitterTask task; | 10 final CodeEmitterTask task; |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 // closure that constructs the initial value. | 844 // closure that constructs the initial value. |
| 845 return js('#(#,#,#,#,#)', | 845 return js('#(#,#,#,#,#)', |
| 846 [js(lazyInitializerName), | 846 [js(lazyInitializerName), |
| 847 js(isolateProperties), | 847 js(isolateProperties), |
| 848 js.string(element.name), | 848 js.string(element.name), |
| 849 js.string(namer.globalPropertyName(element)), | 849 js.string(namer.globalPropertyName(element)), |
| 850 js.string(namer.lazyInitializerName(element)), | 850 js.string(namer.lazyInitializerName(element)), |
| 851 code]); | 851 code]); |
| 852 } | 852 } |
| 853 | 853 |
| 854 void emitMetadata(List<String> globalMetadata, CodeOutput output) { | 854 void emitMetadata(Program program, CodeOutput output) { |
| 855 String metadataAccess = | 855 |
| 856 generateEmbeddedGlobalAccessString(embeddedNames.METADATA); | 856 addMetadataGlobal(List<String> list, String global) { |
| 857 output.add('$metadataAccess$_=$_['); | 857 String globalAccess = generateEmbeddedGlobalAccessString(global); |
| 858 for (String metadata in globalMetadata) { | 858 output.add('$globalAccess$_=$_['); |
| 859 if (metadata is String) { | 859 for (String data in list) { |
| 860 if (metadata != 'null') { | 860 if (data is String) { |
| 861 output.add(metadata); | 861 if (data != 'null') { |
| 862 } | 862 output.add(data); |
| 863 } else { | 863 } |
| 864 throw 'Unexpected value in metadata: ${Error.safeToString(metadata)}'; | 864 } else { |
| 865 } | 865 throw 'Unexpected value in ${global}: ${Error.safeToString(data)}'; |
| 866 output.add(',$n'); | 866 } |
| 867 } | 867 output.add(',$n'); |
| 868 output.add('];$n'); | 868 } |
| 869 output.add('];$n'); |
| 870 } |
| 871 |
| 872 addMetadataGlobal(program.metadata, embeddedNames.METADATA); |
| 873 addMetadataGlobal(program.metadataTypes, embeddedNames.TYPES); |
| 869 } | 874 } |
| 870 | 875 |
| 871 void emitCompileTimeConstants(CodeOutput output, | 876 void emitCompileTimeConstants(CodeOutput output, |
| 872 List<Constant> constants, | 877 List<Constant> constants, |
| 873 {bool isMainFragment}) { | 878 {bool isMainFragment}) { |
| 874 assert(isMainFragment != null); | 879 assert(isMainFragment != null); |
| 875 | 880 |
| 876 if (constants.isEmpty) return; | 881 if (constants.isEmpty) return; |
| 877 CodeOutput constantOutput = output; | 882 CodeOutput constantOutput = output; |
| 878 if (compiler.hasIncrementalSupport && isMainFragment) { | 883 if (compiler.hasIncrementalSupport && isMainFragment) { |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 } | 1487 } |
| 1483 | 1488 |
| 1484 // Static field initializations require the classes and compile-time | 1489 // Static field initializations require the classes and compile-time |
| 1485 // constants to be set up. | 1490 // constants to be set up. |
| 1486 emitStaticNonFinalFieldInitializations(mainOutput, mainOutputUnit); | 1491 emitStaticNonFinalFieldInitializations(mainOutput, mainOutputUnit); |
| 1487 interceptorEmitter.emitTypeToInterceptorMap(program, mainOutput); | 1492 interceptorEmitter.emitTypeToInterceptorMap(program, mainOutput); |
| 1488 emitLazilyInitializedStaticFields(mainOutput); | 1493 emitLazilyInitializedStaticFields(mainOutput); |
| 1489 | 1494 |
| 1490 mainOutput.add('\n'); | 1495 mainOutput.add('\n'); |
| 1491 | 1496 |
| 1492 emitMetadata(task.metadataCollector.globalMetadata, mainOutput); | 1497 emitMetadata(program, mainOutput); |
| 1493 | 1498 |
| 1494 isolateProperties = isolatePropertiesName; | 1499 isolateProperties = isolatePropertiesName; |
| 1495 // The following code should not use the short-hand for the | 1500 // The following code should not use the short-hand for the |
| 1496 // initialStatics. | 1501 // initialStatics. |
| 1497 mainOutput.add('${namer.currentIsolate}$_=${_}null$N'); | 1502 mainOutput.add('${namer.currentIsolate}$_=${_}null$N'); |
| 1498 | 1503 |
| 1499 emitFinishIsolateConstructorInvocation(mainOutput); | 1504 emitFinishIsolateConstructorInvocation(mainOutput); |
| 1500 mainOutput.add( | 1505 mainOutput.add( |
| 1501 '${namer.currentIsolate}$_=${_}new ${namer.isolateName}()$N'); | 1506 '${namer.currentIsolate}$_=${_}new ${namer.isolateName}()$N'); |
| 1502 | 1507 |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2024 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2020 if (element.isInstanceMember) { | 2025 if (element.isInstanceMember) { |
| 2021 cachedClassBuilders.remove(element.enclosingClass); | 2026 cachedClassBuilders.remove(element.enclosingClass); |
| 2022 | 2027 |
| 2023 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2028 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2024 | 2029 |
| 2025 } | 2030 } |
| 2026 } | 2031 } |
| 2027 } | 2032 } |
| 2028 } | 2033 } |
| OLD | NEW |