| 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 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 compiler.sourceMapUri, compiler.outputUri); | 1665 compiler.sourceMapUri, compiler.outputUri); |
| 1666 mainBuffer.add( | 1666 mainBuffer.add( |
| 1667 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); | 1667 generateSourceMapTag(compiler.sourceMapUri, compiler.outputUri)); |
| 1668 assembledCode = mainBuffer.getText(); | 1668 assembledCode = mainBuffer.getText(); |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 compiler.outputProvider('', 'js') | 1671 compiler.outputProvider('', 'js') |
| 1672 ..add(assembledCode) | 1672 ..add(assembledCode) |
| 1673 ..close(); | 1673 ..close(); |
| 1674 compiler.assembledCode = assembledCode; | 1674 compiler.assembledCode = assembledCode; |
| 1675 |
| 1676 if (!compiler.useContentSecurityPolicy) { |
| 1677 CodeBuffer cspBuffer = new CodeBuffer(); |
| 1678 cspBuffer.add(mainBuffer); |
| 1679 cspBuffer.write(""" |
| 1680 { |
| 1681 var message = |
| 1682 'Deprecation: Automatic generation of output for Content Security\\n' + |
| 1683 'Policy is deprecated and will be removed with the next development\\n' + |
| 1684 'release. Use the --csp option to generate CSP restricted output.'; |
| 1685 if (typeof dartPrint == "function") { |
| 1686 dartPrint(message); |
| 1687 } else if (typeof console == "object" && typeof console.log == "function") { |
| 1688 console.log(message); |
| 1689 } else if (typeof print == "function") { |
| 1690 print(message); |
| 1691 } |
| 1692 }\n"""); |
| 1693 |
| 1694 cspBuffer.write( |
| 1695 jsAst.prettyPrint( |
| 1696 precompiledFunctionAst, compiler, |
| 1697 allowVariableMinification: false).getText()); |
| 1698 |
| 1699 compiler.outputProvider('', 'precompiled.js') |
| 1700 ..add(cspBuffer.getText()) |
| 1701 ..close(); |
| 1702 } |
| 1675 } | 1703 } |
| 1676 | 1704 |
| 1677 /// Returns a map from OutputUnit to a hash of its content. The hash uniquely | 1705 /// Returns a map from OutputUnit to a hash of its content. The hash uniquely |
| 1678 /// identifies the code of the output-unit. It does not include | 1706 /// identifies the code of the output-unit. It does not include |
| 1679 /// boilerplate JS code, like the sourcemap directives or the hash | 1707 /// boilerplate JS code, like the sourcemap directives or the hash |
| 1680 /// itself. | 1708 /// itself. |
| 1681 Map<OutputUnit, String> emitDeferredOutputUnits() { | 1709 Map<OutputUnit, String> emitDeferredOutputUnits() { |
| 1682 if (!compiler.deferredLoadTask.isProgramSplit) return const {}; | 1710 if (!compiler.deferredLoadTask.isProgramSplit) return const {}; |
| 1683 | 1711 |
| 1684 Map<OutputUnit, CodeBuffer> outputBuffers = | 1712 Map<OutputUnit, CodeBuffer> outputBuffers = |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2005 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2033 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2006 if (element.isInstanceMember) { | 2034 if (element.isInstanceMember) { |
| 2007 cachedClassBuilders.remove(element.enclosingClass); | 2035 cachedClassBuilders.remove(element.enclosingClass); |
| 2008 | 2036 |
| 2009 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2037 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2010 | 2038 |
| 2011 } | 2039 } |
| 2012 } | 2040 } |
| 2013 } | 2041 } |
| 2014 } | 2042 } |
| OLD | NEW |