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

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

Issue 2778223002: Add primitive to create closures and use it for closure conversion (Closed)
Patch Set: Follow common pattern for AST nodes with References in ClosureCreation 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
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/kernel/lib/ast.dart
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index a27c198a9326d3d6d21fcbdd261217bed35c2d67..0112b5a7286a9cfd651dfbe5f032e6e43bbf8ae5 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -2855,6 +2855,49 @@ 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;
+ Expression contextVector;
+ FunctionType functionType;
+
+ ClosureCreation(Member topLevelFunction, Expression contextVector,
+ FunctionType functionType)
+ : this.byReference(
+ getMemberReference(topLevelFunction), contextVector, functionType);
+
+ ClosureCreation.byReference(
+ this.topLevelFunctionReference, this.contextVector, this.functionType) {
+ contextVector?.parent = this;
+ }
+
+ Procedure get topLevelFunction => topLevelFunctionReference?.asProcedure;
+
+ void set topLevelFunction(Member topLevelFunction) {
+ topLevelFunctionReference = getMemberReference(topLevelFunction);
+ }
+
+ 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
// ------------------------------------------------------------------------
« no previous file with comments | « pkg/kernel/binary.md ('k') | pkg/kernel/lib/binary/ast_from_binary.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698