Phase 7k: bytes(n) / words(n) allocators (retire mem_alloc)

Allocation reads as intent, not malloc:

  mem_alloc(64)          -> bytes(64)              (64 bytes -> a byte buffer)
  mem_alloc(w * h * 4)   -> words(w * h)           (w*h 32-bit words)

bytes(n) mallocs n bytes and returns a plain pointer (byte-indexed); words(n)
mallocs n*4 bytes and returns a `words` pointer (int-indexed). Since words(X) and
mem_alloc(X*4) allocate the identical number of bytes, the migration cannot change
any allocation size — the `* 4` factor just moves from the argument into the
allocator name, pairing naturally with the Phase-7j `words` retyping
(`var fb: words = words(w * h)`).

Migrated 102 sites (mem_alloc(E*4) -> words(E), else bytes(E)); deleted the
mem_alloc intrinsic. mem_realloc/free/copy/set stay as the low-level
reallocation/free family. Reseeded (22565 lines); C-free fixpoint holds; goldens
byte-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:26:15 +03:00
parent 5cab68ea2e
commit 86948d2b19
22 changed files with 3118 additions and 3069 deletions

View file

@ -80,35 +80,35 @@ var ui_active: int = -1
var ui_focus: int = -1
fn rt_ui_init() -> void {
ui_type = mem_alloc(UI_MAX * 4)
ui_parent = mem_alloc(UI_MAX * 4)
ui_w = mem_alloc(UI_MAX * 4)
ui_h = mem_alloc(UI_MAX * 4)
ui_x = mem_alloc(UI_MAX * 4)
ui_y = mem_alloc(UI_MAX * 4)
ui_haspos = mem_alloc(UI_MAX * 4)
ui_pad = mem_alloc(UI_MAX * 4)
ui_gap = mem_alloc(UI_MAX * 4)
ui_bg = mem_alloc(UI_MAX * 4)
ui_fg = mem_alloc(UI_MAX * 4)
ui_border = mem_alloc(UI_MAX * 4)
ui_align = mem_alloc(UI_MAX * 4)
ui_grow = mem_alloc(UI_MAX * 4)
ui_font = mem_alloc(UI_MAX * 4)
ui_size = mem_alloc(UI_MAX * 4)
ui_skin = mem_alloc(UI_MAX * 4)
ui_inset = mem_alloc(UI_MAX * 4)
ui_img = mem_alloc(UI_MAX * 4)
ui_focusable = mem_alloc(UI_MAX * 4)
ui_rx = mem_alloc(UI_MAX * 4)
ui_ry = mem_alloc(UI_MAX * 4)
ui_rw = mem_alloc(UI_MAX * 4)
ui_rh = mem_alloc(UI_MAX * 4)
ui_visible = mem_alloc(UI_MAX * 4)
ui_fired = mem_alloc(UI_MAX * 4)
ui_hasdyn = mem_alloc(UI_MAX * 4)
ui_dyn = mem_alloc(UI_MAX * 96)
ui_text = mem_alloc(UI_MAX * 8)
ui_type = words(UI_MAX)
ui_parent = words(UI_MAX)
ui_w = words(UI_MAX)
ui_h = words(UI_MAX)
ui_x = words(UI_MAX)
ui_y = words(UI_MAX)
ui_haspos = words(UI_MAX)
ui_pad = words(UI_MAX)
ui_gap = words(UI_MAX)
ui_bg = words(UI_MAX)
ui_fg = words(UI_MAX)
ui_border = words(UI_MAX)
ui_align = words(UI_MAX)
ui_grow = words(UI_MAX)
ui_font = words(UI_MAX)
ui_size = words(UI_MAX)
ui_skin = words(UI_MAX)
ui_inset = words(UI_MAX)
ui_img = words(UI_MAX)
ui_focusable = words(UI_MAX)
ui_rx = words(UI_MAX)
ui_ry = words(UI_MAX)
ui_rw = words(UI_MAX)
ui_rh = words(UI_MAX)
ui_visible = words(UI_MAX)
ui_fired = words(UI_MAX)
ui_hasdyn = words(UI_MAX)
ui_dyn = bytes(UI_MAX * 96)
ui_text = bytes(UI_MAX * 8)
}
# ---- build-time interface (called by compiler-emitted code) ---------------