Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * Top level generator object for writing code and keeping track of | 6 * Top level generator object for writing code and keeping track of |
| 7 * dependencies. | 7 * dependencies. |
| 8 * | 8 * |
| 9 * Should have two compilation models, but only one implemented so far. | 9 * Should have two compilation models, but only one implemented so far. |
| 10 * | 10 * |
| (...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1863 final y = visitValue(node.y); | 1863 final y = visitValue(node.y); |
| 1864 var name = TokenKind.binaryMethodName(node.op.kind); | 1864 var name = TokenKind.binaryMethodName(node.op.kind); |
| 1865 if (node.op.kind == TokenKind.NE) { | 1865 if (node.op.kind == TokenKind.NE) { |
| 1866 name = ':ne'; | 1866 name = ':ne'; |
| 1867 } | 1867 } |
| 1868 if (name == null) { | 1868 if (name == null) { |
| 1869 world.internalError('unimplemented binary op ${node.op}', node.span); | 1869 world.internalError('unimplemented binary op ${node.op}', node.span); |
| 1870 return; | 1870 return; |
| 1871 } | 1871 } |
| 1872 return x.invoke(this, name, node, new Arguments(null, [y])); | 1872 return x.invoke(this, name, node, new Arguments(null, [y])); |
| 1873 } else { | 1873 } else if ((assignKind != 0) && (node.y is BinaryExpression)){ |
| 1874 return _visitAssign(assignKind, node.x, node.y, node, null, isVoid); | 1874 BinaryExpression y = node.y; |
| 1875 } | 1875 if (TokenKind.infixPrecedence(y.op.kind) <= |
| 1876 TokenKind.infixPrecedence(assignKind)) { | |
|
jimhug
2011/12/15 17:43:18
I would prefer not to include this check. My gene
dgrove
2011/12/15 17:51:45
It doesn't any changes in minfrog, for instance. I
dgrove
2011/12/15 17:51:45
Done.
| |
| 1877 // This handles transforming A x= B y C => A = A x (B y C) when | |
| 1878 // precedence of x >= precedence of y. | |
| 1879 return _visitAssign(assignKind, node.x, | |
| 1880 new ParenExpression(node.y, node.y.span), node, null, isVoid); | |
| 1881 } | |
| 1882 } | |
| 1883 return _visitAssign(assignKind, node.x, node.y, node, null, isVoid); | |
| 1876 } | 1884 } |
| 1877 | 1885 |
| 1878 /** | 1886 /** |
| 1879 * Visits an assignment expression. | 1887 * Visits an assignment expression. |
| 1880 * Note: captureOriginal can optionally capture the original value of the | 1888 * Note: captureOriginal can optionally capture the original value of the |
| 1881 * left side. This is used by postfix expressions to ensure they return the | 1889 * left side. This is used by postfix expressions to ensure they return the |
| 1882 * original value, before it has been modified. | 1890 * original value, before it has been modified. |
| 1883 */ | 1891 */ |
| 1884 _visitAssign(int kind, Expression xn, Expression yn, Node position, | 1892 _visitAssign(int kind, Expression xn, Expression yn, Node position, |
| 1885 Value captureOriginal(Value right), [bool isVoid = false]) { | 1893 Value captureOriginal(Value right), [bool isVoid = false]) { |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2538 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); | 2546 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); |
| 2539 } | 2547 } |
| 2540 for (int i = bareCount; i < length; i++) { | 2548 for (int i = bareCount; i < length; i++) { |
| 2541 var name = getName(i); | 2549 var name = getName(i); |
| 2542 if (name == null) name = '\$$i'; | 2550 if (name == null) name = '\$$i'; |
| 2543 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); | 2551 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); |
| 2544 } | 2552 } |
| 2545 return new Arguments(nodes, result); | 2553 return new Arguments(nodes, result); |
| 2546 } | 2554 } |
| 2547 } | 2555 } |
| OLD | NEW |