Commit 47d9e5be
47d9e5be162eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): expr_emit_is_bigint detects attr_reader and const-as-obj recv
Extends the walker to recognize APP.count (const obj_App + attr_reader)
and obj.attr_reader paths where the ivar slot is bigint. The puts /
print / type-expected paths now upgrade these to bigint dispatch.
Promote-mode: +3 (593 -> 596). Default 633/0/0.
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- 47d9e5be162e
- Parent
- 6d65a589df0b
spinel_codegen.rbmodifiedView file
@@ -15740,6 +15740,44 @@
1574015740
return 11574115741
end1574215742
end15743+
# Const-as-instance: `APP.count` where APP is `const obj_App` and15744+
# `count` is App's instance method (or attr_reader). Look up the15745+
# const's static type and resolve the imeth.15746+
ci_eb_const = find_const_idx(rname_eb)15747+
if ci_eb_const >= 0 && ci_eb_const < @const_types.length15748+
ct_eb_const = base_type(@const_types[ci_eb_const])15749+
if is_obj_type(ct_eb_const) == 115750+
cls_eb_const = ct_eb_const[4, ct_eb_const.length - 4]15751+
cidx_eb_const = find_class_idx(cls_eb_const)15752+
if cidx_eb_const >= 015753+
cret_eb_const = cls_method_return(cidx_eb_const, mn_eb)15754+
if base_type(cret_eb_const) == "bigint"15755+
return 115756+
end15757+
# attr_reader on obj instance — return type is the ivar slot.15758+
if cls_has_attr_reader(cidx_eb_const, mn_eb) == 115759+
slot_eb_const = cls_ivar_type(cidx_eb_const, "@" + mn_eb)15760+
if base_type(slot_eb_const) == "bigint"15761+
return 115762+
end15763+
end15764+
end15765+
end15766+
end15767+
end15768+
# Same shape: recv is an obj_<C> typed expression and mname is15769+
# an attr_reader. Cover the bigint slot regardless of whether15770+
# the method-return table reports the right type.15771+
rcv_t_eb_attr = base_type(infer_type(rcv_eb_user))15772+
if is_obj_type(rcv_t_eb_attr) == 115773+
cls_eb_attr = rcv_t_eb_attr[4, rcv_t_eb_attr.length - 4]15774+
cidx_eb_attr = find_class_idx(cls_eb_attr)15775+
if cidx_eb_attr >= 0 && cls_has_attr_reader(cidx_eb_attr, mn_eb) == 115776+
slot_eb_attr = cls_ivar_type(cidx_eb_attr, "@" + mn_eb)15777+
if base_type(slot_eb_attr) == "bigint"15778+
return 115779+
end15780+
end1574315781
end1574415782
end1574515783
if mn_eb != "+" && mn_eb != "-" && mn_eb != "*" && mn_eb != "/" && mn_eb != "%" && mn_eb != "**" &&