OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.startup_emitter.model_emitter; | 5 library dart2js.js_emitter.startup_emitter.model_emitter; |
6 | 6 |
7 import 'dart:convert' show JsonEncoder; | 7 import 'dart:convert' show JsonEncoder; |
8 | 8 |
9 import 'package:js_runtime/shared/embedded_names.dart' | 9 import 'package:js_runtime/shared/embedded_names.dart' |
10 show | 10 show |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 compiler.outputProvider('', 'js', OutputType.js), codeOutputListeners); | 253 compiler.outputProvider('', 'js', OutputType.js), codeOutputListeners); |
254 outputBuffers[fragment] = mainOutput; | 254 outputBuffers[fragment] = mainOutput; |
255 | 255 |
256 js.Program program = new js.Program([ | 256 js.Program program = new js.Program([ |
257 buildGeneratedBy(), | 257 buildGeneratedBy(), |
258 new js.Comment(HOOKS_API_USAGE), | 258 new js.Comment(HOOKS_API_USAGE), |
259 isSplit ? buildDeferredInitializerGlobal() : new js.Block.empty(), | 259 isSplit ? buildDeferredInitializerGlobal() : new js.Block.empty(), |
260 code | 260 code |
261 ]); | 261 ]); |
262 | 262 |
263 mainOutput.addBuffer( | 263 mainOutput.addBuffer(js.createCodeBuffer( |
264 js.createCodeBuffer(program, compiler, monitor: compiler.dumpInfoTask)); | 264 program, compiler.options, backend.sourceInformationStrategy, |
| 265 monitor: compiler.dumpInfoTask)); |
265 | 266 |
266 if (shouldGenerateSourceMap) { | 267 if (shouldGenerateSourceMap) { |
267 mainOutput.add(SourceMapBuilder.generateSourceMapTag( | 268 mainOutput.add(SourceMapBuilder.generateSourceMapTag( |
268 compiler.options.sourceMapUri, compiler.options.outputUri)); | 269 compiler.options.sourceMapUri, compiler.options.outputUri)); |
269 } | 270 } |
270 | 271 |
271 mainOutput.close(); | 272 mainOutput.close(); |
272 | 273 |
273 if (shouldGenerateSourceMap) { | 274 if (shouldGenerateSourceMap) { |
274 SourceMapBuilder.outputSourceMap( | 275 SourceMapBuilder.outputSourceMap( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // | 315 // |
315 // deferredInitializer.current = <pretty-printed code>; | 316 // deferredInitializer.current = <pretty-printed code>; |
316 // deferredInitializer[<hash>] = deferredInitializer.current; | 317 // deferredInitializer[<hash>] = deferredInitializer.current; |
317 | 318 |
318 js.Program program = new js.Program([ | 319 js.Program program = new js.Program([ |
319 buildGeneratedBy(), | 320 buildGeneratedBy(), |
320 buildDeferredInitializerGlobal(), | 321 buildDeferredInitializerGlobal(), |
321 js.js.statement('$deferredInitializersGlobal.current = #', code) | 322 js.js.statement('$deferredInitializersGlobal.current = #', code) |
322 ]); | 323 ]); |
323 | 324 |
324 output.addBuffer( | 325 output.addBuffer(js.createCodeBuffer( |
325 js.createCodeBuffer(program, compiler, monitor: compiler.dumpInfoTask)); | 326 program, compiler.options, backend.sourceInformationStrategy, |
| 327 monitor: compiler.dumpInfoTask)); |
326 | 328 |
327 // Make a unique hash of the code (before the sourcemaps are added) | 329 // Make a unique hash of the code (before the sourcemaps are added) |
328 // This will be used to retrieve the initializing function from the global | 330 // This will be used to retrieve the initializing function from the global |
329 // variable. | 331 // variable. |
330 String hash = hasher.getHash(); | 332 String hash = hasher.getHash(); |
331 | 333 |
332 // Now we copy the deferredInitializer.current into its correct hash. | 334 // Now we copy the deferredInitializer.current into its correct hash. |
333 output.add('\n${deferredInitializersGlobal}["$hash"] = ' | 335 output.add('\n${deferredInitializersGlobal}["$hash"] = ' |
334 '${deferredInitializersGlobal}.current'); | 336 '${deferredInitializersGlobal}.current'); |
335 | 337 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // data. | 378 // data. |
377 mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 379 mapping["_comment"] = "This mapping shows which compiled `.js` files are " |
378 "needed for a given deferred library import."; | 380 "needed for a given deferred library import."; |
379 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 381 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); |
380 compiler.outputProvider( | 382 compiler.outputProvider( |
381 compiler.options.deferredMapUri.path, '', OutputType.info) | 383 compiler.options.deferredMapUri.path, '', OutputType.info) |
382 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) | 384 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) |
383 ..close(); | 385 ..close(); |
384 } | 386 } |
385 } | 387 } |
OLD | NEW |