Commit 464d7e36
464d7e3640a5Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 1 file · ~1 modified
Description
fix: remove dead methods and fread warning in self-compiled output
Remove emit_return (unused, caused int-to-pointer warning) and scan_captured_locals (only self-recursive, never called externally, caused 4 type mismatch warnings). Fix fread return value warning in sp_file_read runtime.
Self-compilation now produces zero warnings with -Wno-all.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 464d7e3640a5
- Parent
- 5dc3e55ce6a1
spinel_codegen.rbmodifiedView file
@@ -748,14 +748,6 @@
748748
@out = @out + s + 10.chr749749
end750750
751-
def emit_return(val)752-
s = "" + val753-
if @in_gc_scope == 1754-
emit(" SP_GC_RESTORE();")755-
end756-
emit(" return " + s + ";")757-
0758-
end759751
760752
# ---- Type inference ----761753
def infer_type(nid)@@ -6187,7 +6179,7 @@
61876179
end61886180
61896181
def emit_file_io_runtime6190-
emit_raw("static const char *sp_file_read(const char *path) { FILE *f = fopen(path, \"rb\"); if (!f) return \"\"; fseek(f, 0, SEEK_END); long sz = ftell(f); fseek(f, 0, SEEK_SET); char *buf = (char *)malloc(sz + 1); if (sz > 0) fread(buf, 1, sz, f); buf[sz] = 0; fclose(f); return buf; }")6182+
emit_raw("static const char *sp_file_read(const char *path) { FILE *f = fopen(path, \"rb\"); if (!f) return \"\"; fseek(f, 0, SEEK_END); long sz = ftell(f); fseek(f, 0, SEEK_SET); char *buf = (char *)malloc(sz + 1); if (sz > 0) { size_t r = fread(buf, 1, sz, f); (void)r; } buf[sz] = 0; fclose(f); return buf; }")61916183
emit_raw("static void sp_file_write(const char *path, const char *data) { FILE *f = fopen(path, \"w\"); if (f) { fputs(data, f); fclose(f); } }")61926184
emit_raw("static mrb_bool sp_file_exist(const char *path) { FILE *f = fopen(path, \"r\"); if (f) { fclose(f); return TRUE; } return FALSE; }")61936185
emit_raw("static void sp_file_delete(const char *path) { remove(path); }")@@ -13761,88 +13753,6 @@
1376113753
emit(" }")1376213754
end1376313755
@in_loop = old13764-
end13765-
13766-
def scan_captured_locals(nid, excludes, names, types)13767-
# Type hint: use str_array method to force param typing13768-
if excludes.length < 013769-
excludes.push("")13770-
end13771-
if names.length < 013772-
names.push("")13773-
end13774-
if types.length < 013775-
types.push("")13776-
end13777-
if nid < 013778-
return13779-
end13780-
if @nd_type[nid] == "LocalVariableReadNode"13781-
lname = @nd_name[nid]13782-
if not_in(lname, excludes) == 113783-
if not_in(lname, names) == 113784-
names.push(lname)13785-
vt = find_var_type(lname)13786-
if vt == ""13787-
vt = "int"13788-
end13789-
types.push(vt)13790-
end13791-
end13792-
end13793-
if @nd_type[nid] == "LocalVariableWriteNode"13794-
lname = @nd_name[nid]13795-
if not_in(lname, excludes) == 113796-
if not_in(lname, names) == 113797-
names.push(lname)13798-
vt = find_var_type(lname)13799-
if vt == ""13800-
vt = "int"13801-
end13802-
types.push(vt)13803-
end13804-
end13805-
end13806-
# Recurse13807-
if @nd_body[nid] >= 013808-
scan_captured_locals(@nd_body[nid], excludes, names, types)13809-
end13810-
stmts = parse_id_list(@nd_stmts[nid])13811-
k = 013812-
while k < stmts.length13813-
scan_captured_locals(stmts[k], excludes, names, types)13814-
k = k + 113815-
end13816-
if @nd_expression[nid] >= 013817-
scan_captured_locals(@nd_expression[nid], excludes, names, types)13818-
end13819-
if @nd_predicate[nid] >= 013820-
scan_captured_locals(@nd_predicate[nid], excludes, names, types)13821-
end13822-
if @nd_left[nid] >= 013823-
scan_captured_locals(@nd_left[nid], excludes, names, types)13824-
end13825-
if @nd_right[nid] >= 013826-
scan_captured_locals(@nd_right[nid], excludes, names, types)13827-
end13828-
if @nd_subsequent[nid] >= 013829-
scan_captured_locals(@nd_subsequent[nid], excludes, names, types)13830-
end13831-
if @nd_else_clause[nid] >= 013832-
scan_captured_locals(@nd_else_clause[nid], excludes, names, types)13833-
end13834-
if @nd_arguments[nid] >= 013835-
scan_captured_locals(@nd_arguments[nid], excludes, names, types)13836-
end13837-
args = parse_id_list(@nd_args[nid])13838-
k = 013839-
while k < args.length13840-
scan_captured_locals(args[k], excludes, names, types)13841-
k = k + 113842-
end13843-
if @nd_receiver[nid] >= 013844-
scan_captured_locals(@nd_receiver[nid], excludes, names, types)13845-
end1384613756
end1384713757
1384813758
def compile_map_block(nid)