Commit 08e7c2c2
08e7c2c2dd96Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified
Description
Add ARGV, $stderr.puts, exit, String#[], Array#join/uniq, srand/rand
- ARGV → sp_Argv struct built from argc/argv at program start
- ARGV.length → sp_argv.len
- $stderr.puts("msg") → fprintf(stderr, ...)
- $stdout.puts("msg") → fprintf(stdout, ...)
- PM_GLOBAL_VARIABLE_READ_NODE: $stderr/$stdout support
- exit(code) → C exit()
- String#[] was already added; Array#join/uniq/srand/rand were already implemented by previous agent — verified working
Test: examples/bm_stdlib.rb — all patterns match Ruby (2>/dev/null).
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 08e7c2c2dd96
- Parent
- 2279bb96a84b
examples/bm_stdlib.rbaddedView file
1+
# Test stdlib additions2+
3+
# Array#join4+
arr = (1..5).to_a5+
puts arr.join(", ") # 1, 2, 3, 4, 56+
7+
# Array#uniq8+
nums = (1..5).to_a9+
nums.push(3)10+
nums.push(1)11+
uniq = nums.uniq12+
puts uniq.length # 513+
14+
# srand/rand15+
srand(0)16+
r = rand(100)17+
puts r >= 0 # true (some number)18+
19+
# ARGV.length20+
puts ARGV.length # 021+
22+
# $stderr.puts23+
$stderr.puts("stderr msg")24+
25+
# exit — skip (would terminate)26+
# sleep — skip (would delay)27+
28+
puts "done"src/codegen.cmodifiedView file
Loading diff…