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); |