Phase 8b: modern names for the raw-memory and OS/IO primitives

Groups B and C of the leftover-primitive cleanup — renames, not new machinery,
and deliberately NO unsafe_ prefix (a __-prefix is itself a C convention, and an
`unsafe` marker carries no signal in a fully-manual-memory language with no safe
subset to contrast against).

  memory:  mem_free -> free   mem_realloc -> resize   mem_set -> fill
           ptr_add -> offset
  process: os_argc -> arg_count   os_arg -> arg   os_exit -> exit
           os_system -> run   os_getenv -> getenv   read_byte -> read_char
  dead:    mem_copy, os_time, write_byte (0 uses) — deleted

Two reseeds: accept both old and new names in the intrinsic dispatch, then
migrate every call site and drop the old names. file_open/read/write/seek/tell/
close are left as-is — they're the domain-prefixed syscall layer wrapped by
read_file, not the argc/argv-style C-ness the audit targeted; a `File` type is a
separate, larger design if wanted.

test.sh's CLI smoke updated (os_exit -> exit); check-vocabulary's grammar marker
moved off the deleted names. Reseeded (22243 lines); C-free fixpoint holds;
goldens identical; 18/18; vocab + doc-fences clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-08-28 02:55:24 +03:00
parent 6f1ba2c214
commit d3301684f1
19 changed files with 2468 additions and 2614 deletions

View file

@ -75,7 +75,7 @@ fn z_table_build(table: words, lengths: words, n: int) -> void {
offs[l] = offs[l] + 1
}
}
mem_free(offs)
free(offs)
}
fn z_decode(table: words) -> int {
@ -181,7 +181,7 @@ fn z_fixed_tables(lit: ptr, dist: ptr) -> void {
z_table_build(lit, lengths, 288)
for i in 0 .. 30 { lengths[i] = 5 }
z_table_build(dist, lengths, 30)
mem_free(lengths)
free(lengths)
}
fn z_dynamic_tables(lit: ptr, dist: ptr) -> int {
@ -233,9 +233,9 @@ fn z_dynamic_tables(lit: ptr, dist: ptr) -> int {
let dl: words = words(32)
for i in 0 .. ndist { dl[i] = lengths[nlen + i] }
z_table_build(dist, dl, ndist)
mem_free(dl)
mem_free(lengths)
mem_free(clen)
free(dl)
free(lengths)
free(clen)
return 1
}
@ -262,8 +262,8 @@ fn z_inflate(src: ptr, len: int, out: ptr, cap: int) -> int {
if btype == 3 { return -1 }
if w < 0 { return -1 }
}
mem_free(lit)
mem_free(dist)
free(lit)
free(dist)
return w
}
@ -272,5 +272,5 @@ fn z_uncompress(src: ptr, len: int, out: ptr, cap: int) -> int {
if len < 2 { return -1 }
let cmf = src[0]
if (cmf & 15) != 8 { return -1 }
return z_inflate(ptr_add(src, 2), len - 2, out, cap)
return z_inflate(offset(src, 2), len - 2, out, cap)
}