OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// A library to help transform compounds and null-aware accessors into | 5 /// A library to help transform compounds and null-aware accessors into |
6 /// let expressions. | 6 /// let expressions. |
7 library kernel.frontend.accessors; | 7 library kernel.frontend.accessors; |
8 | 8 |
9 import '../ast.dart'; | 9 import '../ast.dart'; |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 offset: offset, | 60 offset: offset, |
61 voidContext: voidContext, | 61 voidContext: voidContext, |
62 interfaceTarget: interfaceTarget); | 62 interfaceTarget: interfaceTarget); |
63 } | 63 } |
64 | 64 |
65 Expression buildPostfixIncrement(Name binaryOperator, | 65 Expression buildPostfixIncrement(Name binaryOperator, |
66 {int offset: TreeNode.noOffset, | 66 {int offset: TreeNode.noOffset, |
67 bool voidContext: false, | 67 bool voidContext: false, |
68 Procedure interfaceTarget}) { | 68 Procedure interfaceTarget}) { |
69 if (voidContext) { | 69 if (voidContext) { |
70 return buildPrefixIncrement(binaryOperator, offset: offset, | 70 return buildPrefixIncrement(binaryOperator, |
71 voidContext: true, interfaceTarget: interfaceTarget); | 71 offset: offset, voidContext: true, interfaceTarget: interfaceTarget); |
72 } | 72 } |
73 var value = new VariableDeclaration.forValue(_makeRead()); | 73 var value = new VariableDeclaration.forValue(_makeRead()); |
74 valueAccess() => new VariableGet(value); | 74 valueAccess() => new VariableGet(value); |
75 var dummy = new VariableDeclaration.forValue(_makeWrite( | 75 var dummy = new VariableDeclaration.forValue(_makeWrite( |
76 builtBinary = makeBinary(valueAccess(), binaryOperator, interfaceTarget, | 76 builtBinary = makeBinary( |
77 new IntLiteral(1), offset: offset), | 77 valueAccess(), binaryOperator, interfaceTarget, new IntLiteral(1), |
| 78 offset: offset), |
78 true)); | 79 true)); |
79 return _finish(makeLet(value, makeLet(dummy, valueAccess()))); | 80 return _finish(makeLet(value, makeLet(dummy, valueAccess()))); |
80 } | 81 } |
81 | 82 |
82 Expression _makeSimpleRead() => _makeRead(); | 83 Expression _makeSimpleRead() => _makeRead(); |
83 | 84 |
84 Expression _makeSimpleWrite(Expression value, bool voidContext) { | 85 Expression _makeSimpleWrite(Expression value, bool voidContext) { |
85 return _makeWrite(value, voidContext); | 86 return _makeWrite(value, voidContext); |
86 } | 87 } |
87 | 88 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 427 |
427 VariableDeclaration makeOrReuseVariable(Expression value) { | 428 VariableDeclaration makeOrReuseVariable(Expression value) { |
428 // TODO: Devise a way to remember if a variable declaration was reused | 429 // TODO: Devise a way to remember if a variable declaration was reused |
429 // or is fresh (hence needs a let binding). | 430 // or is fresh (hence needs a let binding). |
430 return new VariableDeclaration.forValue(value); | 431 return new VariableDeclaration.forValue(value); |
431 } | 432 } |
432 | 433 |
433 Expression wrapInvalid(Expression e) { | 434 Expression wrapInvalid(Expression e) { |
434 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); | 435 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); |
435 } | 436 } |
OLD | NEW |