@scriptc/compiler 0.0.22 → 0.0.23
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 +39 -3
- package/dist/backend/emission/emit-async.js +3 -1
- package/dist/backend/emission/emit-async.js.map +1 -1
- package/dist/backend/emission/emit-exprs.d.ts +10 -0
- package/dist/backend/emission/emit-exprs.js +127 -10
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-stmts.js +13 -5
- package/dist/backend/emission/emit-stmts.js.map +1 -1
- package/dist/backend/emission/emit-types.js +4 -1
- package/dist/backend/emission/emit-types.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +11 -1
- package/dist/backend/emission/emitter.js +61 -1
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.js +304 -21
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +3 -2
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/compat/fetch-profile.d.ts +10 -0
- package/dist/compat/fetch-profile.js +55 -6
- package/dist/compat/fetch-profile.js.map +1 -1
- package/dist/coverage/surface-manifest.js +16 -1
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +10 -0
- package/dist/diagnostics/diagnostic.js +27 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +3 -7
- package/dist/frontend/lowering/lower-builtins.js +80 -55
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +1 -0
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +28 -8
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +1 -1
- package/dist/frontend/lowering/lower-exprs.js +25 -4
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +7 -1
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +21 -0
- package/dist/frontend/lowering/lower-island.js +284 -10
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +8 -4
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +1 -0
- package/dist/frontend/lowering/lowerer.js +6 -2
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.js +43 -12
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/program.d.ts +4 -4
- package/dist/frontend/program.js +264 -46
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.d.ts +10 -0
- package/dist/frontend/resolve.js +37 -0
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/ts7/enums.d.ts +9 -0
- package/dist/frontend/ts7/enums.js +8 -6
- package/dist/frontend/ts7/enums.js.map +1 -1
- package/dist/frontend/ts7/program.js +4 -1
- package/dist/frontend/ts7/program.js.map +1 -1
- package/dist/frontend/types.d.ts +4 -4
- package/dist/frontend/types.js +25 -8
- package/dist/frontend/types.js.map +1 -1
- package/dist/ir/nodes.d.ts +24 -11
- package/dist/ir/nodes.js +6 -1
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +45 -8
- package/dist/ir/validate.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +137 -28
|
@@ -785,6 +785,41 @@ export function lowerBuiltinModuleCall(L, expr, bi, fn, loc) {
|
|
|
785
785
|
if (bi.module === "fs" && bi.member === "watch") {
|
|
786
786
|
return lowerFsWatchCall(L, expr, loc);
|
|
787
787
|
}
|
|
788
|
+
// fs.readSync(fd, buffer, offset, length[, position]) — normalize the
|
|
789
|
+
// current-offset forms to Node/libuv's -1 sentinel so the IR and native
|
|
790
|
+
// ABI stay fixed-width. A real numeric position is a positioned read
|
|
791
|
+
// and therefore must not advance the descriptor. Literal null is the
|
|
792
|
+
// documented current-offset spelling; richer nullable expressions must
|
|
793
|
+
// narrow first so no effectful evaluation is silently discarded.
|
|
794
|
+
if (bi.module === "fs" && bi.member === "readSync") {
|
|
795
|
+
const supported = "use readSync(fd, buffer, offset, length[, position]) with a numeric position or literal null; options objects and bigint positions have no lowering";
|
|
796
|
+
if ((expr.arguments.length !== 4 && expr.arguments.length !== 5) ||
|
|
797
|
+
expr.arguments.some(ts.isSpreadElement)) {
|
|
798
|
+
L.noLowering(`readSync with ${expr.arguments.length} argument${expr.arguments.length === 1 ? "" : "s"}`, expr, supported);
|
|
799
|
+
}
|
|
800
|
+
const args = [
|
|
801
|
+
L.lowerExprExpecting(expr.arguments[0], F64),
|
|
802
|
+
L.lowerExprExpecting(expr.arguments[1], BYTES_U8),
|
|
803
|
+
L.lowerExprExpecting(expr.arguments[2], F64),
|
|
804
|
+
L.lowerExprExpecting(expr.arguments[3], F64),
|
|
805
|
+
];
|
|
806
|
+
const positionNode = expr.arguments[4];
|
|
807
|
+
let positionValueNode = positionNode;
|
|
808
|
+
while (positionValueNode && ts.isParenthesizedExpression(positionValueNode)) {
|
|
809
|
+
positionValueNode = positionValueNode.expression;
|
|
810
|
+
}
|
|
811
|
+
if (positionNode === undefined || positionValueNode.kind === ts.SyntaxKind.NullKeyword) {
|
|
812
|
+
args.push({ kind: "numLit", value: -1, type: F64, loc });
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
const positionType = L.mapTypeOf(L.typeOf(positionNode));
|
|
816
|
+
if (positionType?.kind !== "f64") {
|
|
817
|
+
L.noLowering(`readSync with a '${positionType ? L.fmt(positionType) : L.checker.typeToString(L.typeOf(positionNode))}' position`, positionNode, supported);
|
|
818
|
+
}
|
|
819
|
+
args.push(L.lowerExprExpecting(positionNode, F64));
|
|
820
|
+
}
|
|
821
|
+
return { kind: "libCall", fn: "fs.readSync", args, type: F64, loc };
|
|
822
|
+
}
|
|
788
823
|
if (bi.module === "child_process" &&
|
|
789
824
|
(bi.member === "execFileSync" || bi.member === "execSync")) {
|
|
790
825
|
return L.lowerExecSyncCall(expr, bi.member === "execSync", loc);
|
|
@@ -5326,13 +5361,29 @@ export function lowerNumberStaticCall(L, call, access) {
|
|
|
5326
5361
|
}
|
|
5327
5362
|
return null; // other Number statics land on the member fence
|
|
5328
5363
|
}
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5364
|
+
const DATE_GETTER_FNS = {
|
|
5365
|
+
getFullYear: "date.getFullYear",
|
|
5366
|
+
getUTCFullYear: "date.getUTCFullYear",
|
|
5367
|
+
getMonth: "date.getMonth",
|
|
5368
|
+
getUTCMonth: "date.getUTCMonth",
|
|
5369
|
+
getDate: "date.getDate",
|
|
5370
|
+
getUTCDate: "date.getUTCDate",
|
|
5371
|
+
getDay: "date.getDay",
|
|
5372
|
+
getUTCDay: "date.getUTCDay",
|
|
5373
|
+
getHours: "date.getHours",
|
|
5374
|
+
getUTCHours: "date.getUTCHours",
|
|
5375
|
+
getMinutes: "date.getMinutes",
|
|
5376
|
+
getUTCMinutes: "date.getUTCMinutes",
|
|
5377
|
+
getSeconds: "date.getSeconds",
|
|
5378
|
+
getUTCSeconds: "date.getUTCSeconds",
|
|
5379
|
+
getMilliseconds: "date.getMilliseconds",
|
|
5380
|
+
getUTCMilliseconds: "date.getUTCMilliseconds",
|
|
5381
|
+
getTimezoneOffset: "date.getTimezoneOffset",
|
|
5382
|
+
};
|
|
5383
|
+
const DATE_METHOD_HINT = "getTime(), valueOf(), toISOString(), the local/UTC calendar getters, and getTimezoneOffset() are supported; Date setters and locale/string formatters have no lowering";
|
|
5384
|
+
/** The Date slice: statics plus read-only Date values backed by one
|
|
5385
|
+
* TimeClip'd millisecond scalar. Construction lives in lowerNew;
|
|
5386
|
+
* identity and mutating methods remain fenced. */
|
|
5336
5387
|
export function lowerDateCall(L, call, access) {
|
|
5337
5388
|
if (call.questionDotToken || access.questionDotToken)
|
|
5338
5389
|
return null;
|
|
@@ -5363,60 +5414,34 @@ export function lowerDateCall(L, call, access) {
|
|
|
5363
5414
|
}
|
|
5364
5415
|
return { kind: "libCall", fn: "date.utc", args, type: F64, loc };
|
|
5365
5416
|
}
|
|
5366
|
-
if (
|
|
5417
|
+
if (L.mapTypeOf(L.typeOf(access.expression))?.kind !== "date")
|
|
5367
5418
|
return null;
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
|
|
5371
|
-
const sym = L.resolveValueSymbol(recv.expression);
|
|
5372
|
-
if (!sym || sym.name !== "Date" || !L.isStdlibSymbol(sym))
|
|
5373
|
-
return null;
|
|
5374
|
-
if (access.name.text === "getTime") {
|
|
5375
|
-
// The composed `new Date(x).getTime()` read — the Date value
|
|
5376
|
-
// between the two never materializes (the toISOString precedent).
|
|
5377
|
-
// new Date().getTime() IS Date.now(); the STRING form parses the
|
|
5378
|
-
// bounded date-string grammar (the X509 validity shape portless's
|
|
5379
|
-
// cert-expiry check reads, plus ECMA's own date-time format) and
|
|
5380
|
-
// answers NaN elsewhere — a documented divergence from V8's wider
|
|
5381
|
-
// parser. The ms form is pointless composition; the fence points at
|
|
5382
|
-
// the value.
|
|
5383
|
-
if (call.arguments.length !== 0) {
|
|
5384
|
-
L.noLowering("getTime with arguments", call);
|
|
5385
|
-
}
|
|
5386
|
-
const ctorArgs = recv.arguments ?? [];
|
|
5387
|
-
if (ctorArgs.length === 0) {
|
|
5388
|
-
return { kind: "libCall", fn: "date.now", args: [], type: F64, loc };
|
|
5389
|
-
}
|
|
5390
|
-
if (ctorArgs.length !== 1) {
|
|
5391
|
-
L.noLowering("new Date with year/month/day arguments", recv, "the field constructor is local-time; only new Date() and new Date(dateString) compose with .getTime()");
|
|
5392
|
-
}
|
|
5393
|
-
const arg = L.lowerExpr(ctorArgs[0]);
|
|
5394
|
-
if (arg.type.kind !== "string") {
|
|
5395
|
-
L.noLowering(`new Date of '${L.fmt(arg.type)}' values composed with .getTime()`, ctorArgs[0], arg.type.kind === "f64"
|
|
5396
|
-
? "new Date(ms).getTime() is the ms value — use it directly (or Date.now())"
|
|
5397
|
-
: "the composed form parses date STRINGS — narrow unions first");
|
|
5398
|
-
}
|
|
5399
|
-
return { kind: "libCall", fn: "date.parseGetTime", args: [arg], type: F64, loc };
|
|
5400
|
-
}
|
|
5419
|
+
if (!L.isStdlibMember(access))
|
|
5420
|
+
return null;
|
|
5421
|
+
const name = access.name.text;
|
|
5401
5422
|
if (call.arguments.length !== 0) {
|
|
5402
|
-
L.noLowering(
|
|
5423
|
+
L.noLowering(`Date.prototype.${name} with arguments`, call, DATE_METHOD_HINT);
|
|
5403
5424
|
}
|
|
5404
|
-
const
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5425
|
+
const receiver = L.lowerExpr(access.expression);
|
|
5426
|
+
if (receiver.type.kind !== "date")
|
|
5427
|
+
L.badType(access.expression, L.typeOf(access.expression));
|
|
5428
|
+
if (name === "getTime" || name === "valueOf") {
|
|
5429
|
+
return {
|
|
5430
|
+
kind: "libCall",
|
|
5431
|
+
fn: name === "getTime" ? "date.getTime" : "date.valueOf",
|
|
5432
|
+
args: [receiver],
|
|
5433
|
+
type: F64,
|
|
5434
|
+
loc,
|
|
5435
|
+
};
|
|
5408
5436
|
}
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
if (arg.type.kind !== "f64") {
|
|
5412
|
-
L.noLowering(`new Date of '${L.fmt(arg.type)}' values`, ctorArgs[0], "only the milliseconds form composes — new Date(ms).toISOString(); date-string parsing has no lowering");
|
|
5413
|
-
}
|
|
5414
|
-
ms = arg;
|
|
5437
|
+
if (name === "toISOString") {
|
|
5438
|
+
return { kind: "libCall", fn: "date.toISOStringValue", args: [receiver], type: STRING, loc };
|
|
5415
5439
|
}
|
|
5416
|
-
|
|
5417
|
-
|
|
5440
|
+
const fn = DATE_GETTER_FNS[name];
|
|
5441
|
+
if (fn !== undefined) {
|
|
5442
|
+
return { kind: "libCall", fn, args: [receiver], type: F64, loc };
|
|
5418
5443
|
}
|
|
5419
|
-
|
|
5444
|
+
L.noLowering(`Date.prototype.${name}`, call, DATE_METHOD_HINT, L.checker.getSymbolAtLocation(access.name));
|
|
5420
5445
|
}
|
|
5421
5446
|
/** A direct construction of THE stdlib TextEncoder/TextDecoder, through
|
|
5422
5447
|
* type-only wrappers. Name alone is never enough: a user class with the
|