Commit 664fec1a

664fec1a02d5Merged

Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

feat(codegen): Integer#[idx] (bit indexing)

n[k] returns bit k (0-indexed from LSB) of integer n. The call was previously falling through to the unknown-method 0-fallback. Lower as ((rc >> idx) & 1).

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
664fec1a02d5
Parent
78de785dc7bf

spinel_codegen.rbmodifiedView file

@@ -17135,6 +17135,17 @@
1713517135 if mname == "itself"
1713617136 return rc
1713717137 end
17138+ # Integer#[idx] — bit indexing. `n[k]` returns bit k of n.
17139+ if mname == "[]"
17140+ args_id = @nd_arguments[nid]
17141+ if args_id >= 0
17142+ aargs = get_args(args_id)
17143+ if aargs.length > 0
17144+ idx = compile_expr(aargs[0])
17145+ return "(((" + rc + ") >> (" + idx + ")) & 1)"
17146+ end
17147+ end
17148+ end
1713817149 ""
1713917150 end
1714017151