Files
scriptc/tests/fixtures/self-hosting/serialize.ts
Chris Tate 7b007e03ef feat(compiler): bootstrap the LLVM emitter natively
- Run the production LLVM backend natively and reproduce its output across compiler generations.
- Replace unchecked emitter contexts with explicit shared state and callback hosts.
- Preserve NaN in serialized IR and respect optional record storage during spreads.
2026-09-27 22:29:24 -05:00

25 lines
972 B
TypeScript

import { readFileSync } from "node:fs";
import { deserializeModule, serializeModule } from "../../../packages/compiler/src/ir/serialize.js";
import { validateModule } from "../../../packages/compiler/src/ir/validate.js";
try {
const mod = deserializeModule(readFileSync(process.argv[2]!, "utf8"));
const errors = validateModule(mod);
if (errors.length > 0) {
console.log(JSON.stringify(errors));
process.exitCode = 1;
} else {
// Introduce a native NaN before serialization, independently of the
// input document's sentinel decoding.
if (process.argv[3] === "nan") {
const statement = mod.functions[0]!.body[0];
if (statement?.kind === "exprStmt" && statement.expr.kind === "numLit") statement.expr.value = NaN;
}
console.log(serializeModule(mod));
}
} catch (error) {
if (error instanceof Error) console.log(error.name + ": " + error.message);
else console.log("unexpected thrown value");
process.exitCode = 1;
}