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 'package:js_runtime/shared/embedded_names.dart' | 7 import 'package:js_runtime/shared/embedded_names.dart' |
8 show | 8 show |
9 CREATE_NEW_ISOLATE, | 9 CREATE_NEW_ISOLATE, |
10 DEFERRED_LIBRARY_URIS, | 10 DEFERRED_LIBRARY_URIS, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 js.Statement mainAst = emitMainFragment(program); | 144 js.Statement mainAst = emitMainFragment(program); |
145 | 145 |
146 js.TokenCounter counter = new js.TokenCounter(); | 146 js.TokenCounter counter = new js.TokenCounter(); |
147 fragmentsCode.forEach(counter.countTokens); | 147 fragmentsCode.forEach(counter.countTokens); |
148 counter.countTokens(mainAst); | 148 counter.countTokens(mainAst); |
149 | 149 |
150 program.finalizers.forEach((js.TokenFinalizer f) => f.finalizeTokens()); | 150 program.finalizers.forEach((js.TokenFinalizer f) => f.finalizeTokens()); |
151 | 151 |
152 // TODO(johnnniwinther): Support source maps in this emitter. | 152 // TODO(johnnniwinther): Support source maps in this emitter. |
153 for (int i = 0; i < fragmentsCode.length; ++i) { | 153 for (int i = 0; i < fragmentsCode.length; ++i) { |
154 String code = js.createCodeBuffer(fragmentsCode[i], compiler).getText(); | 154 String code = js |
| 155 .createCodeBuffer(fragmentsCode[i], compiler.options, |
| 156 backend.sourceInformationStrategy) |
| 157 .getText(); |
155 totalSize += code.length; | 158 totalSize += code.length; |
156 compiler.outputProvider( | 159 compiler.outputProvider( |
157 fragments[i + 1].outputFileName, deferredExtension, OutputType.jsPart) | 160 fragments[i + 1].outputFileName, deferredExtension, OutputType.jsPart) |
158 ..add(code) | 161 ..add(code) |
159 ..close(); | 162 ..close(); |
160 } | 163 } |
161 | 164 |
162 String mainCode = js.createCodeBuffer(mainAst, compiler).getText(); | 165 String mainCode = js |
| 166 .createCodeBuffer( |
| 167 mainAst, compiler.options, backend.sourceInformationStrategy) |
| 168 .getText(); |
163 compiler.outputProvider(mainFragment.outputFileName, 'js', OutputType.js) | 169 compiler.outputProvider(mainFragment.outputFileName, 'js', OutputType.js) |
164 ..add(buildGeneratedBy(compiler)) | 170 ..add(buildGeneratedBy(compiler)) |
165 ..add(mainCode) | 171 ..add(mainCode) |
166 ..close(); | 172 ..close(); |
167 totalSize += mainCode.length; | 173 totalSize += mainCode.length; |
168 | 174 |
169 return totalSize; | 175 return totalSize; |
170 } | 176 } |
171 | 177 |
172 /// Returns a [js.Literal] that represents the string result of unparsing | 178 /// Returns a [js.Literal] that represents the string result of unparsing |
173 /// [value]. | 179 /// [value]. |
174 /// | 180 /// |
175 /// The returned node will, when its string value is requested, pretty-print | 181 /// The returned node will, when its string value is requested, pretty-print |
176 /// the given [value] and, if [protectForEval] is true, wrap the resulting | 182 /// the given [value] and, if [protectForEval] is true, wrap the resulting |
177 /// string in parenthesis. The result is also escaped. | 183 /// string in parenthesis. The result is also escaped. |
178 /// | 184 /// |
179 /// See [_UnparsedNode] for details. | 185 /// See [_UnparsedNode] for details. |
180 js.Literal unparse(Compiler compiler, js.Node value, | 186 js.Literal unparse(Compiler compiler, js.Node value, |
181 {bool protectForEval: true}) { | 187 {bool protectForEval: true}) { |
182 return new js.UnparsedNode(value, compiler, protectForEval); | 188 return new js.UnparsedNode(value, compiler.options, protectForEval); |
183 } | 189 } |
184 | 190 |
185 String buildGeneratedBy(compiler) { | 191 String buildGeneratedBy(compiler) { |
186 var suffix = ''; | 192 var suffix = ''; |
187 if (compiler.options.hasBuildId) { | 193 if (compiler.options.hasBuildId) { |
188 suffix = ' version: ${compiler.options.buildId}'; | 194 suffix = ' version: ${compiler.options.buildId}'; |
189 } | 195 } |
190 return '// Generated by dart2js, the Dart to JavaScript compiler$suffix.\n'; | 196 return '// Generated by dart2js, the Dart to JavaScript compiler$suffix.\n'; |
191 } | 197 } |
192 | 198 |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 #eagerClasses; | 1274 #eagerClasses; |
1269 | 1275 |
1270 var end = Date.now(); | 1276 var end = Date.now(); |
1271 // print('Setup: ' + (end - start) + ' ms.'); | 1277 // print('Setup: ' + (end - start) + ' ms.'); |
1272 | 1278 |
1273 #invokeMain; // Start main. | 1279 #invokeMain; // Start main. |
1274 | 1280 |
1275 })(Date.now(), #code) | 1281 })(Date.now(), #code) |
1276 }"""; | 1282 }"""; |
1277 } | 1283 } |
OLD | NEW |