| 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 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1758 | 1758 |
| 1759 visitLocalGet(HLocalGet node) { | 1759 visitLocalGet(HLocalGet node) { |
| 1760 use(node.receiver); | 1760 use(node.receiver); |
| 1761 } | 1761 } |
| 1762 | 1762 |
| 1763 visitLocalSet(HLocalSet node) { | 1763 visitLocalSet(HLocalSet node) { |
| 1764 use(node.value); | 1764 use(node.value); |
| 1765 assignVariable(variableNames.getName(node.receiver), pop()); | 1765 assignVariable(variableNames.getName(node.receiver), pop()); |
| 1766 } | 1766 } |
| 1767 | 1767 |
| 1768 void registerForeignType(HType type) { |
| 1769 DartType dartType = type.computeType(compiler); |
| 1770 if (dartType == null) { |
| 1771 assert(type == HType.UNKNOWN); |
| 1772 return; |
| 1773 } |
| 1774 world.registerInstantiatedClass(dartType.element); |
| 1775 } |
| 1776 |
| 1768 visitForeign(HForeign node) { | 1777 visitForeign(HForeign node) { |
| 1769 String code = node.code.slowToString(); | 1778 String code = node.code.slowToString(); |
| 1770 List<HInstruction> inputs = node.inputs; | 1779 List<HInstruction> inputs = node.inputs; |
| 1771 if (node.isJsStatement()) { | 1780 if (node.isJsStatement()) { |
| 1772 if (!inputs.isEmpty) { | 1781 if (!inputs.isEmpty) { |
| 1773 compiler.internalError("foreign statement with inputs: $code", | 1782 compiler.internalError("foreign statement with inputs: $code", |
| 1774 instruction: node); | 1783 instruction: node); |
| 1775 } | 1784 } |
| 1776 pushStatement(new js.LiteralStatement(code), node); | 1785 pushStatement(new js.LiteralStatement(code), node); |
| 1777 } else { | 1786 } else { |
| 1778 List<js.Expression> data = <js.Expression>[]; | 1787 List<js.Expression> data = <js.Expression>[]; |
| 1779 for (int i = 0; i < inputs.length; i++) { | 1788 for (int i = 0; i < inputs.length; i++) { |
| 1780 use(inputs[i]); | 1789 use(inputs[i]); |
| 1781 data.add(pop()); | 1790 data.add(pop()); |
| 1782 } | 1791 } |
| 1783 push(new js.LiteralExpression.withData(code, data), node); | 1792 push(new js.LiteralExpression.withData(code, data), node); |
| 1784 } | 1793 } |
| 1785 DartType type = types[node].computeType(compiler); | 1794 registerForeignType(types[node]); |
| 1786 if (type != null) { | |
| 1787 world.registerInstantiatedClass(type.element); | |
| 1788 } | |
| 1789 // TODO(sra): Tell world.nativeEnqueuer about the types created here. | 1795 // TODO(sra): Tell world.nativeEnqueuer about the types created here. |
| 1790 } | 1796 } |
| 1791 | 1797 |
| 1792 visitForeignNew(HForeignNew node) { | 1798 visitForeignNew(HForeignNew node) { |
| 1793 String jsClassReference = backend.namer.isolateAccess(node.element); | 1799 String jsClassReference = backend.namer.isolateAccess(node.element); |
| 1794 List<HInstruction> inputs = node.inputs; | 1800 List<HInstruction> inputs = node.inputs; |
| 1795 // We can't use 'visitArguments', since our arguments start at input[0]. | 1801 // We can't use 'visitArguments', since our arguments start at input[0]. |
| 1796 List<js.Expression> arguments = <js.Expression>[]; | 1802 List<js.Expression> arguments = <js.Expression>[]; |
| 1797 for (int i = 0; i < inputs.length; i++) { | 1803 for (int i = 0; i < inputs.length; i++) { |
| 1798 use(inputs[i]); | 1804 use(inputs[i]); |
| 1799 arguments.add(pop()); | 1805 arguments.add(pop()); |
| 1800 } | 1806 } |
| 1801 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it | 1807 // TODO(floitsch): jsClassReference is an Access. We shouldn't treat it |
| 1802 // as if it was a string. | 1808 // as if it was a string. |
| 1803 push(new js.New(new js.VariableUse(jsClassReference), arguments), node); | 1809 push(new js.New(new js.VariableUse(jsClassReference), arguments), node); |
| 1810 registerForeignType(types[node]); |
| 1804 } | 1811 } |
| 1805 | 1812 |
| 1806 js.Expression newLiteralBool(bool value) { | 1813 js.Expression newLiteralBool(bool value) { |
| 1807 if (compiler.enableMinification) { | 1814 if (compiler.enableMinification) { |
| 1808 // Use !0 for true, !1 for false. | 1815 // Use !0 for true, !1 for false. |
| 1809 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); | 1816 return new js.Prefix("!", new js.LiteralNumber(value ? "0" : "1")); |
| 1810 } else { | 1817 } else { |
| 1811 return new js.LiteralBool(value); | 1818 return new js.LiteralBool(value); |
| 1812 } | 1819 } |
| 1813 } | 1820 } |
| (...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2996 if (leftType.canBeNull() && rightType.canBeNull()) { | 3003 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2997 if (left.isConstantNull() || right.isConstantNull() || | 3004 if (left.isConstantNull() || right.isConstantNull() || |
| 2998 (leftType.isPrimitive() && leftType == rightType)) { | 3005 (leftType.isPrimitive() && leftType == rightType)) { |
| 2999 return '=='; | 3006 return '=='; |
| 3000 } | 3007 } |
| 3001 return null; | 3008 return null; |
| 3002 } else { | 3009 } else { |
| 3003 return '==='; | 3010 return '==='; |
| 3004 } | 3011 } |
| 3005 } | 3012 } |
| OLD | NEW |