| 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.js_emitter.lazy_emitter.model_emitter; | 5 library dart2js.js_emitter.lazy_emitter.model_emitter; |
| 6 | 6 |
| 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; | 7 import '../../constants/values.dart' show ConstantValue, FunctionConstantValue; |
| 8 import '../../dart2jslib.dart' show Compiler; | 8 import '../../dart2jslib.dart' show Compiler; |
| 9 import '../../elements/elements.dart' show ClassElement, FunctionElement; | 9 import '../../elements/elements.dart' show ClassElement, FunctionElement; |
| 10 import '../../js/js.dart' as js; | 10 import '../../js/js.dart' as js; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (isConstantInlinedOrAlreadyEmitted(value)) { | 122 if (isConstantInlinedOrAlreadyEmitted(value)) { |
| 123 return constantEmitter.generate(value); | 123 return constantEmitter.generate(value); |
| 124 } | 124 } |
| 125 return js.js('#.#()', [namer.globalObjectForConstant(value), | 125 return js.js('#.#()', [namer.globalObjectForConstant(value), |
| 126 namer.constantName(value)]); | 126 namer.constantName(value)]); |
| 127 } | 127 } |
| 128 | 128 |
| 129 int emitProgram(Program program) { | 129 int emitProgram(Program program) { |
| 130 List<Fragment> fragments = program.fragments; | 130 List<Fragment> fragments = program.fragments; |
| 131 MainFragment mainFragment = fragments.first; | 131 MainFragment mainFragment = fragments.first; |
| 132 Iterable<Fragment> deferredFragments = program.deferredFragments; |
| 132 | 133 |
| 133 int totalSize = 0; | 134 int totalSize = 0; |
| 134 | 135 |
| 135 // We have to emit the deferred fragments first, since we need their | 136 // We have to emit the deferred fragments first, since we need their |
| 136 // deferred hash (which depends on the output) when emitting the main | 137 // deferred hash (which depends on the output) when emitting the main |
| 137 // fragment. | 138 // fragment. |
| 138 List<js.Expression> fragmentsCode = fragments.skip(1).map( | 139 List<js.Expression> fragmentsCode = deferredFragments.map( |
| 139 (DeferredFragment deferredUnit) { | 140 (DeferredFragment deferredUnit) { |
| 140 js.Expression types = | 141 js.Expression types = |
| 141 program.metadataTypesForOutputUnit(deferredUnit.outputUnit); | 142 program.metadataTypesForOutputUnit(deferredUnit.outputUnit); |
| 142 return emitDeferredFragment(types, deferredUnit, program.holders); | 143 return emitDeferredFragment(types, deferredUnit, program.holders); |
| 143 }).toList(); | 144 }).toList(); |
| 144 | 145 |
| 145 js.Statement mainAst = emitMainFragment(program); | 146 js.Statement mainAst = emitMainFragment(program); |
| 146 | 147 |
| 147 js.TokenCounter counter = new js.TokenCounter(); | 148 js.TokenCounter counter = new js.TokenCounter(); |
| 148 fragmentsCode.forEach(counter.countTokens); | 149 fragmentsCode.forEach(counter.countTokens); |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 | 1239 |
| 1239 var end = Date.now(); | 1240 var end = Date.now(); |
| 1240 // print('Setup: ' + (end - start) + ' ms.'); | 1241 // print('Setup: ' + (end - start) + ' ms.'); |
| 1241 | 1242 |
| 1242 #invokeMain; // Start main. | 1243 #invokeMain; // Start main. |
| 1243 | 1244 |
| 1244 })(Date.now(), #code) | 1245 })(Date.now(), #code) |
| 1245 }"""; | 1246 }"""; |
| 1246 | 1247 |
| 1247 } | 1248 } |
| OLD | NEW |