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

Unified Diff: pkg/kernel/lib/transformations/closure/converter.dart

Issue 2891053003: Add support for converted closures with explicit contexts to VM (Closed)
Patch Set: Return statement-to-block conversion for procedure bodies Created 3 years, 6 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/kernel/lib/transformations/closure/converter.dart
diff --git a/pkg/kernel/lib/transformations/closure/converter.dart b/pkg/kernel/lib/transformations/closure/converter.dart
index e1865f7fd6d90a6c04a8e0dbeba37456490f612f..571ba500674094ea237ecd2f162e673a0c45853f 100644
--- a/pkg/kernel/lib/transformations/closure/converter.dart
+++ b/pkg/kernel/lib/transformations/closure/converter.dart
@@ -230,6 +230,7 @@ class ClosureConverter extends Transformer {
}
}
rewriter = null;
+ context = null;
// Transform constructor body.
FunctionNode function = node.function;
if (function.body != null && function.body is! EmptyStatement) {
@@ -483,7 +484,7 @@ class ClosureConverter extends Transformer {
TreeNode visitBlock(Block node) {
return saveContext(() {
BlockRewriter blockRewriter = rewriter = rewriter.forNestedBlock(node);
- blockRewriter.transformStatements(node, this);
+ blockRewriter.transformStatements(this);
return node;
});
}
@@ -627,25 +628,26 @@ class ClosureConverter extends Transformer {
}
TreeNode visitStaticGet(StaticGet node) {
- Member target = node.target;
- if (target is Procedure && target.kind == ProcedureKind.Method) {
- VariableDeclaration contextVariable = new VariableDeclaration(
- "#contextParameter",
- type: const VectorType());
- Expression expression = getTearOffExpression(
- null, node.target, contextVariable, new NullLiteral());
- expression.transformChildren(this);
- return expression;
- }
+ // TODO(dmitryas): Add support for tear-offs. When added, uncomment this.
kustermann 2017/06/20 12:13:13 Consider filing an issue about kernel-based closur
Dmitry Stefantsov 2017/06/22 14:12:51 Good idea! I was thinking about doing it, but the
+ //
+ // Member target = node.target;
+ // if (target is Procedure && target.kind == ProcedureKind.Method) {
+ // VariableDeclaration contextVariable = new VariableDeclaration(
+ // "#contextParameter",
+ // type: const VectorType());
+ // Expression expression = getTearOffExpression(
+ // null, node.target, contextVariable, new NullLiteral());
+ // expression.transformChildren(this);
+ // return expression;
+ // }
return super.visitStaticGet(node);
}
TreeNode visitPropertyGet(PropertyGet node) {
Name tearOffName = tearOffGetterNames[node.name];
if (tearOffName != null) {
- MethodInvocation replacement = new MethodInvocation(
- node.receiver, tearOffName, new Arguments(<Expression>[]));
- return super.visitMethodInvocation(replacement);
+ PropertyGet replacement = new PropertyGet(node.receiver, tearOffName);
+ return super.visitPropertyGet(replacement);
}
return super.visitPropertyGet(node);
}
@@ -871,7 +873,7 @@ class ClosureConverter extends Transformer {
self, procedure, contextVariable, parent.expression)));
Procedure tearOffMethod = new Procedure(
- name, ProcedureKind.Method, tearOffMethodFunction,
+ name, ProcedureKind.Getter, tearOffMethodFunction,
fileUri: currentFileUri);
newClassMembers.add(tearOffMethod);
« no previous file with comments | « no previous file | pkg/kernel/lib/transformations/closure/rewriter.dart » ('j') | pkg/kernel/test/closures/suite.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698