Chromium Code Reviews| Index: pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart |
| diff --git a/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart b/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart |
| index 277966315b3c6ee24c63c05a598664cff5034e28..dca7038f2d703f9bf736775fceb77a07a2e26d50 100644 |
| --- a/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart |
| +++ b/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart |
| @@ -536,7 +536,7 @@ class ASTEmitter |
| } |
| // Emit a variable declaration if we are required to do so. |
| - // This is to ensure that a fresh closure variable is created. |
| + // For captured variables, this ensures that a fresh variable is created. |
| if (stmt.isDeclaration) { |
| assert(isFirstOccurrence); |
| assert(isDeclaredHere); |
| @@ -831,6 +831,11 @@ class ASTEmitter |
| } |
| @override |
| + Expression visitVariableUse(tree.VariableUse exp, |
| + BuilderContext<Statement> context) { |
|
Kevin Millikin (Google)
2015/02/26 12:43:17
Indentation is messed up.
asgerf
2015/02/27 12:05:19
Done.
|
| + return visitVariable(exp.variable, context); |
| + } |
| + |
| Expression visitVariable(tree.Variable exp, |
|
Kevin Millikin (Google)
2015/02/26 12:43:17
I'd probably get rid of this visitVariable method
asgerf
2015/02/27 12:05:19
Done.
|
| BuilderContext<Statement> context) { |
| return new Identifier(context.getVariableName(exp)) |
| @@ -1233,12 +1238,15 @@ class UnshadowParameters extends tree.RecursiveVisitor { |
| tree.Variable newParam = new tree.Variable(definition.element, |
| param.element); |
| definition.parameters[i] = newParam; |
| - definition.body = new tree.Assign(param, newParam, definition.body); |
| + definition.body = new tree.Assign(param, new tree.VariableUse(newParam), |
| + definition.body); |
| newParam.writeCount = 1; // Being a parameter counts as a write. |
| + param.writeCount--; // Not a parameter anymore. |
|
asgerf
2015/02/25 12:40:30
This was technically a bug, although the reference
|
| } |
| } |
| } |
| + @override |
| visitVariable(tree.Variable variable) { |
| if (shadowedParameters.contains(variable)) { |
| hasShadowedUse.add(variable); |