Chromium Code Reviews| 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1019 uri = library.canonicalUri; | 1019 uri = library.canonicalUri; |
| 1020 if (uri.scheme == 'file' && compiler.options.outputUri != null) { | 1020 if (uri.scheme == 'file' && compiler.options.outputUri != null) { |
| 1021 uri = | 1021 uri = |
| 1022 relativize(compiler.options.outputUri, library.canonicalUri, false); | 1022 relativize(compiler.options.outputUri, library.canonicalUri, false); |
| 1023 } | 1023 } |
| 1024 } | 1024 } |
| 1025 | 1025 |
| 1026 String libraryName = (!compiler.options.enableMinification || | 1026 String libraryName = (!compiler.options.enableMinification || |
| 1027 backend.mirrorsData.mustRetainLibraryNames) | 1027 backend.mirrorsData.mustRetainLibraryNames) |
| 1028 // TODO(johnniwinther): Support library names for entities. | 1028 // TODO(johnniwinther): Support library names for entities. |
| 1029 ? library is LibraryElement ? library.libraryName : library.name | 1029 ? library is LibraryElement ? library.libraryName : '' |
| 1030 : ""; | 1030 : ""; |
| 1031 | 1031 |
| 1032 jsAst.Fun metadata = | 1032 jsAst.Fun metadata = |
| 1033 task.metadataCollector.buildLibraryMetadataFunction(library); | 1033 task.metadataCollector.buildLibraryMetadataFunction(library); |
| 1034 | 1034 |
| 1035 ClassBuilder descriptor = libraryDescriptors[fragment][library]; | 1035 ClassBuilder descriptor = libraryDescriptors[fragment][library]; |
| 1036 | 1036 |
| 1037 jsAst.ObjectInitializer initializer; | 1037 jsAst.ObjectInitializer initializer; |
| 1038 if (descriptor == null) { | 1038 if (descriptor == null) { |
| 1039 // Nothing of the library was emitted. | 1039 // Nothing of the library was emitted. |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1896 output.close(); | 1896 output.close(); |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 hunkHashes[outputUnit] = hash; | 1899 hunkHashes[outputUnit] = hash; |
| 1900 } | 1900 } |
| 1901 return hunkHashes; | 1901 return hunkHashes; |
| 1902 } | 1902 } |
| 1903 | 1903 |
| 1904 jsAst.Comment buildGeneratedBy() { | 1904 jsAst.Comment buildGeneratedBy() { |
| 1905 List<String> options = []; | 1905 List<String> options = []; |
| 1906 if (compiler.commonElements.mirrorsLibrary != null) options.add('mirrors'); | 1906 if (compiler.commonElements.mirrorsLibrary != null && |
| 1907 !compiler.options.loadFromDill) { | |
| 1908 // TODO(johnniwinther): Add `isMirrorsUsed` to [BackendData] instead | |
|
Siggi Cherem (dart-lang)
2017/05/30 22:34:42
+1 - to take this a step further, should we have a
Johnni Winther
2017/05/31 09:08:40
Acknowledged.
| |
| 1909 // of checking `mirrorsLibrary`. | |
| 1910 options.add('mirrors'); | |
| 1911 } | |
| 1907 if (compiler.options.useContentSecurityPolicy) options.add("CSP"); | 1912 if (compiler.options.useContentSecurityPolicy) options.add("CSP"); |
| 1908 return new jsAst.Comment(generatedBy(compiler, flavor: options.join(", "))); | 1913 return new jsAst.Comment(generatedBy(compiler, flavor: options.join(", "))); |
| 1909 } | 1914 } |
| 1910 | 1915 |
| 1911 void outputDeferredMap() { | 1916 void outputDeferredMap() { |
| 1912 Map<String, dynamic> mapping = new Map<String, dynamic>(); | 1917 Map<String, dynamic> mapping = new Map<String, dynamic>(); |
| 1913 // Json does not support comments, so we embed the explanation in the | 1918 // Json does not support comments, so we embed the explanation in the |
| 1914 // data. | 1919 // data. |
| 1915 mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 1920 mapping["_comment"] = "This mapping shows which compiled `.js` files are " |
| 1916 "needed for a given deferred library import."; | 1921 "needed for a given deferred library import."; |
| 1917 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 1922 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); |
| 1918 compiler.outputProvider( | 1923 compiler.outputProvider( |
| 1919 compiler.options.deferredMapUri.path, '', OutputType.info) | 1924 compiler.options.deferredMapUri.path, '', OutputType.info) |
| 1920 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) | 1925 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) |
| 1921 ..close(); | 1926 ..close(); |
| 1922 } | 1927 } |
| 1923 } | 1928 } |
| OLD | NEW |