Commit f3a8c100
f3a8c100a0e0Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 5 files · ~5 modified
Description
Add Fiber.new codegen: emit static body fn + sp_Fiber_new
Lower Fiber.new { |param| body } into a static void _fiber_body_N(sp_Fiber *) function emitted into the g_procs deferred buffer. The body parameter is loaded from _fb->resumed_value; the last expression sets _fb->yielded_value (or nil for void/statement-only bodies).
Also wire up:
- TY_FIBER type in types.h/types.c and SP_BUILTIN_FIBER in sp_runtime.h
- analyze.c: Fiber.new / Fiber.current / Fiber.yield return types
- codegen.c: Fiber instance methods (resume, alive?, transfer, value)
- codegen.c: Fiber.yield(val) and Fiber.current class method dispatch
Fixes rescue_bind_in_fiber_body, bundle_misc_c_10, fiber_gc_root_isolation (+3 tests, 756 pass / 84 error).
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- f3a8c100a0e0
- Parent
- 92163abdc968
lib/sp_runtime.hmodifiedView file
@@ -2676,6 +2676,7 @@
26762676
#define SP_BUILTIN_SYM_POLY_HASH (-19)26772677
#define SP_BUILTIN_POLY_POLY_HASH (-20)26782678
#define SP_BUILTIN_OBJECT (-21) /* Object.new identity sentinel */2679+
#define SP_BUILTIN_FIBER (-22) /* sp_Fiber * boxed into poly slot */26792680
/* sp_RbVal is defined in sp_gc.h (the mark helpers dispatch on its tag). */26802681
static sp_RbVal sp_box_int(mrb_int v) { sp_RbVal r; r.tag = SP_TAG_INT; r.cls_id = 0; r.v.i = v; return r; }26812682
static sp_RbVal sp_box_str(const char *v) { sp_RbVal r; r.tag = SP_TAG_STR; r.cls_id = 0; r.v.s = v; return r; }src/analyze.cmodifiedView file
Loading diff…
src/codegen.cmodifiedView file
Loading diff…
src/types.cmodifiedView file
Loading diff…
src/types.hmodifiedView file
Loading diff…