Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| index 40a747308c37b9f4be70cc4cc5ec6662b73d3d74..9752d20a604f48ea3558887687afe0e12bcfa869 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart |
| @@ -1460,22 +1460,6 @@ class OldEmitter implements Emitter { |
| cspPrecompiledConstructorNamesFor(outputUnit).add(js('#', constructorName)); |
| } |
| - /// Extracts the output name of the compiler's outputUri. |
| - String deferredPartFileName(OutputUnit outputUnit, |
| - {bool addExtension: true}) { |
| - String outPath = compiler.outputUri != null |
| - ? compiler.outputUri.path |
| - : "out"; |
| - String outName = outPath.substring(outPath.lastIndexOf('/') + 1); |
| - String extension = addExtension ? ".part.js" : ""; |
| - if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) { |
| - return "$outName$extension"; |
| - } else { |
| - String name = outputUnit.name; |
| - return "${outName}_$name$extension"; |
| - } |
| - } |
| - |
| void emitLibraries(Iterable<LibraryElement> libraries) { |
| if (libraries.isEmpty) return; |
| @@ -1733,6 +1717,10 @@ class OldEmitter implements Emitter { |
| emitDeferredBoilerPlate(mainBuffer, deferredLoadHashes); |
| + if (compiler.deferredMapUri != null) { |
| + outputDeferredMap(); |
| + } |
| + |
| // Static field initializations require the classes and compile-time |
| // constants to be set up. |
| emitStaticNonFinalFieldInitializations(mainBuffer, mainOutputUnit); |
| @@ -2093,7 +2081,7 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) { |
| List<String> hashes = new List<String>(); |
| deferredLibraryHashes[loadId] = new List<String>(); |
| for (OutputUnit outputUnit in outputUnits) { |
| - uris.add(deferredPartFileName(outputUnit)); |
| + uris.add(backend.outputFileName("${outputUnit.name}.part.js")); |
|
floitsch
2015/01/05 15:46:19
no. backend.deferredPartFileName(...)
sigurdm
2015/01/06 09:02:20
Done.
|
| hashes.add(deferredLoadHashes[outputUnit]); |
| } |
| @@ -2212,7 +2200,8 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) { |
| outputBuffer.write('${deferredInitializers}["$hash"]$_=$_' |
| '${deferredInitializers}.current$N'); |
| - String partPrefix = deferredPartFileName(outputUnit, addExtension: false); |
| + String partPrefix = |
| + backend.outputFileName(outputUnit.name); |
| if (generateSourceMap) { |
| Uri mapUri, partUri; |
| Uri sourceMapUri = compiler.sourceMapUri; |
| @@ -2270,6 +2259,18 @@ function(originalDescriptor, name, holder, isStatic, globalFunctionsAccess) { |
| ..close(); |
| } |
| + void outputDeferredMap() { |
| + Map<String, dynamic> mapping = new Map(); |
|
floitsch
2015/01/05 15:46:19
new Map<String, dynamic>
sigurdm
2015/01/06 09:02:20
Done.
|
| + // Json does not support comments, so we embed the explanation in the |
| + // data. |
| + mapping["_comment"] = "This mapping shows which compiled `.js` files are " |
| + "needed for a given deferred library import."; |
| + mapping.addAll(compiler.deferredLoadTask.getDeferredMap()); |
| + compiler.outputProvider(compiler.deferredMapUri.path, 'deferred_map') |
| + ..add(const JsonEncoder.withIndent(" ").convert(mapping)) |
| + ..close(); |
| + } |
| + |
| void invalidateCaches() { |
| if (!compiler.hasIncrementalSupport) return; |
| if (cachedElements.isEmpty) return; |