| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 | 10 |
| (...skipping 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 | 1806 |
| 1807 js.Expression newLiteralBool(bool value) { | 1807 js.Expression newLiteralBool(bool value) { |
| 1808 if (compiler.enableMinification) { | 1808 if (compiler.enableMinification) { |
| 1809 // Use !0 for true, !1 for false. | 1809 // Use !0 for true, !1 for false. |
| 1810 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); | 1810 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); |
| 1811 } else { | 1811 } else { |
| 1812 return new js.LiteralBool(value); | 1812 return new js.LiteralBool(value); |
| 1813 } | 1813 } |
| 1814 } | 1814 } |
| 1815 | 1815 |
| 1816 void generateConstant(ConstantValue constant) { |
| 1817 if (constant.isFunction) { |
| 1818 FunctionConstantValue function = constant; |
| 1819 registry.registerStaticUse(function.element); |
| 1820 } |
| 1821 if (constant.isType) { |
| 1822 // If the type is a web component, we need to ensure the constructors are |
| 1823 // available to 'upgrade' the native object. |
| 1824 TypeConstantValue type = constant; |
| 1825 Element element = type.representedType.element; |
| 1826 if (element != null && element.isClass) { |
| 1827 registry.registerTypeConstant(element); |
| 1828 } |
| 1829 } |
| 1830 push(backend.emitter.constantReference(constant)); |
| 1831 } |
| 1832 |
| 1816 visitConstant(HConstant node) { | 1833 visitConstant(HConstant node) { |
| 1817 assert(isGenerateAtUseSite(node)); | 1834 assert(isGenerateAtUseSite(node)); |
| 1818 push(backend.emitter.constantReference(node.constant)); | 1835 generateConstant(node.constant); |
| 1836 |
| 1819 registry.registerCompileTimeConstant(node.constant); | 1837 registry.registerCompileTimeConstant(node.constant); |
| 1820 backend.constants.addCompileTimeConstantForEmission(node.constant); | 1838 backend.constants.addCompileTimeConstantForEmission(node.constant); |
| 1821 } | 1839 } |
| 1822 | 1840 |
| 1823 visitNot(HNot node) { | 1841 visitNot(HNot node) { |
| 1824 assert(node.inputs.length == 1); | 1842 assert(node.inputs.length == 1); |
| 1825 generateNot(node.inputs[0]); | 1843 generateNot(node.inputs[0]); |
| 1826 attachLocationToLast(node); | 1844 attachLocationToLast(node); |
| 1827 } | 1845 } |
| 1828 | 1846 |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2706 js.PropertyAccess accessHelper(String name) { | 2724 js.PropertyAccess accessHelper(String name) { |
| 2707 Element helper = backend.findHelper(name); | 2725 Element helper = backend.findHelper(name); |
| 2708 if (helper == null) { | 2726 if (helper == null) { |
| 2709 // For mocked-up tests. | 2727 // For mocked-up tests. |
| 2710 return js.js('(void 0).$name'); | 2728 return js.js('(void 0).$name'); |
| 2711 } | 2729 } |
| 2712 registry.registerStaticUse(helper); | 2730 registry.registerStaticUse(helper); |
| 2713 return backend.namer.elementAccess(helper); | 2731 return backend.namer.elementAccess(helper); |
| 2714 } | 2732 } |
| 2715 } | 2733 } |
| OLD | NEW |