| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.js_model.locals; | 5 library dart2js.js_model.locals; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
| 8 | 8 |
| 9 import '../closure.dart'; | 9 import '../closure.dart'; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 @override | 127 @override |
| 128 Local getLocalVariable(ir.VariableDeclaration node) { | 128 Local getLocalVariable(ir.VariableDeclaration node) { |
| 129 return _map.putIfAbsent(node, () { | 129 return _map.putIfAbsent(node, () { |
| 130 return new JLocal(node.name, currentMember); | 130 return new JLocal(node.name, currentMember); |
| 131 }); | 131 }); |
| 132 } | 132 } |
| 133 | 133 |
| 134 @override | 134 @override |
| 135 // TODO(johnniwinther): Split this out into two methods -- one for |
| 136 // FunctionDeclaration and one for FunctionExpression, since basically the |
| 137 // whole thing is different depending on the node type. The reason it's not |
| 138 // done yet is the version of this function that it's overriding has a little |
| 139 // bit of commonality. |
| 135 Local getLocalFunction(ir.TreeNode node) { | 140 Local getLocalFunction(ir.TreeNode node) { |
| 136 assert(node is ir.FunctionDeclaration || node is ir.FunctionExpression, | 141 assert(node is ir.FunctionDeclaration || node is ir.FunctionExpression, |
| 137 failedAt(currentMember, 'Invalid local function node: $node')); | 142 failedAt(currentMember, 'Invalid local function node: $node')); |
| 138 return _map.putIfAbsent(node, () { | 143 var lookupName = node; |
| 144 if (node is ir.FunctionDeclaration) lookupName = node.variable; |
| 145 return _map.putIfAbsent(lookupName, () { |
| 139 String name; | 146 String name; |
| 140 if (node is ir.FunctionDeclaration) { | 147 if (node is ir.FunctionDeclaration) { |
| 141 name = node.variable.name; | 148 name = node.variable.name; |
| 142 } else if (node is ir.FunctionExpression) { | 149 } else if (node is ir.FunctionExpression) { |
| 143 name = ''; | 150 name = ''; |
| 144 } | 151 } |
| 145 return new JLocal(name, currentMember); | 152 return new JLocal(name, currentMember); |
| 146 }); | 153 }); |
| 147 } | 154 } |
| 148 | 155 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 sb.write(memberContext.enclosingClass.name); | 292 sb.write(memberContext.enclosingClass.name); |
| 286 sb.write('.'); | 293 sb.write('.'); |
| 287 } | 294 } |
| 288 sb.write(memberContext.name); | 295 sb.write(memberContext.name); |
| 289 sb.write('#'); | 296 sb.write('#'); |
| 290 sb.write(name); | 297 sb.write(name); |
| 291 sb.write(')'); | 298 sb.write(')'); |
| 292 return sb.toString(); | 299 return sb.toString(); |
| 293 } | 300 } |
| 294 } | 301 } |
| OLD | NEW |