Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/old_emitter/emitter.dart

Issue 656783002: Revert "Add support for source maps in deferred libraries." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/compiler/dart2js/source_map_deferred_d2js_validity_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 7
8 class OldEmitter implements Emitter { 8 class OldEmitter implements Emitter {
9 final Compiler compiler; 9 final Compiler compiler;
10 final CodeEmitterTask task; 10 final CodeEmitterTask task;
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 [ constructorName, js.string(constructorName), 1286 [ constructorName, js.string(constructorName),
1287 constructorName, 1287 constructorName,
1288 constructorName, js.string(constructorName), 1288 constructorName, js.string(constructorName),
1289 constructorName, 1289 constructorName,
1290 constructorName 1290 constructorName
1291 ])); 1291 ]));
1292 1292
1293 cspPrecompiledConstructorNamesFor(outputUnit).add(js('#', constructorName)); 1293 cspPrecompiledConstructorNamesFor(outputUnit).add(js('#', constructorName));
1294 } 1294 }
1295 1295
1296 /// Extracts the output name of the compiler's outputUri. 1296 /// Returns a name composed of the main output file name and [name].
1297 String deferredPartFileName(OutputUnit outputUnit, 1297 String deferredPartFileName(OutputUnit outputUnit,
1298 {bool addExtension: true}) { 1298 {bool addExtension: true}) {
1299 String outPath = compiler.outputUri != null 1299 String outPath = compiler.outputUri != null
1300 ? compiler.outputUri.path 1300 ? compiler.outputUri.path
1301 : "out"; 1301 : "out";
1302 String outName = outPath.substring(outPath.lastIndexOf('/') + 1); 1302 String outName = outPath.substring(outPath.lastIndexOf('/') + 1);
1303 String extension = addExtension ? ".part.js" : ""; 1303 String extension = addExtension ? ".part.js" : "";
1304 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) { 1304 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) {
1305 return "$outName$extension"; 1305 return "$outName$extension";
1306 } else { 1306 } else {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 if (compiler.useContentSecurityPolicy) { 1639 if (compiler.useContentSecurityPolicy) {
1640 mainBuffer.write( 1640 mainBuffer.write(
1641 jsAst.prettyPrint( 1641 jsAst.prettyPrint(
1642 precompiledFunctionAst, 1642 precompiledFunctionAst,
1643 compiler, 1643 compiler,
1644 monitor: compiler.dumpInfoTask, 1644 monitor: compiler.dumpInfoTask,
1645 allowVariableMinification: false).getText()); 1645 allowVariableMinification: false).getText());
1646 } 1646 }
1647 1647
1648 String assembledCode = mainBuffer.getText(); 1648 String assembledCode = mainBuffer.getText();
1649 String sourceMapTags = "";
1649 if (generateSourceMap) { 1650 if (generateSourceMap) {
1650 outputSourceMap(assembledCode, mainBuffer, '', 1651 outputSourceMap(assembledCode, mainBuffer, '',
1651 compiler.sourceMapUri, compiler.outputUri); 1652 compiler.sourceMapUri, compiler.outputUri);
1652 mainBuffer.add( 1653 sourceMapTags =
1653 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); 1654 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri);
1654 assembledCode = mainBuffer.getText();
1655 } 1655 }
1656 1656 mainBuffer.add(sourceMapTags);
1657 assembledCode = mainBuffer.getText();
1657 compiler.outputProvider('', 'js') 1658 compiler.outputProvider('', 'js')
1658 ..add(assembledCode) 1659 ..add(assembledCode)
1659 ..close(); 1660 ..close();
1660 compiler.assembledCode = assembledCode; 1661 compiler.assembledCode = assembledCode;
1661 1662
1662 if (!compiler.useContentSecurityPolicy) { 1663 if (!compiler.useContentSecurityPolicy) {
1663 CodeBuffer cspBuffer = new CodeBuffer(); 1664 CodeBuffer cspBuffer = new CodeBuffer();
1664 cspBuffer.add(mainBuffer); 1665 cspBuffer.add(mainBuffer);
1665 cspBuffer.write(""" 1666 cspBuffer.write("""
1666 { 1667 {
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 jsAst.FunctionDeclaration precompiledFunctionAst = 1877 jsAst.FunctionDeclaration precompiledFunctionAst =
1877 buildCspPrecompiledFunctionFor(outputUnit); 1878 buildCspPrecompiledFunctionFor(outputUnit);
1878 1879
1879 outputBuffer.write( 1880 outputBuffer.write(
1880 jsAst.prettyPrint( 1881 jsAst.prettyPrint(
1881 precompiledFunctionAst, compiler, 1882 precompiledFunctionAst, compiler,
1882 monitor: compiler.dumpInfoTask, 1883 monitor: compiler.dumpInfoTask,
1883 allowVariableMinification: false).getText()); 1884 allowVariableMinification: false).getText());
1884 } 1885 }
1885 1886
1887 String code = outputBuffer.getText();
1888
1886 // Make a unique hash of the code (before the sourcemaps are added) 1889 // 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 1890 // This will be used to retrieve the initializing function from the global
1888 // variable. 1891 // variable.
1889 String hash = hashOfString(outputBuffer.getText()); 1892 String hash = hashOfString(code);
1890
1891 outputBuffer.add('${deferredInitializers}["$hash"]$_=$_'
1892 '${deferredInitializers}.current$N');
1893
1894 String partPrefix = deferredPartFileName(outputUnit, addExtension: false);
1895 if (generateSourceMap) {
1896 String partName = "$partPrefix.part";
1897 String mapFileName = partName + ".js.map";
1898 List<String> mapSegments = compiler.sourceMapUri.pathSegments.toList();
1899 mapSegments[mapSegments.length - 1] = mapFileName;
1900 Uri mapUri = compiler.sourceMapUri.replace(pathSegments: mapSegments);
1901
1902 String partFileName = partName + ".js";
1903 List<String> partSegments = compiler.outputUri.pathSegments.toList();
1904 partSegments[mapSegments.length - 1] = partFileName;
1905 Uri partUri = compiler.outputUri.replace(pathSegments: partSegments);
1906
1907 outputSourceMap(outputBuffer.getText(), outputBuffer, partName,
1908 mapUri, partUri);
1909 outputBuffer.add(generateSourceMapTag(mapUri, partUri));
1910 }
1911 1893
1912 outputBuffers[outputUnit] = outputBuffer; 1894 outputBuffers[outputUnit] = outputBuffer;
1913 compiler.outputProvider(partPrefix, 'part.js') 1895 compiler.outputProvider(
1914 ..add(outputBuffer.getText()) 1896 deferredPartFileName(outputUnit, addExtension: false), 'part.js')
1897 ..add(code)
1898 ..add('${deferredInitializers}["$hash"]$_=$_'
1899 '${deferredInitializers}.current$N')
1915 ..close(); 1900 ..close();
1916 1901
1917 hunkHashes[outputUnit] = hash; 1902 hunkHashes[outputUnit] = hash;
1903 // TODO(johnniwinther): Support source maps for deferred code.
1918 } 1904 }
1919 return hunkHashes; 1905 return hunkHashes;
1920 } 1906 }
1921 1907
1922 String buildGeneratedBy() { 1908 String buildGeneratedBy() {
1923 var suffix = ''; 1909 var suffix = '';
1924 if (compiler.hasBuildId) suffix = ' version: ${compiler.buildId}'; 1910 if (compiler.hasBuildId) suffix = ' version: ${compiler.buildId}';
1925 return '// Generated by dart2js, the Dart to JavaScript compiler$suffix.\n'; 1911 return '// Generated by dart2js, the Dart to JavaScript compiler$suffix.\n';
1926 } 1912 }
1927 1913
(...skipping 18 matching lines...) Expand all
1946 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { 1932 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) {
1947 if (element.isInstanceMember) { 1933 if (element.isInstanceMember) {
1948 cachedClassBuilders.remove(element.enclosingClass); 1934 cachedClassBuilders.remove(element.enclosingClass);
1949 1935
1950 nativeEmitter.cachedBuilders.remove(element.enclosingClass); 1936 nativeEmitter.cachedBuilders.remove(element.enclosingClass);
1951 1937
1952 } 1938 }
1953 } 1939 }
1954 } 1940 }
1955 } 1941 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/source_map_deferred_d2js_validity_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698