Phase 7i: byte indexing p[i] / p[i] = v (retire peek8/poke8)
Raw byte access is now indexing, not C-style peek/poke: peek8(src, i) -> src[i] (reads a byte, widened to int) poke8(out, j, r) -> out[j] = r (narrows the int to a byte) E_INDEX on a non-slice pointer/string lowers to a `getelementptr i8` + load/zext (read) or trunc/store (write) — byte-identical to the old peek8/poke8, so the migration reproduces the compiler exactly. A "byte" element type (llty i8) drives the widen/narrow. The compiler's own byte work now reads naturally, e.g. `is_slice_ty` is `t[0] == 91 and t[1] == 93`. Subtlety fixed on the way: g_addr_ty (the out-param carrying the indexed element type) must be set AFTER evaluating the index expression, since a member/index in the index would otherwise clobber it — doing it early made a byte read load a full pointer from a byte address and crash the self-compile. Two reseeds: add byte-index support keeping peek8/poke8, then migrate 148 call sites and delete the intrinsics (+ the now-dead emit_gep_i8). Vocabulary drops peek8/poke8. Reseeded (22604 lines); C-free fixpoint holds; goldens identical; 18/18; vocab clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3aaf983cf5
commit
feb3a71e56
25 changed files with 3309 additions and 3388 deletions
|
|
@ -219,16 +219,16 @@ fn rt_ui_set_text(id: int, s: str) -> void {
|
|||
if id >= ui_n { return }
|
||||
let base = id * 96
|
||||
var i = 0
|
||||
var ch = peek8(s, 0)
|
||||
var ch = s[0]
|
||||
while ch != 0 {
|
||||
if i >= 95 { ch = 0 }
|
||||
if ch != 0 {
|
||||
poke8(ui_dyn, base + i, ch)
|
||||
ui_dyn[base + i] = ch
|
||||
i = i + 1
|
||||
ch = peek8(s, i)
|
||||
ch = s[i]
|
||||
}
|
||||
}
|
||||
poke8(ui_dyn, base + i, 0)
|
||||
ui_dyn[base + i] = 0
|
||||
poke32(ui_hasdyn, id, 1)
|
||||
}
|
||||
|
||||
|
|
@ -239,12 +239,12 @@ fn rt_ui_set_int(id: int, n: int) -> void {
|
|||
var at = 0
|
||||
var v = n
|
||||
if v < 0 {
|
||||
poke8(ui_dyn, base, 45)
|
||||
ui_dyn[base] = 45
|
||||
at = 1
|
||||
v = 0 - v
|
||||
}
|
||||
if v == 0 {
|
||||
poke8(ui_dyn, base + at, 48)
|
||||
ui_dyn[base + at] = 48
|
||||
at = at + 1
|
||||
} else {
|
||||
var digits = 0
|
||||
|
|
@ -257,12 +257,12 @@ fn rt_ui_set_int(id: int, n: int) -> void {
|
|||
while p > 0 {
|
||||
var div = 1
|
||||
for k in 1 .. p { div = div * 10 }
|
||||
poke8(ui_dyn, base + at, 48 + (v / div) % 10)
|
||||
ui_dyn[base + at] = 48 + (v / div) % 10
|
||||
at = at + 1
|
||||
p = p - 1
|
||||
}
|
||||
}
|
||||
poke8(ui_dyn, base + at, 0)
|
||||
ui_dyn[base + at] = 0
|
||||
poke32(ui_hasdyn, id, 1)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue