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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart

Issue 756383004: Refactored treatment of closure variables in dart2js CPS. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments Created 6 years 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
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
index c49c6a4f624da4569898b330e869be7198256082..d7ec6a950c08a2c129ea352e784b1b2ed492cc72 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart
@@ -27,6 +27,10 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
return namer.useElementName(node);
}
+ String visitClosureVariable(ClosureVariable node) {
+ return namer.getName(node);
+ }
+
/// Main entry point for creating a [String] from a [Node]. All recursive
/// calls must go through this method.
String visit(Node node) {
@@ -37,10 +41,13 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
String visitFunctionDefinition(FunctionDefinition node) {
String name = node.element.name;
namer.useReturnName(node.returnContinuation);
+ String closureVariables = node.closureVariables.isEmpty
+ ? ''
+ : '{${node.closureVariables.map(namer.defineClosureName).join(' ')}} ';
String parameters = node.parameters.map(visit).join(' ');
String body = indentBlock(() => visit(node.body));
- return '$indentation(FunctionDefinition $name ($parameters return)\n'
- '$body)';
+ return '$indentation(FunctionDefinition $name $closureVariables'
+ '($parameters return)\n$body)';
}
String visitFieldDefinition(FieldDefinition node) {
@@ -169,14 +176,14 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
}
String visitGetClosureVariable(GetClosureVariable node) {
- return '(GetClosureVariable ${node.variable.name})';
+ return '(GetClosureVariable ${visit(node.variable.definition)})';
}
String visitSetClosureVariable(SetClosureVariable node) {
String value = access(node.value);
String body = indentBlock(() => visit(node.body));
- return '$indentation(SetClosureVariable ${node.variable.name} $value\n'
- '$body)';
+ return '$indentation(SetClosureVariable ${visit(node.variable.definition)} '
+ '$value\n$body)';
}
String visitTypeOperator(TypeOperator node) {
@@ -200,7 +207,8 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
String visitDeclareFunction(DeclareFunction node) {
String function = indentBlock(() => visit(node.definition));
String body = indentBlock(() => visit(node.body));
- return '$indentation(DeclareFunction ${node.variable.name} =\n'
+ String name = namer.getName(node.variable.definition);
+ return '$indentation(DeclareFunction $name =\n'
'$function in\n'
'$body)';
}
@@ -227,6 +235,11 @@ class _Namer {
return _names[parameter] = parameter.hint.name;
}
+ String defineClosureName(ClosureVariable variable) {
+ assert(!_names.containsKey(variable));
+ return _names[variable] = variable.hint.name;
+ }
+
String defineContinuationName(Node node) {
assert(!_names.containsKey(node));
return _names[node] = 'k${_continuationCounter++}';
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698