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

Unified Diff: pkg/kernel/lib/ast.dart

Issue 2778223002: Add primitive to create closures and use it for closure conversion (Closed)
Patch Set: Skip context param in closure type construction, rather than remove it Created 3 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
Index: pkg/kernel/lib/ast.dart
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index a27c198a9326d3d6d21fcbdd261217bed35c2d67..508130ebff056f97276928bbd12e5ebf8d01e44d 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -2855,6 +2855,38 @@ class VectorCopy extends Expression {
}
}
+/// Expression of the form `MakeClosure(f, c, t)` where `f` is a name of a
+/// closed top-level function, `c` is a Vector representing closure context, and
+/// `t` is the type of the resulting closure.
+class ClosureCreation extends Expression {
+ Reference topLevelFunctionReference;
asgerf 2017/03/31 12:08:43 Great! To be consistent with the other AST nodes:
Dmitry Stefantsov 2017/03/31 12:40:18 Good idea! Obviously, I didn't payed attention to
+ Expression contextVector;
+ FunctionType functionType;
+
+ ClosureCreation(
+ this.topLevelFunctionReference, this.contextVector, this.functionType) {
+ contextVector?.parent = this;
+ }
+
+ accept(ExpressionVisitor v) => v.visitClosureCreation(this);
+ accept1(ExpressionVisitor1 v, arg) => v.visitClosureCreation(this, arg);
+
+ visitChildren(Visitor v) {
+ contextVector?.accept(v);
+ }
+
+ transformChildren(Transformer v) {
+ if (contextVector != null) {
+ contextVector = contextVector.accept(v);
+ contextVector?.parent = this;
+ }
+ }
+
+ DartType getStaticType(TypeEnvironment types) {
+ return functionType;
+ }
+}
+
// ------------------------------------------------------------------------
// STATEMENTS
// ------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698