selfhost: drop snake_case locals in dyn/dynout/obj + w6a + cgen + ww driver

This commit is contained in:
2026-05-11 16:33:02 +09:00
parent c64e96cbd6
commit 97ca76d2bb
18 changed files with 1795 additions and 1795 deletions

View File

@@ -4,7 +4,7 @@
// per-kind helper: cgblock, cgreturn, cgexprstmt, cglet, cgif, cgfor,
// cgmassign, cgbreak, cgcontinue.
//
// The expression generator (cgexpr) lives in cgen_expr.ww; the
// The expression generator (cgexpr) lives in cgenexpr.ww; the
// foundation (types, emit primitives, collect* tables, FFI/module
// maps) lives in cgen.ww.
@@ -39,7 +39,7 @@ fn cgstmt(c: *cgen, n: *node) void = {
if (k == N_BREAK) { cgbreak(c, n); return; };
if (k == N_CONTINUE) { cgcontinue(c, n); return; };
c.last_was_return = 0;
c.lastwasreturn = 0;
};
fn cgblock(c: *cgen, n: *node) void = {
@@ -73,16 +73,16 @@ fn cgreturn(c: *cgen, n: *node) void = {
emitline("\tMOVQ\tBP, SP\n");
emitline("\tPOPQ\tBP\n");
emitline("\tRET\n");
c.last_was_return = 1;
c.lastwasreturn = 1;
return;
};
// Tagged-union return: pack as (AX=tag, DX=value0, CX=value1).
// For str variant, cgexpr leaves (AX=ptr, BX=len), so we
// shuffle DX←AX (ptr) and CX←BX (len), then load tag.
// For other variants, cgexpr leaves AX, shuffle DX←AX.
if (istaggedtype(c.fn_ret)) {
if (istaggedtype(c.fnret)) {
cgexpr(c, rhs);
let idx: i32 = taggedvariantindex(c, c.fn_ret, rhs);
let idx: i32 = taggedvariantindex(c, c.fnret, rhs);
if (nodeisstr(c, rhs)) {
emitline("\tMOVQ\tBX, CX\n");
emitline("\tMOVQ\tAX, DX\n");
@@ -96,7 +96,7 @@ fn cgreturn(c: *cgen, n: *node) void = {
emitline("\tMOVQ\tBP, SP\n");
emitline("\tPOPQ\tBP\n");
emitline("\tRET\n");
c.last_was_return = 1;
c.lastwasreturn = 1;
return;
};
cgexpr(c, rhs);
@@ -108,19 +108,19 @@ fn cgreturn(c: *cgen, n: *node) void = {
};
// SysV: 16-byte aggregates (str, 2-tuple) return in (AX, DX).
// cgexpr leaves str in (AX, BX); shuffle BX→DX.
if (isstrtype(c, c.fn_ret)) {
if (isstrtype(c, c.fnret)) {
emitline("\tMOVQ\tBX, DX\n");
};
emitline("\tMOVQ\tBP, SP\n");
emitline("\tPOPQ\tBP\n");
emitline("\tRET\n");
c.last_was_return = 1;
c.lastwasreturn = 1;
return;
};
fn cgexprstmt(c: *cgen, n: *node) void = {
if (n.lhs != nil) { cgexpr(c, n.lhs); };
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
@@ -162,7 +162,7 @@ fn cglet(c: *cgen, n: *node) void = {
emitline("\tMOVQ\tCX, ");
emitoff((off + 16): i64);
emitline("(BP)\n");
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
let tagidx: i32 = taggedvariantindex(c, n.lhs, rhs);
@@ -184,7 +184,7 @@ fn cglet(c: *cgen, n: *node) void = {
emitline(", ");
emitoff(off: i64);
emitline("(BP)\n");
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
// Struct literal init: `let p: point = point{x=..., y=...};`.
@@ -224,7 +224,7 @@ fn cglet(c: *cgen, n: *node) void = {
};
fieldnode = fieldnode.next;
};
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
};
@@ -262,7 +262,7 @@ fn cglet(c: *cgen, n: *node) void = {
emitline("(BP)\n");
};
};
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
@@ -282,7 +282,7 @@ fn cgif(c: *cgen, n: *node) void = {
cgstmt(c, n.els);
};
emitlabel(endl);
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
@@ -302,18 +302,18 @@ fn cgfor(c: *cgen, n: *node) void = {
emitline("\tJE\t"); emitline(endl); emitline("\n");
};
c.loop_end_buf[c.loop_top] = endl;
c.loop_cont_buf[c.loop_top] = topl;
c.loop_top += 1;
c.loopendbuf[c.looptop] = endl;
c.loopcontbuf[c.looptop] = topl;
c.looptop += 1;
if (n.body != nil) { cgstmt(c, n.body); };
c.loop_top -= 1;
c.looptop -= 1;
if (n.rhs != nil) { cgexpr(c, n.rhs); };
emitline("\tJMP\t"); emitline(topl); emitline("\n");
emitlabel(endl);
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
@@ -349,25 +349,25 @@ fn cgmassign(c: *cgen, n: *node) void = {
};
};
};
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
fn cgbreak(c: *cgen, n: *node) void = {
if (c.loop_top > 0) {
let lbl: str = c.loop_end_buf[c.loop_top - 1];
if (c.looptop > 0) {
let lbl: str = c.loopendbuf[c.looptop - 1];
emitline("\tJMP\t"); emitline(lbl); emitline("\n");
};
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};
fn cgcontinue(c: *cgen, n: *node) void = {
if (c.loop_top > 0) {
let lbl: str = c.loop_cont_buf[c.loop_top - 1];
if (c.looptop > 0) {
let lbl: str = c.loopcontbuf[c.looptop - 1];
emitline("\tJMP\t"); emitline(lbl); emitline("\n");
};
c.last_was_return = 0;
c.lastwasreturn = 0;
return;
};