selfhost/cmd/{w6a,w6l}: migrate 10 amalloc sites to alloc(T{...})!
Phase 0 batch 2. Sites: w6a/parse.ww (asym, aprog, aoperand ×2), w6l/main.ww (lnk), w6l/obj.ww (defent, armember, lobj, lrel ×2). obj.ww's hdrsize *u8 buffer at line 344 + 7 other runtime-N byte buffers across the three files (path bufs, n+1 cstr copies, cap realloc) stay deferred to #8. Verified via 991_w6a_ww + 992_w6l_ww + 995_self_rebuild + 996_dyn_ww byte-identity. make test 132/132.
This commit is contained in:
@@ -1313,9 +1313,7 @@ export fn intern(a: *asm_, name: str) *asym = {
|
||||
if (streq(s.name, name)) { return s; };
|
||||
s = s.snext;
|
||||
};
|
||||
let n: *asym = amalloc(a.a, 64u64): *asym;
|
||||
n.name = name;
|
||||
n.snext = a.syms;
|
||||
let n: *asym = alloc(asym { name = name, snext = a.syms })!;
|
||||
a.syms = n;
|
||||
return n;
|
||||
};
|
||||
@@ -1516,15 +1514,9 @@ fn parseoperand(a: *asm_, p: *u8, offin: u64, n: u64, out: *aoperand) u64 = {
|
||||
|
||||
// Append a fresh aprog to the list with given opcode and label.
|
||||
fn addprog(a: *asm_, opc: i32, lbl: str) *aprog = {
|
||||
let pr: *aprog = amalloc(a.a, 96u64): *aprog;
|
||||
pr.as_ = opc;
|
||||
pr.line = a.line;
|
||||
pr.label = lbl;
|
||||
pr.link = nil;
|
||||
pr.bytes = nil;
|
||||
pr.nbytes = 0u64;
|
||||
pr.from = amalloc(a.a, 48u64): *aoperand;
|
||||
pr.to = amalloc(a.a, 48u64): *aoperand;
|
||||
let pr: *aprog = alloc(aprog { as_ = opc, line = a.line, label = lbl })!;
|
||||
pr.from = alloc(aoperand { })!;
|
||||
pr.to = alloc(aoperand { })!;
|
||||
if (a.head == nil) { a.head = pr; }
|
||||
else { a.tail.link = pr; };
|
||||
a.tail = pr;
|
||||
|
||||
Reference in New Issue
Block a user