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 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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 js.string(namer.globalPropertyName(element)), | 674 js.string(namer.globalPropertyName(element)), |
675 js.string(namer.lazyInitializerName(element)), | 675 js.string(namer.lazyInitializerName(element)), |
676 code, | 676 code, |
677 js.string(element.name)]); | 677 js.string(element.name)]); |
678 } | 678 } |
679 } | 679 } |
680 | 680 |
681 jsAst.Statement buildMetadata(Program program, OutputUnit outputUnit) { | 681 jsAst.Statement buildMetadata(Program program, OutputUnit outputUnit) { |
682 List<jsAst.Statement> parts = <jsAst.Statement>[]; | 682 List<jsAst.Statement> parts = <jsAst.Statement>[]; |
683 | 683 |
684 jsAst.Expression constructList(List<jsAst.Expression> list) { | 684 jsAst.Expression types = program.metadataTypesForOutputUnit(outputUnit); |
685 return new jsAst.ArrayInitializer(list == null ? [] : list); | |
686 } | |
687 | |
688 List<jsAst.Expression> types = program.metadataTypes[outputUnit]; | |
689 | 685 |
690 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) { | 686 if (outputUnit == compiler.deferredLoadTask.mainOutputUnit) { |
691 jsAst.Expression metadataAccess = | 687 jsAst.Expression metadataAccess = |
692 generateEmbeddedGlobalAccess(embeddedNames.METADATA); | 688 generateEmbeddedGlobalAccess(embeddedNames.METADATA); |
693 jsAst.Expression typesAccess = | 689 jsAst.Expression typesAccess = |
694 generateEmbeddedGlobalAccess(embeddedNames.TYPES); | 690 generateEmbeddedGlobalAccess(embeddedNames.TYPES); |
695 | 691 |
696 parts..add(js.statement('# = #;', [metadataAccess, | 692 parts..add(js.statement('# = #;', [metadataAccess, program.metadata])) |
697 constructList(program.metadata)])) | 693 ..add(js.statement('# = #;', [typesAccess, types])); |
698 ..add(js.statement('# = #;', [typesAccess, constructList(types)])); | |
699 } else if (types != null) { | 694 } else if (types != null) { |
700 parts.add(js.statement('var ${namer.deferredTypesName} = #;', | 695 parts.add(js.statement('var ${namer.deferredTypesName} = #;', |
701 constructList(types))); | 696 types)); |
702 } | 697 } |
703 return new jsAst.Block(parts); | 698 return new jsAst.Block(parts); |
704 } | 699 } |
705 | 700 |
706 jsAst.Statement buildCompileTimeConstants(List<Constant> constants, | 701 jsAst.Statement buildCompileTimeConstants(List<Constant> constants, |
707 {bool isMainFragment}) { | 702 {bool isMainFragment}) { |
708 assert(isMainFragment != null); | 703 assert(isMainFragment != null); |
709 | 704 |
710 if (constants.isEmpty) return js.comment("No constants in program."); | 705 if (constants.isEmpty) return js.comment("No constants in program."); |
711 List<jsAst.Statement> parts = <jsAst.Statement>[]; | 706 List<jsAst.Statement> parts = <jsAst.Statement>[]; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 | 1063 |
1069 // Emit all required typedef declarations into the main output unit. | 1064 // Emit all required typedef declarations into the main output unit. |
1070 // TODO(karlklose): unify required classes and typedefs to declarations | 1065 // TODO(karlklose): unify required classes and typedefs to declarations |
1071 // and have builders for each kind. | 1066 // and have builders for each kind. |
1072 for (TypedefElement typedef in typedefsNeededForReflection) { | 1067 for (TypedefElement typedef in typedefsNeededForReflection) { |
1073 LibraryElement library = typedef.library; | 1068 LibraryElement library = typedef.library; |
1074 // TODO(karlklose): add a TypedefBuilder and move this code there. | 1069 // TODO(karlklose): add a TypedefBuilder and move this code there. |
1075 DartType type = typedef.alias; | 1070 DartType type = typedef.alias; |
1076 // TODO(zarah): reify type variables once reflection on type arguments of | 1071 // TODO(zarah): reify type variables once reflection on type arguments of |
1077 // typedefs is supported. | 1072 // typedefs is supported. |
1078 int typeIndex = | 1073 jsAst.Expression typeIndex = |
1079 task.metadataCollector.reifyType(type, ignoreTypeVariables: true); | 1074 task.metadataCollector.reifyType(type, ignoreTypeVariables: true); |
1080 ClassBuilder builder = new ClassBuilder(typedef, namer); | 1075 ClassBuilder builder = new ClassBuilder(typedef, namer); |
1081 builder.addProperty(embeddedNames.TYPEDEF_TYPE_PROPERTY_NAME, | 1076 builder.addProperty(embeddedNames.TYPEDEF_TYPE_PROPERTY_NAME, typeIndex); |
1082 js.number(typeIndex)); | |
1083 builder.addProperty(embeddedNames.TYPEDEF_PREDICATE_PROPERTY_NAME, | 1077 builder.addProperty(embeddedNames.TYPEDEF_PREDICATE_PROPERTY_NAME, |
1084 js.boolean(true)); | 1078 js.boolean(true)); |
1085 | 1079 |
1086 // We can be pretty sure that the objectClass is initialized, since | 1080 // We can be pretty sure that the objectClass is initialized, since |
1087 // typedefs are only emitted with reflection, which requires lots of | 1081 // typedefs are only emitted with reflection, which requires lots of |
1088 // classes. | 1082 // classes. |
1089 assert(compiler.objectClass != null); | 1083 assert(compiler.objectClass != null); |
1090 builder.superName = namer.className(compiler.objectClass); | 1084 builder.superName = namer.className(compiler.objectClass); |
1091 jsAst.Node declaration = builder.toObjectInitializer(); | 1085 jsAst.Node declaration = builder.toObjectInitializer(); |
1092 String mangledName = namer.globalPropertyName(typedef); | 1086 String mangledName = namer.globalPropertyName(typedef); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 | 1253 |
1260 void assembleProgram(Program program) { | 1254 void assembleProgram(Program program) { |
1261 for (Fragment fragment in program.fragments) { | 1255 for (Fragment fragment in program.fragments) { |
1262 for (Library library in fragment.libraries) { | 1256 for (Library library in fragment.libraries) { |
1263 assembleLibrary(library, fragment); | 1257 assembleLibrary(library, fragment); |
1264 } | 1258 } |
1265 } | 1259 } |
1266 assembleTypedefs(program); | 1260 assembleTypedefs(program); |
1267 } | 1261 } |
1268 | 1262 |
1269 void emitMainOutputUnit(Program program, | 1263 jsAst.Program buildOutputAstForMain(Program program, |
1270 Map<OutputUnit, String> deferredLoadHashes) { | 1264 Map<OutputUnit, _DeferredOutputUnitHash> deferredLoadHashes) { |
1271 MainFragment mainFragment = program.fragments.first; | 1265 MainFragment mainFragment = program.mainFragment; |
1272 OutputUnit mainOutputUnit = mainFragment.outputUnit; | 1266 OutputUnit mainOutputUnit = mainFragment.outputUnit; |
1273 | |
1274 LineColumnCollector lineColumnCollector; | |
1275 List<CodeOutputListener> codeOutputListeners; | |
1276 if (generateSourceMap) { | |
1277 lineColumnCollector = new LineColumnCollector(); | |
1278 codeOutputListeners = <CodeOutputListener>[lineColumnCollector]; | |
1279 } | |
1280 | |
1281 CodeOutput mainOutput = | |
1282 new StreamCodeOutput(compiler.outputProvider('', 'js'), | |
1283 codeOutputListeners); | |
1284 outputBuffers[mainOutputUnit] = mainOutput; | |
1285 | |
1286 bool isProgramSplit = program.isSplit; | 1267 bool isProgramSplit = program.isSplit; |
1287 | 1268 |
1288 List<jsAst.Statement> statements = <jsAst.Statement>[]; | 1269 List<jsAst.Statement> statements = <jsAst.Statement>[]; |
1289 | 1270 |
1290 statements..add(buildGeneratedBy()) | 1271 statements..add(buildGeneratedBy()) |
1291 ..add(js.comment(HOOKS_API_USAGE)); | 1272 ..add(js.comment(HOOKS_API_USAGE)); |
1292 | 1273 |
1293 if (isProgramSplit) { | 1274 if (isProgramSplit) { |
1294 /// For deferred loading we communicate the initializers via this global | 1275 /// For deferred loading we communicate the initializers via this global |
1295 /// variable. The deferred hunks will add their initialization to this. | 1276 /// variable. The deferred hunks will add their initialization to this. |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 "metadata": buildMetadata(program, mainOutputUnit), | 1461 "metadata": buildMetadata(program, mainOutputUnit), |
1481 "convertToFastObject": buildConvertToFastObjectFunction(), | 1462 "convertToFastObject": buildConvertToFastObjectFunction(), |
1482 "convertToSlowObject": buildConvertToSlowObjectFunction(), | 1463 "convertToSlowObject": buildConvertToSlowObjectFunction(), |
1483 "convertGlobalObjectsToFastObjects": | 1464 "convertGlobalObjectsToFastObjects": |
1484 buildConvertGlobalObjectToFastObjects(), | 1465 buildConvertGlobalObjectToFastObjects(), |
1485 "debugFastObjects": buildDebugFastObjectCode(), | 1466 "debugFastObjects": buildDebugFastObjectCode(), |
1486 "init": buildInitFunction(), | 1467 "init": buildInitFunction(), |
1487 "main": buildMain(mainFragment.invokeMain) | 1468 "main": buildMain(mainFragment.invokeMain) |
1488 })); | 1469 })); |
1489 | 1470 |
1490 mainOutput.addBuffer(jsAst.prettyPrint(new jsAst.Program(statements), | 1471 return new jsAst.Program(statements); |
| 1472 } |
| 1473 |
| 1474 void emitMainOutputUnit(OutputUnit mainOutputUnit, jsAst.Program program) { |
| 1475 LineColumnCollector lineColumnCollector; |
| 1476 List<CodeOutputListener> codeOutputListeners; |
| 1477 if (generateSourceMap) { |
| 1478 lineColumnCollector = new LineColumnCollector(); |
| 1479 codeOutputListeners = <CodeOutputListener>[lineColumnCollector]; |
| 1480 } |
| 1481 |
| 1482 CodeOutput mainOutput = |
| 1483 new StreamCodeOutput(compiler.outputProvider('', 'js'), |
| 1484 codeOutputListeners); |
| 1485 outputBuffers[mainOutputUnit] = mainOutput; |
| 1486 |
| 1487 |
| 1488 mainOutput.addBuffer(jsAst.prettyPrint(program, |
1491 compiler, | 1489 compiler, |
1492 monitor: compiler.dumpInfoTask)); | 1490 monitor: compiler.dumpInfoTask)); |
1493 | 1491 |
1494 if (compiler.deferredMapUri != null) { | 1492 if (compiler.deferredMapUri != null) { |
1495 outputDeferredMap(); | 1493 outputDeferredMap(); |
1496 } | 1494 } |
1497 | 1495 |
1498 if (generateSourceMap) { | 1496 if (generateSourceMap) { |
1499 mainOutput.add( | 1497 mainOutput.add( |
1500 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); | 1498 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 descriptors.remove(library); | 1645 descriptors.remove(library); |
1648 } | 1646 } |
1649 | 1647 |
1650 outputs[outputUnit] = new jsAst.ArrayInitializer(parts); | 1648 outputs[outputUnit] = new jsAst.ArrayInitializer(parts); |
1651 } | 1649 } |
1652 } | 1650 } |
1653 | 1651 |
1654 return outputs; | 1652 return outputs; |
1655 } | 1653 } |
1656 | 1654 |
| 1655 void finalizeTokensInAst(jsAst.Program main, |
| 1656 Iterable<jsAst.Program> deferredParts) { |
| 1657 task.metadataCollector.countTokensInProgram(main); |
| 1658 deferredParts.forEach(task.metadataCollector.countTokensInProgram); |
| 1659 task.metadataCollector.finalizeTokens(); |
| 1660 } |
| 1661 |
1657 int emitProgram(ProgramBuilder programBuilder) { | 1662 int emitProgram(ProgramBuilder programBuilder) { |
1658 Program program = programBuilder.buildProgram( | 1663 Program program = programBuilder.buildProgram( |
1659 storeFunctionTypesInMetadata: true); | 1664 storeFunctionTypesInMetadata: true); |
1660 | 1665 |
1661 assembleProgram(program); | 1666 assembleProgram(program); |
1662 | 1667 |
1663 // Construct the ASTs for all deferred output units. | 1668 // Construct the ASTs for all deferred output units. |
1664 Map<OutputUnit, jsAst.Program> deferredParts = | 1669 Map<OutputUnit, jsAst.Program> deferredParts = |
1665 buildOutputAstForDeferredCode(program); | 1670 buildOutputAstForDeferredCode(program); |
1666 | 1671 |
| 1672 Map<OutputUnit, _DeferredOutputUnitHash> deferredHashTokens = |
| 1673 new Map<OutputUnit, _DeferredOutputUnitHash>.fromIterables( |
| 1674 deferredParts.keys, |
| 1675 deferredParts.keys.map((OutputUnit unit) { |
| 1676 return new _DeferredOutputUnitHash(unit); |
| 1677 }) |
| 1678 ); |
| 1679 |
| 1680 jsAst.Program mainOutput = |
| 1681 buildOutputAstForMain(program, deferredHashTokens); |
| 1682 |
| 1683 finalizeTokensInAst(mainOutput, deferredParts.values); |
| 1684 |
1667 // Emit deferred units first, so we have their hashes. | 1685 // Emit deferred units first, so we have their hashes. |
1668 // Map from OutputUnit to a hash of its content. The hash uniquely | 1686 // Map from OutputUnit to a hash of its content. The hash uniquely |
1669 // identifies the code of the output-unit. It does not include | 1687 // identifies the code of the output-unit. It does not include |
1670 // boilerplate JS code, like the sourcemap directives or the hash | 1688 // boilerplate JS code, like the sourcemap directives or the hash |
1671 // itself. | 1689 // itself. |
1672 Map<OutputUnit, String> deferredLoadHashes = | 1690 Map<OutputUnit, String> deferredLoadHashes = |
1673 emitDeferredOutputUnits(deferredParts); | 1691 emitDeferredOutputUnits(deferredParts); |
1674 emitMainOutputUnit(program, deferredLoadHashes); | 1692 |
| 1693 deferredHashTokens.forEach((OutputUnit key, _DeferredOutputUnitHash token) { |
| 1694 token.setHash(deferredLoadHashes[key]); |
| 1695 }); |
| 1696 emitMainOutputUnit(program.mainFragment.outputUnit, mainOutput); |
1675 | 1697 |
1676 if (backend.requiresPreamble && | 1698 if (backend.requiresPreamble && |
1677 !backend.htmlLibraryIsLoaded) { | 1699 !backend.htmlLibraryIsLoaded) { |
1678 compiler.reportHint(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); | 1700 compiler.reportHint(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); |
1679 } | 1701 } |
1680 // Return the total program size. | 1702 // Return the total program size. |
1681 return outputBuffers.values.fold(0, (a, b) => a + b.length); | 1703 return outputBuffers.values.fold(0, (a, b) => a + b.length); |
1682 } | 1704 } |
1683 | 1705 |
1684 String generateSourceMapTag(Uri sourceMapUri, Uri fileUri) { | 1706 String generateSourceMapTag(Uri sourceMapUri, Uri fileUri) { |
(...skipping 25 matching lines...) Expand all Loading... |
1710 if (owner == null) { | 1732 if (owner == null) { |
1711 compiler.internalError(element, 'Owner is null.'); | 1733 compiler.internalError(element, 'Owner is null.'); |
1712 } | 1734 } |
1713 return elementDescriptors | 1735 return elementDescriptors |
1714 .putIfAbsent(fragment, () => new Map<Element, ClassBuilder>()) | 1736 .putIfAbsent(fragment, () => new Map<Element, ClassBuilder>()) |
1715 .putIfAbsent(owner, () => new ClassBuilder(owner, namer)); | 1737 .putIfAbsent(owner, () => new ClassBuilder(owner, namer)); |
1716 } | 1738 } |
1717 | 1739 |
1718 /// Emits support-code for deferred loading into [output]. | 1740 /// Emits support-code for deferred loading into [output]. |
1719 jsAst.Statement buildDeferredBoilerPlate( | 1741 jsAst.Statement buildDeferredBoilerPlate( |
1720 Map<OutputUnit, String> deferredLoadHashes) { | 1742 Map<OutputUnit, _DeferredOutputUnitHash> deferredLoadHashes) { |
1721 List<jsAst.Statement> parts = <jsAst.Statement>[]; | 1743 List<jsAst.Statement> parts = <jsAst.Statement>[]; |
1722 | 1744 |
1723 parts.add(js.statement(''' | 1745 parts.add(js.statement(''' |
1724 { | 1746 { |
1725 // Function for checking if a hunk is loaded given its hash. | 1747 // Function for checking if a hunk is loaded given its hash. |
1726 #isHunkLoaded = function(hunkHash) { | 1748 #isHunkLoaded = function(hunkHash) { |
1727 return !!$deferredInitializers[hunkHash]; | 1749 return !!$deferredInitializers[hunkHash]; |
1728 }; | 1750 }; |
1729 #deferredInitialized = new Object(null); | 1751 #deferredInitialized = new Object(null); |
1730 // Function for checking if a hunk is initialized given its hash. | 1752 // Function for checking if a hunk is initialized given its hash. |
(...skipping 13 matching lines...) Expand all Loading... |
1744 embeddedNames.IS_HUNK_INITIALIZED), | 1766 embeddedNames.IS_HUNK_INITIALIZED), |
1745 "initializeLoadedHunk": generateEmbeddedGlobalAccess( | 1767 "initializeLoadedHunk": generateEmbeddedGlobalAccess( |
1746 embeddedNames.INITIALIZE_LOADED_HUNK), | 1768 embeddedNames.INITIALIZE_LOADED_HUNK), |
1747 "deferredInitialized": generateEmbeddedGlobalAccess( | 1769 "deferredInitialized": generateEmbeddedGlobalAccess( |
1748 embeddedNames.DEFERRED_INITIALIZED)})); | 1770 embeddedNames.DEFERRED_INITIALIZED)})); |
1749 | 1771 |
1750 // Write a javascript mapping from Deferred import load ids (derrived | 1772 // Write a javascript mapping from Deferred import load ids (derrived |
1751 // from the import prefix.) to a list of lists of uris of hunks to load, | 1773 // from the import prefix.) to a list of lists of uris of hunks to load, |
1752 // and a corresponding mapping to a list of hashes used by | 1774 // and a corresponding mapping to a list of hashes used by |
1753 // INITIALIZE_LOADED_HUNK and IS_HUNK_LOADED. | 1775 // INITIALIZE_LOADED_HUNK and IS_HUNK_LOADED. |
1754 Map<String, List<String>> deferredLibraryUris = | 1776 Map<String, List<jsAst.LiteralString>> deferredLibraryUris = |
1755 new Map<String, List<String>>(); | 1777 new Map<String, List<jsAst.LiteralString>>(); |
1756 Map<String, List<String>> deferredLibraryHashes = | 1778 Map<String, List<_DeferredOutputUnitHash>> deferredLibraryHashes = |
1757 new Map<String, List<String>>(); | 1779 new Map<String, List<_DeferredOutputUnitHash>>(); |
1758 compiler.deferredLoadTask.hunksToLoad.forEach( | 1780 compiler.deferredLoadTask.hunksToLoad.forEach( |
1759 (String loadId, List<OutputUnit>outputUnits) { | 1781 (String loadId, List<OutputUnit>outputUnits) { |
1760 List<String> uris = new List<String>(); | 1782 List<jsAst.LiteralString> uris = new List<jsAst.LiteralString>(); |
1761 List<String> hashes = new List<String>(); | 1783 List<_DeferredOutputUnitHash> hashes = |
1762 deferredLibraryHashes[loadId] = new List<String>(); | 1784 new List<_DeferredOutputUnitHash>(); |
| 1785 deferredLibraryHashes[loadId] = new List<_DeferredOutputUnitHash>(); |
1763 for (OutputUnit outputUnit in outputUnits) { | 1786 for (OutputUnit outputUnit in outputUnits) { |
1764 uris.add(backend.deferredPartFileName(outputUnit.name)); | 1787 uris.add(js.escapedString( |
| 1788 backend.deferredPartFileName(outputUnit.name))); |
1765 hashes.add(deferredLoadHashes[outputUnit]); | 1789 hashes.add(deferredLoadHashes[outputUnit]); |
1766 } | 1790 } |
1767 | 1791 |
1768 deferredLibraryUris[loadId] = uris; | 1792 deferredLibraryUris[loadId] = uris; |
1769 deferredLibraryHashes[loadId] = hashes; | 1793 deferredLibraryHashes[loadId] = hashes; |
1770 }); | 1794 }); |
1771 | 1795 |
1772 void emitMapping(String name, Map<String, List<String>> mapping) { | 1796 void emitMapping(String name, Map<String, List<jsAst.Expression>> mapping) { |
1773 List<jsAst.Property> properties = new List<jsAst.Property>(); | 1797 List<jsAst.Property> properties = new List<jsAst.Property>(); |
1774 mapping.forEach((String key, List<String> values) { | 1798 mapping.forEach((String key, List<jsAst.Expression> values) { |
1775 properties.add(new jsAst.Property(js.escapedString(key), | 1799 properties.add(new jsAst.Property(js.escapedString(key), |
1776 new jsAst.ArrayInitializer( | 1800 new jsAst.ArrayInitializer(values))); |
1777 values.map(js.escapedString).toList()))); | |
1778 }); | 1801 }); |
1779 jsAst.Node initializer = | 1802 jsAst.Node initializer = |
1780 new jsAst.ObjectInitializer(properties, isOneLiner: true); | 1803 new jsAst.ObjectInitializer(properties, isOneLiner: true); |
1781 | 1804 |
1782 jsAst.Node globalName = generateEmbeddedGlobalAccess(name); | 1805 jsAst.Node globalName = generateEmbeddedGlobalAccess(name); |
1783 parts.add(js.statement("# = #", [globalName, initializer])); | 1806 parts.add(js.statement("# = #", [globalName, initializer])); |
1784 } | 1807 } |
1785 | 1808 |
1786 emitMapping(embeddedNames.DEFERRED_LIBRARY_URIS, deferredLibraryUris); | 1809 emitMapping(embeddedNames.DEFERRED_LIBRARY_URIS, deferredLibraryUris); |
1787 emitMapping(embeddedNames.DEFERRED_LIBRARY_HASHES, | 1810 emitMapping(embeddedNames.DEFERRED_LIBRARY_HASHES, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 // in stack traces and profile entries. | 1849 // in stack traces and profile entries. |
1827 body.add(js.statement('var dart = #', libraryDescriptor)); | 1850 body.add(js.statement('var dart = #', libraryDescriptor)); |
1828 | 1851 |
1829 if (compiler.useContentSecurityPolicy) { | 1852 if (compiler.useContentSecurityPolicy) { |
1830 body.add(buildCspPrecompiledFunctionFor(outputUnit)); | 1853 body.add(buildCspPrecompiledFunctionFor(outputUnit)); |
1831 } | 1854 } |
1832 body.add( | 1855 body.add( |
1833 js.statement('$setupProgramName(dart, ${typesAccess}.length);')); | 1856 js.statement('$setupProgramName(dart, ${typesAccess}.length);')); |
1834 } | 1857 } |
1835 | 1858 |
1836 if (task.metadataCollector.types[outputUnit] != null) { | 1859 body..add(buildMetadata(program, outputUnit)) |
1837 body..add(buildMetadata(program, outputUnit)) | 1860 ..add(js.statement('${typesAccess}.push.apply(${typesAccess}, ' |
1838 ..add(js.statement('${typesAccess}.push.apply(${typesAccess}, ' | 1861 '${namer.deferredTypesName});')); |
1839 '${namer.deferredTypesName});')); | |
1840 } | |
1841 | 1862 |
1842 // Set the currentIsolate variable to the current isolate (which is | 1863 // Set the currentIsolate variable to the current isolate (which is |
1843 // provided as second argument). | 1864 // provided as second argument). |
1844 body.add(js.statement("${namer.currentIsolate} = arguments[1];")); | 1865 body.add(js.statement("${namer.currentIsolate} = arguments[1];")); |
1845 | 1866 |
1846 body.add(buildCompileTimeConstants(fragment.constants, | 1867 body.add(buildCompileTimeConstants(fragment.constants, |
1847 isMainFragment: false)); | 1868 isMainFragment: false)); |
1848 body.add(buildStaticNonFinalFieldInitializations(outputUnit)); | 1869 body.add(buildStaticNonFinalFieldInitializations(outputUnit)); |
1849 | 1870 |
1850 List<jsAst.Statement> statements = <jsAst.Statement>[]; | 1871 List<jsAst.Statement> statements = <jsAst.Statement>[]; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1980 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2001 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
1981 if (element.isInstanceMember) { | 2002 if (element.isInstanceMember) { |
1982 cachedClassBuilders.remove(element.enclosingClass); | 2003 cachedClassBuilders.remove(element.enclosingClass); |
1983 | 2004 |
1984 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2005 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
1985 | 2006 |
1986 } | 2007 } |
1987 } | 2008 } |
1988 } | 2009 } |
1989 } | 2010 } |
OLD | NEW |