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

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

Issue 827763003: Reapply "Allow LetCont to bind multiple continuations." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
« 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 8496f54f37743d52f384703ade6b070735b4922f..e18e01781df19fdd56e89370ee6e907aba3fc0bf 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
@@ -76,20 +76,31 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
}
String visitLetCont(LetCont node) {
- String cont = newContinuationName(node.continuation);
- // TODO(karlklose): this should be changed to `.map(visit).join(' ')` and
- // should recurse to [visit]. Currently we can't do that, because the
- // unstringifier_test produces [LetConts] with dummy arguments on them.
- String parameters = node.continuation.parameters
- .map((p) => '${decorator(p, newValueName(p))}')
- .join(' ');
- String contBody =
- indentBlock(() => indentBlock(() => visit(node.continuation.body)));
+ String conts;
+ bool first = true;
+ for (Continuation continuation in node.continuations) {
+ String name = newContinuationName(continuation);
+ if (continuation.isRecursive) name = 'rec $name';
+ // TODO(karlklose): this should be changed to `.map(visit).join(' ')` and
+ // should recurse to [visit]. Currently we can't do that, because the
+ // unstringifier_test produces [LetConts] with dummy arguments on them.
+ String parameters = continuation.parameters
+ .map((p) => '${decorator(p, newValueName(p))}')
+ .join(' ');
+ String body =
+ indentBlock(() => indentBlock(() => visit(continuation.body)));
+ if (first) {
+ first = false;
+ conts = '($name ($parameters)\n$body)';
+ } else {
+ // Each subsequent line is indented additional spaces to align it
+ // with the previous continuation.
+ String indent = '$indentation${' ' * '(LetCont ('.length}';
+ conts = '$conts\n$indent($name ($parameters)\n$body)';
+ }
+ }
String body = indentBlock(() => visit(node.body));
- String op = node.continuation.isRecursive ? 'LetCont*' : 'LetCont';
- return '$indentation($op ($cont ($parameters)\n'
- '$contBody)\n'
- '$body)';
+ return '$indentation($LetCont ($conts)\n$body)';
}
String formatArguments(Invoke node) {
@@ -99,7 +110,7 @@ class SExpressionStringifier extends Visitor<String> with Indentation {
node.arguments.getRange(0, positionalArgumentCount).map(access));
for (int i = 0; i < node.selector.namedArgumentCount; ++i) {
String name = node.selector.namedArguments[i];
- Definition arg = node.arguments[positionalArgumentCount + i].definition;
+ String arg = access(node.arguments[positionalArgumentCount + i]);
args.add("($name: $arg)");
}
return '(${args.join(' ')})';
« 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