Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1665)

Unified Diff: sdk/lib/_internal/compiler/implementation/ir/ir_pickler.dart

Issue 231863007: Support local variables in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/ir/ir_pickler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ir/ir_pickler.dart b/sdk/lib/_internal/compiler/implementation/ir/ir_pickler.dart
index b55ab52d84426c505ee3ce516baa92affc954976..563b6b97a5306fe1114cf8ac5fe5cffa32744e62 100644
--- a/sdk/lib/_internal/compiler/implementation/ir/ir_pickler.dart
+++ b/sdk/lib/_internal/compiler/implementation/ir/ir_pickler.dart
@@ -40,7 +40,7 @@ part 'ir_unpickler.dart';
* | byte(NODE_INVOKE_STATIC) element selector
* reference(continuation) {reference(argument)}
* | byte(NODE_INVOKE_CONTINUATION) reference(continuation)
- * reference(argument)
+ * {reference(argument)}
*
* reference ::= int(indexDelta)
*
@@ -68,10 +68,12 @@ class Pickles {
static const int FIRST_NODE_TAG = STRING_UTF8 + 1;
static const int NODE_CONSTANT = FIRST_NODE_TAG;
- static const int NODE_LET_CONT = NODE_CONSTANT + 1;
+ static const int NODE_IS_TRUE = NODE_CONSTANT + 1;
+ static const int NODE_LET_CONT = NODE_IS_TRUE + 1;
static const int NODE_INVOKE_STATIC = NODE_LET_CONT + 1;
static const int NODE_INVOKE_CONTINUATION = NODE_INVOKE_STATIC + 1;
- static const int LAST_NODE_TAG = NODE_INVOKE_CONTINUATION;
+ static const int NODE_BRANCH = NODE_INVOKE_CONTINUATION + 1;
+ static const int LAST_NODE_TAG = NODE_BRANCH;
static const int FIRST_CONST_TAG = LAST_NODE_TAG + 1;
static const int CONST_BOOL = FIRST_CONST_TAG;
@@ -173,7 +175,7 @@ class Pickler extends ir.Visitor {
offset = 0;
emitted = <Object, int>{};
index = 0;
- function.accept(this);
+ visit(function);
int sizeOffset = offset;
writeInt(emitted.length);
@@ -282,10 +284,10 @@ class Pickler extends ir.Visitor {
writeInt(index - entryIndex);
}
- void writeBackReferenceList(List entries) {
- writeInt(entries.length);
- for (int i = 0; i < entries.length; i++) {
- writeBackReference(entries[i]);
+ void writeBackReferenceList(int length, Iterable entries) {
+ writeInt(length);
+ for (var x in entries) {
+ writeBackReference(x);
}
}
@@ -364,14 +366,14 @@ class Pickler extends ir.Visitor {
recordForBackReference(parameter);
writeElement(parameter.element);
}
- node.body.accept(this);
+ visit(node.body);
}
void visitLetPrim(ir.LetPrim node) {
- node.primitive.accept(this);
+ visit(node.primitive);
// The right-hand side is bound in the body.
recordForBackReference(node.primitive);
- node.body.accept(this);
+ visit(node.body);
}
void visitLetCont(ir.LetCont node) {
@@ -384,10 +386,10 @@ class Pickler extends ir.Visitor {
writeInt(node.continuation.parameters.length);
// The continuation is bound in the body.
recordForBackReference(node.continuation);
- node.body.accept(this);
+ visit(node.body);
// The continuation parameters are bound in the continuation's body.
node.continuation.parameters.forEach(recordForBackReference);
- node.continuation.body.accept(this);
+ visit(node.continuation.body);
}
void visitInvokeStatic(ir.InvokeStatic node) {
@@ -397,14 +399,22 @@ class Pickler extends ir.Visitor {
// TODO(lry): compact encoding when the arity of the selector and the
// arguments list are the same
writeBackReference(node.continuation.definition);
- writeBackReferenceList(node.arguments.map(
- (a) => a.definition).toList(growable: false));
+ writeBackReferenceList(node.arguments.length,
+ node.arguments.map((a) => a.definition));
}
void visitInvokeContinuation(ir.InvokeContinuation node) {
writeByte(Pickles.NODE_INVOKE_CONTINUATION);
writeBackReference(node.continuation.definition);
- writeBackReference(node.argument.definition);
+ writeBackReferenceList(node.arguments.length,
+ node.arguments.map((a) => a.definition));
+ }
+
+ void visitBranch(ir.Branch node) {
+ writeByte(Pickles.NODE_BRANCH);
+ visit(node.condition);
+ writeBackReference(node.trueContinuation.definition);
+ writeBackReference(node.falseContinuation.definition);
}
void visitConstant(ir.Constant node) {
@@ -412,6 +422,11 @@ class Pickler extends ir.Visitor {
node.value.accept(constantPickler);
}
+ void visitIsTrue(ir.IsTrue node) {
+ writeByte(Pickles.NODE_IS_TRUE);
+ writeBackReference(node.value.definition);
+ }
+
void visitNode(ir.Node node) {
throw "Unexpected $node in pickler.";
}

Powered by Google App Engine
This is Rietveld 408576698