Commit e68173cb
e68173cb9f8aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
Merge pull request #109 from ryanseys/rs-block-forward-self-call
fix(codegen): forward &block at self-call sites
Details
- Commit
- e68173cb9f8a
- Parent
- 2dea1fbc799f
- Merge parent
- 90c8e5c48b09
spinel_codegen.rbmodifiedView file
@@ -13955,23 +13955,35 @@
1395513955
if cidx >= 01395613956
owner = find_method_owner(@current_class_idx, mname)1395713957
# Look up the method's owning class so we can fill in defaults13958-
# from @cls_meth_defaults (issue #49).13958+
# from @cls_meth_defaults (issue #49) and check for a &block slot.1395913959
owner_ci = find_class_idx(owner)1396013960
owner_midx = -11396113961
if owner_ci >= 01396213962
owner_midx = cls_find_method_direct(owner_ci, mname)1396313963
end13964+
# Omit the trailing &block slot from default-padding when the13965+
# callee declares one — we'll fill it explicitly from the13966+
# call site's literal block below.13967+
has_proc = cls_method_has_block_param(owner_ci, owner_midx)1396413968
ca = ""1396513969
if owner_midx >= 013966-
ca = compile_typed_call_args(nid, owner_ci, owner_midx, 0)13970+
ca = compile_typed_call_args(nid, owner_ci, owner_midx, has_proc)1396713971
else1396813972
ca = compile_call_args(nid)1396913973
end13970-
if ca != ""13971-
return "sp_" + owner + "_" + sanitize_name(mname) + "(self, " + ca + ")"13972-
else13973-
return "sp_" + owner + "_" + sanitize_name(mname) + "(self)"13974+
bp = ""13975+
if has_proc == 113976+
if has_literal_block(nid) == 113977+
@needs_proc = 113978+
bp = compile_proc_literal(nid)13979+
else13980+
# The callee declares &block but the call site provides13981+
# none — fill the slot with NULL so the C call has the13982+
# right arity.13983+
bp = "0"13984+
end1397413985
end13986+
return "sp_" + owner + "_" + sanitize_name(mname) + "(self" + build_call_tail(ca, bp) + ")"1397513987
end1397613988
# Check attr_readers (bare method call like `x` meaning self.x)1397713989
readers = @cls_attr_readers[@current_class_idx].split(";")test/block_forward_self_call.rbaddedView file
Loading diff…