Commit 03933eb9
03933eb9bb2bMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 8 months ago · 2 files · +1 added · ~1 modified
Description
Add Symbol, String methods, Integer#to_s, boolean puts
New features:
- Symbol literals (:hello) → C string constants
- String#length/size → strlen()
- String#upcase/downcase → sp_str_upcase/downcase (ctype.h)
- String#include?(str) → strstr() != NULL
- String + String → sp_str_concat (malloc'd)
- Integer#to_s → sp_int_to_s (snprintf)
- puts with Boolean → "true"/"false"
Test: examples/bm_strings.rb — all patterns, output matches Ruby. All regressions pass.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 03933eb9bb2b
- Parent
- f43f48b6b12f
examples/bm_strings.rbaddedView file
1+
# Test Symbol and String methods2+
3+
# Symbol4+
s = :hello5+
puts s # hello6+
7+
# String methods8+
str = "Hello, World!"9+
puts str.length # 1310+
puts str.upcase # HELLO, WORLD!11+
puts str.downcase # hello, world!12+
puts str.include?("World") # true13+
puts str.include?("xyz") # false14+
15+
# String concatenation16+
a = "foo"17+
b = "bar"18+
c = a + b19+
puts c # foobar20+
21+
# to_s on integers22+
n = 4223+
puts n.to_s # 42src/codegen.cmodifiedView file
Loading diff…