Commit 3dad6a2f
3dad6a2f4392Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): step block wraps loop counter into bigint slot when promoted
compile_step_block emitted for (lv_i = start; lv_i <= limit; lv_i += step) directly into the function-level LV, so a promote-
mode-widened lv_i: sp_Bigint * slot tripped the C compiler on
the <= comparison and the += step arithmetic.
Mirror the for/times/downto/range fixes: when find_var_type(bp)
returns bigint, allocate a fresh mrb_int counter and box into
the LV on each iteration via sp_bigint_new_int(counter).
Promote-mode test count: 480 pass / 54 fail / 84 error -> 480 pass / 55 fail / 83 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 3dad6a2f4392
- Parent
- f4e69c34cfdc
spinel_codegen.rbmodifiedView file
emit(" {") emit(" mrb_int lv_" + bp1 + " = 0;") end emit(" for (lv_" + bp1 + " = " + rc + "; lv_" + bp1 + " <= " + limit_val + "; lv_" + bp1 + " += " + step_val + ") {") bp_t_st = find_var_type(bp1) if bp_t_st == "bigint" @needs_bigint = 1 stmp_st = new_temp emit(" for (mrb_int " + stmp_st + " = " + rc + "; " + stmp_st + " <= " + limit_val + "; " + stmp_st + " += " + step_val + ") {") emit(" lv_" + bp1 + " = sp_bigint_new_int(" + stmp_st + ");") else emit(" for (lv_" + bp1 + " = " + rc + "; lv_" + bp1 + " <= " + limit_val + "; lv_" + bp1 + " += " + step_val + ") {") end @indent = @indent + 1 push_scope declare_var(bp1, "int") declare_var(bp1, bp_t_st == "bigint" ? "bigint" : "int") redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]])