@scriptc/compiler 0.0.34 → 0.0.35
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/cc-cache.test.js +969 -7
- package/dist/backend/cc-cache.test.js.map +1 -1
- package/dist/backend/cc.d.ts +90 -18
- package/dist/backend/cc.js +953 -276
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/llvm/split.d.ts +43 -0
- package/dist/backend/llvm/split.js +227 -0
- package/dist/backend/llvm/split.js.map +1 -0
- package/dist/backend/llvm/split.test.d.ts +1 -0
- package/dist/backend/llvm/split.test.js +102 -0
- package/dist/backend/llvm/split.test.js.map +1 -0
- package/dist/backend/object-localize.test.js +20 -0
- package/dist/backend/object-localize.test.js.map +1 -1
- package/dist/executable/early-cache.d.ts +86 -0
- package/dist/executable/early-cache.js +460 -0
- package/dist/executable/early-cache.js.map +1 -0
- package/dist/executable/early-cache.test.d.ts +1 -0
- package/dist/executable/early-cache.test.js +300 -0
- package/dist/executable/early-cache.test.js.map +1 -0
- package/dist/ffi/profile.d.ts +7 -2
- package/dist/ffi/profile.js +1 -0
- package/dist/ffi/profile.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.js +2 -2
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +14 -4
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.js +18 -23
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +22 -10
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-island.js +3 -3
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.js +1 -1
- package/dist/frontend/lowering/lower-mixins.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +1 -1
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +6 -0
- package/dist/frontend/lowering/lowerer.js +230 -81
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +1 -1
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/program.js +42 -13
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +40 -2
- package/dist/frontend/ts7/checker.js +194 -32
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/types.js +20 -42
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +219 -101
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +6 -0
- package/dist/ir/nodes.js +28 -0
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +7 -1
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/early-cache.js +4 -23
- package/dist/library/early-cache.js.map +1 -1
- package/dist/library/implementation-identity.d.ts +23 -0
- package/dist/library/implementation-identity.js +84 -0
- package/dist/library/implementation-identity.js.map +1 -0
- package/dist/startup-cache.d.ts +6 -0
- package/dist/startup-cache.js +6 -0
- package/dist/startup-cache.js.map +1 -0
- package/package.json +3 -2
- package/surface-manifest.json +1 -1
|
@@ -1823,7 +1823,7 @@ export function lowerTernary(L, expr, expected) {
|
|
|
1823
1823
|
const argIdent = c.arguments[0];
|
|
1824
1824
|
const sym = L.resolveValueSymbol(argIdent);
|
|
1825
1825
|
const t = L.checker.getTypeAtLocation(argIdent);
|
|
1826
|
-
const constituents = t.isUnionType() ?
|
|
1826
|
+
const constituents = t.isUnionType() ? ts.constituentTypes(t) : [];
|
|
1827
1827
|
const nonArray = constituents.filter((a) => !L.checker.isArrayType(a) && !L.checker.isTupleType(a));
|
|
1828
1828
|
const mapped = L.mapTypeOf(t);
|
|
1829
1829
|
const armCount = mapped?.kind === "union" ? L.arrayValueTags(mapped.unionId).length : 0;
|
|
@@ -3755,7 +3755,7 @@ export function lowerArrayLiteral(L, expr, expected) {
|
|
|
3755
3755
|
* for effect and are not stored. Null for every other target. */
|
|
3756
3756
|
function settledDropNames(L, tsType) {
|
|
3757
3757
|
let names = null;
|
|
3758
|
-
const parts = tsType.isUnionType() ?
|
|
3758
|
+
const parts = tsType.isUnionType() ? ts.constituentTypes(tsType) : [tsType];
|
|
3759
3759
|
for (const part of parts) {
|
|
3760
3760
|
const sym = part.getSymbol();
|
|
3761
3761
|
if (!sym ||
|
|
@@ -3832,7 +3832,7 @@ function literalKeySpellingOf(t) {
|
|
|
3832
3832
|
return String(t.value);
|
|
3833
3833
|
if (t.isUnionType()) {
|
|
3834
3834
|
let out = null;
|
|
3835
|
-
for (const arm of
|
|
3835
|
+
for (const arm of ts.constituentTypes(t)) {
|
|
3836
3836
|
const s = arm.isStringLiteralType() ? arm.value : arm.isNumberLiteralType() ? String(arm.value) : null;
|
|
3837
3837
|
if (s === null || (out !== null && s !== out))
|
|
3838
3838
|
return null;
|
|
@@ -4183,7 +4183,7 @@ function literalUnionArmOf(L, expr, tsType, recordArms) {
|
|
|
4183
4183
|
* equal or width-liftable. */
|
|
4184
4184
|
const fits = (litT, ftT) => {
|
|
4185
4185
|
if (ftT.isUnionType())
|
|
4186
|
-
return
|
|
4186
|
+
return ts.constituentTypes(ftT).some((a) => fits(litT, a));
|
|
4187
4187
|
if (ftT.isStringLiteralType())
|
|
4188
4188
|
return litT.isStringLiteralType() && litT.value === ftT.value;
|
|
4189
4189
|
if (ftT.isNumberLiteralType())
|
|
@@ -4205,7 +4205,7 @@ function literalUnionArmOf(L, expr, tsType, recordArms) {
|
|
|
4205
4205
|
};
|
|
4206
4206
|
const armShapeIds = new Set(recordArms.map((a) => a.shapeId));
|
|
4207
4207
|
const candidates = new Set();
|
|
4208
|
-
for (const member of
|
|
4208
|
+
for (const member of ts.constituentTypes(tsType)) {
|
|
4209
4209
|
const mMapped = L.mapTypeOf(member);
|
|
4210
4210
|
if (mMapped?.kind !== "record" || !armShapeIds.has(mMapped.shapeId) || candidates.has(mMapped.shapeId))
|
|
4211
4211
|
continue;
|
|
@@ -4350,7 +4350,7 @@ export function lowerObjectLiteral(L, expr) {
|
|
|
4350
4350
|
// slot's field types (`lanIp: string | null`), which the literal's own
|
|
4351
4351
|
// type narrows away (a field written as `lanIp: null` types as bare
|
|
4352
4352
|
// `null`, which maps to nothing on its own).
|
|
4353
|
-
if (tsType.isUnionType() &&
|
|
4353
|
+
if (tsType.isUnionType() && ts.constituentTypes(tsType).some((t) => t.getSymbol()?.name === "PromiseLike")) {
|
|
4354
4354
|
tsType = L.checker.getAwaitedType(tsType) ?? tsType;
|
|
4355
4355
|
}
|
|
4356
4356
|
let mapped = L.mapTypeOf(tsType);
|
|
@@ -4380,7 +4380,7 @@ export function lowerObjectLiteral(L, expr) {
|
|
|
4380
4380
|
if (ctxShape && !ctxShape.indexValue && !ctxShape.tuple) {
|
|
4381
4381
|
const names = new Set(ctxShape.fields.map((f) => f.name));
|
|
4382
4382
|
const ctxHasProp = (name) => {
|
|
4383
|
-
const members = tsType.isUnionType() ?
|
|
4383
|
+
const members = tsType.isUnionType() ? ts.constituentTypes(tsType) : [tsType];
|
|
4384
4384
|
return members.some((m) => L.checker.getPropertyOfType(m, name) !== undefined);
|
|
4385
4385
|
};
|
|
4386
4386
|
const extraOf = (text) => !names.has(text) && !ctxHasProp(text);
|
|
@@ -5955,7 +5955,12 @@ export function lowerRecordKeyRead(L, expr, shapeId, shape, includeUndefined = f
|
|
|
5955
5955
|
if (dk.type.kind !== "string") {
|
|
5956
5956
|
L.unsupported("SC1090", keyNode, "indexing records with non-string or non-number keys");
|
|
5957
5957
|
}
|
|
5958
|
-
|
|
5958
|
+
const read = { kind: "dynKeyGet", key: dk, value: obj, type: DYN, loc };
|
|
5959
|
+
// Absence probes must keep the checked-dynamic undefined produced by
|
|
5960
|
+
// a missing key. The ordinary read narrows to the checker's declared
|
|
5961
|
+
// index value (and therefore validates it); ===/!==, ||, and ?? need
|
|
5962
|
+
// to observe the missing value instead of throwing during that check.
|
|
5963
|
+
return includeUndefined ? read : L.maybeNarrow(read, expr);
|
|
5959
5964
|
}
|
|
5960
5965
|
if (litKey !== null) {
|
|
5961
5966
|
const field = shape.fields.find((f) => f.name === litKey);
|
|
@@ -6036,6 +6041,13 @@ export function lowerAbsenceProbe(L, node) {
|
|
|
6036
6041
|
const target = L.fieldTarget(expr);
|
|
6037
6042
|
if (target?.container !== "recordOvf")
|
|
6038
6043
|
return null;
|
|
6044
|
+
// A JS file-scope object-literal global is record-shaped to the
|
|
6045
|
+
// checker but stored in the checked-dynamic tree to preserve object
|
|
6046
|
+
// identity. Reuse the normal dyn-aware field read; constructing a
|
|
6047
|
+
// recordKeyGet here would give the validator a dyn receiver.
|
|
6048
|
+
if (target.obj.type.kind === "dyn") {
|
|
6049
|
+
return L.fieldGetExpr(target, locOf(expr), expr);
|
|
6050
|
+
}
|
|
6039
6051
|
if (target.fieldType.kind === "union" &&
|
|
6040
6052
|
L.armTag(target.fieldType.unionId, UNDEFINED_T) >= 0) {
|
|
6041
6053
|
return null;
|
|
@@ -7627,7 +7639,7 @@ function errorRootedObjectOf(L, t) {
|
|
|
7627
7639
|
if (rooted(direct))
|
|
7628
7640
|
return direct;
|
|
7629
7641
|
if (t.isIntersectionType()) {
|
|
7630
|
-
for (const part of
|
|
7642
|
+
for (const part of ts.constituentTypes(t)) {
|
|
7631
7643
|
const m = L.mapTypeOf(part);
|
|
7632
7644
|
if (rooted(m))
|
|
7633
7645
|
return m;
|
|
@@ -7882,7 +7894,7 @@ function aliasTypeofArmOf(L, e, strip) {
|
|
|
7882
7894
|
const arm = def.arms[tags[0]];
|
|
7883
7895
|
// The checker-side arm: the union part whose (widened) mapping IS
|
|
7884
7896
|
// the proven IR arm — what typeOf answers inside the branch.
|
|
7885
|
-
const parts = valT.isUnionType() ?
|
|
7897
|
+
const parts = valT.isUnionType() ? ts.constituentTypes(valT) : [valT];
|
|
7886
7898
|
const tsArm = parts.find((p) => {
|
|
7887
7899
|
const m = L.mapTypeOf(L.checker.getBaseTypeOfLiteralType(p));
|
|
7888
7900
|
return m !== null && typeEquals(m, arm);
|