Chromium Code Reviews| Index: frog/leg/ssa/builder.dart |
| diff --git a/frog/leg/ssa/builder.dart b/frog/leg/ssa/builder.dart |
| index 359e7cd95a50864237fe4af110e85a182d552111..93e5b14216420ed33d3230cb8513db7be0fc0c0f 100644 |
| --- a/frog/leg/ssa/builder.dart |
| +++ b/frog/leg/ssa/builder.dart |
| @@ -216,11 +216,10 @@ class LocalsHandler { |
| new ClosureTranslator(builder.compiler, builder.elements); |
| closureData = translator.translate(node); |
| - if (closureData.thisElement !== null && |
| - isAccessedDirectly(closureData.thisElement)) { |
| + if (closureData.thisElement !== null && !closureData.isClosure()) { |
| HInstruction thisInstruction = new HThis(); |
| - updateLocal(closureData.thisElement, thisInstruction); |
| builder.add(thisInstruction); |
| + updateLocal(closureData.thisElement, thisInstruction); |
| } |
| FunctionParameters params = function.computeParameters(builder.compiler); |
| @@ -240,6 +239,12 @@ class LocalsHandler { |
| closureData.freeVariableMapping.forEach((Element from, Element to) { |
| redirectElement(from, to); |
| }); |
| + // Inside closure redirect references to itself to [:this:]. |
| + if (closureData.isClosure()) { |
| + HInstruction thisInstruction = new HThis(); |
| + builder.add(thisInstruction); |
| + updateLocal(closureData.closureElement, thisInstruction); |
|
ngeoffray
2012/02/13 10:13:38
Could you share some code with line 219? It looks
floitsch
2012/02/13 12:03:42
Refactored together.
|
| + } |
| } |
| /** |
| @@ -1403,8 +1408,7 @@ class SsaBuilder implements Visitor { |
| visit(node.selector); |
| closureTarget = pop(); |
| } else { |
| - assert(element.kind === ElementKind.VARIABLE || |
| - element.kind === ElementKind.PARAMETER); |
| + assert(Elements.isLocal(element)); |
| closureTarget = localsHandler.readLocal(element); |
| } |
| var inputs = <HInstruction>[]; |