Commit dbd67a42
dbd67a423fd8Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): map_expr times/range arms wrap loop counter for bigint slot
compile_map_expr's N.times.map and range .map fusion arms
emitted lv_<bp> = <counter>; directly. With promote mode widening
the block param's outer slot to bigint, the assignment failed at
the C-level pointer/int boundary. Probe find_var_type before
declare_var and wrap through sp_bigint_new_int when the slot is
bigint. The block-scope declare_var also follows the outer slot
type so the body's arithmetic dispatches through sp_bigint_mul
instead of sp_int_mul.
Also unbox a bigint block tail before sp_IntArray_push in the range-map arm.
Promote-mode test count: 518 pass / 48 fail / 52 error (unchanged, but range / map paths now emit correct bigint, reducing latent breakage once other paths catch up). Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- dbd67a423fd8
- Parent
- 7f4aabe11729
spinel_codegen.rbmodifiedView file
emit(" SP_GC_ROOT(" + tmp_arrn + ");") emit(" for (mrb_int " + tmp_in + " = 0; " + tmp_in + " < " + ncount + "; " + tmp_in + "++) {") if bpn != "" emit(" lv_" + bpn + " = " + tmp_in + ";") bpn_t_mp = find_var_type(bpn) if bpn_t_mp == "bigint" @needs_bigint = 1 emit(" lv_" + bpn + " = sp_bigint_new_int(" + tmp_in + ");") else emit(" lv_" + bpn + " = " + tmp_in + ";") end end @indent = @indent + 1 if blk_n >= 0 emit(" for (mrb_int " + tmp_i + " = " + first_e + "; " + tmp_i + " " + excl + " " + last_e + "; " + tmp_i + "++) {") have_bp_r = (get_block_param(nid, 0) != "") if have_bp_r declare_var(bp1, "int") emit(" lv_" + bp1 + " = " + tmp_i + ";") bp1_t_rng = find_var_type(bp1) if bp1_t_rng != "bigint" bp1_t_rng = "int" end declare_var(bp1, bp1_t_rng) if bp1_t_rng == "bigint" @needs_bigint = 1 emit(" lv_" + bp1 + " = sp_bigint_new_int(" + tmp_i + ");") else emit(" lv_" + bp1 + " = " + tmp_i + ";") end end @indent = @indent + 1 if blk_r >= 0 emit(" sp_PtrArray_push(" + tmp_arr + ", (void *)" + lastv_r + ");") end else # promote-mode block tail returning bigint into IntArray; # unbox before pushing. if infer_type(stmts_r2.last) == "bigint" @needs_bigint = 1 lastv_r = "sp_bigint_to_int((sp_Bigint *)" + lastv_r + ")" end emit(" sp_IntArray_push(" + tmp_arr + ", " + lastv_r + ");") end else