@scriptc/compiler 0.3.5 → 0.3.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/ambient/scriptc-node-fallback.d.ts +278 -32
- package/dist/backend/llvm/dyn.js +31 -1
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +45 -1
- package/dist/backend/llvm/emitter.js +412 -104
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-dispatch.js +1 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +25 -1
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +11 -0
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +28 -1
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +61 -1
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +21 -3
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +10 -0
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +43 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-test.js +16 -3
- package/dist/backend/llvm/lib-test.js.map +1 -1
- package/dist/backend/llvm/nullable-unions.d.ts +6 -3
- package/dist/backend/llvm/nullable-unions.js +2 -0
- package/dist/backend/llvm/nullable-unions.js.map +1 -1
- package/dist/backend/llvm/record-results.d.ts +1 -1
- package/dist/backend/llvm/record-results.js +2 -2
- package/dist/backend/llvm/record-results.js.map +1 -1
- package/dist/backend/llvm/reference-writes.js +1 -0
- package/dist/backend/llvm/reference-writes.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +3 -0
- package/dist/backend/llvm/shapes.js +5 -0
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/speculative-integers.d.ts +74 -0
- package/dist/backend/llvm/speculative-integers.js +571 -0
- package/dist/backend/llvm/speculative-integers.js.map +1 -0
- package/dist/backend/llvm/speculative-integers.test.d.ts +1 -0
- package/dist/backend/llvm/speculative-integers.test.js +148 -0
- package/dist/backend/llvm/speculative-integers.test.js.map +1 -0
- package/dist/backend/may-throw.js +2 -0
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/native/executable.js +3 -0
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +1 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/runtime-pack.d.ts +7 -3
- package/dist/backend/runtime-pack.js +12 -6
- package/dist/backend/runtime-pack.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +15 -6
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/contracts/check.js +1 -0
- package/dist/contracts/check.js.map +1 -1
- package/dist/coverage/surface-manifest.js +3 -3
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +1 -1
- package/dist/diagnostics/diagnostic.js +6 -2
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/builtin-calls.js +10 -0
- package/dist/frontend/lowering/builtin-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/callable-aliases.js +31 -3
- package/dist/frontend/lowering/builtins/callable-aliases.js.map +1 -1
- package/dist/frontend/lowering/builtins/compression.d.ts +9 -0
- package/dist/frontend/lowering/builtins/compression.js +145 -30
- package/dist/frontend/lowering/builtins/compression.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.js +12 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/errors.js +5 -3
- package/dist/frontend/lowering/builtins/errors.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +4 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +11 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem.d.ts +8 -0
- package/dist/frontend/lowering/builtins/filesystem.js +139 -2
- package/dist/frontend/lowering/builtins/filesystem.js.map +1 -1
- package/dist/frontend/lowering/builtins/hash-stream.d.ts +12 -0
- package/dist/frontend/lowering/builtins/hash-stream.js +80 -0
- package/dist/frontend/lowering/builtins/hash-stream.js.map +1 -0
- package/dist/frontend/lowering/builtins/module-calls.js +13 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/process.js +9 -2
- package/dist/frontend/lowering/builtins/process.js.map +1 -1
- package/dist/frontend/lowering/builtins/readline.d.ts +45 -13
- package/dist/frontend/lowering/builtins/readline.js +812 -47
- package/dist/frontend/lowering/builtins/readline.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.d.ts +4 -0
- package/dist/frontend/lowering/builtins/workers.js +58 -0
- package/dist/frontend/lowering/builtins/workers.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +55 -0
- package/dist/frontend/lowering/class-protocols.js +735 -0
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/containers/array-from-async.d.ts +18 -0
- package/dist/frontend/lowering/containers/array-from-async.js +282 -0
- package/dist/frontend/lowering/containers/array-from-async.js.map +1 -0
- package/dist/frontend/lowering/containers/collection-grouping.js +2 -1
- package/dist/frontend/lowering/containers/collection-grouping.js.map +1 -1
- package/dist/frontend/lowering/containers/collection-methods.js +27 -23
- package/dist/frontend/lowering/containers/collection-methods.js.map +1 -1
- package/dist/frontend/lowering/divergences.js +188 -15
- package/dist/frontend/lowering/divergences.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +71 -22
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +39 -1
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +10 -1
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +107 -13
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +23 -3
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-mock.d.ts +11 -1
- package/dist/frontend/lowering/lower-mock.js +377 -61
- package/dist/frontend/lowering/lower-mock.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +1 -0
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +161 -16
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +48 -7
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +1 -3
- package/dist/frontend/lowering/lower-stream.js +317 -20
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lower-test.js +147 -48
- package/dist/frontend/lowering/lower-test.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +10 -0
- package/dist/frontend/lowering/lowerer.js +8 -0
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/null-prototype.d.ts +13 -0
- package/dist/frontend/lowering/null-prototype.js +33 -0
- package/dist/frontend/lowering/null-prototype.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -3
- package/dist/frontend/lowering/surfaces.js +27 -5
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/mock-shapes.d.ts +5 -0
- package/dist/frontend/mock-shapes.js +27 -2
- package/dist/frontend/mock-shapes.js.map +1 -1
- package/dist/frontend/program.js +5 -4
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/type-mapper.js +95 -4
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +36 -0
- package/dist/ir/builtin-effects.js.map +1 -1
- package/dist/ir/builtin-signatures.d.ts +1 -1
- package/dist/ir/builtin-signatures.js +167 -6
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/function-references.test.js +1 -0
- package/dist/ir/function-references.test.js.map +1 -1
- package/dist/ir/int32-slots.js +22 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +28 -0
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-loop-facts.d.ts +14 -6
- package/dist/ir/integer-loop-facts.js +119 -35
- package/dist/ir/integer-loop-facts.js.map +1 -1
- package/dist/ir/integer-ranges.js +1 -5
- package/dist/ir/integer-ranges.js.map +1 -1
- package/dist/ir/integer-ranges.test.js +60 -0
- package/dist/ir/integer-ranges.test.js.map +1 -1
- package/dist/ir/ir.d.ts +13 -0
- package/dist/ir/ir.js +4 -0
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/runtime-features.d.ts +3 -1
- package/dist/ir/runtime-features.js +96 -6
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/runtime-features.test.js +62 -0
- package/dist/ir/runtime-features.test.js.map +1 -1
- package/dist/ir/traverse.js +4 -0
- package/dist/ir/traverse.js.map +1 -1
- package/dist/ir/validate.js +45 -3
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +38 -0
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/ir-policy.js +5 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +31 -19
|
@@ -981,13 +981,42 @@ export function isOsConstantsSymbol(symbol, ctx, types = false) {
|
|
|
981
981
|
/** worker_threads' Worker and MessagePort: owned runtime handles that keep
|
|
982
982
|
* their live object representation (DYN) wherever they are stored. */
|
|
983
983
|
function isWorkerHandleSymbol(symbol, ctx) {
|
|
984
|
-
return ((symbol?.name === "Worker" ||
|
|
984
|
+
return ((symbol?.name === "Worker" ||
|
|
985
|
+
symbol?.name === "MessagePort" ||
|
|
986
|
+
symbol?.name === "MessageChannel") &&
|
|
985
987
|
ctx.checker
|
|
986
988
|
.declarationsOf(symbol)
|
|
987
989
|
.some((d) => (ts.isClassDeclaration(d) || ts.isInterfaceDeclaration(d)) &&
|
|
988
990
|
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
989
991
|
isDeclaredInAmbientModule(d, "worker_threads")));
|
|
990
992
|
}
|
|
993
|
+
/** The `{ message: any }` object type (or its union with undefined) that
|
|
994
|
+
* worker_threads declares as receiveMessageOnPort's result. */
|
|
995
|
+
function isReceiveMessageResult(type, ctx) {
|
|
996
|
+
const members = type.isUnionType() ? ts.constituentTypes(type) : [type];
|
|
997
|
+
let found = false;
|
|
998
|
+
for (const member of members) {
|
|
999
|
+
if (member.flags & ts.TypeFlags.Undefined)
|
|
1000
|
+
continue;
|
|
1001
|
+
const decl = member.getSymbol()
|
|
1002
|
+
? ctx.checker.declarationsOf(member.getSymbol())[0]
|
|
1003
|
+
: undefined;
|
|
1004
|
+
let fn = decl?.parent;
|
|
1005
|
+
while (fn && ts.isUnionTypeNode(fn))
|
|
1006
|
+
fn = fn.parent;
|
|
1007
|
+
if (!decl ||
|
|
1008
|
+
!ts.isTypeLiteralNode(decl) ||
|
|
1009
|
+
!fn ||
|
|
1010
|
+
!ts.isFunctionDeclaration(fn) ||
|
|
1011
|
+
fn.name?.text !== "receiveMessageOnPort" ||
|
|
1012
|
+
!ctx.isStdlibFile(decl.getSourceFile()) ||
|
|
1013
|
+
!isDeclaredInAmbientModule(fn, "worker_threads")) {
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
found = true;
|
|
1017
|
+
}
|
|
1018
|
+
return found;
|
|
1019
|
+
}
|
|
991
1020
|
/** True for a type built only from worker handles, null/undefined, and
|
|
992
1021
|
* arrays of those: values that keep the live DYN representation. */
|
|
993
1022
|
export function isWorkerHandleType(type, ctx) {
|
|
@@ -1070,6 +1099,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1070
1099
|
if (moduleId !== null)
|
|
1071
1100
|
return { kind: "moduleNs", moduleId };
|
|
1072
1101
|
}
|
|
1102
|
+
// worker_threads.receiveMessageOnPort's `{ message: any } | undefined`:
|
|
1103
|
+
// the runtime's { message } object, a checked-dynamic value.
|
|
1104
|
+
if (isReceiveMessageResult(type, ctx))
|
|
1105
|
+
return DYN;
|
|
1073
1106
|
// @types/node spells child_process.ExecFileException as an intersection
|
|
1074
1107
|
// type alias over two Error-derived metadata interfaces. The value is
|
|
1075
1108
|
// still one ordinary Error; recognize the owned alias before generic
|
|
@@ -1721,6 +1754,27 @@ function mapTypeInner(type, ctx) {
|
|
|
1721
1754
|
isDeclaredInAmbientModule(d, "readline/promises")))) {
|
|
1722
1755
|
return F64;
|
|
1723
1756
|
}
|
|
1757
|
+
// readline.Key: emitKeys' key object stays a checked-dynamic value, so
|
|
1758
|
+
// it keeps Node's own shape (an undefined name, the escape sequences'
|
|
1759
|
+
// code member).
|
|
1760
|
+
if (psym?.name === "Key" &&
|
|
1761
|
+
checker
|
|
1762
|
+
.declarationsOf(psym)
|
|
1763
|
+
.some((d) => ts.isInterfaceDeclaration(d) &&
|
|
1764
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1765
|
+
(isDeclaredInAmbientModule(d, "readline") ||
|
|
1766
|
+
isDeclaredInAmbientModule(d, "readline/promises")))) {
|
|
1767
|
+
return DYN;
|
|
1768
|
+
}
|
|
1769
|
+
// readline/promises.Readline: an f64 handle the same way.
|
|
1770
|
+
if (psym?.name === "Readline" &&
|
|
1771
|
+
checker
|
|
1772
|
+
.declarationsOf(psym)
|
|
1773
|
+
.some((d) => (ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d)) &&
|
|
1774
|
+
ctx.isStdlibFile(d.getSourceFile()) &&
|
|
1775
|
+
isDeclaredInAmbientModule(d, "readline/promises"))) {
|
|
1776
|
+
return F64;
|
|
1777
|
+
}
|
|
1724
1778
|
// diagnostics_channel.Channel: the channel value is an f64 handle into
|
|
1725
1779
|
// the runtime's channel registry (the readline.Interface precedent —
|
|
1726
1780
|
// Node's channels are process-lived too, its WeakRef machinery aside).
|
|
@@ -1936,9 +1990,10 @@ function mapTypeInner(type, ctx) {
|
|
|
1936
1990
|
// The stdlib Console interface (the global console and node:console
|
|
1937
1991
|
// Console instances) is a native handle carried by the checked-dynamic
|
|
1938
1992
|
// representation and consumed by the console method lowerings. The
|
|
1939
|
-
// stdlib Disposable (events.addAbortListener's result)
|
|
1940
|
-
//
|
|
1941
|
-
|
|
1993
|
+
// stdlib Disposable (events.addAbortListener's result) and
|
|
1994
|
+
// AsyncDisposable are checked objects carrying their Symbol.dispose or
|
|
1995
|
+
// Symbol.asyncDispose method.
|
|
1996
|
+
if ((psym?.name === "Console" || psym?.name === "Disposable" || psym?.name === "AsyncDisposable") &&
|
|
1942
1997
|
checker
|
|
1943
1998
|
.declarationsOf(psym)
|
|
1944
1999
|
.some((d) => ts.isInterfaceDeclaration(d) && ctx.isStdlibFile(d.getSourceFile()))) {
|
|
@@ -2942,6 +2997,16 @@ function mapTypeInner(type, ctx) {
|
|
|
2942
2997
|
ctx.isStdlibFile(d.getSourceFile()))) {
|
|
2943
2998
|
return { kind: "record", shapeId: perfEntryShape(ctx.shapes, ctx.unions) };
|
|
2944
2999
|
}
|
|
3000
|
+
// readline's getCursorPos() record, in Node's key order ({ cols, rows }).
|
|
3001
|
+
if (isStdlibInterface("CursorPos")) {
|
|
3002
|
+
return {
|
|
3003
|
+
kind: "record",
|
|
3004
|
+
shapeId: ctx.shapes.intern([
|
|
3005
|
+
{ name: "cols", type: F64 },
|
|
3006
|
+
{ name: "rows", type: F64 },
|
|
3007
|
+
], false, undefined, ["cols", "rows"]),
|
|
3008
|
+
};
|
|
3009
|
+
}
|
|
2945
3010
|
// process.memoryUsage()'s record, in Node's key order.
|
|
2946
3011
|
if (isStdlibInterface("MemoryUsage")) {
|
|
2947
3012
|
const names = ["rss", "heapTotal", "heapUsed", "external", "arrayBuffers"];
|
|
@@ -3099,6 +3164,14 @@ function mapTypeInner(type, ctx) {
|
|
|
3099
3164
|
checker.getPropertiesOfType(widened).length > 0)
|
|
3100
3165
|
return DYN;
|
|
3101
3166
|
}
|
|
3167
|
+
// A union of such hybrids that all map to ONE record is that record:
|
|
3168
|
+
// node:test's Mock<F | Implementation> distributes to (F & { mock }) |
|
|
3169
|
+
// (Implementation & { mock }), and the two function types can map alike.
|
|
3170
|
+
if (widened.isUnionType()) {
|
|
3171
|
+
const hybrid = mapUniformHybridUnion(widened, ctx);
|
|
3172
|
+
if (hybrid)
|
|
3173
|
+
return hybrid;
|
|
3174
|
+
}
|
|
3102
3175
|
const callSigs = checker.getCallSignatures(widened);
|
|
3103
3176
|
if (callSigs.length === 1) {
|
|
3104
3177
|
const sig = callSigs[0];
|
|
@@ -4209,6 +4282,23 @@ function mapHybridCallableIntersection(widened, ctx) {
|
|
|
4209
4282
|
fields.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
4210
4283
|
return { kind: "record", shapeId: shapes.intern(fields, false, undefined, declaredOrder) };
|
|
4211
4284
|
}
|
|
4285
|
+
/** The record every part of a union of function-with-properties
|
|
4286
|
+
* intersections maps to, or null when a part does not map to the same one. */
|
|
4287
|
+
function mapUniformHybridUnion(widened, ctx) {
|
|
4288
|
+
const parts = ts.constituentTypes(widened);
|
|
4289
|
+
if (!parts.every((p) => p.isIntersectionType()))
|
|
4290
|
+
return null;
|
|
4291
|
+
let first = null;
|
|
4292
|
+
for (const part of parts) {
|
|
4293
|
+
if (ctx.checker.getConstructSignatures(part).length > 0)
|
|
4294
|
+
return null;
|
|
4295
|
+
const mapped = mapHybridCallableIntersection(part, ctx);
|
|
4296
|
+
if (!mapped || (first && typeKey(mapped) !== typeKey(first)))
|
|
4297
|
+
return null;
|
|
4298
|
+
first ??= mapped;
|
|
4299
|
+
}
|
|
4300
|
+
return first;
|
|
4301
|
+
}
|
|
4212
4302
|
/** Optional standard error metadata refines an existing Error identity;
|
|
4213
4303
|
* it does not allocate a structural copy or extend its native layout. */
|
|
4214
4304
|
function mapErrorMetadataIntersection(type, ctx) {
|
|
@@ -4227,6 +4317,7 @@ function mapErrorMetadataIntersection(type, ctx) {
|
|
|
4227
4317
|
"TypeError",
|
|
4228
4318
|
"URIError",
|
|
4229
4319
|
"AggregateError",
|
|
4320
|
+
"SuppressedError",
|
|
4230
4321
|
].includes(symbol.name) &&
|
|
4231
4322
|
ctx.checker.declarationsOf(symbol).some((decl) => ctx.isStdlibFile(decl.getSourceFile())));
|
|
4232
4323
|
});
|