| 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 // Note: copied from package:kernel at revision 7346348. | 5 // Note: copied from package:kernel at revision 7346348. |
| 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 library kernel.frontend.accessors; | 9 library kernel.frontend.accessors; |
| 10 | 10 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 419 } |
| 420 | 420 |
| 421 Expression _finish(Expression body) { | 421 Expression _finish(Expression body) { |
| 422 return makeLet(indexVariable, body); | 422 return makeLet(indexVariable, body); |
| 423 } | 423 } |
| 424 } | 424 } |
| 425 | 425 |
| 426 class StaticAccessor extends Accessor { | 426 class StaticAccessor extends Accessor { |
| 427 Member readTarget; | 427 Member readTarget; |
| 428 Member writeTarget; | 428 Member writeTarget; |
| 429 int charOffset; |
| 429 | 430 |
| 430 StaticAccessor(this.readTarget, this.writeTarget); | 431 StaticAccessor(this.readTarget, this.writeTarget, this.charOffset); |
| 431 | 432 |
| 432 _makeRead() => | 433 _makeRead() => |
| 433 readTarget == null ? makeInvalidRead() : new StaticGet(readTarget); | 434 readTarget == null ? makeInvalidRead() : new StaticGet(readTarget) |
| 435 ..fileOffset = charOffset; |
| 434 | 436 |
| 435 _makeWrite(Expression value, bool voidContext) { | 437 _makeWrite(Expression value, bool voidContext) { |
| 436 return writeTarget == null | 438 return writeTarget == null |
| 437 ? makeInvalidWrite(value) | 439 ? makeInvalidWrite(value) |
| 438 : new StaticSet(writeTarget, value); | 440 : new StaticSet(writeTarget, value)..fileOffset = charOffset; |
| 439 } | 441 } |
| 440 } | 442 } |
| 441 | 443 |
| 442 class ReadOnlyAccessor extends Accessor { | 444 class ReadOnlyAccessor extends Accessor { |
| 443 Expression expression; | 445 Expression expression; |
| 444 VariableDeclaration value; | 446 VariableDeclaration value; |
| 445 | 447 |
| 446 ReadOnlyAccessor(this.expression); | 448 ReadOnlyAccessor(this.expression); |
| 447 | 449 |
| 448 _makeSimpleRead() => expression; | 450 _makeSimpleRead() => expression; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 478 | 480 |
| 479 VariableDeclaration makeOrReuseVariable(Expression value) { | 481 VariableDeclaration makeOrReuseVariable(Expression value) { |
| 480 // TODO: Devise a way to remember if a variable declaration was reused | 482 // TODO: Devise a way to remember if a variable declaration was reused |
| 481 // or is fresh (hence needs a let binding). | 483 // or is fresh (hence needs a let binding). |
| 482 return new VariableDeclaration.forValue(value); | 484 return new VariableDeclaration.forValue(value); |
| 483 } | 485 } |
| 484 | 486 |
| 485 Expression wrapInvalid(Expression e) { | 487 Expression wrapInvalid(Expression e) { |
| 486 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); | 488 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); |
| 487 } | 489 } |
| OLD | NEW |