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 | 7 |
8 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' | 8 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' |
9 show | 9 show |
10 KernelArguments, | 10 KernelArguments, |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 } | 569 } |
570 | 570 |
571 class StaticAccessor extends Accessor { | 571 class StaticAccessor extends Accessor { |
572 Member readTarget; | 572 Member readTarget; |
573 Member writeTarget; | 573 Member writeTarget; |
574 | 574 |
575 StaticAccessor( | 575 StaticAccessor( |
576 BuilderHelper helper, this.readTarget, this.writeTarget, Token token) | 576 BuilderHelper helper, this.readTarget, this.writeTarget, Token token) |
577 : super(helper, token); | 577 : super(helper, token); |
578 | 578 |
579 Expression _makeRead(KernelComplexAssignment complexAssignment) => | 579 Expression _makeRead(KernelComplexAssignment complexAssignment) { |
580 readTarget == null | 580 if (readTarget == null) { |
581 ? makeInvalidRead() | 581 return makeInvalidRead(); |
582 : helper.makeStaticGet(readTarget, token); | 582 } else { |
| 583 var read = helper.makeStaticGet(readTarget, token); |
| 584 complexAssignment?.read = read; |
| 585 return read; |
| 586 } |
| 587 } |
583 | 588 |
584 Expression _makeWrite(Expression value, bool voidContext, | 589 Expression _makeWrite(Expression value, bool voidContext, |
585 KernelComplexAssignment complexAssignment) { | 590 KernelComplexAssignment complexAssignment) { |
586 return writeTarget == null | 591 Expression write; |
587 ? makeInvalidWrite(value) | 592 if (writeTarget == null) { |
588 : new StaticSet(writeTarget, value) | 593 write = makeInvalidWrite(value); |
589 ..fileOffset = offsetForToken(token); | 594 } else { |
| 595 write = new StaticSet(writeTarget, value); |
| 596 complexAssignment?.write = write; |
| 597 } |
| 598 write.fileOffset = offsetForToken(token); |
| 599 return write; |
590 } | 600 } |
591 } | 601 } |
592 | 602 |
593 class ReadOnlyAccessor extends Accessor { | 603 class ReadOnlyAccessor extends Accessor { |
594 Expression expression; | 604 Expression expression; |
595 VariableDeclaration value; | 605 VariableDeclaration value; |
596 | 606 |
597 ReadOnlyAccessor(BuilderHelper helper, this.expression, Token token) | 607 ReadOnlyAccessor(BuilderHelper helper, this.expression, Token token) |
598 : super(helper, token); | 608 : super(helper, token); |
599 | 609 |
(...skipping 29 matching lines...) Expand all Loading... |
629 | 639 |
630 Expression buildIsNull(Expression value, {int offset: TreeNode.noOffset}) { | 640 Expression buildIsNull(Expression value, {int offset: TreeNode.noOffset}) { |
631 return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset); | 641 return makeBinary(value, equalsName, null, new NullLiteral(), offset: offset); |
632 } | 642 } |
633 | 643 |
634 VariableDeclaration makeOrReuseVariable(Expression value) { | 644 VariableDeclaration makeOrReuseVariable(Expression value) { |
635 // TODO: Devise a way to remember if a variable declaration was reused | 645 // TODO: Devise a way to remember if a variable declaration was reused |
636 // or is fresh (hence needs a let binding). | 646 // or is fresh (hence needs a let binding). |
637 return new VariableDeclaration.forValue(value); | 647 return new VariableDeclaration.forValue(value); |
638 } | 648 } |
OLD | NEW |