selfhost: drop snake_case locals in dyn/dynout/obj + w6a + cgen + ww driver
This commit is contained in:
@@ -115,7 +115,7 @@ type fieldinfo = struct {
|
||||
type structinfo = struct {
|
||||
sname: str,
|
||||
fields: *fieldinfo,
|
||||
tot_size: i32,
|
||||
totsize: i32,
|
||||
sinext: *structinfo,
|
||||
};
|
||||
|
||||
@@ -150,9 +150,9 @@ type cgen = struct {
|
||||
a: *arena,
|
||||
locals: *local,
|
||||
frame: i32,
|
||||
last_was_return: i32,
|
||||
lastwasreturn: i32,
|
||||
labelseq: i32,
|
||||
strlit_seq: i32,
|
||||
strlitseq: i32,
|
||||
strlits: *strlit,
|
||||
ffis: *ffi,
|
||||
defs: *defent,
|
||||
@@ -160,25 +160,25 @@ type cgen = struct {
|
||||
aliases: *aliasent,
|
||||
structs: *structinfo,
|
||||
mods: *modent, // non-exported decls → originating module
|
||||
fn_name: str,
|
||||
fn_ret: *node, // declared return type of current fn (or nil)
|
||||
loop_top: i32,
|
||||
loop_end_buf: *str, // stack of end labels for break
|
||||
loop_cont_buf: *str, // stack of cont labels for continue
|
||||
fnname: str,
|
||||
fnret: *node, // declared return type of current fn (or nil)
|
||||
looptop: i32,
|
||||
loopendbuf: *str, // stack of end labels for break
|
||||
loopcontbuf: *str, // stack of cont labels for continue
|
||||
};
|
||||
|
||||
fn cgeninit(c: *cgen, a: *arena) void = {
|
||||
c.a = a;
|
||||
c.locals = nil;
|
||||
c.frame = 0;
|
||||
c.last_was_return = 0;
|
||||
c.lastwasreturn = 0;
|
||||
c.labelseq = 0;
|
||||
// Note: strlit_seq, strlits, ffis are *not* reset here; they
|
||||
// persist across cgfn calls within one file. cgfile resets them
|
||||
// at the start of each compilation unit.
|
||||
c.loop_top = 0;
|
||||
c.loop_end_buf = amalloc(a, (LOOP_MAX: u64) * 16u64): *str;
|
||||
c.loop_cont_buf = amalloc(a, (LOOP_MAX: u64) * 16u64): *str;
|
||||
c.looptop = 0;
|
||||
c.loopendbuf = amalloc(a, (LOOP_MAX: u64) * 16u64): *str;
|
||||
c.loopcontbuf = amalloc(a, (LOOP_MAX: u64) * 16u64): *str;
|
||||
};
|
||||
|
||||
// localalloc — append a slot for `name` without dedup. Used for
|
||||
@@ -310,7 +310,7 @@ fn emitoff(v: i64) void = {
|
||||
fn mklabel(c: *cgen, base: str) str = {
|
||||
let buf: [128]u8;
|
||||
let i: i32 = 0;
|
||||
let fname: str = c.fn_name;
|
||||
let fname: str = c.fnname;
|
||||
let j: i32 = 0;
|
||||
for (j < fname.len) {
|
||||
buf[i] = fname[j];
|
||||
@@ -362,8 +362,8 @@ fn internstrlit(c: *cgen, bytes: str) str = {
|
||||
// New label "_S_<seq>".
|
||||
let buf: [32]u8;
|
||||
buf[0] = 95u8; buf[1] = 83u8; buf[2] = 95u8; // "_S_"
|
||||
let n: i32 = strconv.i64toa(buf[3:32], c.strlit_seq: i64);
|
||||
c.strlit_seq += 1;
|
||||
let n: i32 = strconv.i64toa(buf[3:32], c.strlitseq: i64);
|
||||
c.strlitseq += 1;
|
||||
let total: i32 = 3 + n;
|
||||
let p: *u8 = amalloc(c.a, (total: u64) + 1u64): *u8;
|
||||
let i: i32 = 0;
|
||||
|
||||
Reference in New Issue
Block a user