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

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

Issue 2994353002: Fix the locals lookup of variables and partial implementation of boxing of variables.
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
« no previous file with comments | « pkg/compiler/lib/src/js_model/closure.dart ('k') | pkg/compiler/lib/src/js_model/elements.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b6e7d3ba64262a0af859bdbec9c9516ae3f06180..ed482e7a669ab07c3fe3c28a24910ac1ae139a85 100644
--- a/pkg/compiler/lib/src/js_model/closure_visitors.dart
+++ b/pkg/compiler/lib/src/js_model/closure_visitors.dart
@@ -11,8 +11,6 @@ import 'closure.dart';
/// various points to build CapturedScope that can respond to queries
/// about how a particular variable is being used at any point in the code.
class CapturedScopeBuilder extends ir.Visitor {
- ir.TreeNode _currentLocalFunction;
-
ScopeModel _model;
/// A map of each visited call node with the associated information about what
@@ -70,7 +68,7 @@ class CapturedScopeBuilder extends ir.Visitor {
/// Update the [CapturedScope] object corresponding to
/// this node if any variables are captured.
- void attachCapturedScopeVariables(ir.Node node) {
+ void attachCapturedScopeVariables(ir.TreeNode node) {
Set<ir.VariableDeclaration> capturedVariablesForScope =
new Set<ir.VariableDeclaration>();
@@ -84,15 +82,18 @@ class CapturedScopeBuilder extends ir.Visitor {
}
if (!capturedVariablesForScope.isEmpty) {
assert(_model.scopeInfo != null);
- assert(_currentLocalFunction != null);
KernelScopeInfo from = _model.scopeInfo;
- _scopesCapturedInClosureMap[node] = new KernelCapturedScope(
+ var capturedScope = new KernelCapturedScope(
capturedVariablesForScope,
new NodeBox(getBoxName(), _executableContext),
- _currentLocalFunction,
from.localsUsedInTryOrSync,
from.freeVariables,
_hasThisLocal);
+ _model.scopeInfo =
+ _scopesCapturedInClosureMap[node.parent] = capturedScope;
+ _currentScopeInfo.capturedScopes.add(node.parent);
+ print(
+ 'FUUUUUUUUUUUUUUUUUUU ${node.parent} ${_executableContext.parent} $_currentScopeInfo');
}
}
@@ -154,6 +155,17 @@ class CapturedScopeBuilder extends ir.Visitor {
node.visitChildren(this);
}
+ @override
+ visitVariableDeclaration(ir.VariableDeclaration declaration) {
+ if (!declaration.isFieldFormal) {
+ _scopeVariables.add(declaration);
+ }
+
+ if (declaration.initializer != null) {
+ declaration.initializer.accept(this);
+ }
+ }
+
/// Add this variable to the set of free variables if appropriate and add to
/// the tally of variables used in try or sync blocks.
void _markVariableAsUsed(ir.VariableDeclaration variable) {
@@ -213,7 +225,6 @@ class CapturedScopeBuilder extends ir.Visitor {
scope.boxedVariables,
scope.capturedVariablesAccessor,
boxedLoopVariables,
- scope.context,
scope.localsUsedInTryOrSync,
scope.freeVariables,
scope.hasThisLocal);
@@ -223,7 +234,6 @@ class CapturedScopeBuilder extends ir.Visitor {
bool oldIsInsideClosure = _isInsideClosure;
ir.TreeNode oldExecutableContext = _executableContext;
KernelScopeInfo oldScopeInfo = _currentScopeInfo;
- ir.TreeNode oldLocalFunction = _currentLocalFunction;
// _outermostNode is only null the first time we enter the body of the
// field, constructor, or method that is being analyzed.
@@ -233,11 +243,11 @@ class CapturedScopeBuilder extends ir.Visitor {
_currentScopeInfo = new KernelScopeInfo(_hasThisLocal);
if (_isInsideClosure) {
_closuresToGenerate[node] = _currentScopeInfo;
- _currentLocalFunction = node.parent;
+ print("EEEEEEEEEEEEEEEeee $_currentScopeInfo");
} else {
_outermostNode = node;
- _model.scopeInfo = _currentScopeInfo;
}
+ _model.scopeInfo = _currentScopeInfo;
enterNewScope(node, () {
node.visitChildren(this);
@@ -250,7 +260,6 @@ class CapturedScopeBuilder extends ir.Visitor {
_isInsideClosure = oldIsInsideClosure;
_currentScopeInfo = oldScopeInfo;
_executableContext = oldExecutableContext;
- _currentLocalFunction = oldLocalFunction;
// Mark all free variables as captured and expect to encounter them in the
// outer function.
« no previous file with comments | « pkg/compiler/lib/src/js_model/closure.dart ('k') | pkg/compiler/lib/src/js_model/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698