Commit ac52488a

ac52488aee0dMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified

Description

feat: String#start_with? and #end_with? support multiple arguments

Multi-argument form returns true if ANY of the patterns match, compiled as OR of individual sp_str_start_with / sp_str_end_with calls.

Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]

Details

Commit
ac52488aee0d
Parent
1761f25e911d

spinel_codegen.rbmodifiedView file

@@ -11796,9 +11796,35 @@
1179611796 return "sp_str_include(" + rc + ", " + compile_arg0(nid) + ")"
1179711797 end
1179811798 if mname == "start_with?"
11799+ args_id = @nd_arguments[nid]
11800+ if args_id >= 0
11801+ aargs = get_args(args_id)
11802+ if aargs.length > 1
11803+ parts = "".split(",")
11804+ k = 0
11805+ while k < aargs.length
11806+ parts.push("sp_str_start_with(" + rc + ", " + compile_expr(aargs[k]) + ")")
11807+ k = k + 1
11808+ end
11809+ return "(" + parts.join(" || ") + ")"
11810+ end
11811+ end
1179911812 return "sp_str_start_with(" + rc + ", " + compile_arg0(nid) + ")"
1180011813 end
1180111814 if mname == "end_with?"
11815+ args_id = @nd_arguments[nid]
11816+ if args_id >= 0
11817+ aargs = get_args(args_id)
11818+ if aargs.length > 1
11819+ parts = "".split(",")
11820+ k = 0
11821+ while k < aargs.length
11822+ parts.push("sp_str_end_with(" + rc + ", " + compile_expr(aargs[k]) + ")")
11823+ k = k + 1
11824+ end
11825+ return "(" + parts.join(" || ") + ")"
11826+ end
11827+ end
1180211828 return "sp_str_end_with(" + rc + ", " + compile_arg0(nid) + ")"
1180311829 end
1180411830 if mname == "split"