From c18b62127bca30fd7d1e1baf58b1f2ef17a90899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Mu=C3=B1oz?= Date: Fri, 8 Sep 2017 17:35:42 -0400 Subject: [PATCH] Don't rely on callerScope to yield --- .../runtime/lib/compiled/opcodes/vm.ts | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts b/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts index c55b382fa0..9c72aa8086 100644 --- a/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts +++ b/packages/@glimmer/runtime/lib/compiled/opcodes/vm.ts @@ -142,7 +142,7 @@ APPEND_OPCODES.add(Op.InvokeYield, vm => { let { stack } = vm; let handle = check(stack.pop(), CheckOption(CheckHandle)); - let _scope = check(stack.pop(), CheckOption(CheckScope)) as Option; // FIXME(mmun): shouldn't need to cast this + let scope = check(stack.pop(), CheckOption(CheckScope)) as Option; // FIXME(mmun): shouldn't need to cast this let table = check(stack.pop(), CheckOption(CheckBlockSymbolTable)); assert(table === null || (table && typeof table === 'object' && Array.isArray(table.parameters)), stackAssert('Option', table)); @@ -154,32 +154,30 @@ APPEND_OPCODES.add(Op.InvokeYield, vm => { // To balance the pop{Frame,Scope} vm.pushFrame(); - let blockScope = vm.scope().getCallerScope()!; - vm.pushScope(blockScope); - + vm.pushScope(scope!); // Could be null but it doesnt matter as it is immediatelly popped. return; } - let locals = table.parameters; - let localsCount = locals.length; + let invokingScope = scope!; + // If necessary, create a child scope { - let blockScope = vm.scope().getCallerScope()!; - if (localsCount > 0) { - blockScope = blockScope.child(); - } - vm.pushScope(blockScope); - } + let locals = table.parameters; + let localsCount = locals.length; - let scope = vm.scope(); + if (localsCount > 0) { + invokingScope = invokingScope.child(); - for (let i=0; i