| 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 library dart2js.new_js_emitter.model_emitter; | 5 library dart2js.new_js_emitter.model_emitter; |
| 6 | 6 |
| 7 import '../../dart2jslib.dart' show Compiler; | 7 import '../../dart2jslib.dart' show Compiler; |
| 8 import '../../dart_types.dart' show DartType; | 8 import '../../dart_types.dart' show DartType; |
| 9 import '../../elements/elements.dart' show ClassElement; | 9 import '../../elements/elements.dart' show ClassElement; |
| 10 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 int emitProgram(Program program) { | 62 int emitProgram(Program program) { |
| 63 List<Fragment> fragments = program.fragments; | 63 List<Fragment> fragments = program.fragments; |
| 64 MainFragment mainFragment = fragments.first; | 64 MainFragment mainFragment = fragments.first; |
| 65 | 65 |
| 66 int totalSize = 0; | 66 int totalSize = 0; |
| 67 | 67 |
| 68 // We have to emit the deferred fragments first, since we need their | 68 // We have to emit the deferred fragments first, since we need their |
| 69 // deferred hash (which depends on the output) when emitting the main | 69 // deferred hash (which depends on the output) when emitting the main |
| 70 // fragment. | 70 // fragment. |
| 71 fragments.skip(1).forEach((DeferredFragment deferredUnit) { | 71 fragments.skip(1).forEach((DeferredFragment deferredUnit) { |
| 72 js.Expression ast = | 72 js.Expression ast = emitDeferredFragment(deferredUnit, program.holders); |
| 73 emitDeferredFragment(deferredUnit, mainFragment.holders); | |
| 74 String code = js.prettyPrint(ast, compiler).getText(); | 73 String code = js.prettyPrint(ast, compiler).getText(); |
| 75 totalSize += code.length; | 74 totalSize += code.length; |
| 76 compiler.outputProvider(deferredUnit.outputFileName, deferredExtension) | 75 compiler.outputProvider(deferredUnit.outputFileName, deferredExtension) |
| 77 ..add(code) | 76 ..add(code) |
| 78 ..close(); | 77 ..close(); |
| 79 }); | 78 }); |
| 80 | 79 |
| 81 js.Statement mainAst = emitMainFragment(program); | 80 js.Statement mainAst = emitMainFragment(program); |
| 82 String mainCode = js.prettyPrint(mainAst, compiler).getText(); | 81 String mainCode = js.prettyPrint(mainAst, compiler).getText(); |
| 83 compiler.outputProvider(mainFragment.outputFileName, 'js') | 82 compiler.outputProvider(mainFragment.outputFileName, 'js') |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 js.Statement emitMainFragment(Program program) { | 103 js.Statement emitMainFragment(Program program) { |
| 105 MainFragment fragment = program.fragments.first; | 104 MainFragment fragment = program.fragments.first; |
| 106 List<js.Expression> elements = fragment.libraries.map(emitLibrary).toList(); | 105 List<js.Expression> elements = fragment.libraries.map(emitLibrary).toList(); |
| 107 elements.add( | 106 elements.add( |
| 108 emitLazilyInitializedStatics(fragment.staticLazilyInitializedFields)); | 107 emitLazilyInitializedStatics(fragment.staticLazilyInitializedFields)); |
| 109 | 108 |
| 110 js.Expression code = new js.ArrayInitializer(elements); | 109 js.Expression code = new js.ArrayInitializer(elements); |
| 111 | 110 |
| 112 Map<String, dynamic> holes = | 111 Map<String, dynamic> holes = |
| 113 {'deferredInitializer': emitDeferredInitializerGlobal(program.loadMap), | 112 {'deferredInitializer': emitDeferredInitializerGlobal(program.loadMap), |
| 114 'holders': emitHolders(fragment.holders), | 113 'holders': emitHolders(program.holders), |
| 115 'tearOff': buildTearOffCode(backend), | 114 'tearOff': buildTearOffCode(backend), |
| 116 'parseFunctionDescriptor': | 115 'parseFunctionDescriptor': |
| 117 js.js.statement(parseFunctionDescriptorBoilerplate), | 116 js.js.statement(parseFunctionDescriptorBoilerplate), |
| 118 'cyclicThrow': | 117 'cyclicThrow': |
| 119 backend.emitter.staticFunctionAccess(backend.getCyclicThrowHelper()), | 118 backend.emitter.staticFunctionAccess(backend.getCyclicThrowHelper()), |
| 120 'outputContainsConstantList': program.outputContainsConstantList, | 119 'outputContainsConstantList': program.outputContainsConstantList, |
| 121 'embeddedGlobals': emitEmbeddedGlobals(program), | 120 'embeddedGlobals': emitEmbeddedGlobals(program), |
| 122 'constants': emitConstants(fragment.constants), | 121 'constants': emitConstants(fragment.constants), |
| 123 'staticNonFinals': | 122 'staticNonFinals': |
| 124 emitStaticNonFinalFields(fragment.staticNonFinalFields), | 123 emitStaticNonFinalFields(fragment.staticNonFinalFields), |
| 125 'operatorIsPrefix': js.string(namer.operatorIsPrefix), | 124 'operatorIsPrefix': js.string(namer.operatorIsPrefix), |
| 126 'eagerClasses': emitEagerClassInitializations(fragment.libraries), | 125 'eagerClasses': emitEagerClassInitializations(fragment.libraries), |
| 127 'invokeMain': fragment.invokeMain, | 126 'invokeMain': fragment.invokeMain, |
| 128 'code': code}; | 127 'code': code}; |
| 129 | 128 |
| 130 holes.addAll(nativeHoles(program)); | 129 holes.addAll(nativeHoles(program)); |
| 131 | 130 |
| 132 return js.js.statement(boilerplate, holes); | 131 return js.js.statement(boilerplate, holes); |
| 133 } | 132 } |
| 134 | 133 |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 | 977 |
| 979 var end = Date.now(); | 978 var end = Date.now(); |
| 980 // print('Setup: ' + (end - start) + ' ms.'); | 979 // print('Setup: ' + (end - start) + ' ms.'); |
| 981 | 980 |
| 982 #invokeMain; // Start main. | 981 #invokeMain; // Start main. |
| 983 | 982 |
| 984 }(Date.now(), #code) | 983 }(Date.now(), #code) |
| 985 }"""; | 984 }"""; |
| 986 | 985 |
| 987 } | 986 } |
| OLD | NEW |