Commit 8ae0a60f
8ae0a60fbdf5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): compile_puts_single dispatches bigint via sp_bigint_to_s
Also extend expr_emit_is_bigint walker to catch class-method returns via ConstantReadNode / ConstantPathNode recv (CounterClass.count etc.). puts on stale-int upgraded args now hits the bigint arm cleanly.
Promote-mode: +2 (590 -> 592). Default 633/0/0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 8ae0a60fbdf5
- Parent
- eddc7bf75da7
spinel_codegen.rbmodifiedView file
@@ -15724,6 +15724,20 @@
1572415724
end1572515725
end1572615726
end15727+
# Class-method call: `CounterClass.count` lowers to15728+
# sp_CounterClass_cls_count whose return slot may have been15729+
# promoted to bigint. Detect via the recv's ConstantReadNode15730+
# (or ConstantPathNode) and the cls_cmeth_return.15731+
if @nd_type[rcv_eb_user] == "ConstantReadNode" || @nd_type[rcv_eb_user] == "ConstantPathNode"15732+
rname_eb = resolve_const_read_name(@nd_name[rcv_eb_user])15733+
cidx_eb = find_class_idx(rname_eb)15734+
if cidx_eb >= 015735+
cret_eb = cls_method_return(cidx_eb, mn_eb, "cmeth")15736+
if base_type(cret_eb) == "bigint"15737+
return 115738+
end15739+
end15740+
end1572715741
end1572815742
if mn_eb != "+" && mn_eb != "-" && mn_eb != "*" && mn_eb != "/" && mn_eb != "%" && mn_eb != "**" &&1572915743
mn_eb != "&" && mn_eb != "|" && mn_eb != "^" && mn_eb != "<<" && mn_eb != ">>" &&@@ -32537,6 +32551,11 @@
3253732551
emit(" { const char *_ps = (const char *)(" + val + "->data); if (_ps) { fputs(_ps, stdout); if (!*_ps || _ps[strlen(_ps)-1] != '" + bsl_n + "') putchar('" + bsl_n + "'); } else putchar('" + bsl_n + "'); }")3253832552
return3253932553
end32554+
if at == "bigint"32555+
@needs_bigint = 132556+
emit(" { const char *_bs = sp_bigint_to_s((sp_Bigint *)" + val + "); fputs(_bs, stdout); putchar('" + bsl_n + "'); }")32557+
return32558+
end3254032559
if at == "int"3254132560
emit(" printf(\"%lld" + bsl_n + "\", (long long)" + val + ");")3254232561
return