Commit 0be20b62
0be20b62343aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Regex literals + match? / !~ (bool predicates)
Foundation for regex in the C rewrite: each distinct /re/ literal is collected into a table, compiled once via re_compile in a generated sp_re_init() (run at main startup), and referenced as an sp_re_pat_ global. Prism flag bits are mapped to the engine's RE_FLAG_* values.
Dispatches the bool-returning, MatchData-free predicates against those patterns: /re/.match?(str[, pos]), str.match?(/re/[, pos]), and str !~ /re/. The analyzer types match? and !~ as Bool. =~ / match / scan / sub / gsub (which set match globals or build MatchData) are follow-ups.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 0be20b62343a
- Parent
- 6fcaad4b160c
src/analyze.cmodifiedView file
return ty_is_numeric(rt) ? rt : TY_UNKNOWN; if (!strcmp(name, "!")) return TY_BOOL; if (!strcmp(name, "respond_to?") && recv >= 0) return TY_BOOL; if ((!strcmp(name, "match?") || !strcmp(name, "!~")) && recv >= 0) return TY_BOOL; if (recv >= 0 && argc == 1 && is_arith_op(name)) { if (rt == TY_STRING) {src/codegen.cmodifiedView file
Loading diff…