| Index: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
|
| index 37e91fe15c09214d1a826163661a57e93dcd4d6c..31c14680f471540da06cb5d3dbe83ece3bf7da61 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
|
| @@ -64,7 +64,11 @@ abstract class InteriorNode extends Node {
|
| void set body(Expression body);
|
| }
|
|
|
| -/// An expression with a subexpression as body.
|
| +/// An expression that creates new bindings and continues evaluation in
|
| +/// a subexpression.
|
| +///
|
| +/// The interior expressions are [LetPrim], [LetCont], [LetHandler], and
|
| +/// [LetMutable].
|
| abstract class InteriorExpression extends Expression implements InteriorNode {
|
| Expression get next => body;
|
| }
|
| @@ -557,17 +561,17 @@ class Unreachable extends TailExpression {
|
| /// Gets the value from a [MutableVariable].
|
| ///
|
| /// [MutableVariable]s can be seen as ref cells that are not first-class
|
| -/// values. A [LetPrim] with a [GetMutableVariable] can then be seen as:
|
| +/// values. A [LetPrim] with a [GetMutable] can then be seen as:
|
| ///
|
| /// let prim p = ![variable] in [body]
|
| ///
|
| -class GetMutableVariable extends Primitive {
|
| +class GetMutable extends Primitive {
|
| final Reference<MutableVariable> variable;
|
|
|
| - GetMutableVariable(MutableVariable variable)
|
| + GetMutable(MutableVariable variable)
|
| : this.variable = new Reference<MutableVariable>(variable);
|
|
|
| - accept(Visitor visitor) => visitor.visitGetMutableVariable(this);
|
| + accept(Visitor visitor) => visitor.visitGetMutable(this);
|
|
|
| bool get isSafeForElimination => true;
|
| bool get isSafeForReordering => false;
|
| @@ -579,21 +583,18 @@ class GetMutableVariable extends Primitive {
|
| /// values. This can be seen as a dereferencing assignment:
|
| ///
|
| /// { [variable] := [value]; [body] }
|
| -class SetMutableVariable extends InteriorExpression {
|
| +class SetMutable extends Primitive {
|
| final Reference<MutableVariable> variable;
|
| final Reference<Primitive> value;
|
| - Expression body;
|
|
|
| - SetMutableVariable(MutableVariable variable, Primitive value)
|
| + SetMutable(MutableVariable variable, Primitive value)
|
| : this.variable = new Reference<MutableVariable>(variable),
|
| this.value = new Reference<Primitive>(value);
|
|
|
| - accept(Visitor visitor) => visitor.visitSetMutableVariable(this);
|
| + accept(Visitor visitor) => visitor.visitSetMutable(this);
|
|
|
| - Expression plug(Expression expr) {
|
| - assert(body == null);
|
| - return body = expr;
|
| - }
|
| + bool get isSafeForElimination => false;
|
| + bool get isSafeForReordering => false;
|
| }
|
|
|
| /// Invoke a continuation in tail position.
|
| @@ -662,22 +663,19 @@ class Branch extends TailExpression {
|
| }
|
|
|
| /// Directly assigns to a field on a given object.
|
| -class SetField extends InteriorExpression {
|
| +class SetField extends Primitive {
|
| final Reference<Primitive> object;
|
| FieldElement field;
|
| final Reference<Primitive> value;
|
| - Expression body;
|
|
|
| SetField(Primitive object, this.field, Primitive value)
|
| : this.object = new Reference<Primitive>(object),
|
| this.value = new Reference<Primitive>(value);
|
|
|
| - Expression plug(Expression expr) {
|
| - assert(body == null);
|
| - return body = expr;
|
| - }
|
| -
|
| accept(Visitor visitor) => visitor.visitSetField(this);
|
| +
|
| + bool get isSafeForElimination => false;
|
| + bool get isSafeForReordering => false;
|
| }
|
|
|
| /// Directly reads from a field on a given object.
|
| @@ -778,21 +776,18 @@ class GetStatic extends Primitive {
|
| }
|
|
|
| /// Sets the value of a static field.
|
| -class SetStatic extends InteriorExpression {
|
| +class SetStatic extends Primitive {
|
| final FieldElement element;
|
| final Reference<Primitive> value;
|
| - Expression body;
|
| final SourceInformation sourceInformation;
|
|
|
| SetStatic(this.element, Primitive value, [this.sourceInformation])
|
| : this.value = new Reference<Primitive>(value);
|
|
|
| - Expression plug(Expression expr) {
|
| - assert(body == null);
|
| - return body = expr;
|
| - }
|
| -
|
| accept(Visitor visitor) => visitor.visitSetStatic(this);
|
| +
|
| + bool get isSafeForElimination => false;
|
| + bool get isSafeForReordering => false;
|
| }
|
|
|
| /// Reads the value of a lazily initialized static field.
|
| @@ -1125,7 +1120,7 @@ abstract class Visitor<T> {
|
| T visitRethrow(Rethrow node);
|
| T visitBranch(Branch node);
|
| T visitTypeCast(TypeCast node);
|
| - T visitSetMutableVariable(SetMutableVariable node);
|
| + T visitSetMutable(SetMutable node);
|
| T visitSetStatic(SetStatic node);
|
| T visitGetLazyStatic(GetLazyStatic node);
|
| T visitSetField(SetField node);
|
| @@ -1136,7 +1131,7 @@ abstract class Visitor<T> {
|
| T visitLiteralMap(LiteralMap node);
|
| T visitConstant(Constant node);
|
| T visitCreateFunction(CreateFunction node);
|
| - T visitGetMutableVariable(GetMutableVariable node);
|
| + T visitGetMutable(GetMutable node);
|
| T visitParameter(Parameter node);
|
| T visitContinuation(Continuation node);
|
| T visitMutableVariable(MutableVariable node);
|
| @@ -1283,12 +1278,11 @@ class RecursiveVisitor implements Visitor {
|
| node.typeArguments.forEach(processReference);
|
| }
|
|
|
| - processSetMutableVariable(SetMutableVariable node) {}
|
| - visitSetMutableVariable(SetMutableVariable node) {
|
| - processSetMutableVariable(node);
|
| + processSetMutable(SetMutable node) {}
|
| + visitSetMutable(SetMutable node) {
|
| + processSetMutable(node);
|
| processReference(node.variable);
|
| processReference(node.value);
|
| - visit(node.body);
|
| }
|
|
|
| processGetLazyStatic(GetLazyStatic node) {}
|
| @@ -1328,9 +1322,9 @@ class RecursiveVisitor implements Visitor {
|
| processMutableVariable(node);
|
| }
|
|
|
| - processGetMutableVariable(GetMutableVariable node) {}
|
| - visitGetMutableVariable(GetMutableVariable node) {
|
| - processGetMutableVariable(node);
|
| + processGetMutable(GetMutable node) {}
|
| + visitGetMutable(GetMutable node) {
|
| + processGetMutable(node);
|
| processReference(node.variable);
|
| }
|
|
|
| @@ -1370,7 +1364,6 @@ class RecursiveVisitor implements Visitor {
|
| processSetField(node);
|
| processReference(node.object);
|
| processReference(node.value);
|
| - visit(node.body);
|
| }
|
|
|
| processGetField(GetField node) {}
|
| @@ -1388,7 +1381,6 @@ class RecursiveVisitor implements Visitor {
|
| visitSetStatic(SetStatic node) {
|
| processSetStatic(node);
|
| processReference(node.value);
|
| - visit(node.body);
|
| }
|
|
|
| processCreateBox(CreateBox node) {}
|
|
|