Commit 6b4d1466
6b4d146606afMerged
Islam Gagiev <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
feat(codegen): add Integer#allbits?
Bitwise check: returns true when all bits in the mask are set in the receiver. Formula: (self & mask) == mask.
- spinel_codegen.rb: infer_type returns "bool", codegen emits bitwise AND comparison
- test/integer_allbits.rb: 11 cases including zero mask, negative, large values
Details
- Commit
- 6b4d146606af
- Parent
- eaad8a4edb93
spinel_codegen.rbmodifiedView file
@@ -2339,6 +2339,9 @@
23392339
if mname == "odd?"23402340
return "bool"23412341
end2342+
if mname == "allbits?"2343+
return "bool"2344+
end23422345
if mname == "zero?"23432346
return "bool"23442347
end@@ -18425,6 +18428,10 @@
1842518428
if mname == "odd?"1842618429
return "((" + rc + ") % 2 != 0)"1842718430
end18431+
if mname == "allbits?"18432+
mask = compile_arg0(nid)18433+
return "(((" + rc + ") & (" + mask + ")) == (" + mask + "))"18434+
end1842818435
if mname == "zero?"1842918436
return "((" + rc + ") == 0)"1843018437
endtest/integer_allbits.rbaddedView file
Loading diff…
test/integer_allbits.rb.expectedaddedView file
Loading diff…