Commit 995f8980

995f89809716Merged

Richard Ramsden <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

Cleanup dead code

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

Details

Commit
995f89809716
Parent
fdceb0c5ecd8

spinel_codegen.rbmodifiedView file

@@ -179,7 +179,6 @@
179179 @needs_str_poly_hash = 0
180180 @needs_sym_poly_hash = 0
181181 @needs_sym_intern = 0
182- @needs_string_helpers = 0
183182 @needs_setjmp = 0
184183 @needs_file_io = 0
185184 @needs_mutable_str = 0
@@ -7050,7 +7049,6 @@
70507049 end
70517050 if t == "InterpolatedXStringNode"
70527051 @needs_file_io = 1
7053- @needs_string_helpers = 1
70547052 end
70557053 if t == "RegularExpressionNode"
70567054 @needs_regexp = 1
@@ -7114,10 +7112,8 @@
71147112 @needs_str_array = 1
71157113 end
71167114 if t == "InterpolatedStringNode"
7117- @needs_string_helpers = 1
71187115 end
71197116 if t == "SymbolNode"
7120- @needs_string_helpers = 1
71217117 end
71227118 if t == "GlobalVariableWriteNode"
71237119 gname = @nd_name[nid]
@@ -7159,14 +7155,12 @@
71597155 mname == "gsub" || mname == "index" || mname == "sub" || mname == "tr" ||
71607156 mname == "ljust" || mname == "rjust" || mname == "capitalize" ||
71617157 mname == "count" || mname == "<<"
7162- @needs_string_helpers = 1
71637158 end
71647159 if mname == "rand" || mname == "srand" || mname == "sample" ||
71657160 mname == "shuffle" || mname == "shuffle!"
71667161 @needs_rand = 1
71677162 end
71687163 if mname == "split"
7169- @needs_string_helpers = 1
71707164 @needs_str_array = 1
71717165 @needs_gc = 1
71727166 end
@@ -7183,7 +7177,6 @@
71837177 if @nd_receiver[nid] >= 0
71847178 rt = infer_type(@nd_receiver[nid])
71857179 if rt == "string"
7186- @needs_string_helpers = 1
71877180 # Long string concat chains emit SP_GC_ROOT temps, so the
71887181 # enclosing function needs SP_GC_SAVE() in its header.
71897182 if mname == "+"
@@ -7193,7 +7186,6 @@
71937186 end
71947187 end
71957188 if mname == "[]"
7196- @needs_string_helpers = 1
71977189 end
71987190 if mname == "new"
71997191 if @nd_receiver[nid] >= 0
@@ -7307,10 +7299,8 @@
73077299 if rn == "File"
73087300 @needs_file_io = 1
73097301 if mname == "join"
7310- @needs_string_helpers = 1
73117302 end
73127303 if mname == "basename"
7313- @needs_string_helpers = 1
73147304 end
73157305 end
73167306 end
@@ -12414,7 +12404,6 @@
1241412404 end
1241512405 if t == "InterpolatedXStringNode"
1241612406 @needs_file_io = 1
12417- @needs_string_helpers = 1
1241812407 interp = compile_interpolated(nid)
1241912408 return "sp_backtick(" + interp + ")"
1242012409 end
@@ -12627,7 +12616,6 @@
1262712616 end
1262812617
1262912618 def compile_interpolated(nid)
12630- @needs_string_helpers = 1
1263112619 parts = parse_id_list(@nd_parts[nid])
1263212620 if parts.length == 0
1263312621 return "(&(\"\\xff\")[1])"
@@ -13682,11 +13670,9 @@
1368213670 return "0"
1368313671 end
1368413672 if mname == "format"
13685- @needs_string_helpers = 1
1368613673 return compile_sprintf_call(nid)
1368713674 end
1368813675 if mname == "sprintf"
13689- @needs_string_helpers = 1
1369013676 return compile_sprintf_call(nid)
1369113677 end
1369213678 if mname == "putc"
@@ -13734,7 +13720,6 @@
1373413720 if st != ""
1373513721 # Redirect as self.mname - string methods
1373613722 if st == "string"
13737- @needs_string_helpers = 1
1373813723 if mname == "upcase"
1373913724 return "sp_str_upcase(self)"
1374013725 end
@@ -13775,7 +13760,6 @@
1377513760 # int methods
1377613761 if st == "int"
1377713762 if mname == "to_s"
13778- @needs_string_helpers = 1
1377913763 return "sp_int_to_s(self)"
1378013764 end
1378113765 if mname == "to_f"
@@ -13791,7 +13775,6 @@
1379113775 return "(mrb_int)(self)"
1379213776 end
1379313777 if mname == "to_s"
13794- @needs_string_helpers = 1
1379513778 return "sp_float_to_s(self)"
1379613779 end
1379713780 end
@@ -13977,10 +13960,8 @@
1397713960 if at == "string"
1397813961 parts.push(compile_expr(aargs[0]))
1397913962 elsif at == "int"
13980- @needs_string_helpers = 1
1398113963 parts.push("sp_int_to_s(" + compile_expr(aargs[0]) + ")")
1398213964 elsif at == "float"
13983- @needs_string_helpers = 1
1398413965 parts.push("sp_float_to_s(" + compile_expr(aargs[0]) + ")")
1398513966 else
1398613967 parts.push(compile_expr(aargs[0]))
@@ -14058,11 +14039,9 @@
1405814039 if mname == "+"
1405914040 lt = infer_type(recv)
1406014041 if lt == "mutable_str"
14061- @needs_string_helpers = 1
1406214042 return "sp_str_concat(" + compile_expr(recv) + "->data, " + compile_arg0(nid) + ")"
1406314043 end
1406414044 if lt == "string"
14065- @needs_string_helpers = 1
1406614045 # Flatten chained string concat: a + b + c → sp_str_concat3(a,b,c)
1406714046 parts = collect_concat_chain(nid)
1406814047 if parts.length == 3
@@ -14104,7 +14083,6 @@
1410414083 end
1410514084 if lt == "poly"
1410614085 @needs_rb_value = 1
14107- @needs_string_helpers = 1
1410814086 return "sp_poly_add(" + compile_expr(recv) + ", " + box_expr_to_poly(@nd_arguments[nid] >= 0 ? get_args(@nd_arguments[nid])[0] : -1) + ")"
1410914087 end
1411014088 if is_array_type(lt) == 1
@@ -14135,7 +14113,6 @@
1413514113 if mname == "*"
1413614114 lt = infer_type(recv)
1413714115 if lt == "string"
14138- @needs_string_helpers = 1
1413914116 return "sp_str_repeat(" + compile_expr(recv) + ", " + compile_arg0(nid) + ")"
1414014117 end
1414114118 if lt == "poly"
@@ -14351,7 +14328,6 @@
1435114328 return "(sp_String_append(" + rc + ", " + val + "), " + rc + ")"
1435214329 end
1435314330 if lt == "string"
14354- @needs_string_helpers = 1
1435514331 return "sp_str_concat(" + compile_expr(recv) + ", " + compile_arg0(nid) + ")"
1435614332 end
1435714333 return "(" + compile_expr(recv) + " << " + compile_arg0(nid) + ")"
@@ -14600,7 +14576,6 @@
1460014576 end
1460114577
1460214578 def compile_string_method_expr(nid, mname, rc)
14603- @needs_string_helpers = 1
1460414579 if mname == "length"
1460514580 # Only use hoisted length if the receiver matches (otherwise we'd
1460614581 # return the wrong string's length).
@@ -14862,7 +14837,6 @@
1486214837 return fn + "(" + lprefix + ", " + compile_arg0(nid) + ", 1)"
1486314838 end
1486414839 if mname == "reverse"
14865- @needs_string_helpers = 1
1486614840 return "sp_str_reverse(" + rc + ")"
1486714841 end
1486814842 if mname == "freeze"
@@ -15050,7 +15024,6 @@
1505015024 return rc
1505115025 end
1505215026 if mname == "inspect"
15053- @needs_string_helpers = 1
1505415027 return "sp_str_concat(\":\", sp_sym_to_s(" + rc + "))"
1505515028 end
1505615029 if mname == "length" || mname == "size"
@@ -15110,7 +15083,6 @@
1511015083
1511115084 def compile_int_method_expr(nid, mname, rc)
1511215085 if mname == "to_s"
15113- @needs_string_helpers = 1
1511415086 if @nd_arguments[nid] >= 0
1511515087 aargs = get_args(@nd_arguments[nid])
1511615088 if aargs.length > 0
@@ -15188,7 +15160,6 @@
1518815160 return "TRUE"
1518915161 end
1519015162 if mname == "chr"
15191- @needs_string_helpers = 1
1519215163 return "sp_int_chr(" + rc + ")"
1519315164 end
1519415165 if mname == "succ" || mname == "next"
@@ -15205,7 +15176,6 @@
1520515176 return rc
1520615177 end
1520715178 if mname == "to_s"
15208- @needs_string_helpers = 1
1520915179 return "sp_float_to_s(" + rc + ")"
1521015180 end
1521115181 if mname == "inspect"
@@ -15673,7 +15643,6 @@
1567315643 return "sp_IntArray_uniq(" + rc + ")"
1567415644 end
1567515645 if mname == "join"
15676- @needs_string_helpers = 1
1567715646 jarg = compile_arg0(nid)
1567815647 if jarg == "0"
1567915648 jarg = "\"\""
@@ -15884,7 +15853,6 @@
1588415853 return "sp_StrArray_get(" + rc + ", sp_StrArray_length(" + rc + ") - 1)"
1588515854 end
1588615855 if mname == "join"
15887- @needs_string_helpers = 1
1588815856 jarg = compile_arg0(nid)
1588915857 if jarg == "0"
1589015858 jarg = "\"\""
@@ -16420,7 +16388,6 @@
1642016388 return "(sp_file_delete(" + compile_arg0(nid) + "), 0)"
1642116389 end
1642216390 if mname == "join"
16423- @needs_string_helpers = 1
1642416391 args_id = @nd_arguments[nid]
1642516392 if args_id >= 0
1642616393 arg_ids = get_args(args_id)
@@ -16431,7 +16398,6 @@
1643116398 return "\"\""
1643216399 end
1643316400 if mname == "basename"
16434- @needs_string_helpers = 1
1643516401 return "sp_file_basename(" + compile_arg0(nid) + ")"
1643616402 end
1643716403 end
@@ -17658,7 +17624,6 @@
1765817624 end
1765917625 if ht == "str_str_hash"
1766017626 @needs_str_str_hash = 1
17661- @needs_string_helpers = 1
1766217627 tmp = new_temp
1766317628 emit(" sp_StrStrHash *" + tmp + " = sp_StrStrHash_new();")
1766417629 elems.each { |el|
@@ -17905,7 +17870,6 @@
1790517870 end
1790617871 if op == "+"
1790717872 if vt == "string" && infer_type(@nd_expression[nid]) == "string"
17908- @needs_string_helpers = 1
1790917873 emit(" " + vref + " = sp_str_concat(" + vref + ", " + val + ");")
1791017874 else
1791117875 emit(" " + vref + " += " + val + ";")
@@ -19005,7 +18969,6 @@
1900518969 return 1
1900618970 end
1900718971 if rt == "string"
19008- @needs_string_helpers = 1
1900918972 rc = compile_expr_gc_rooted(recv)
1901018973 val = compile_arg0(nid)
1901118974 # If receiver is a local variable, reassign
@@ -19328,7 +19291,6 @@
1932819291 bp = "_c"
1932919292 end
1933019293 declare_var(bp, "string")
19331- @needs_string_helpers = 1
1933219294 tmp = new_temp
1933319295 src = rc
1933419296 if rt == "mutable_str"
@@ -22644,7 +22606,6 @@
2264422606 end
2264522607
2264622608 def compile_sprintf_call(nid)
22647- @needs_string_helpers = 1
2264822609 args_id = @nd_arguments[nid]
2264922610 if args_id < 0
2265022611 return "\"\""