w6a: replace private streq with strings.compare (Wave-2 hand-rolled->lib)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 })!;
|
||||
|
||||
Reference in New Issue
Block a user