Update native emission fixtures for direct joins

- Exercise the current scalar join helper and verify reuse.
- Preserve native and Node emission and refusal contracts.
This commit is contained in:
Chris Tate
2026-10-06 16:58:38 -05:00
parent 4583e69738
commit 9ac2334202
3 changed files with 9 additions and 14 deletions
-2
View File
@@ -16,7 +16,6 @@ interface Request {
classObjects: string[];
sources: { file: string; text: string }[];
writers?: IrType[];
textUnions?: string[];
joinUnions?: string[];
indent?: boolean;
}
@@ -69,7 +68,6 @@ try {
const walkers = new LlWalkers(host);
const helpers: string[] = [];
for (const type of request.writers ?? []) helpers.push(walkers.jsonWriteHelper(type));
for (const union of request.textUnions ?? []) helpers.push(walkers.unionToStrHelper(union));
for (const union of request.joinUnions ?? []) helpers.push(walkers.unionJoinHelper(union));
if (request.indent) helpers.push(walkers.jsonIndentHelper());
const classes = [...graph.values()].map((meta) => ({
+3 -5
View File
@@ -20,7 +20,6 @@ export interface EmissionRequest {
classObjects: string[];
sources: { file: string; text: string }[];
writers?: IrType[];
textUnions?: string[];
joinUnions?: string[];
indent?: boolean;
}
@@ -322,12 +321,11 @@ export function emissionCases(): EmissionCase[] {
textUnion.unions = [{ id: "text", arms: [BOOL, F64, STRING, { kind: "nullT" }, UNDEFINED_T] }];
const textRequest = emissionRequest();
textRequest.writers = [{ kind: "union", unionId: "text" }];
textRequest.textUnions = ["text", "text"];
textRequest.joinUnions = ["text"];
textRequest.joinUnions = ["text", "text"];
add(
"union JSON, string and join helpers",
"union JSON and direct join helpers",
textUnion,
["switch i32", "@scr_str_retain"],
["switch i32", "@scr_arr_peek_ref", "@scr_jb_put_number"],
textRequest,
);
+6 -7
View File
@@ -119,6 +119,9 @@ for (const backend of ["llvm"] as const) {
emitted.debug,
].join("\n");
for (const expected of item.contains) expect(definitions, item.name).toContain(expected);
if ((item.request.joinUnions?.length ?? 0) > 1) {
expect(definitions.match(/define internal ptr @sc_uj_/g), item.name).toHaveLength(1);
}
if (item.name.startsWith("class forest")) {
expect(
emitted.classes.map((meta) => [meta.name, meta.root, meta.pre, meta.post]),
@@ -167,10 +170,6 @@ for (const backend of ["llvm"] as const) {
request: { ...emissionRequest(), writers: [{ kind: "union", unionId: "Missing" }] },
message: "jsonStringify of unknown union Missing",
},
{
request: { ...emissionRequest(), textUnions: ["Missing"] },
message: "ToString of unknown union Missing",
},
{
request: { ...emissionRequest(), joinUnions: ["Missing"] },
message: "join of unknown union Missing",
@@ -189,11 +188,11 @@ for (const backend of ["llvm"] as const) {
expect(
run(
unsupported,
{ ...emissionRequest(), textUnions: ["containers"] },
"unsupported union stringification",
{ ...emissionRequest(), joinUnions: ["containers"] },
"unsupported union join",
1,
),
).toContain("unionToStr:array");
).toContain("unionJoin:array");
for (const source of [
"711-inheritance-dispatch.ts",