refactor(lang): rename the ptr/ptrs types to pointer/pointers

Expand the abbreviated pointer types to full words on the language surface:
  ptr   ->  pointer     (a raw address / FFI handle)
  ptrs  ->  pointers    (a buffer of pointers)

The Ludic type name is distinct from LLVM's own `ptr` spelling: llty() maps
`pointer`/`pointers` to LLVM `ptr`, and the emitted IR keeps `ptr`, so only
the Ludic-level surface changes. Rewrites type annotations across all
sources, the 8 hardcoded pointer type-tags, the `pointers`-buffer indexing
in emit_addr, the grammars/LSP/JetBrains tokens, and the docs
(type-ptr -> type-pointer, type-ptrs -> type-pointers). int/bool keep their
conventional short spelling (like Math).

Reseeded; C-free fixpoint holds; all suites green (45/24/29); site + check.py OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-08-30 01:58:54 +03:00
parent b7745a4600
commit effb3f637f
76 changed files with 516 additions and 516 deletions

View file

@ -329,7 +329,7 @@ function rt_running() -> bool {
}
# ---- writing the frame out ------------------------------------------------
function rt_put_str(buf: ptr, at: int, s: string) -> int {
function rt_put_str(buf: pointer, at: int, s: string) -> int {
var i = 0
var n = at
var ch = s[0]
@ -342,7 +342,7 @@ function rt_put_str(buf: ptr, at: int, s: string) -> int {
return n
}
function rt_put_int(buf: ptr, at: int, v: int) -> int {
function rt_put_int(buf: pointer, at: int, v: int) -> int {
if v == 0 {
buf[at] = 48
return at + 1
@ -402,7 +402,7 @@ import "ui.ludic"
# A character grid the game paints with map_row() and reads with tile(). Stored
# as one byte per cell in a flat buffer; out-of-bounds reads answer '#' so a
# caller can treat the edge of the world as wall without special-casing it.
var rt_map: ptr = null
var rt_map: pointer = null
var rt_mapw: int = 0
var rt_maph: int = 0
@ -436,7 +436,7 @@ function rt_tile(x: int, y: int) -> int {
# ---- status line ----------------------------------------------------------
# One persistent string of feedback/dialogue, copied into runtime-owned memory
# so it survives whatever the caller does with the original.
var rt_statusbuf: ptr = null
var rt_statusbuf: pointer = null
function rt_status(s: string) -> void {
var i = 0
@ -452,7 +452,7 @@ function rt_status(s: string) -> void {
rt_statusbuf[i] = 0
}
function rt_status_text() -> ptr {
function rt_status_text() -> pointer {
return rt_statusbuf
}
@ -460,7 +460,7 @@ function rt_status_text() -> ptr {
# The compiler writes the ECS (entities, components, archetype kinds) because
# only it knows their shape. Everything below belongs to the runtime, so the
# runtime writes it — same order both ways.
function rt_save_state(f: ptr) -> void {
function rt_save_state(f: pointer) -> void {
let w: words = bytes(16)
w[0] = rt_rng
w[1] = rt_mapw
@ -473,7 +473,7 @@ function rt_save_state(f: ptr) -> void {
free(w)
}
function rt_load_state(f: ptr) -> void {
function rt_load_state(f: pointer) -> void {
let w: words = bytes(16)
file_read(f, w, 16)
rt_rng = w[0]

View file

@ -13,7 +13,7 @@ const IMG_MAX: int = 32
const SPR_MAX: int = 160
const SPR_SZ: int = 16
var img_px: ptrs = null # IMG_MAX pointers to RGBA buffers
var img_px: pointers = null # IMG_MAX pointers to RGBA buffers
var img_w: words = null
var img_h: words = null
var img_n: int = 0
@ -30,11 +30,11 @@ function rt_image_init() -> void {
}
# ---- decoding -------------------------------------------------------------
function png_be32(b: ptr, at: int) -> int {
function png_be32(b: pointer, at: int) -> int {
return (b[at] << 24) | (b[at + 1] << 16) | (b[at + 2] << 8) | b[at + 3]
}
function png_tag(b: ptr, at: int, a: int, c: int, d: int, e: int) -> bool {
function png_tag(b: pointer, at: int, a: int, c: int, d: int, e: int) -> bool {
if b[at] != a { return false }
if b[at + 1] != c { return false }
if b[at + 2] != d { return false }
@ -42,7 +42,7 @@ function png_tag(b: ptr, at: int, a: int, c: int, d: int, e: int) -> bool {
return true
}
function rt_read_file(path: string) -> ptr {
function rt_read_file(path: string) -> pointer {
let f = file_open(path, "rb")
if (f == null) { return null }
file_seek(f, 0, 2)

View file

@ -13,14 +13,14 @@
# ============================================================================
# ---- bit reader (DEFLATE packs bits least-significant-first) ---------------
var z_src: ptr = null
var z_src: pointer = null
var z_len: int = 0
var z_pos: int = 0
var z_bitbuf: int = 0
var z_bitcnt: int = 0
var z_err: int = 0
function z_start(src: ptr, len: int) -> void {
function z_start(src: pointer, len: int) -> void {
z_src = src
z_len = len
z_pos = 0
@ -48,7 +48,7 @@ function z_bits(need: int) -> int {
# ---- Huffman tables -------------------------------------------------------
# A table is a single buffer: 16 length-counts followed by the symbols in
# canonical order. One allocation, no structs.
function z_table_new(nsym: int) -> ptr {
function z_table_new(nsym: int) -> pointer {
return words((16 + nsym))
}
@ -125,7 +125,7 @@ function z_dist_extra(sym: int) -> int {
# ---- block decoders -------------------------------------------------------
# `out` is the destination window; returns the new write position, or -1.
function z_stored(out: ptr, at: int, cap: int) -> int {
function z_stored(out: pointer, at: int, cap: int) -> int {
z_bitbuf = 0
z_bitcnt = 0 # stored blocks are byte-aligned
if z_pos + 4 > z_len { return -1 }
@ -142,7 +142,7 @@ function z_stored(out: ptr, at: int, cap: int) -> int {
return w
}
function z_codes(out: ptr, at: int, cap: int, lit: ptr, dist: ptr) -> int {
function z_codes(out: pointer, at: int, cap: int, lit: pointer, dist: pointer) -> int {
var w = at
var sym = z_decode(lit)
while sym != 256 {
@ -172,7 +172,7 @@ function z_codes(out: ptr, at: int, cap: int, lit: ptr, dist: ptr) -> int {
return w
}
function z_fixed_tables(lit: ptr, dist: ptr) -> void {
function z_fixed_tables(lit: pointer, dist: pointer) -> void {
let lengths: words = words(288)
for i in 0 .. 144 { lengths[i] = 8 }
for i in 144 .. 256 { lengths[i] = 9 }
@ -184,7 +184,7 @@ function z_fixed_tables(lit: ptr, dist: ptr) -> void {
free(lengths)
}
function z_dynamic_tables(lit: ptr, dist: ptr) -> int {
function z_dynamic_tables(lit: pointer, dist: pointer) -> int {
let nlen = z_bits(5) + 257
let ndist = z_bits(5) + 1
let ncode = z_bits(4) + 4
@ -240,7 +240,7 @@ function z_dynamic_tables(lit: ptr, dist: ptr) -> int {
}
# Inflate a raw DEFLATE stream. Returns bytes written, or -1.
function z_inflate(src: ptr, len: int, out: ptr, cap: int) -> int {
function z_inflate(src: pointer, len: int, out: pointer, cap: int) -> int {
z_start(src, len)
let lit = z_table_new(288)
let dist = z_table_new(30)
@ -268,7 +268,7 @@ function z_inflate(src: ptr, len: int, out: ptr, cap: int) -> int {
}
# zlib wrapper (RFC 1950): two header bytes, then DEFLATE, then Adler-32.
function z_uncompress(src: ptr, len: int, out: ptr, cap: int) -> int {
function z_uncompress(src: pointer, len: int, out: pointer, cap: int) -> int {
if len < 2 { return -1 }
let cmf = src[0]
if (cmf & 15) != 8 { return -1 }

View file

@ -18,7 +18,7 @@ const TT_EDGES: int = 16384 # line segments in one glyph
const TT_GC: int = 512 # glyph cache entries
# ---- per-font tables (parallel arrays; index = font id) -------------------
var tt_data: ptrs = null
var tt_data: pointers = null
var tt_size: words = null
var tt_upem: words = null
var tt_nglyf: words = null
@ -61,7 +61,7 @@ var gc_h: words = null
var gc_ox: words = null
var gc_oy: words = null
var gc_adv: words = null
var gc_bmp: ptrs = null
var gc_bmp: pointers = null
function rt_tt_init() -> void {
tt_data = bytes(TT_MAX * 8)
@ -105,24 +105,24 @@ function rt_tt_init() -> void {
}
# ---- big-endian readers ---------------------------------------------------
function tt_u16(d: ptr, at: int) -> int {
function tt_u16(d: pointer, at: int) -> int {
return ((d[at] << 8) | d[at + 1])
}
function tt_i16(d: ptr, at: int) -> int {
function tt_i16(d: pointer, at: int) -> int {
let v = tt_u16(d, at)
if v >= 32768 { return v - 65536 }
return v
}
function tt_u32(d: ptr, at: int) -> int {
function tt_u32(d: pointer, at: int) -> int {
return (d[at] << 24) | (d[at + 1] << 16) | (d[at + 2] << 8) | d[at + 3]
}
function tt_i8(d: ptr, at: int) -> int {
function tt_i8(d: pointer, at: int) -> int {
let v = d[at]
if v >= 128 { return v - 256 }
return v
}
function tt_find_table(d: ptr, base: int, a: int, b: int, c: int, e: int) -> int {
function tt_find_table(d: pointer, base: int, a: int, b: int, c: int, e: int) -> int {
let n = tt_u16(d, base + 4)
for i in 0 .. n {
let rec = base + 12 + i * 16
@ -138,7 +138,7 @@ function tt_find_table(d: ptr, base: int, a: int, b: int, c: int, e: int) -> int
}
# pick the most capable Unicode subtable, as the C loader did
function tt_pick_cmap(id: int, d: ptr, co: int) -> void {
function tt_pick_cmap(id: int, d: pointer, co: int) -> void {
tt_cmap[id] = 0 - 1
tt_cfmt[id] = 0
if co < 0 { return }

View file

@ -51,7 +51,7 @@ var gr_ox: int = 0
var gr_oy: int = 0
var gr_adv: int = 0
function tt_raster(id: int, gid: int, px: int) -> ptr {
function tt_raster(id: int, gid: int, px: int) -> pointer {
let upem = tt_upem[id]
let scale = fx(px) / upem
gr_adv = flr(fx(tt_advance(id, gid)) * scale + 0.5)
@ -298,7 +298,7 @@ function tt_utf8(s: string, at: int) -> int {
}
# ---- drawing --------------------------------------------------------------
function tt_blit(bmp: ptr, w: int, h: int, dx: int, dy: int, colour: int) -> void {
function tt_blit(bmp: pointer, w: int, h: int, dx: int, dy: int, colour: int) -> void {
if (bmp == null) { return }
let cr = ((colour >> 16) & 255)
let cg = ((colour >> 8) & 255)

View file

@ -72,8 +72,8 @@ var ui_rh: words = null
var ui_visible: words = null
var ui_fired: words = null
var ui_hasdyn: words = null
var ui_dyn: ptr = null # UI_MAX * 96 bytes
var ui_text: ptrs = null # UI_MAX static string pointers
var ui_dyn: pointer = null # UI_MAX * 96 bytes
var ui_text: pointers = null # UI_MAX static string pointers
var ui_n: int = 0
var ui_active: int = -1
@ -175,14 +175,14 @@ function rt_ui_static_text(i: int, s: string) -> void {
}
# ---- text helpers: TrueType when a font is loaded, bitmap otherwise -------
function ui_str(i: int) -> ptr {
function ui_str(i: int) -> pointer {
if ui_hasdyn[i] == 1 { return offset(ui_dyn, i * 96) }
let t = ui_text[i]
if (t == null) { return offset(ui_dyn, i * 96) }
return t
}
function ui_draw_text(font: int, x: int, y: int, s: ptr, colour: int, size: int) -> void {
function ui_draw_text(font: int, x: int, y: int, s: pointer, colour: int, size: int) -> void {
if font >= 0 {
if font < tt_n {
rt_text_ttf(font, x, y, s, colour, size)
@ -192,7 +192,7 @@ function ui_draw_text(font: int, x: int, y: int, s: ptr, colour: int, size: int)
rt_text(x, y, s, colour, max(size / 8, 1))
}
function ui_tw(font: int, s: ptr, size: int) -> int {
function ui_tw(font: int, s: pointer, size: int) -> int {
if font >= 0 {
if font < tt_n { return rt_text_w(font, s, size) }
}