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

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

Issue 1021813002: Redo "Use an explicit 'this' parameter instead of 'This' nodes." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 34cd076d3c0941f0a6eec0baa1e8520d82735286..3b71d9adc3e9594612cd22a96079363539b94d6a 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
@@ -46,11 +46,17 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
return decorator(node, s);
}
+ String formatThisParameter(Parameter thisParameter) {
+ return thisParameter == null ? '()' : '(${visit(thisParameter)})';
+ }
+
String visitFunctionDefinition(FunctionDefinition node) {
String name = node.element.name;
+ String thisParameter = formatThisParameter(node.thisParameter);
String parameters = node.parameters.map(visit).join(' ');
String body = visit(node.body);
- return '$indentation(FunctionDefinition $name ($parameters) return\n'
+ return '$indentation'
+ '(FunctionDefinition $name $thisParameter ($parameters) return\n'
'$body)';
}
@@ -68,6 +74,7 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
String visitConstructorDefinition(ConstructorDefinition node) {
String name = node.element.name;
if (name != '') name = '$name ';
+ String thisParameter = formatThisParameter(node.thisParameter);
String parameters = node.parameters.map(visit).join(' ');
if (node.body != null) {
String initializers = indentBlock(() {
@@ -80,17 +87,19 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
});
});
String body = visit(node.body);
- return '$indentation(ConstructorDefinition $name($parameters) return'
+ return '$indentation'
+ '(ConstructorDefinition $name$thisParameter ($parameters) return'
' (\n$initializers)\n$body)';
} else {
- return '$indentation(ConstructorDefinition $name($parameters) return)';
+ return '$indentation'
+ '(ConstructorDefinition $name$thisParameter ($parameters) return)';
}
}
String visitFieldInitializer(FieldInitializer node) {
String name = node.element.name;
String body = visit(node.body);
- return '$indentation(FieldInitializer $name\$body)';
+ return '$indentation(FieldInitializer $name\n$body)';
}
String visitSuperInitializer(SuperInitializer node) {
@@ -235,10 +244,6 @@ class SExpressionStringifier extends Indentation implements Visitor<String> {
return '(Constant $value)';
}
- String visitThis(This node) {
- return '(This)';
- }
-
String visitReifyTypeVar(ReifyTypeVar node) {
return '$indentation(ReifyTypeVar ${node.typeVariable.name})';
}
@@ -417,6 +422,9 @@ class _Namer {
int _valueCounter = 0;
int _continuationCounter = 0;
+ // TODO(sra): Make the methods not assert and print something indicating an
+ // error, so printer can be used to inspect broken terms.
+
String nameParameter(Parameter parameter) {
assert(!_names.containsKey(parameter));
return _names[parameter] = parameter.hint.name;
« 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