Commit d5706015
d5706015539cMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified
Description
Add method(:name) → sp_Proc, fix sp_float_to_s format string
method(:name) wraps a named function in sp_Proc via adapter:
- Scans AST for method() calls, emits adapter functions at file scope
- Adapter: meth_adapt(void *env, mrb_int arg) → sp_(arg)
- sp_Proc_new(meth_adapt, NULL) returned as expression
Fix: sp_float_to_s format string was consumed by vfprintf (%g → %%g)
Test: examples/bm_method.rb — method(:double).call(5) → 10.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- d5706015539c
- Parent
- 4880c5964ded
examples/bm_method.rbaddedView file
1+
def double(x)2+
x * 23+
end4+
5+
# Direct call for type inference6+
puts double(1) # 27+
8+
m = method(:double)9+
puts m.call(5) # 1010+
puts m.call(10) # 2011+
12+
def add_ten(x)13+
x + 1014+
end15+
16+
puts add_ten(0) # 1017+
18+
a = method(:add_ten)19+
puts a.call(3) # 1320+
21+
puts "done"src/codegen.cmodifiedView file
Loading diff…