@scriptc/compiler 0.0.7 → 0.0.8
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/emission/emit-exprs.js +47 -1
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-island.js +9 -1
- package/dist/backend/emission/emit-island.js.map +1 -1
- package/dist/backend/emission/emit-stmts.js +3 -1
- package/dist/backend/emission/emit-stmts.js.map +1 -1
- package/dist/backend/emission/emit-walkers.js +22 -8
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/emission/emitter.js +5 -1
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/emission/may-throw.js +4 -3
- package/dist/backend/emission/may-throw.js.map +1 -1
- package/dist/backend/llvm/emitter.js +94 -7
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +43 -1
- package/dist/diagnostics/diagnostic.js +103 -5
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lib-contract.d.ts +24 -6
- package/dist/frontend/lib-contract.js +125 -44
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.js +16 -1
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +47 -7
- package/dist/frontend/lowering/lower-calls.js +560 -36
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +14 -1
- package/dist/frontend/lowering/lower-classes.js +85 -15
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.js +43 -1
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-emitter.js +1 -1
- package/dist/frontend/lowering/lower-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +26 -3
- package/dist/frontend/lowering/lower-exprs.js +455 -40
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +7 -0
- package/dist/frontend/lowering/lower-island.js +71 -10
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +1 -1
- package/dist/frontend/lowering/lower-mixins.js +1 -1
- package/dist/frontend/lowering/lower-modules.js +95 -4
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +421 -43
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +19 -3
- package/dist/frontend/lowering/lowerer.js +188 -11
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/types.d.ts +28 -1
- package/dist/frontend/types.js +300 -8
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +37 -7
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +28 -2
- package/dist/ir/nodes.js +35 -3
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +35 -6
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/profile.d.ts +17 -3
- package/dist/library/profile.js +38 -9
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar.js +162 -43
- package/dist/library/sidecar.js.map +1 -1
- package/dist/library/trap-teaching.d.ts +11 -0
- package/dist/library/trap-teaching.js +49 -0
- package/dist/library/trap-teaching.js.map +1 -0
- package/package.json +2 -2
- package/surface-manifest.json +37 -2
package/dist/ir/validate.js
CHANGED
|
@@ -704,6 +704,8 @@ export const LIB_FN_SIGS = {
|
|
|
704
704
|
"error.domClone": { argTypes: [null, DYN], result: VOID },
|
|
705
705
|
"dyn.errInstanceof": { argTypes: [DYN, F64], result: BOOL },
|
|
706
706
|
"dyn.objKeys": { argTypes: [DYN], result: DYN },
|
|
707
|
+
"dyn.hasOwn": { argTypes: [DYN, STRING], result: BOOL },
|
|
708
|
+
"dyn.assign": { argTypes: [DYN, DYN], result: DYN },
|
|
707
709
|
"dyn.objValues": { argTypes: [DYN], result: DYN },
|
|
708
710
|
"dyn.objEntries": { argTypes: [DYN], result: DYN },
|
|
709
711
|
"dyn.structuredClone": { argTypes: [DYN, DYN], result: DYN },
|
|
@@ -1764,6 +1766,13 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
|
|
|
1764
1766
|
checkExpr(e.left);
|
|
1765
1767
|
checkExpr(e.right);
|
|
1766
1768
|
expectType(e.right, e.type, "nullish right operand");
|
|
1769
|
+
// The ISLAND form: `a ?? b` over an engine value — left, right,
|
|
1770
|
+
// and result are all handles (the emitters' jsval nullish arm).
|
|
1771
|
+
if (e.left.type.kind === "jsval") {
|
|
1772
|
+
if (e.type.kind !== "jsval")
|
|
1773
|
+
err("jsval nullish must answer jsval", e.loc);
|
|
1774
|
+
break;
|
|
1775
|
+
}
|
|
1767
1776
|
if (e.left.type.kind !== "union") {
|
|
1768
1777
|
err(`nullish left must be a union, got ${e.left.type.kind}`, e.loc);
|
|
1769
1778
|
break;
|
|
@@ -2329,8 +2338,12 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
|
|
|
2329
2338
|
// declared params plus that one must match.
|
|
2330
2339
|
if (e.type.kind === "func") {
|
|
2331
2340
|
const wantRet = callSiteReturnType(target);
|
|
2332
|
-
|
|
2333
|
-
|
|
2341
|
+
// ISLAND-REST types (restAbi jsval) SPELL their trailing engine
|
|
2342
|
+
// array param — the lifted signature matches directly, no
|
|
2343
|
+
// hidden slot.
|
|
2344
|
+
const hiddenRest = e.type.rest === true && e.type.restAbi !== "jsval";
|
|
2345
|
+
const declared = hiddenRest ? target.params.slice(0, -1) : target.params;
|
|
2346
|
+
const restOk = !hiddenRest ||
|
|
2334
2347
|
(target.params.length === e.type.params.length + 1 &&
|
|
2335
2348
|
target.params[target.params.length - 1].type.kind === "dyn");
|
|
2336
2349
|
if (!restOk ||
|
|
@@ -4414,20 +4427,23 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
|
|
|
4414
4427
|
lt: 2, le: 2, gt: 2, ge: 2, eq: 2, neq: 2, instanceOf: 2,
|
|
4415
4428
|
neg: 1, plus: 1, truthy: 1, not: 1, typeof: 1, toStr: 1,
|
|
4416
4429
|
getProp: 1, setProp: 2, getIdx: 2, setIdx: 3, globalGet: 0,
|
|
4417
|
-
undefLit: 0, nullLit: 0, iterNew: 1,
|
|
4430
|
+
undefLit: 0, nullLit: 0, iterNew: 1, defineGetter: 3, objSpread: 2,
|
|
4418
4431
|
callMethod: null, optCallMethod: null, callFn: null, construct: null, // receiver/callee + any number of args
|
|
4419
|
-
objLit: null, arrLit: null, // variable length (objLit: key/value pairs)
|
|
4432
|
+
objLit: null, arrLit: null, tplStrings: null, // variable length (objLit: key/value pairs; tplStrings: n cooked + n raw)
|
|
4420
4433
|
};
|
|
4421
4434
|
const want = arity[e.op];
|
|
4422
4435
|
if (want !== null && want !== undefined && e.args.length !== want) {
|
|
4423
4436
|
err(`jsOp ${e.op} takes ${want} arg(s), got ${e.args.length}`, e.loc);
|
|
4424
4437
|
}
|
|
4425
|
-
if (want === null && e.op !== "objLit" && e.op !== "arrLit" && e.args.length < 1) {
|
|
4438
|
+
if (want === null && e.op !== "objLit" && e.op !== "arrLit" && e.op !== "tplStrings" && e.args.length < 1) {
|
|
4426
4439
|
err(`jsOp ${e.op} needs a receiver/callee arg`, e.loc);
|
|
4427
4440
|
}
|
|
4428
4441
|
if (e.op === "objLit" && e.args.length % 2 !== 0) {
|
|
4429
4442
|
err("jsOp objLit takes key/value pairs", e.loc);
|
|
4430
4443
|
}
|
|
4444
|
+
if (e.op === "tplStrings" && e.args.length % 2 !== 0) {
|
|
4445
|
+
err("jsOp tplStrings takes n cooked + n raw strings", e.loc);
|
|
4446
|
+
}
|
|
4431
4447
|
for (const a of e.args) {
|
|
4432
4448
|
if (a.type.kind !== "jsval")
|
|
4433
4449
|
err(`jsOp ${e.op} arg must be jsval, got ${a.type.kind}`, e.loc);
|
|
@@ -4681,7 +4697,20 @@ function validateFunction(fn, functions, classes, records, unions, globals, erro
|
|
|
4681
4697
|
break;
|
|
4682
4698
|
}
|
|
4683
4699
|
if (!shape.indexValue) {
|
|
4684
|
-
|
|
4700
|
+
// Signature-free dispatch: every declared field shares ONE type
|
|
4701
|
+
// (the frontend's gate), the value IS that type, and a key miss
|
|
4702
|
+
// traps at runtime — so overflowOnly writes cannot exist here.
|
|
4703
|
+
const common = shape.fields[0]?.type;
|
|
4704
|
+
if (!common || !shape.fields.every((f) => typeEquals(f.type, common))) {
|
|
4705
|
+
err(`recordKeySet on non-index-signature shape ${s.shapeId} without one shared field type`, s.loc);
|
|
4706
|
+
break;
|
|
4707
|
+
}
|
|
4708
|
+
if (s.overflowOnly) {
|
|
4709
|
+
err(`recordKeySet overflowOnly on signature-free shape ${s.shapeId}`, s.loc);
|
|
4710
|
+
}
|
|
4711
|
+
expectType(s.obj, { kind: "record", shapeId: s.shapeId }, "recordKeySet receiver");
|
|
4712
|
+
expectType(s.key, STRING, "recordKeySet key");
|
|
4713
|
+
expectType(s.value, common, "recordKeySet value");
|
|
4685
4714
|
break;
|
|
4686
4715
|
}
|
|
4687
4716
|
expectType(s.obj, { kind: "record", shapeId: s.shapeId }, "recordKeySet receiver");
|