Chromium Code Reviews| 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 Local getLocalFunction(ir.TreeNode node) { | 135 Local getLocalFunction(ir.TreeNode node) { |
|
sra1
2017/07/28 22:09:40
Can we split this into two methods for FunctionExp
Emily Fortuna
2017/07/28 23:17:08
Added a TODO, for discussion with Johnni.
| |
| 136 assert(node is ir.FunctionDeclaration || node is ir.FunctionExpression, | 136 assert(node is ir.FunctionDeclaration || node is ir.FunctionExpression, |
| 137 failedAt(currentMember, 'Invalid local function node: $node')); | 137 failedAt(currentMember, 'Invalid local function node: $node')); |
| 138 return _map.putIfAbsent(node, () { | 138 var lookupName = node; |
| 139 if (node is ir.FunctionDeclaration) lookupName = node.variable; | |
| 140 return _map.putIfAbsent(lookupName, () { | |
| 139 String name; | 141 String name; |
| 140 if (node is ir.FunctionDeclaration) { | 142 if (node is ir.FunctionDeclaration) { |
| 141 name = node.variable.name; | 143 name = node.variable.name; |
| 142 } else if (node is ir.FunctionExpression) { | 144 } else if (node is ir.FunctionExpression) { |
| 143 name = ''; | 145 name = ''; |
| 144 } | 146 } |
| 145 return new JLocal(name, currentMember); | 147 return new JLocal(name, currentMember); |
| 146 }); | 148 }); |
| 147 } | 149 } |
| 148 | 150 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 sb.write(memberContext.enclosingClass.name); | 287 sb.write(memberContext.enclosingClass.name); |
| 286 sb.write('.'); | 288 sb.write('.'); |
| 287 } | 289 } |
| 288 sb.write(memberContext.name); | 290 sb.write(memberContext.name); |
| 289 sb.write('#'); | 291 sb.write('#'); |
| 290 sb.write(name); | 292 sb.write(name); |
| 291 sb.write(')'); | 293 sb.write(')'); |
| 292 return sb.toString(); | 294 return sb.toString(); |
| 293 } | 295 } |
| 294 } | 296 } |
| OLD | NEW |