Commit bb226b75

bb226b75a185Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

Merge pull request #180 from mame/pr/poly-builtin-ptr-array

fix(codegen): dispatch [] / length on poly recv that's a PtrArray

Conflicts:

spinel_codegen.rb

Details

Commit
bb226b75a185
Parent
7b14b0a63c06
Merge parent
35ac35f26089

spinel_codegen.rbmodifiedView file

@@ -19749,9 +19749,12 @@
1974919749 yc = "(sp_sym)sp_IntArray_get((sp_IntArray *)" + recv_tmp + ".v.p, " + a0 + ")"
1975019750 emit(" if (" + recv_tmp + ".cls_id == SP_BUILTIN_SYM_ARRAY) " + result_tmp + " = sp_box_sym(" + yc + ");")
1975119751 end
19752- # PtrArray's element type is class-specific (sp_<C> *) so a
19753- # uniform poly result needs sp_box_obj — but we don't have a
19754- # cls_id here. Defer (the issue notes this is more involved).
19752+ # PtrArray dispatch — get returns a void* which we cast to
19753+ # mrb_int when the receiver is poly. Callers that immediately
19754+ # do `<obj>.reset`-style dispatch expect a pointer back.
19755+ pc = "(mrb_int)sp_PtrArray_get((sp_PtrArray *)" + recv_tmp + ".v.p, " + a0 + ")"
19756+ prhs = is_poly_ret == 1 ? "sp_box_obj((void *)" + pc + ", 0)" : pc
19757+ emit(" if (" + recv_tmp + ".cls_id == SP_BUILTIN_PTR_ARRAY) " + result_tmp + " = " + prhs + ";")
1975519758 end
1975619759 # `length` / `size` — every built-in array exposes its own
1975719760 # `_length` helper (sym_array shares IntArray's). PtrArray is