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

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

Issue 2981423003: Move .getLocalFunction from KernelToElementMap to KernelToLocalsMap (Closed)
Patch Set: Updated cf. comments Created 3 years, 5 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 75080f717ab7ab2bdbb349feac678faee19fce91..9b714b26ef37564a68b568338f0c49a2912dd17d 100644
--- a/pkg/compiler/lib/src/js_model/locals.dart
+++ b/pkg/compiler/lib/src/js_model/locals.dart
@@ -24,7 +24,7 @@ class GlobalLocalsMap {
class KernelToLocalsMapImpl implements KernelToLocalsMap {
final List<MemberEntity> _members = <MemberEntity>[];
- Map<ir.VariableDeclaration, JLocal> _map = <ir.VariableDeclaration, JLocal>{};
+ Map<ir.TreeNode, JLocal> _map = <ir.TreeNode, JLocal>{};
Map<ir.TreeNode, JJumpTarget> _jumpTargetMap;
Set<ir.BreakStatement> _breaksAsContinue;
@@ -125,13 +125,28 @@ class KernelToLocalsMapImpl implements KernelToLocalsMap {
}
@override
- Local getLocal(ir.VariableDeclaration node) {
+ Local getLocalVariable(ir.VariableDeclaration node) {
return _map.putIfAbsent(node, () {
return new JLocal(node.name, currentMember);
});
}
@override
+ Local getLocalFunction(ir.TreeNode node) {
+ assert(node is ir.FunctionDeclaration || node is ir.FunctionExpression,
+ failedAt(currentMember, 'Invalid local function node: $node'));
+ return _map.putIfAbsent(node, () {
+ String name;
+ if (node is ir.FunctionDeclaration) {
+ name = node.variable.name;
+ } else if (node is ir.FunctionExpression) {
+ name = '';
+ }
+ return new JLocal(name, currentMember);
+ });
+ }
+
+ @override
CapturedLoopScope getCapturedLoopScope(
ClosureDataLookup closureLookup, ir.TreeNode node) {
return closureLookup.getCapturedLoopScope(node);
« 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