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

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

Issue 2778223002: Add primitive to create closures and use it for closure conversion (Closed)
Patch Set: Fix bug: put parameters with no initalizers into contexts correctly 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..f60a34bb4cf3e904a1bb3ce47ebab7f6099a610d 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 {
+ String topLevelFunctionName;
asgerf 2017/03/31 11:03:52 Again, please use a reference to the member
Dmitry Stefantsov 2017/03/31 11:54:13 Done.
+ Expression contextVector;
+ FunctionType functionType;
+
+ ClosureCreation(
+ this.topLevelFunctionName, 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