selfhost: port switch — N_SWITCH parser + cgen + scratch slot
This commit is contained in:
@@ -87,6 +87,11 @@ fn scanlocals(c: *cgen, n: *node) i32 = {
|
||||
bidx += 1;
|
||||
};
|
||||
};
|
||||
// `switch` allocates an 8B scratch slot for the scrutinee so case
|
||||
// bodies can spill through SP without losing it. The slot is named
|
||||
// ".sw_<labelseq>" at cgen time — unique per switch — so it must
|
||||
// not dedup. Count it here so the frame SUBQ matches.
|
||||
if (n.kind == nkind.N_SWITCH) { total += 8; };
|
||||
// Match-arm binding (`case let v: T => ...`) gets a slot too.
|
||||
// Crucially we do NOT dedup these against c.locals: C cgen
|
||||
// handles a match as an expression with a by-value locals copy,
|
||||
|
||||
Reference in New Issue
Block a user