| 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 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 outputSourceMap(assembledCode, mainBuffer, '', | 1646 outputSourceMap(assembledCode, mainBuffer, '', |
| 1647 compiler.sourceMapUri, compiler.outputUri); | 1647 compiler.sourceMapUri, compiler.outputUri); |
| 1648 mainBuffer.write( | 1648 mainBuffer.write( |
| 1649 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); | 1649 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); |
| 1650 assembledCode = mainBuffer.getText(); | 1650 assembledCode = mainBuffer.getText(); |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 compiler.outputProvider('', 'js') | 1653 compiler.outputProvider('', 'js') |
| 1654 ..add(assembledCode) | 1654 ..add(assembledCode) |
| 1655 ..close(); | 1655 ..close(); |
| 1656 compiler.assembledCode = assembledCode; |
| 1656 } | 1657 } |
| 1657 | 1658 |
| 1658 /// Used by incremental compilation to patch up the prototype of | 1659 /// Used by incremental compilation to patch up the prototype of |
| 1659 /// [oldConstructor] for use as prototype of [newConstructor]. | 1660 /// [oldConstructor] for use as prototype of [newConstructor]. |
| 1660 jsAst.Fun buildSchemaChangeFunction() { | 1661 jsAst.Fun buildSchemaChangeFunction() { |
| 1661 return js(''' | 1662 return js(''' |
| 1662 function(newConstructor, oldConstructor, superclass) { | 1663 function(newConstructor, oldConstructor, superclass) { |
| 1663 // Invariant: newConstructor.prototype has no interesting properties besides | 1664 // Invariant: newConstructor.prototype has no interesting properties besides |
| 1664 // generated accessors. These are copied to oldPrototype which will be | 1665 // generated accessors. These are copied to oldPrototype which will be |
| 1665 // updated by other incremental changes. | 1666 // updated by other incremental changes. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 | 1825 |
| 1825 nativeEmitter.generateNativeClasses(nativeClasses, mainBuffer, | 1826 nativeEmitter.generateNativeClasses(nativeClasses, mainBuffer, |
| 1826 additionalProperties); | 1827 additionalProperties); |
| 1827 | 1828 |
| 1828 nativeEmitter.finishGenerateNativeClasses(); | 1829 nativeEmitter.finishGenerateNativeClasses(); |
| 1829 nativeEmitter.assembleCode(nativeBuffer); | 1830 nativeEmitter.assembleCode(nativeBuffer); |
| 1830 | 1831 |
| 1831 return nativeBuffer; | 1832 return nativeBuffer; |
| 1832 } | 1833 } |
| 1833 | 1834 |
| 1834 int emitProgram(Program program) { | 1835 void emitProgram(Program program) { |
| 1835 // Shorten the code by using [namer.currentIsolate] as temporary. | 1836 // Shorten the code by using [namer.currentIsolate] as temporary. |
| 1836 isolateProperties = namer.currentIsolate; | 1837 isolateProperties = namer.currentIsolate; |
| 1837 | 1838 |
| 1838 // Emit deferred units first, so we have their hashes. | 1839 // Emit deferred units first, so we have their hashes. |
| 1839 // Map from OutputUnit to a hash of its content. The hash uniquely | 1840 // Map from OutputUnit to a hash of its content. The hash uniquely |
| 1840 // identifies the code of the output-unit. It does not include | 1841 // identifies the code of the output-unit. It does not include |
| 1841 // boilerplate JS code, like the sourcemap directives or the hash | 1842 // boilerplate JS code, like the sourcemap directives or the hash |
| 1842 // itself. | 1843 // itself. |
| 1843 Map<OutputUnit, String> deferredLoadHashes = emitDeferredOutputUnits(); | 1844 Map<OutputUnit, String> deferredLoadHashes = emitDeferredOutputUnits(); |
| 1844 CodeBuffer nativeBuffer = buildNativesBuffer(); | 1845 CodeBuffer nativeBuffer = buildNativesBuffer(); |
| 1845 emitMainOutputUnit(deferredLoadHashes, nativeBuffer); | 1846 emitMainOutputUnit(deferredLoadHashes, nativeBuffer); |
| 1846 | 1847 |
| 1847 if (backend.requiresPreamble && | 1848 if (backend.requiresPreamble && |
| 1848 !backend.htmlLibraryIsLoaded) { | 1849 !backend.htmlLibraryIsLoaded) { |
| 1849 compiler.reportHint(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); | 1850 compiler.reportHint(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); |
| 1850 } | 1851 } |
| 1851 | |
| 1852 // Return the total program size. | |
| 1853 return outputBuffers.values.fold(0, (a, b) => a + b.length); | |
| 1854 } | 1852 } |
| 1855 | 1853 |
| 1856 String generateSourceMapTag(Uri sourceMapUri, Uri fileUri) { | 1854 String generateSourceMapTag(Uri sourceMapUri, Uri fileUri) { |
| 1857 if (sourceMapUri != null && fileUri != null) { | 1855 if (sourceMapUri != null && fileUri != null) { |
| 1858 String sourceMapFileName = relativize(fileUri, sourceMapUri, false); | 1856 String sourceMapFileName = relativize(fileUri, sourceMapUri, false); |
| 1859 return ''' | 1857 return ''' |
| 1860 | 1858 |
| 1861 //# sourceMappingURL=$sourceMapFileName | 1859 //# sourceMappingURL=$sourceMapFileName |
| 1862 '''; | 1860 '''; |
| 1863 } | 1861 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2096 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2094 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2097 if (element.isInstanceMember) { | 2095 if (element.isInstanceMember) { |
| 2098 cachedClassBuilders.remove(element.enclosingClass); | 2096 cachedClassBuilders.remove(element.enclosingClass); |
| 2099 | 2097 |
| 2100 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2098 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2101 | 2099 |
| 2102 } | 2100 } |
| 2103 } | 2101 } |
| 2104 } | 2102 } |
| 2105 } | 2103 } |
| OLD | NEW |