| 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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 return false; | 1025 return false; |
| 1026 })(); | 1026 })(); |
| 1027 '''); | 1027 '''); |
| 1028 | 1028 |
| 1029 return supportsDirectProtoAccess; | 1029 return supportsDirectProtoAccess; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 jsAst.Expression generateLibraryDescriptor( | 1032 jsAst.Expression generateLibraryDescriptor( |
| 1033 LibraryElement library, Fragment fragment) { | 1033 LibraryElement library, Fragment fragment) { |
| 1034 var uri = ""; | 1034 var uri = ""; |
| 1035 if (!compiler.options.enableMinification || backend.mustPreserveUris) { | 1035 if (!compiler.options.enableMinification || |
| 1036 backend.mirrorsData.mustPreserveUris) { |
| 1036 uri = library.canonicalUri; | 1037 uri = library.canonicalUri; |
| 1037 if (uri.scheme == 'file' && compiler.options.outputUri != null) { | 1038 if (uri.scheme == 'file' && compiler.options.outputUri != null) { |
| 1038 uri = | 1039 uri = |
| 1039 relativize(compiler.options.outputUri, library.canonicalUri, false); | 1040 relativize(compiler.options.outputUri, library.canonicalUri, false); |
| 1040 } | 1041 } |
| 1041 } | 1042 } |
| 1042 | 1043 |
| 1043 String libraryName = (!compiler.options.enableMinification || | 1044 String libraryName = (!compiler.options.enableMinification || |
| 1044 backend.mirrorsData.mustRetainLibraryNames) | 1045 backend.mirrorsData.mustRetainLibraryNames) |
| 1045 ? library.libraryName | 1046 ? library.libraryName |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 | 1080 |
| 1080 void assemblePrecompiledConstructor( | 1081 void assemblePrecompiledConstructor( |
| 1081 OutputUnit outputUnit, | 1082 OutputUnit outputUnit, |
| 1082 jsAst.Name constructorName, | 1083 jsAst.Name constructorName, |
| 1083 jsAst.Expression constructorAst, | 1084 jsAst.Expression constructorAst, |
| 1084 List<jsAst.Name> fields) { | 1085 List<jsAst.Name> fields) { |
| 1085 cspPrecompiledFunctionFor(outputUnit) | 1086 cspPrecompiledFunctionFor(outputUnit) |
| 1086 .add(new jsAst.FunctionDeclaration(constructorName, constructorAst)); | 1087 .add(new jsAst.FunctionDeclaration(constructorName, constructorAst)); |
| 1087 | 1088 |
| 1088 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME; | 1089 String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME; |
| 1089 bool hasIsolateSupport = backend.hasIsolateSupport; | 1090 bool hasIsolateSupport = backend.backendUsage.isIsolateInUse; |
| 1090 jsAst.Node fieldNamesArray; | 1091 jsAst.Node fieldNamesArray; |
| 1091 if (hasIsolateSupport) { | 1092 if (hasIsolateSupport) { |
| 1092 fieldNamesArray = | 1093 fieldNamesArray = |
| 1093 new jsAst.ArrayInitializer(fields.map(js.quoteName).toList()); | 1094 new jsAst.ArrayInitializer(fields.map(js.quoteName).toList()); |
| 1094 } else { | 1095 } else { |
| 1095 fieldNamesArray = new jsAst.LiteralNull(); | 1096 fieldNamesArray = new jsAst.LiteralNull(); |
| 1096 } | 1097 } |
| 1097 | 1098 |
| 1098 cspPrecompiledFunctionFor(outputUnit).add(js.statement( | 1099 cspPrecompiledFunctionFor(outputUnit).add(js.statement( |
| 1099 r''' | 1100 r''' |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1625 // boilerplate JS code, like the sourcemap directives or the hash | 1626 // boilerplate JS code, like the sourcemap directives or the hash |
| 1626 // itself. | 1627 // itself. |
| 1627 Map<OutputUnit, String> deferredLoadHashes = | 1628 Map<OutputUnit, String> deferredLoadHashes = |
| 1628 emitDeferredOutputUnits(deferredParts); | 1629 emitDeferredOutputUnits(deferredParts); |
| 1629 | 1630 |
| 1630 deferredHashTokens.forEach((OutputUnit key, _DeferredOutputUnitHash token) { | 1631 deferredHashTokens.forEach((OutputUnit key, _DeferredOutputUnitHash token) { |
| 1631 token.setHash(deferredLoadHashes[key]); | 1632 token.setHash(deferredLoadHashes[key]); |
| 1632 }); | 1633 }); |
| 1633 emitMainOutputUnit(program.mainFragment.outputUnit, mainOutput); | 1634 emitMainOutputUnit(program.mainFragment.outputUnit, mainOutput); |
| 1634 | 1635 |
| 1635 if (backend.requiresPreamble && !backend.htmlLibraryIsLoaded) { | 1636 if (backend.backendUsage.requiresPreamble && !backend.htmlLibraryIsLoaded) { |
| 1636 reporter.reportHintMessage(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); | 1637 reporter.reportHintMessage(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); |
| 1637 } | 1638 } |
| 1638 // Return the total program size. | 1639 // Return the total program size. |
| 1639 return outputBuffers.values.fold(0, (a, b) => a + b.length); | 1640 return outputBuffers.values.fold(0, (a, b) => a + b.length); |
| 1640 } | 1641 } |
| 1641 | 1642 |
| 1642 String generateSourceMapTag(Uri sourceMapUri, Uri fileUri) { | 1643 String generateSourceMapTag(Uri sourceMapUri, Uri fileUri) { |
| 1643 if (sourceMapUri != null && fileUri != null) { | 1644 if (sourceMapUri != null && fileUri != null) { |
| 1644 String sourceMapFileName = relativize(fileUri, sourceMapUri, false); | 1645 String sourceMapFileName = relativize(fileUri, sourceMapUri, false); |
| 1645 return ''' | 1646 return ''' |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1937 // data. | 1938 // data. |
| 1938 mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 1939 mapping["_comment"] = "This mapping shows which compiled `.js` files are " |
| 1939 "needed for a given deferred library import."; | 1940 "needed for a given deferred library import."; |
| 1940 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 1941 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); |
| 1941 compiler.outputProvider( | 1942 compiler.outputProvider( |
| 1942 compiler.options.deferredMapUri.path, 'deferred_map') | 1943 compiler.options.deferredMapUri.path, 'deferred_map') |
| 1943 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) | 1944 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) |
| 1944 ..close(); | 1945 ..close(); |
| 1945 } | 1946 } |
| 1946 } | 1947 } |
| OLD | NEW |