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 additions
2+
3+# Array#join
4+arr = (1..5).to_a
5+puts arr.join(", ") # 1, 2, 3, 4, 5
6+
7+# Array#uniq
8+nums = (1..5).to_a
9+nums.push(3)
10+nums.push(1)
11+uniq = nums.uniq
12+puts uniq.length # 5
13+
14+# srand/rand
15+srand(0)
16+r = rand(100)
17+puts r >= 0 # true (some number)
18+
19+# ARGV.length
20+puts ARGV.length # 0
21+
22+# $stderr.puts
23+$stderr.puts("stderr msg")
24+
25+# exit — skip (would terminate)
26+# sleep — skip (would delay)
27+
28+puts "done"