w6c: append() accepts struct CALL rvalue elements (#34)

Evaluate the call pre-grow into a per-site scratch, receiving by the
N_LET matrix (sret / float / odd-tail / GP), then grow, slot, sized
ladder. Both stages, byte-identical. The two reject pins graduate to
16B GP accept rows; three new fixtures cover 24B GP, 3B/4B tails,
16B float, and 40B sret.
This commit is contained in:
2026-08-08 14:10:55 +09:00
parent 956246b3f0
commit 50d70e74e4
9 changed files with 295 additions and 27 deletions

View File

@@ -0,0 +1,25 @@
//ww:run-exit 0
// #34 close: append() accepts a struct CALL rvalue element — GP
// register-class receive (24B str+i32), odd sub-8 (3B), and sized
// tail (4B) shapes, evaluated pre-grow into a per-site scratch.
package main;
type gp24 = struct { name: str, id: i32 };
type odd3 = struct { a: u8, b: u8, c: u8 };
type tail4 = struct { v: i32 };
fn mkgp(id: i32) gp24 = { let e: gp24; e.name = "x"; e.id = id; return e; };
fn mkodd() odd3 = { let e: odd3; e.a = 1u8; e.b = 2u8; e.c = 3u8; return e; };
fn mktail() tail4 = { let e: tail4; e.v = 5; return e; };
fn main() i32 = {
let gs: []gp24 = [];
append(gs, mkgp(7));
append(gs, mkgp(9));
if (gs.len != 2 || gs[0].id != 7 || gs[1].id != 9) { return 1; };
if (gs[0].name.len != 1) { return 2; };
let os_: []odd3 = [];
append(os_, mkodd());
if (os_[0].a != 1u8 || os_[0].c != 3u8) { return 3; };
let ts: []tail4 = [];
append(ts, mktail());
if (ts[0].v != 5) { return 4; };
return 0;
};

View File

@@ -0,0 +1,18 @@
//ww:run-exit 0
// #34 close, float leg: a float-bearing <=16B struct CALL element is
// received on independent SSE/GP return cursors (the #171a matrix).
package main;
type flt16 = struct { x: f64, n: i64 };
fn mkflt(v: f64, n: i64) flt16 = {
let e: flt16; e.x = v; e.n = n; return e;
};
fn main() i32 = {
let fs: []flt16 = [];
append(fs, mkflt(2.5, 11i64));
append(fs, mkflt(0.25, 13i64));
if (fs.len != 2) { return 1; };
if (fs[0].n != 11i64 || fs[1].n != 13i64) { return 2; };
if (fs[0].x != 2.5) { return 3; };
if (fs[1].x != 0.25) { return 4; };
return 0;
};

View File

@@ -0,0 +1,20 @@
//ww:run-exit 0
// #34 close, sret leg: a >24B struct CALL element writes through the
// hidden RDI into the append scratch before the grow.
package main;
type big40 = struct { a: i64, b: i64, c: i64, d: i64, e: i64 };
fn mkbig(base: i64) big40 = {
let e: big40;
e.a = base; e.b = base + 1i64; e.c = base + 2i64;
e.d = base + 3i64; e.e = base + 4i64;
return e;
};
fn main() i32 = {
let bs: []big40 = [];
append(bs, mkbig(10i64));
append(bs, mkbig(20i64));
if (bs.len != 2) { return 1; };
if (bs[0].a != 10i64 || bs[0].e != 14i64) { return 2; };
if (bs[1].a != 20i64 || bs[1].e != 24i64) { return 3; };
return 0;
};

View File

@@ -1,11 +0,0 @@
//ww:error "#34: append() struct element source shape unsupported (rule-7)"
package main;
type pt = struct { x: i32, y: i32, z: i64 };
fn mk() pt = {
return pt { x = 1, y = 2, z = 3 };
};
export fn main() i32 = {
let xs: []pt = [];
append(xs, mk());
return 0;
};

View File

@@ -1,9 +0,0 @@
//ww:error "#34: append() struct element source shape unsupported (rule-7)"
package main;
type box = struct { pc: size, a: i64 };
fn mk() box = { return box { pc = 1, a = 2 }; };
export fn main() i32 = {
let bs: []box = [];
append(bs, mk());
return 0;
};