| 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 import 'package:front_end/src/fasta/builder/ast_factory.dart'; | 5 import 'package:front_end/src/fasta/builder/ast_factory.dart'; |
| 6 | 6 |
| 7 /// A library to help transform compounds and null-aware accessors into | 7 /// A library to help transform compounds and null-aware accessors into |
| 8 /// let expressions. | 8 /// let expressions. |
| 9 | 9 |
| 10 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; | 10 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 var fact = helper.typePromoter | 166 var fact = helper.typePromoter |
| 167 .getFactForAccess(variable, helper.functionNestingLevel); | 167 .getFactForAccess(variable, helper.functionNestingLevel); |
| 168 var scope = helper.typePromoter.currentScope; | 168 var scope = helper.typePromoter.currentScope; |
| 169 return helper.astFactory.variableGet(variable, fact, scope, token); | 169 return helper.astFactory.variableGet(variable, fact, scope, token); |
| 170 } | 170 } |
| 171 | 171 |
| 172 Expression _makeWrite(Expression value, bool voidContext) { | 172 Expression _makeWrite(Expression value, bool voidContext) { |
| 173 helper.typePromoter.mutateVariable(variable, helper.functionNestingLevel); | 173 helper.typePromoter.mutateVariable(variable, helper.functionNestingLevel); |
| 174 return variable.isFinal || variable.isConst | 174 return variable.isFinal || variable.isConst |
| 175 ? makeInvalidWrite(value) | 175 ? makeInvalidWrite(value) |
| 176 : new VariableSet(variable, value) | 176 : helper.astFactory.variableSet(variable, value) |
| 177 ..fileOffset = offsetForToken(token); | 177 ..fileOffset = offsetForToken(token); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 class PropertyAccessor extends Accessor { | 181 class PropertyAccessor extends Accessor { |
| 182 VariableDeclaration _receiverVariable; | 182 VariableDeclaration _receiverVariable; |
| 183 Expression receiver; | 183 Expression receiver; |
| 184 Name name; | 184 Name name; |
| 185 Member getter, setter; | 185 Member getter, setter; |
| 186 | 186 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 | 552 |
| 553 VariableDeclaration makeOrReuseVariable(Expression value) { | 553 VariableDeclaration makeOrReuseVariable(Expression value) { |
| 554 // TODO: Devise a way to remember if a variable declaration was reused | 554 // TODO: Devise a way to remember if a variable declaration was reused |
| 555 // or is fresh (hence needs a let binding). | 555 // or is fresh (hence needs a let binding). |
| 556 return new VariableDeclaration.forValue(value); | 556 return new VariableDeclaration.forValue(value); |
| 557 } | 557 } |
| 558 | 558 |
| 559 Expression wrapInvalid(Expression e) { | 559 Expression wrapInvalid(Expression e) { |
| 560 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); | 560 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); |
| 561 } | 561 } |
| OLD | NEW |