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

Unified Diff: pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart

Issue 1088493002: Assignment expressions in tree IR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments Created 5 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: pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart
index a6423f30581b1ed6874ae94220ce2391e89bf0c6..e3a431896130f48bfe037ee8908e2c0db043a97c 100644
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart
@@ -76,11 +76,6 @@ class BlockCollector extends StatementVisitor {
visitStatement(node.next);
}
- visitAssign(Assign node) {
- _addStatement(node);
- visitStatement(node.next);
- }
-
visitReturn(Return node) {
_addStatement(node);
}
@@ -173,11 +168,10 @@ class BlockCollector extends StatementVisitor {
visitStatement(node.next);
}
- visitSetField(SetField node) {
+ visitVariableDeclaration(VariableDeclaration node) {
_addStatement(node);
visitStatement(node.next);
}
-
}
class TreeTracer extends TracerUtil with StatementVisitor {
@@ -266,14 +260,6 @@ class TreeTracer extends TracerUtil with StatementVisitor {
// These do not get added to a block's list of statements.
}
- visitAssign(Assign node) {
- String name = names.varName(node.variable);
- String rhs = expr(node.value);
- Variable v = node.variable;
- String extra = "(r=${v.readCount}, w=${v.writeCount})";
- printStatement(null, "assign $name = $rhs $extra");
- }
-
visitReturn(Return node) {
printStatement(null, "return ${expr(node.value)}");
}
@@ -321,6 +307,12 @@ class TreeTracer extends TracerUtil with StatementVisitor {
printStatement(null, 'function ${node.definition.element.name}');
}
+ visitVariableDeclaration(VariableDeclaration node) {
+ String variable = names.varName(node.variable);
+ String value = expr(node.value);
+ printStatement(null, 'declare $variable = $value');
+ }
+
visitSetField(SetField node) {
String object = expr(node.object);
String field = node.field.name;
@@ -345,6 +337,12 @@ class SubexpressionVisitor extends ExpressionVisitor<String> {
return names.varName(node.variable);
}
+ String visitAssign(Assign node) {
+ String variable = names.varName(node.variable);
+ String value = visitExpression(node.value);
+ return '$variable = $value';
+ }
+
String formatArguments(Invoke node) {
List<String> args = new List<String>();
int positionalArgumentCount = node.selector.positionalArgumentCount;
@@ -426,7 +424,10 @@ class SubexpressionVisitor extends ExpressionVisitor<String> {
}
static bool usesInfixNotation(Expression node) {
- return node is Conditional || node is LogicalOperator;
+ return node is Conditional ||
+ node is LogicalOperator ||
+ node is Assign ||
+ node is SetField;
}
String visitConditional(Conditional node) {
@@ -483,6 +484,16 @@ class SubexpressionVisitor extends ExpressionVisitor<String> {
return '$object.$field';
}
+ String visitSetField(SetField node) {
+ String object = visitExpression(node.object);
+ String field = node.field.name;
+ if (usesInfixNotation(node.object)) {
+ object = '($object)';
+ }
+ String value = visitExpression(node.value);
+ return '$object.$field = $value';
+ }
+
String visitCreateBox(CreateBox node) {
return 'CreateBox';
}
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart ('k') | tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698