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:
parent
058cac88ec
commit
839a6bf0c0
11 changed files with 3555 additions and 3542 deletions
|
|
@ -7,7 +7,7 @@ fn hexdig(n: int) -> int { if n < 10 { return 48 + n }; return 55 + n } # 0-9
|
|||
fn emit_str_const(s: ptr) -> ptr {
|
||||
let name = ("@.str" + itoa(ll_str))
|
||||
ll_str = ll_str + 1
|
||||
let n = slen(s)
|
||||
let n = len(s)
|
||||
emith(name); emith(" = private unnamed_addr constant [")
|
||||
emith(itoa(n + 1)); emith(" x i8] c\"")
|
||||
var i = 0
|
||||
|
|
@ -75,7 +75,7 @@ fn emit_header() -> void {
|
|||
emith("@L_argc = internal global i32 0\n")
|
||||
emith("@L_argv = internal global ptr null\n")
|
||||
emith("@.gametitle = private unnamed_addr constant [")
|
||||
emith(itoa(slen(g_game_name) + 1)); emith(" x i8] c\""); emith(g_game_name); emith("\\00\"\n")
|
||||
emith(itoa(len(g_game_name) + 1)); emith(" x i8] c\""); emith(g_game_name); emith("\\00\"\n")
|
||||
emith("%LSlice = type { ptr, i32, i32 }\n")
|
||||
# property layouts — a %Cmp_ record of named fields, emitted here so `new`
|
||||
# works whether or not the program runs the ECS. The per-entity @S_/@H_ arrays
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue