Commit c41cb810
c41cb81060bbMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 7 files · +2 added · ~5 modified
Description
runtime,codegen: StringScanner as libspinel_rt.a builtin
Replaces the stale oniguruma-based lib/strscan.c with a real implementation (lib/sp_strscan.c) using spinel's internal regex engine (re_compile / re_exec). The scanner struct is GC-allocated through the sp_ext_* shim so the lifetime tracks the main heap instead of leaking.
StringScanner is now a builtin primitive type (stringscanner →
sp_StringScanner *); StringScanner.new is intercepted on the
ConstantReadNode receiver and method calls dispatch through
strscan_runtime_call. The Ruby stub at lib/strscan.rb is empty
so spinel doesn't emit a competing struct.
Methods supported: scan, check, scan_until, matched, matched?, pos, pos=, eos?, getch, peek, unscan, rest, rest_size, rest?, terminate, string, pre_match, post_match, reset.
Fixes #845 Fixes #812
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- c41cb81060bb
- Parent
- 552f78da6b09
MakefilemodifiedView file
@mkdir -p build $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_pack.c -o build/sp_pack.obuild/sp_strscan.o: lib/sp_strscan.c lib/mruby_shim.h @mkdir -p build $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib -Ilib/regexp lib/sp_strscan.c -o build/sp_strscan.oSP_RT_LIB = lib/libspinel_rt.a$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o ar rcs $@ $^regexp: $(SP_RT_LIB)lib/sp_runtime.hmodifiedView file
Loading diff…
lib/sp_strscan.caddedView file
Loading diff…
lib/strscan.rbmodifiedView file
Loading diff…
spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
test/string_scanner_basic.rbaddedView file
Loading diff…