Chromium Code Reviews| Index: pkg/compiler/lib/src/js/rewrite_async.dart |
| diff --git a/pkg/compiler/lib/src/js/rewrite_async.dart b/pkg/compiler/lib/src/js/rewrite_async.dart |
| index 66d94ab9baa42838cbcbb13757574dde4fa1f13f..3de7fb20e1863803dcfe92962dcd4865d254aa84 100644 |
| --- a/pkg/compiler/lib/src/js/rewrite_async.dart |
| +++ b/pkg/compiler/lib/src/js/rewrite_async.dart |
| @@ -1770,14 +1770,32 @@ class SyncStarRewriter extends AsyncRewriterBase { |
| } |
| @override |
| - js.Fun finishFunction(List<js.Parameter> params, |
| + js.Fun finishFunction(List<js.Parameter> parameters, |
| js.Statement rewrittenBody, |
| js.VariableDeclarationList variableDeclarations) { |
| + // Each iterator invocation on the iterable should work on its own copy of |
| + // the parameters. |
| + List<js.VariableInitialization> declarations = |
| + new List<js.VariableInitialization>(); |
| + List<js.Parameter> renamedParameters = new List<js.Parameter>(); |
| + for (js.Parameter parameter in parameters) { |
| + String name = parameter.name; |
| + String renamedName = freshName(name); |
| + renamedParameters.add(new js.Parameter(renamedName)); |
| + declarations.add( |
| + new js.VariableInitialization(new js.VariableDeclaration(name), |
| + new js.VariableUse(renamedName))); |
| + } |
| + js.VariableDeclarationList copyParameters = |
|
floitsch
2015/03/04 13:03:02
Add a TODO that you don't need to do this if the p
sigurdm
2015/03/04 13:05:47
Done.
|
| + new js.VariableDeclarationList(declarations); |
| return js.js(""" |
| - function (#params) { |
| + function (#renamedParameters) { |
| if (#needsThis) |
| var #self = this; |
| return new #newIterable(function () { |
| + if (#hasParameters) { |
| + #copyParameters; |
| + } |
| #varDecl; |
| return function #body(#errorCode, #result) { |
| if (#errorCode === #ERROR) { |
| @@ -1789,9 +1807,11 @@ class SyncStarRewriter extends AsyncRewriterBase { |
| }); |
| } |
| """, { |
| - "params": params, |
| + "renamedParameters": renamedParameters, |
| "needsThis": analysis.hasThis, |
| "helperBody": rewrittenBody, |
| + "hasParameters": parameters.isNotEmpty, |
| + "copyParameters": copyParameters, |
| "varDecl": variableDeclarations, |
| "errorCode": errorCodeName, |
| "newIterable": newIterable, |