feat: implement fiber primitives with create, run, yield and caller tracking
Add core fiber functionality including Fiber.create, Fiber.run, Fiber.yield primitives with value passing between fibers. Introduce PRIM_RUN_FIBER result type for interpreter loop, add caller field to ObjFiber struct for yield resumption, and update GC marking to traverse fiber caller chains. Modify wrenNewFiber to accept a function/closure argument and initialize the first call frame. Add debug stack printing with fiber pointer. Include test suite covering fiber creation, run, yield, value passing, type checking, and caller resumption.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
var fiber = Fiber.create(fn {
|
||||
IO.print("fiber")
|
||||
})
|
||||
|
||||
// The first value passed to the fiber is ignored, since there's no yield call
|
||||
// to return it.
|
||||
IO.print("before") // expect: before
|
||||
fiber.run("ignored") // expect: fiber
|
||||
IO.print("after") // expect: after
|
||||
Reference in New Issue
Block a user