Commit 3e29d59b
3e29d59bdf3eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified
Description
feat: Enumerable module with yield-based each and block callbacks
Support class methods that use yield with caller-provided blocks:
- Detect yield in method bodies (including inside nested blocks)
- Add sp_block_fn/_block_env params to methods that use yield
- Generate block callback functions with captured variables via #define aliases for pointer-based mutation
- Object method dispatch with block: scan captures, generate env struct, create callback, pass to method
- Fix has_yield_nodes to recurse into call block bodies
- Fix implicit_return leaking into Array#each block body codegen
- Update forward declarations to include block params
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 3e29d59bdf3e
- Parent
- 6f84ed92e8c5
examples/bm_enumerable.rbaddedView file
1+
class NumberList2+
include Enumerable3+
def initialize4+
@data = (1..5).to_a5+
end6+
def each7+
@data.each do |x|8+
yield x9+
end10+
end11+
end12+
13+
list = NumberList.new14+
total = 015+
list.each do |x|16+
total += x17+
end18+
puts total # 1519+
puts "done"src/codegen.cmodifiedView file
Loading diff…