From 05609dcc34cbbae4d5a9aab6a9f988e88afb9918 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Wed, 3 Jun 2026 03:33:09 +0900 Subject: [PATCH] w6a: replace private streq with strings.compare (Wave-2 hand-rolled->lib) --- selfhost/cmd/w6a/asm.ww | 15 +++------------ selfhost/cmd/w6a/main.combined.ww | 19 ++++--------------- selfhost/cmd/w6a/parse.ww | 4 +--- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/selfhost/cmd/w6a/asm.ww b/selfhost/cmd/w6a/asm.ww index aebaab45..4176d9f2 100644 --- a/selfhost/cmd/w6a/asm.ww +++ b/selfhost/cmd/w6a/asm.ww @@ -15,6 +15,7 @@ import os; import rt; import mem; import opcodes; +import strings; // ---- text buffer growth ------------------------------------------------ @@ -212,20 +213,10 @@ fn sserrw(a: *asm_, prefix: u8, op2: u8, regop: i32, rmop: i32) void = { // ---- label resolution / fixups ---------------------------------------- -fn streq(a: str, b: str) bool = { - if (a.len != b.len) { return false; }; - let i: i32 = 0; - for (i < a.len) { - if (a[i] != b[i]) { return false; }; - i += 1; - }; - return true; -}; - fn resolvelabel(a: *asm_, name: str) u64 = { let s: *asym = a.syms; for (s != nil) { - if (s.defined != 0) { if (streq(s.name, name)) { return s.addr; }; }; + if (s.defined != 0) { if (strings.compare(s.name, name) == 0) { return s.addr; }; }; s = s.snext; }; return 0u64; @@ -234,7 +225,7 @@ fn resolvelabel(a: *asm_, name: str) u64 = { fn labeldefined(a: *asm_, name: str) bool = { let s: *asym = a.syms; for (s != nil) { - if (s.defined != 0) { if (streq(s.name, name)) { return true; }; }; + if (s.defined != 0) { if (strings.compare(s.name, name) == 0) { return true; }; }; s = s.snext; }; return false; diff --git a/selfhost/cmd/w6a/main.combined.ww b/selfhost/cmd/w6a/main.combined.ww index c528154f..5ae9891e 100644 --- a/selfhost/cmd/w6a/main.combined.ww +++ b/selfhost/cmd/w6a/main.combined.ww @@ -3285,12 +3285,10 @@ export fn init(a: *asm_, file: str, src: *u8, len: u64) void = { a.errs = 0; }; -// `streq(str,str)` lives in asm.ww — same bundle, single definition. - export fn intern(a: *asm_, name: str) *asym = { let s: *asym = a.syms; for (s != nil) { - if (streq(s.name, name)) { return s; }; + if (strings.compare(s.name, name) == 0) { return s; }; s = s.snext; }; let n: *asym = alloc(asym { name = name, snext = a.syms })!; @@ -3736,6 +3734,7 @@ import os; import rt; import mem; import opcodes; +import strings; // ---- text buffer growth ------------------------------------------------ @@ -3933,20 +3932,10 @@ fn sserrw(a: *asm_, prefix: u8, op2: u8, regop: i32, rmop: i32) void = { // ---- label resolution / fixups ---------------------------------------- -fn streq(a: str, b: str) bool = { - if (a.len != b.len) { return false; }; - let i: i32 = 0; - for (i < a.len) { - if (a[i] != b[i]) { return false; }; - i += 1; - }; - return true; -}; - fn resolvelabel(a: *asm_, name: str) u64 = { let s: *asym = a.syms; for (s != nil) { - if (s.defined != 0) { if (streq(s.name, name)) { return s.addr; }; }; + if (s.defined != 0) { if (strings.compare(s.name, name) == 0) { return s.addr; }; }; s = s.snext; }; return 0u64; @@ -3955,7 +3944,7 @@ fn resolvelabel(a: *asm_, name: str) u64 = { fn labeldefined(a: *asm_, name: str) bool = { let s: *asym = a.syms; for (s != nil) { - if (s.defined != 0) { if (streq(s.name, name)) { return true; }; }; + if (s.defined != 0) { if (strings.compare(s.name, name) == 0) { return true; }; }; s = s.snext; }; return false; diff --git a/selfhost/cmd/w6a/parse.ww b/selfhost/cmd/w6a/parse.ww index dd11bf56..a44b0c09 100644 --- a/selfhost/cmd/w6a/parse.ww +++ b/selfhost/cmd/w6a/parse.ww @@ -156,12 +156,10 @@ export fn init(a: *asm_, file: str, src: *u8, len: u64) void = { a.errs = 0; }; -// `streq(str,str)` lives in asm.ww — same bundle, single definition. - export fn intern(a: *asm_, name: str) *asym = { let s: *asym = a.syms; for (s != nil) { - if (streq(s.name, name)) { return s; }; + if (strings.compare(s.name, name) == 0) { return s; }; s = s.snext; }; let n: *asym = alloc(asym { name = name, snext = a.syms })!;