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 1
1574115741 end
1574215742 end
15743+ # Const-as-instance: `APP.count` where APP is `const obj_App` and
15744+ # `count` is App's instance method (or attr_reader). Look up the
15745+ # 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.length
15748+ ct_eb_const = base_type(@const_types[ci_eb_const])
15749+ if is_obj_type(ct_eb_const) == 1
15750+ 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 >= 0
15753+ cret_eb_const = cls_method_return(cidx_eb_const, mn_eb)
15754+ if base_type(cret_eb_const) == "bigint"
15755+ return 1
15756+ end
15757+ # attr_reader on obj instance — return type is the ivar slot.
15758+ if cls_has_attr_reader(cidx_eb_const, mn_eb) == 1
15759+ slot_eb_const = cls_ivar_type(cidx_eb_const, "@" + mn_eb)
15760+ if base_type(slot_eb_const) == "bigint"
15761+ return 1
15762+ end
15763+ end
15764+ end
15765+ end
15766+ end
15767+ end
15768+ # Same shape: recv is an obj_<C> typed expression and mname is
15769+ # an attr_reader. Cover the bigint slot regardless of whether
15770+ # 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) == 1
15773+ 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) == 1
15776+ slot_eb_attr = cls_ivar_type(cidx_eb_attr, "@" + mn_eb)
15777+ if base_type(slot_eb_attr) == "bigint"
15778+ return 1
15779+ end
15780+ end
1574315781 end
1574415782 end
1574515783 if mn_eb != "+" && mn_eb != "-" && mn_eb != "*" && mn_eb != "/" && mn_eb != "%" && mn_eb != "**" &&