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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
6 final JavaScriptBackend backend; | 6 final JavaScriptBackend backend; |
7 SsaCodeGeneratorTask(JavaScriptBackend backend) | 7 SsaCodeGeneratorTask(JavaScriptBackend backend) |
8 : this.backend = backend, | 8 : this.backend = backend, |
9 super(backend.compiler); | 9 super(backend.compiler); |
10 String get name() => 'SSA code generator'; | 10 String get name() => 'SSA code generator'; |
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1803 | 1803 |
1804 void visitStaticStore(HStaticStore node) { | 1804 void visitStaticStore(HStaticStore node) { |
1805 world.registerStaticUse(node.element); | 1805 world.registerStaticUse(node.element); |
1806 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1806 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
1807 buffer.add(compiler.namer.isolateAccess(node.element)); | 1807 buffer.add(compiler.namer.isolateAccess(node.element)); |
1808 buffer.add(' = '); | 1808 buffer.add(' = '); |
1809 use(node.inputs[0], JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1809 use(node.inputs[0], JSPrecedence.ASSIGNMENT_PRECEDENCE); |
1810 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1810 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
1811 } | 1811 } |
1812 | 1812 |
1813 void visitStringConcat(HStringConcat node) { | |
1814 JSBinaryOperatorPrecedence operatorPrecedences = JSPrecedence.binary['+']; | |
1815 beginExpression(operatorPrecedences.precedence); | |
1816 useStringified(node.inputs[0], operatorPrecedences.left); | |
1817 buffer.add(' + '); | |
1818 // If the right hand side is a string concatenation itself it is | |
1819 // safe to make it left associative. | |
1820 JSPrecedence rightPrecedence = (node.inputs[1] is HStringConcat) | |
Lasse Reichstein Nielsen
2012/06/06 12:11:40
JSPrecedence -> int.
The JSPrecedence class is jus
kasperl
2012/06/06 13:31:03
Done.
| |
1821 ? JSPrecedence.ADDITIVE_PRECEDENCE | |
1822 : operatorPrecedences.right; | |
1823 useStringified(node.inputs[1], rightPrecedence); | |
1824 endExpression(operatorPrecedences.precedence); | |
1825 } | |
1826 | |
1827 void useStringified(HInstruction node, JSPrecedence precedence) { | |
1828 if (node.isString()) { | |
1829 use(node, precedence); | |
1830 } else { | |
1831 Element convertToString = compiler.findHelper(const SourceString("S")); | |
1832 world.registerStaticUse(convertToString); | |
1833 buffer.add(compiler.namer.isolateAccess(convertToString)); | |
Lasse Reichstein Nielsen
2012/06/06 12:11:40
Maybe we should have a function that does all this
| |
1834 buffer.add('('); | |
1835 use(node, JSPrecedence.EXPRESSION_PRECEDENCE); | |
1836 buffer.add(')'); | |
1837 } | |
1838 } | |
1839 | |
1813 void visitLiteralList(HLiteralList node) { | 1840 void visitLiteralList(HLiteralList node) { |
1814 generateArrayLiteral(node); | 1841 generateArrayLiteral(node); |
1815 } | 1842 } |
1816 | 1843 |
1817 void generateArrayLiteral(HLiteralList node) { | 1844 void generateArrayLiteral(HLiteralList node) { |
1818 buffer.add('['); | 1845 buffer.add('['); |
1819 int len = node.inputs.length; | 1846 int len = node.inputs.length; |
1820 for (int i = 0; i < len; i++) { | 1847 for (int i = 0; i < len; i++) { |
1821 if (i != 0) buffer.add(', '); | 1848 if (i != 0) buffer.add(', '); |
1822 use(node.inputs[i], JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1849 use(node.inputs[i], JSPrecedence.ASSIGNMENT_PRECEDENCE); |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2573 startBailoutSwitch(); | 2600 startBailoutSwitch(); |
2574 } | 2601 } |
2575 } | 2602 } |
2576 | 2603 |
2577 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2604 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
2578 if (labeledBlockInfo.body.start.hasGuards()) { | 2605 if (labeledBlockInfo.body.start.hasGuards()) { |
2579 endBailoutSwitch(); | 2606 endBailoutSwitch(); |
2580 } | 2607 } |
2581 } | 2608 } |
2582 } | 2609 } |
OLD | NEW |