Phase 7f: len(x) works on strings too (retire slen)

`len` is now polymorphic — a slice's element count OR a string's byte length —
so the C-style `slen` (strlen) is gone: `slen(name)` -> `len(name)`. emit_len
branches on the operand type (slice header vs @strlen). Two reseeds: add the
string branch, then migrate the 19 slen calls and delete slen.

Reseeded (22565 lines); C-free fixpoint holds; goldens identical; 18/18; vocab +
doc-fences clean. (String slicing s[a..b] to replace substr is deferred to its
own phase.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-08-28 01:25:57 +03:00
parent 058cac88ec
commit 839a6bf0c0
11 changed files with 3555 additions and 3542 deletions

View file

@ -2,12 +2,6 @@
# slicing out substrings, and integer<->text. All over raw NUL-terminated
# byte buffers reached with peek8/poke8.
fn slen(s: ptr) -> int {
var n = 0
while peek8(s, n) != 0 { n = n + 1 }
return n
}
# a fresh NUL-terminated copy of src[start .. start+n]
fn substr(src: ptr, start: int, n: int) -> ptr {
let b = mem_alloc(n + 1)