Commit a10021ea
a10021ea03feMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): inlined LocalVariableOperatorWriteNode dispatches bigint ops
compile_stmt_with_block's LocalVariableOperatorWriteNode arm
emitted raw C += / -= / *= against the renamed local, which on
a promote-mode-widened sp_Bigint * slot tripped "invalid use of
undefined type" since the bigint struct is opaque.
Add a bigint dispatch arm mirroring the InstanceVariableOperator
WriteNode bigint branch: route +, -, * through sp_bigint_add
/ sub / mul, wrapping a raw mrb_int rhs through sp_bigint_new_int.
Also revert the earlier compile_yield_stmt unbox: block_params_ csig_for_body already promotes the function-pointer signature to sp_Bigint * when the yield arg's static type is bigint, so the call site can pass the raw bigint pointer through.
Promote-mode test count: 502 pass / 43 fail / 73 error -> 503 pass / 43 fail / 72 error. Default raise mode unchanged at 618 / 0 / 0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- a10021ea03fe
- Parent
- 304bb73a0913
spinel_codegen.rbmodifiedView file
aids = get_args(args_id) k = 0 while k < aids.length # The block's C ABI is `(mrb_int, ..., void *)`; promote-mode # widened args are sp_Bigint * locally and need unboxing. yarg_ev = compile_expr(aids[k]) if infer_type(aids[k]) == "bigint" @needs_bigint = 1 yarg_ev = "sp_bigint_to_int((sp_Bigint *)" + yarg_ev + ")" end emitted.push(yarg_ev) emitted.push(compile_expr(aids[k])) k = k + 1 end end rname = remap_local(lname, map_from, map_to) op = @nd_binop[nid] val = compile_expr_remap(@nd_expression[nid], map_from, map_to) vt_lvo = find_var_type(lname) # promote-mode-widened slot: route through sp_bigint_*. if vt_lvo == "bigint" @needs_bigint = 1 rhs_t_lvo = infer_type(@nd_expression[nid]) rhs_big_lvo = rhs_t_lvo == "bigint" ? "(sp_Bigint *)(" + val + ")" : "sp_bigint_new_int(" + val + ")" if op == "+" emit(" lv_" + rname + " = sp_bigint_add((sp_Bigint *)lv_" + rname + ", " + rhs_big_lvo + ");") return end if op == "-" emit(" lv_" + rname + " = sp_bigint_sub((sp_Bigint *)lv_" + rname + ", " + rhs_big_lvo + ");") return end if op == "*" emit(" lv_" + rname + " = sp_bigint_mul((sp_Bigint *)lv_" + rname + ", " + rhs_big_lvo + ");") return end end if op == "+" emit(" lv_" + rname + " += " + val + ";") end