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 rc1713717137
end17138+
# Integer#[idx] — bit indexing. `n[k]` returns bit k of n.17139+
if mname == "[]"17140+
args_id = @nd_arguments[nid]17141+
if args_id >= 017142+
aargs = get_args(args_id)17143+
if aargs.length > 017144+
idx = compile_expr(aargs[0])17145+
return "(((" + rc + ") >> (" + idx + ")) & 1)"17146+
end17147+
end17148+
end1713817149
""1713917150
end1714017151
test/integer_bit_index.rbaddedView file
Loading diff…