selfhost: port append + spread — N_SPREAD parser + rt_ensure builtin

This commit is contained in:
2026-05-12 16:04:17 +09:00
parent f67c07cbae
commit ce5d66e18a
7 changed files with 525 additions and 15 deletions

View File

@@ -217,6 +217,14 @@ fn parsearglist(p: *parser, closekind: tkind, headout: **node) void = {
let tail: *node = nil;
for (true) {
let e: *node = parseexpr(p);
// Hare-style spread: `expr...` in an arg slot becomes a
// marker the callee/builtin can iterate over. Mirrors
// cmd/wcc/parse.c. The only consumer today is `append`.
if (accepttok(p, tkind.TK_ELLIPSIS)) {
let sp: *node = newnode(p.a, nkind.N_SPREAD, e.file, e.line, e.col);
sp.lhs = e;
e = sp;
};
if (head == nil) { head = e; tail = e; }
else { tail.next = e; tail = e; };
if (!accepttok(p, tkind.TK_COMMA)) { break; };