| 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.full_emitter; | 5 library dart2js.js_emitter.full_emitter; |
| 6 | 6 |
| 7 import 'dart:collection' show HashMap; | 7 import 'dart:collection' show HashMap; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 | 1527 |
| 1528 void emitMainOutputUnit(OutputUnit mainOutputUnit, jsAst.Program program) { | 1528 void emitMainOutputUnit(OutputUnit mainOutputUnit, jsAst.Program program) { |
| 1529 LocationCollector locationCollector; | 1529 LocationCollector locationCollector; |
| 1530 List<CodeOutputListener> codeOutputListeners; | 1530 List<CodeOutputListener> codeOutputListeners; |
| 1531 if (generateSourceMap) { | 1531 if (generateSourceMap) { |
| 1532 locationCollector = new LocationCollector(); | 1532 locationCollector = new LocationCollector(); |
| 1533 codeOutputListeners = <CodeOutputListener>[locationCollector]; | 1533 codeOutputListeners = <CodeOutputListener>[locationCollector]; |
| 1534 } | 1534 } |
| 1535 | 1535 |
| 1536 CodeOutput mainOutput = new StreamCodeOutput( | 1536 CodeOutput mainOutput = new StreamCodeOutput( |
| 1537 compiler.outputProvider('', 'js', OutputType.js), codeOutputListeners); | 1537 compiler.outputProvider.createOutputSink('', 'js', OutputType.js), |
| 1538 codeOutputListeners); |
| 1538 outputBuffers[mainOutputUnit] = mainOutput; | 1539 outputBuffers[mainOutputUnit] = mainOutput; |
| 1539 | 1540 |
| 1540 mainOutput.addBuffer(jsAst.createCodeBuffer( | 1541 mainOutput.addBuffer(jsAst.createCodeBuffer( |
| 1541 program, compiler.options, backend.sourceInformationStrategy, | 1542 program, compiler.options, backend.sourceInformationStrategy, |
| 1542 monitor: compiler.dumpInfoTask)); | 1543 monitor: compiler.dumpInfoTask)); |
| 1543 | 1544 |
| 1544 if (compiler.options.deferredMapUri != null) { | 1545 if (compiler.options.deferredMapUri != null) { |
| 1545 outputDeferredMap(); | 1546 outputDeferredMap(); |
| 1546 } | 1547 } |
| 1547 | 1548 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 | 1868 |
| 1868 LocationCollector locationCollector; | 1869 LocationCollector locationCollector; |
| 1869 if (generateSourceMap) { | 1870 if (generateSourceMap) { |
| 1870 locationCollector = new LocationCollector(); | 1871 locationCollector = new LocationCollector(); |
| 1871 outputListeners.add(locationCollector); | 1872 outputListeners.add(locationCollector); |
| 1872 } | 1873 } |
| 1873 | 1874 |
| 1874 String partPrefix = compiler.deferredLoadTask | 1875 String partPrefix = compiler.deferredLoadTask |
| 1875 .deferredPartFileName(outputUnit.name, addExtension: false); | 1876 .deferredPartFileName(outputUnit.name, addExtension: false); |
| 1876 CodeOutput output = new StreamCodeOutput( | 1877 CodeOutput output = new StreamCodeOutput( |
| 1877 compiler.outputProvider(partPrefix, 'part.js', OutputType.jsPart), | 1878 compiler.outputProvider |
| 1879 .createOutputSink(partPrefix, 'part.js', OutputType.jsPart), |
| 1878 outputListeners); | 1880 outputListeners); |
| 1879 | 1881 |
| 1880 outputBuffers[outputUnit] = output; | 1882 outputBuffers[outputUnit] = output; |
| 1881 | 1883 |
| 1882 output.addBuffer(jsAst.createCodeBuffer(outputAsts[outputUnit], | 1884 output.addBuffer(jsAst.createCodeBuffer(outputAsts[outputUnit], |
| 1883 compiler.options, backend.sourceInformationStrategy, | 1885 compiler.options, backend.sourceInformationStrategy, |
| 1884 monitor: compiler.dumpInfoTask)); | 1886 monitor: compiler.dumpInfoTask)); |
| 1885 | 1887 |
| 1886 // Make a unique hash of the code (before the sourcemaps are added) | 1888 // Make a unique hash of the code (before the sourcemaps are added) |
| 1887 // This will be used to retrieve the initializing function from the global | 1889 // This will be used to retrieve the initializing function from the global |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 return new jsAst.Comment(generatedBy(compiler, flavor: options.join(", "))); | 1938 return new jsAst.Comment(generatedBy(compiler, flavor: options.join(", "))); |
| 1937 } | 1939 } |
| 1938 | 1940 |
| 1939 void outputDeferredMap() { | 1941 void outputDeferredMap() { |
| 1940 Map<String, dynamic> mapping = new Map<String, dynamic>(); | 1942 Map<String, dynamic> mapping = new Map<String, dynamic>(); |
| 1941 // Json does not support comments, so we embed the explanation in the | 1943 // Json does not support comments, so we embed the explanation in the |
| 1942 // data. | 1944 // data. |
| 1943 mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 1945 mapping["_comment"] = "This mapping shows which compiled `.js` files are " |
| 1944 "needed for a given deferred library import."; | 1946 "needed for a given deferred library import."; |
| 1945 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 1947 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); |
| 1946 compiler.outputProvider( | 1948 compiler.outputProvider.createOutputSink( |
| 1947 compiler.options.deferredMapUri.path, '', OutputType.info) | 1949 compiler.options.deferredMapUri.path, '', OutputType.info) |
| 1948 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) | 1950 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) |
| 1949 ..close(); | 1951 ..close(); |
| 1950 } | 1952 } |
| 1951 } | 1953 } |
| OLD | NEW |