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

@@ -276,9 +276,13 @@
276276 @mkdir -p build
277277 $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_pack.c -o build/sp_pack.o
278278
279+build/sp_strscan.o: lib/sp_strscan.c lib/mruby_shim.h
280+ @mkdir -p build
281+ $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib -Ilib/regexp lib/sp_strscan.c -o build/sp_strscan.o
282+
279283 SP_RT_LIB = lib/libspinel_rt.a
280284
281-$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o
285+$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o
282286 ar rcs $@ $^
283287
284288 regexp: $(SP_RT_LIB)