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

Unified Diff: pkg/compiler/lib/src/js_model/closure_visitors.dart

Issue 3003963002: Add more tests for closures and change closure indexing to be by FunctionExpression or FunctionDecl… (Closed)
Patch Set: . Created 3 years, 4 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/compiler/lib/src/js_model/closure_visitors.dart
diff --git a/pkg/compiler/lib/src/js_model/closure_visitors.dart b/pkg/compiler/lib/src/js_model/closure_visitors.dart
index 868466b15eb02e55f583de4240de82e24966d93a..c8e451250f0633a0d2334d1cab0a98bac94b6c6c 100644
--- a/pkg/compiler/lib/src/js_model/closure_visitors.dart
+++ b/pkg/compiler/lib/src/js_model/closure_visitors.dart
@@ -25,7 +25,7 @@ class CapturedScopeBuilder extends ir.Visitor {
/// A map of the nodes that we have flagged as necessary to generate closure
/// classes for in a later stage. We map that node to information ascertained
/// about variable usage in the surrounding scope.
- Map<ir.FunctionNode, KernelScopeInfo> get _closuresToGenerate =>
+ Map<ir.TreeNode, KernelScopeInfo> get _closuresToGenerate =>
_model.closuresToGenerate;
/// The local variables that have been declared in the current scope.
@@ -221,6 +221,9 @@ class CapturedScopeBuilder extends ir.Visitor {
}
void visitInvokable(ir.TreeNode node) {
+ assert(node is ir.Member ||
+ node is ir.FunctionExpression ||
+ node is ir.FunctionDeclaration);
bool oldIsInsideClosure = _isInsideClosure;
ir.TreeNode oldExecutableContext = _executableContext;
KernelScopeInfo oldScopeInfo = _currentScopeInfo;
@@ -274,15 +277,28 @@ class CapturedScopeBuilder extends ir.Visitor {
return node == _executableContext;
}
- void translateLazyInitializer(ir.Field field) {
+ @override
+ void visitField(ir.Field field) {
visitInvokable(field);
}
- void translateConstructorOrProcedure(ir.Node constructorOrProcedure) {
- constructorOrProcedure.accept(this);
+ @override
+ void visitConstructor(ir.Constructor constructor) {
+ visitInvokable(constructor);
+ }
+
+ @override
+ void visitProcedure(ir.Procedure procedure) {
+ visitInvokable(procedure);
}
- void visitFunctionNode(ir.FunctionNode functionNode) {
- visitInvokable(functionNode);
+ @override
+ void visitFunctionExpression(ir.FunctionExpression functionExpression) {
+ visitInvokable(functionExpression);
+ }
+
+ @override
+ void visitFunctionDeclaration(ir.FunctionDeclaration functionDeclaration) {
+ visitInvokable(functionDeclaration);
}
}

Powered by Google App Engine
This is Rietveld 408576698