| Index: pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
|
| index 61aa7919fa3648ffe5aa8d317194bba51512a04b..d96a0c86838666613e01fd29873fd5b5e94af5d7 100644
|
| --- a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
|
| +++ b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart
|
| @@ -8,6 +8,8 @@
|
| /// let expressions.
|
| library kernel.frontend.accessors;
|
|
|
| +import 'package:front_end/src/fasta/builder/shadow_ast.dart';
|
| +import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart';
|
| import 'package:kernel/ast.dart';
|
|
|
| import '../names.dart' show indexGetName, indexSetName;
|
| @@ -26,8 +28,8 @@ import '../names.dart' show indexGetName, indexSetName;
|
| /// called.
|
| abstract class Accessor {
|
| /// Builds an [Expression] representing a read from the accessor.
|
| - Expression buildSimpleRead() {
|
| - return _finish(_makeSimpleRead());
|
| + ShadowExpression buildSimpleRead() {
|
| + return _finish(_makeSimpleRead() as ShadowExpression);
|
| }
|
|
|
| /// Builds an [Expression] representing an assignment with the accessor on
|
| @@ -36,7 +38,8 @@ abstract class Accessor {
|
| /// The returned expression evaluates to the assigned value, unless
|
| /// [voidContext] is true, in which case it may evaluate to anything.
|
| Expression buildAssignment(Expression value, {bool voidContext: false}) {
|
| - return _finish(_makeSimpleWrite(value, voidContext));
|
| + return _finish(_makeSimpleWrite(value, voidContext) as ShadowExpression)
|
| + as Expression;
|
| }
|
|
|
| /// Returns an [Expression] representing a null-aware assignment (`??=`) with
|
| @@ -49,14 +52,20 @@ abstract class Accessor {
|
| Expression buildNullAwareAssignment(Expression value, DartType type,
|
| {bool voidContext: false}) {
|
| if (voidContext) {
|
| - return _finish(new ConditionalExpression(buildIsNull(_makeRead()),
|
| - _makeWrite(value, false), new NullLiteral(), type));
|
| + return _finish(new ConditionalExpression(
|
| + buildIsNull(_makeRead()),
|
| + _makeWrite(value, false),
|
| + new NullLiteral(),
|
| + type) as ShadowExpression) as Expression;
|
| }
|
| var tmp = new VariableDeclaration.forValue(_makeRead());
|
| return _finish(makeLet(
|
| tmp,
|
| - new ConditionalExpression(buildIsNull(new VariableGet(tmp)),
|
| - _makeWrite(value, false), new VariableGet(tmp), type)));
|
| + new ConditionalExpression(
|
| + buildIsNull(new VariableGet(tmp)),
|
| + _makeWrite(value, false),
|
| + new VariableGet(tmp),
|
| + type)) as ShadowExpression) as Expression;
|
| }
|
|
|
| /// Returns an [Expression] representing a compound assignment (e.g. `+=`)
|
| @@ -67,7 +76,7 @@ abstract class Accessor {
|
| return _finish(_makeWrite(
|
| makeBinary(
|
| _makeRead(), binaryOperator, interfaceTarget, value, charOffset),
|
| - voidContext));
|
| + voidContext) as ShadowExpression) as Expression;
|
| }
|
|
|
| /// Returns an [Expression] representing a pre-increment or pre-decrement
|
| @@ -93,7 +102,9 @@ abstract class Accessor {
|
| makeBinary(valueAccess(), binaryOperator, interfaceTarget,
|
| new IntLiteral(1), charOffset),
|
| true));
|
| - return _finish(makeLet(value, makeLet(dummy, valueAccess())));
|
| + return _finish(
|
| + makeLet(value, makeLet(dummy, valueAccess())) as ShadowExpression)
|
| + as Expression;
|
| }
|
|
|
| Expression _makeSimpleRead() => _makeRead();
|
| @@ -106,7 +117,7 @@ abstract class Accessor {
|
|
|
| Expression _makeWrite(Expression value, bool voidContext);
|
|
|
| - Expression _finish(Expression body) => body;
|
| + ShadowExpression _finish(ShadowExpression body) => body;
|
|
|
| /// Returns an [Expression] representing a compile-time error.
|
| ///
|
| @@ -130,7 +141,7 @@ class VariableAccessor extends Accessor {
|
| VariableAccessor.internal(this.variable, this.charOffset, this.promotedType);
|
|
|
| _makeRead() =>
|
| - new VariableGet(variable, promotedType)..fileOffset = charOffset;
|
| + new KernelVariableGet(variable, promotedType)..fileOffset = charOffset;
|
|
|
| _makeWrite(Expression value, bool voidContext) {
|
| return variable.isFinal || variable.isConst
|
| @@ -179,7 +190,8 @@ class PropertyAccessor extends Accessor {
|
| ..fileOffset = charOffset;
|
| }
|
|
|
| - _finish(Expression body) => makeLet(_receiverVariable, body);
|
| + _finish(ShadowExpression body) =>
|
| + makeLet(_receiverVariable, body as Expression) as ShadowExpression;
|
| }
|
|
|
| /// Special case of [PropertyAccessor] to avoid creating an indirect access to
|
| @@ -218,10 +230,10 @@ class NullAwarePropertyAccessor extends Accessor {
|
| return new PropertySet(receiverAccess(), name, value, setter);
|
| }
|
|
|
| - _finish(Expression body) => makeLet(
|
| + _finish(ShadowExpression body) => makeLet(
|
| receiver,
|
| - new ConditionalExpression(
|
| - buildIsNull(receiverAccess()), new NullLiteral(), body, type));
|
| + new ConditionalExpression(buildIsNull(receiverAccess()),
|
| + new NullLiteral(), body as Expression, type)) as ShadowExpression;
|
| }
|
|
|
| class SuperPropertyAccessor extends Accessor {
|
| @@ -327,8 +339,9 @@ class IndexAccessor extends Accessor {
|
| valueVariable, makeLet(dummy, new VariableGet(valueVariable)));
|
| }
|
|
|
| - Expression _finish(Expression body) {
|
| - return makeLet(receiverVariable, makeLet(indexVariable, body));
|
| + ShadowExpression _finish(ShadowExpression body) {
|
| + return makeLet(receiverVariable, makeLet(indexVariable, body as Expression))
|
| + as ShadowExpression;
|
| }
|
| }
|
|
|
| @@ -378,7 +391,8 @@ class ThisIndexAccessor extends Accessor {
|
| valueVariable, makeLet(dummy, new VariableGet(valueVariable)));
|
| }
|
|
|
| - Expression _finish(Expression body) => makeLet(indexVariable, body);
|
| + ShadowExpression _finish(ShadowExpression body) =>
|
| + makeLet(indexVariable, body as Expression) as ShadowExpression;
|
| }
|
|
|
| class SuperIndexAccessor extends Accessor {
|
| @@ -424,8 +438,8 @@ class SuperIndexAccessor extends Accessor {
|
| valueVariable, makeLet(dummy, new VariableGet(valueVariable)));
|
| }
|
|
|
| - Expression _finish(Expression body) {
|
| - return makeLet(indexVariable, body);
|
| + ShadowExpression _finish(ShadowExpression body) {
|
| + return makeLet(indexVariable, body as Expression) as ShadowExpression;
|
| }
|
| }
|
|
|
| @@ -462,7 +476,8 @@ class ReadOnlyAccessor extends Accessor {
|
|
|
| _makeWrite(Expression value, bool voidContext) => makeInvalidWrite(value);
|
|
|
| - Expression _finish(Expression body) => makeLet(value, body);
|
| + ShadowExpression _finish(ShadowExpression body) =>
|
| + makeLet(value, body as Expression) as ShadowExpression;
|
| }
|
|
|
| Expression makeLet(VariableDeclaration variable, Expression body) {
|
|
|