OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.clone; | 4 library kernel.clone; |
5 | 5 |
6 import 'ast.dart'; | 6 import 'ast.dart'; |
7 import 'type_algebra.dart'; | 7 import 'type_algebra.dart'; |
8 | 8 |
9 /// Visitor that return a clone of a tree, maintaining references to cloned | 9 /// Visitor that return a clone of a tree, maintaining references to cloned |
10 /// objects. | 10 /// objects. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 275 } |
276 | 276 |
277 visitForInStatement(ForInStatement node) { | 277 visitForInStatement(ForInStatement node) { |
278 var newVariable = clone(node.variable); | 278 var newVariable = clone(node.variable); |
279 return new ForInStatement( | 279 return new ForInStatement( |
280 newVariable, clone(node.iterable), clone(node.body)); | 280 newVariable, clone(node.iterable), clone(node.body)); |
281 } | 281 } |
282 | 282 |
283 visitSwitchStatement(SwitchStatement node) { | 283 visitSwitchStatement(SwitchStatement node) { |
284 for (SwitchCase switchCase in node.cases) { | 284 for (SwitchCase switchCase in node.cases) { |
285 switchCases[switchCase] = | 285 switchCases[switchCase] = new SwitchCase( |
286 new SwitchCase(switchCase.expressions.map(clone).toList(), null); | 286 switchCase.expressions.map(clone).toList(), |
| 287 new List<int>.from(switchCase.expressionOffsets), |
| 288 null); |
287 } | 289 } |
288 return new SwitchStatement( | 290 return new SwitchStatement( |
289 clone(node.expression), node.cases.map(clone).toList()); | 291 clone(node.expression), node.cases.map(clone).toList()); |
290 } | 292 } |
291 | 293 |
292 visitSwitchCase(SwitchCase node) { | 294 visitSwitchCase(SwitchCase node) { |
293 var switchCase = switchCases[node]; | 295 var switchCase = switchCases[node]; |
294 switchCase.body = clone(node.body)..parent = switchCase; | 296 switchCase.body = clone(node.body)..parent = switchCase; |
295 return switchCase; | 297 return switchCase; |
296 } | 298 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 visitArguments(Arguments node) { | 403 visitArguments(Arguments node) { |
402 return new Arguments(node.positional.map(clone).toList(), | 404 return new Arguments(node.positional.map(clone).toList(), |
403 types: node.types.map(visitType).toList(), | 405 types: node.types.map(visitType).toList(), |
404 named: node.named.map(clone).toList()); | 406 named: node.named.map(clone).toList()); |
405 } | 407 } |
406 | 408 |
407 visitNamedExpression(NamedExpression node) { | 409 visitNamedExpression(NamedExpression node) { |
408 return new NamedExpression(node.name, clone(node.value)); | 410 return new NamedExpression(node.name, clone(node.value)); |
409 } | 411 } |
410 } | 412 } |
OLD | NEW |