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

Unified Diff: pkg/compiler/lib/src/js_model/locals.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/js_strategy.dart ('k') | pkg/compiler/lib/src/kernel/element_map.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/locals.dart
diff --git a/pkg/compiler/lib/src/js_model/locals.dart b/pkg/compiler/lib/src/js_model/locals.dart
index cae0cb7339b50ac418c18a2a305efacba1654413..f89bf5c1da2d3473095f2e558b105718956560a1 100644
--- a/pkg/compiler/lib/src/js_model/locals.dart
+++ b/pkg/compiler/lib/src/js_model/locals.dart
@@ -6,6 +6,7 @@ library dart2js.js_model.locals;
import 'package:kernel/ast.dart' as ir;
+import 'closure.dart' show JClosureClass;
import '../closure.dart';
import '../common.dart';
import '../elements/entities.dart';
@@ -125,9 +126,18 @@ class KernelToLocalsMapImpl implements KernelToLocalsMap {
}
@override
- Local getLocalVariable(ir.VariableDeclaration node) {
+ Local getLocalVariable(ir.VariableDeclaration node,
+ {bool isClosureCallMethod = false}) {
+ if (isClosureCallMethod && !_map.containsKey(node)) {
+ // Node might correspond to a free variable in the closure class.
+ assert(currentMember.enclosingClass is JClosureClass);
+ return (currentMember.enclosingClass as JClosureClass)
+ .localsMap
+ .getLocalVariable(node);
+ }
return _map.putIfAbsent(node, () {
- return new JLocal(node.name, currentMember);
+ return new JLocal(
+ node.name, currentMember, node.parent is ir.FunctionNode);
});
}
@@ -280,7 +290,11 @@ class JLocal implements Local {
final String name;
final MemberEntity memberContext;
- JLocal(this.name, this.memberContext);
+ /// True if this local represents a local parameter.
+ final bool isRegularParameter;
+
+ JLocal(this.name, this.memberContext, [isParameter = false])
+ : isRegularParameter = isParameter;
@override
Entity get executableContext => memberContext;
« no previous file with comments | « pkg/compiler/lib/src/js_model/js_strategy.dart ('k') | pkg/compiler/lib/src/kernel/element_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698