fix: pre-allocate slot zero in every compiled chunk to fix REPL local variable declarations

The compiler now always reserves slot zero for either the closure or method
receiver, eliminating a corner case where top-level REPL code lacked the
pre-allocated slot that function/method bodies expect. This ensures local
variables declared in REPL loops (e.g. `for (i in 1..2)`) get correct slot
indexes.

Additionally, inlines `wrenResetFiber` into `wrenNewFiber` and stores the
imported module's closure on the stack before invoking it, preventing a GC
from collecting the closure during import.
This commit is contained in:
Bob Nystrom
2018-04-27 15:20:49 +00:00
parent 7bb024eccc
commit 248e3a69f0
9 changed files with 66 additions and 73 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
{
var a0 = "value"
var a1 = a0
// Slot zero is always taken to hold the closure or receiver.
var a1 = "value"
var a2 = a1
var a3 = a2
var a4 = a3