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

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

Issue 1345983007: dart2js CPS: Clean up the S-Expression builder. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Cleanup. Created 5 years, 3 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/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 2ae63c2bd76a88763c59b1d7d3631fa953354d37..045fad7ed0632a84eceda768b89d0c05034590da 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,24 +76,14 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
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)';
+ conts = visit(continuation);
} 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)';
+ conts = '$conts\n$indent${visit(continuation)}';
}
}
String body = indentBlock(() => visit(node.body));
@@ -120,10 +110,12 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
}
String formatArguments(CallStructure call,
- List<Reference<Primitive>> arguments) {
+ List<Reference<Primitive>> arguments,
+ {bool isIntercepted: false}) {
int positionalArgumentCount = call.positionalArgumentCount;
- List<String> args = new List<String>();
- args.addAll(arguments.getRange(0, positionalArgumentCount).map(access));
+ if (isIntercepted) ++positionalArgumentCount;
+ List<String> args =
+ arguments.getRange(0, positionalArgumentCount).map(access).toList();
List<String> argumentNames = call.getOrderedNamedArguments();
for (int i = 0; i < argumentNames.length; ++i) {
String name = argumentNames[i];
@@ -144,7 +136,8 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
String name = node.selector.name;
String rcv = access(node.receiver);
String cont = access(node.continuation);
- String args = formatArguments(node.selector.callStructure, node.arguments);
+ String args = formatArguments(node.selector.callStructure, node.arguments,
+ isIntercepted: node.receiverIsIntercepted);
return '$indentation(InvokeMethod $rcv $name $args $cont)';
}
@@ -218,8 +211,16 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
}
String visitContinuation(Continuation node) {
- // Continuations are visited directly in visitLetCont.
- return '(Unexpected Continuation)';
+ String name = newContinuationName(node);
+ if (node.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 = node.parameters
+ .map((p) => '${decorator(p, newValueName(p))}')
+ .join(' ');
+ String body = indentBlock(() => indentBlock(() => visit(node.body)));
+ return '($name ($parameters)\n$body)';
}
String visitGetMutable(GetMutable node) {
@@ -294,7 +295,7 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
String className = node.classElement.name;
String arguments = node.arguments.map(access).join(' ');
String typeInformation = node.typeInformation.map(access).join(' ');
- return '(CreateInstance $className ($arguments)$typeInformation)';
+ return '(CreateInstance $className ($arguments) ($typeInformation))';
}
String visitInterceptor(Interceptor node) {
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/cps_ir/type_propagation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698