Chromium Code Reviews| 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) { | |
|
Johnni Winther
2014/11/14 08:33:32
We need to move this to JavaScriptBackend.register
| |
| 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 | |
| 1833 visitConstant(HConstant node) { | 1816 visitConstant(HConstant node) { |
| 1834 assert(isGenerateAtUseSite(node)); | 1817 assert(isGenerateAtUseSite(node)); |
| 1835 generateConstant(node.constant); | 1818 push(backend.emitter.constantReference(node.constant)); |
| 1836 | |
| 1837 registry.registerCompileTimeConstant(node.constant); | 1819 registry.registerCompileTimeConstant(node.constant); |
| 1838 backend.constants.addCompileTimeConstantForEmission(node.constant); | 1820 backend.constants.addCompileTimeConstantForEmission(node.constant); |
| 1839 } | 1821 } |
| 1840 | 1822 |
| 1841 visitNot(HNot node) { | 1823 visitNot(HNot node) { |
| 1842 assert(node.inputs.length == 1); | 1824 assert(node.inputs.length == 1); |
| 1843 generateNot(node.inputs[0]); | 1825 generateNot(node.inputs[0]); |
| 1844 attachLocationToLast(node); | 1826 attachLocationToLast(node); |
| 1845 } | 1827 } |
| 1846 | 1828 |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2724 js.PropertyAccess accessHelper(String name) { | 2706 js.PropertyAccess accessHelper(String name) { |
| 2725 Element helper = backend.findHelper(name); | 2707 Element helper = backend.findHelper(name); |
| 2726 if (helper == null) { | 2708 if (helper == null) { |
| 2727 // For mocked-up tests. | 2709 // For mocked-up tests. |
| 2728 return js.js('(void 0).$name'); | 2710 return js.js('(void 0).$name'); |
| 2729 } | 2711 } |
| 2730 registry.registerStaticUse(helper); | 2712 registry.registerStaticUse(helper); |
| 2731 return backend.namer.elementAccess(helper); | 2713 return backend.namer.elementAccess(helper); |
| 2732 } | 2714 } |
| 2733 } | 2715 } |
| OLD | NEW |