Commit 76b774cd
76b774cdbbb4Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(codegen): poly recv [] with bigint key unboxes for bit shift
Details
- Commit
- 76b774cdbbb4
- Parent
- 01b8238c47fa
spinel_codegen.rbmodifiedView file
@@ -22043,11 +22043,15 @@
2204322043
# For non-int keys (string, sym, ...) the SP_TAG_INT branch2204422044
# is unreachable at runtime and `(recv.v.i >> key)` is2204522045
# invalid C — `>> const char *` won't compile.22046-
if mname == "[]" && arg_compiled.length >= 1 && (arg_types[0] == "int" || arg_types[0] == "poly")22046+
if mname == "[]" && arg_compiled.length >= 1 && (arg_types[0] == "int" || arg_types[0] == "poly" || arg_types[0] == "bigint")2204722047
a0_int = arg_compiled[0]2204822048
if arg_types[0] == "poly"2204922049
a0_int = "(" + a0_int + ").v.i"2205022050
end22051+
if arg_types[0] == "bigint"22052+
@needs_bigint = 122053+
a0_int = "sp_bigint_to_int((sp_Bigint *)" + a0_int + ")"22054+
end2205122055
bit = "((" + recv_tmp + ".v.i >> (" + a0_int + ")) & 1)"2205222056
brhs = is_poly_ret == 1 ? "sp_box_int(" + bit + ")" : bit2205322057
emit(" if (" + recv_tmp + ".tag == SP_TAG_INT) " + tmp + " = " + brhs + ";")