Commit e26c4419
e26c4419b7feMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified
Description
Implement Array#object_id on typed arrays
Typed arrays (int/str/float/sym/poly) had no object_id, since the generic object dispatch doesn't cover value-type-based arrays. Return the receiver's pointer bit pattern, matching String#object_id; it's stable across GC because arrays aren't relocated.
Refs #1216
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- e26c4419b7fe
- Parent
- 85de02a7d573
spinel_codegen.rbmodifiedView file
@@ -23095,6 +23095,11 @@
2309523095
if mname == "append"2309623096
return compile_array_method_expr(nid, "push", rc, recv_type)2309723097
end23098+
# Array#object_id -- the receiver's pointer bit pattern, as for the23099+
# String case. Stable across GC (the array isn't relocated).23100+
if mname == "object_id"23101+
return "((mrb_int)(uintptr_t)(" + rc + "))"23102+
end2309823103
# `map!` / `collect!` -- transform each element in place and return the2309923104
# mutated receiver. The block's last expression is the new value (the2310023105
# codebase's inline-block convention); it must match the array'stest/array_object_id.rbaddedView file
Loading diff…
test/array_object_id.rb.expectedaddedView file
Loading diff…