@scriptc/compiler 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/c/exprs.js +36 -8
- package/dist/backend/c/exprs.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +28 -2
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +8 -0
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +4 -3
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +1 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/coverage/surface-manifest.js +6 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/frontend/lowering/array-indexed-mutation.d.ts +8 -0
- package/dist/frontend/lowering/array-indexed-mutation.js +176 -0
- package/dist/frontend/lowering/array-indexed-mutation.js.map +1 -0
- package/dist/frontend/lowering/containers/string-and-regexp.d.ts +7 -0
- package/dist/frontend/lowering/containers/string-and-regexp.js +190 -13
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/indexed-comparison.d.ts +6 -0
- package/dist/frontend/lowering/indexed-comparison.js +30 -0
- package/dist/frontend/lowering/indexed-comparison.js.map +1 -0
- package/dist/frontend/lowering/lower-builtins.d.ts +1 -1
- package/dist/frontend/lowering/lower-builtins.js +6 -6
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +266 -10
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +3 -27
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +8 -2
- package/dist/frontend/lowering/lower-containers.js +454 -104
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +18 -2
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +2 -0
- package/dist/frontend/lowering/surfaces.js +13 -1
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/ir/ir.d.ts +15 -2
- package/dist/ir/ir.js +2 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/validate.js +43 -26
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +17 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/package.json +17 -17
- package/surface-manifest.json +36 -4
package/dist/backend/c/exprs.js
CHANGED
|
@@ -1477,9 +1477,9 @@ function emitContainerExpr(emitter, e) {
|
|
|
1477
1477
|
return emitter.newTemp(e.type, `scr_arr_state(${arr.name}, ${idx.name})`);
|
|
1478
1478
|
}
|
|
1479
1479
|
case "arrIntrinsic": {
|
|
1480
|
-
// getNumber
|
|
1480
|
+
// getNumber/indexEq produce scalars without invoking user code. A
|
|
1481
1481
|
// stable binding can own its receiver until that lookup finishes.
|
|
1482
|
-
const r = e.method === "getNumber"
|
|
1482
|
+
const r = e.method === "getNumber" || e.method === "indexEq"
|
|
1483
1483
|
? emitStableReceiver(emitter, e.receiver, e.args)
|
|
1484
1484
|
: emitter.emitExpr(e.receiver);
|
|
1485
1485
|
if (e.receiver.type.kind !== "array")
|
|
@@ -1498,6 +1498,12 @@ function emitContainerExpr(emitter, e) {
|
|
|
1498
1498
|
const start = emitter.emitExpr(e.args[0]);
|
|
1499
1499
|
return emitter.newTemp(e.type, `scr_arr_next_present(${r.name}, ${start.name})`);
|
|
1500
1500
|
}
|
|
1501
|
+
case "indexEq": {
|
|
1502
|
+
const index = emitter.emitExpr(e.args[0]);
|
|
1503
|
+
const other = emitStableReceiver(emitter, e.args[1], [e.args[2]]);
|
|
1504
|
+
const otherIndex = emitter.emitExpr(e.args[2]);
|
|
1505
|
+
return emitter.newTemp(e.type, `scr_arr_index_eq(${r.name}, ${index.name}, ${other.name}, ${otherIndex.name})`);
|
|
1506
|
+
}
|
|
1501
1507
|
case "push": {
|
|
1502
1508
|
// Variadic like JS: every argument evaluates first (left to
|
|
1503
1509
|
// right — an argument reading the array sees the pre-push
|
|
@@ -1644,6 +1650,17 @@ function emitContainerExpr(emitter, e) {
|
|
|
1644
1650
|
const cnt = e.args[1] ? emitter.emitExpr(e.args[1]).name : "INFINITY";
|
|
1645
1651
|
return emitter.newTemp(e.type, `scr_arr_splice(${r.name}, ${start.name}, ${cnt})`);
|
|
1646
1652
|
}
|
|
1653
|
+
case "spliceInsert": {
|
|
1654
|
+
const start = emitter.emitExpr(e.args[0]);
|
|
1655
|
+
const count = emitter.emitExpr(e.args[1]);
|
|
1656
|
+
const items = emitter.emitExpr(e.args[2]);
|
|
1657
|
+
return emitter.newTemp(e.type, `scr_arr_splice_insert(${r.name}, ${start.name}, ${count.name}, ${items.name})`);
|
|
1658
|
+
}
|
|
1659
|
+
case "flatCopy":
|
|
1660
|
+
case "flatOne": {
|
|
1661
|
+
const out = emitter.emitExpr(e.args[0]);
|
|
1662
|
+
return emitter.newTemp(e.type, `scr_arr_flat_copy(${r.name}, ${out.name}, ${method === "flatOne" ? "true" : "false"})`);
|
|
1663
|
+
}
|
|
1647
1664
|
default: {
|
|
1648
1665
|
const _exhaustive = method;
|
|
1649
1666
|
void _exhaustive;
|
|
@@ -4049,6 +4066,8 @@ function emitDynamicLibCall(state) {
|
|
|
4049
4066
|
case "dyn.typeof":
|
|
4050
4067
|
// Bare typeof on a dyn value: the dyn kind's JS answer (+1).
|
|
4051
4068
|
return finish(`scr_dyn_typeof(${arg(0)})`);
|
|
4069
|
+
case "dyn.objectTag":
|
|
4070
|
+
return finish(`scr_dyn_object_tag(${arg(0)})`);
|
|
4052
4071
|
case "dyn.toString":
|
|
4053
4072
|
// Receiver-kind-dispatched toString (+1); throws Node's
|
|
4054
4073
|
// TypeError on undefined/null and the "is not a function"
|
|
@@ -7681,22 +7700,23 @@ function emitProcessLibCall(state) {
|
|
|
7681
7700
|
return finish(`scr_stdin_next_chunk()`);
|
|
7682
7701
|
case "process.isTTY":
|
|
7683
7702
|
return finish(`scr_process_is_tty(${arg(0)})`);
|
|
7684
|
-
case "process.columns":
|
|
7685
|
-
|
|
7703
|
+
case "process.columns":
|
|
7704
|
+
case "process.rows": {
|
|
7705
|
+
// ioctl(TIOCGWINSZ): a non-negative dimension wraps the f64 arm;
|
|
7686
7706
|
// a non-TTY stream (or an ioctl refusal) comes back negative
|
|
7687
7707
|
// and yields the interned undefined-arm instance — Node's
|
|
7688
|
-
// missing
|
|
7708
|
+
// missing geometry. Type-directed union construction, like
|
|
7689
7709
|
// process.envGet.
|
|
7690
7710
|
if (e.type.kind !== "union") {
|
|
7691
|
-
throw new InternalCompilerError(
|
|
7711
|
+
throw new InternalCompilerError(`emitter bug: ${e.fn} result is not a union`);
|
|
7692
7712
|
}
|
|
7693
7713
|
const def = emitter.unionsById.get(e.type.unionId);
|
|
7694
7714
|
const f64Tag = def ? def.arms.findIndex((a) => a.kind === "f64") : -1;
|
|
7695
7715
|
const undefTag = undefinedArmTag(e.type, emitter.unionsById);
|
|
7696
7716
|
if (f64Tag < 0 || undefTag < 0) {
|
|
7697
|
-
throw new InternalCompilerError(
|
|
7717
|
+
throw new InternalCompilerError(`emitter bug: ${e.fn} union lacks its arms`);
|
|
7698
7718
|
}
|
|
7699
|
-
const w = emitter.newTemp(F64, `
|
|
7719
|
+
const w = emitter.newTemp(F64, `scr_process_${e.fn === "process.rows" ? "rows" : "columns"}(${arg(0)})`);
|
|
7700
7720
|
const present = `scr_union_new_f64(${f64Tag}, ${w.name})`;
|
|
7701
7721
|
const absent = emitter.unitInstanceRef(e.type.unionId, undefTag);
|
|
7702
7722
|
return emitter.newTemp(e.type, `${w.name} >= 0 ? ${present} : ${absent}`);
|
|
@@ -8534,6 +8554,14 @@ function emitIoLibCall(state) {
|
|
|
8534
8554
|
}
|
|
8535
8555
|
}
|
|
8536
8556
|
function emitLibCallExpr(emitter, e) {
|
|
8557
|
+
const packed = e.args[0];
|
|
8558
|
+
if (e.fn === "string.fromCharCode" && packed?.kind === "arrayLit" &&
|
|
8559
|
+
packed.elems.length === 1 && !packed.spreads?.length) {
|
|
8560
|
+
// The literal is only the variadic ABI pack, never an observable
|
|
8561
|
+
// array. Evaluate the scalar once before bypassing that allocation.
|
|
8562
|
+
const code = emitter.emitExpr(packed.elems[0]);
|
|
8563
|
+
return emitter.newTemp(e.type, `scr_str_from_char_code_one(${code.name})`);
|
|
8564
|
+
}
|
|
8537
8565
|
// Standard-library call. Args are BORROWED (owned temps of the
|
|
8538
8566
|
// current frame, released at statement end); refcounted results come
|
|
8539
8567
|
// back +1 (process.argv: +1 on the runtime's ONE interned array —
|