mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-25 06:24:27 +08:00
- Remove C emission, debugging options, and automatic backend fallback. - Complete LLVM lowering and native bootstrap coverage across supported targets. - Link executables and libraries with precompiled C runtime packs, including iOS and Android.
27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
import { expect, test } from "vitest";
|
|
import { emitLlvmModule } from "../src/backend/llvm/emitter.js";
|
|
import { F64, STRING, VOID, arrayOf, type IrExpr, type IrModule } from "../src/ir/ir.js";
|
|
import { validateModule } from "../src/ir/validate.js";
|
|
|
|
test("scalar fromCharCode avoids a heap argument pack in LLVM", () => {
|
|
const loc = { file: "scalar-char.ts", start: 0, end: 0 };
|
|
const value: IrExpr = { kind: "numLit", value: 65, type: F64, loc };
|
|
const mod: IrModule = {
|
|
irVersion: 13, sourceFile: loc.file, entry: "__main", globals: [],
|
|
functions: [{
|
|
name: "__main", params: [], returnType: VOID, locals: [], loc,
|
|
body: [{ kind: "exprStmt", loc, expr: {
|
|
kind: "libCall", fn: "string.fromCharCode", type: STRING, loc,
|
|
args: [{ kind: "arrayLit", elems: [value], type: arrayOf(F64), loc }],
|
|
} }],
|
|
}],
|
|
};
|
|
expect(validateModule(mod)).toEqual([]);
|
|
|
|
const llvm = emitLlvmModule(mod);
|
|
|
|
expect(llvm).toContain("call ptr @scr_str_from_char_code_one(double");
|
|
|
|
expect(llvm).not.toContain("call ptr @scr_arr_new(");
|
|
});
|