@scriptc/compiler 0.0.10 → 0.0.12
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 +63 -15
- package/ambient/scriptc.d.ts +2 -2
- package/dist/backend/cc.d.ts +2 -2
- package/dist/backend/emission/emit-async.js +1 -1
- package/dist/backend/emission/emit-exprs.js +131 -54
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-island.js +1 -1
- package/dist/backend/emission/emit-shapes.js +1 -1
- package/dist/backend/emission/emit-walkers.d.ts +14 -14
- package/dist/backend/emission/emit-walkers.js +44 -44
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +3 -3
- package/dist/backend/emission/emitter.js +33 -9
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/emission/may-throw.js +1 -1
- package/dist/backend/llvm/dyn.d.ts +10 -10
- package/dist/backend/llvm/dyn.js +26 -26
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +156 -47
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/shapes.js +1 -1
- package/dist/backend/llvm/walkers.js +2 -2
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/coverage/surface-manifest.js +16 -2
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +21 -8
- package/dist/diagnostics/diagnostic.js +48 -14
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +5 -5
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +12 -12
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +63 -7
- package/dist/frontend/lowering/lower-builtins.js +327 -35
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +4 -4
- package/dist/frontend/lowering/lower-calls.js +104 -70
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +7 -0
- package/dist/frontend/lowering/lower-classes.js +82 -6
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +9 -5
- package/dist/frontend/lowering/lower-containers.js +88 -26
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-emitter.d.ts +70 -3
- package/dist/frontend/lowering/lower-emitter.js +438 -31
- package/dist/frontend/lowering/lower-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +87 -12
- package/dist/frontend/lowering/lower-exprs.js +630 -125
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.js +5 -5
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.js +12 -3
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +8 -5
- package/dist/frontend/lowering/lower-modules.js +157 -63
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +24 -0
- package/dist/frontend/lowering/lower-namespaces.js +158 -16
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +11 -11
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +1 -1
- package/dist/frontend/lowering/lower-stmts.js +271 -36
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +171 -20
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +27 -10
- package/dist/frontend/lowering/lowerer.js +156 -54
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +44 -0
- package/dist/frontend/lowering/surfaces.js +236 -5
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm.d.ts +12 -0
- package/dist/frontend/npm.js +30 -0
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/program.d.ts +25 -0
- package/dist/frontend/program.js +145 -136
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/shared.d.ts +1 -1
- package/dist/frontend/shared.js +8 -8
- package/dist/frontend/shared.js.map +1 -1
- package/dist/frontend/types.d.ts +2 -2
- package/dist/frontend/types.js +15 -15
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +169 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +174 -106
- package/dist/ir/nodes.js +69 -24
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +55 -36
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.js +12 -2
- package/dist/library/fence-eval.js.map +1 -1
- package/dist/library/int-infer.d.ts +119 -0
- package/dist/library/int-infer.js +1314 -0
- package/dist/library/int-infer.js.map +1 -0
- package/dist/library/int-infer.test.d.ts +1 -0
- package/dist/library/int-infer.test.js +279 -0
- package/dist/library/int-infer.test.js.map +1 -0
- package/dist/library/profile.d.ts +34 -5
- package/dist/library/profile.js +77 -13
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar-validate.js +1 -1
- package/dist/library/sidecar-validate.js.map +1 -1
- package/dist/library/sidecar.d.ts +24 -1
- package/dist/library/sidecar.js +163 -16
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +210 -12
|
@@ -2,6 +2,7 @@ import * as ts from "../ts7/adapter.js";
|
|
|
2
2
|
import type { Lowerer } from "./lowerer.js";
|
|
3
3
|
import { IrClassDef, IrExpr, IrFunction, IrLocal, IrStmt, IrType, SrcLoc } from "../../ir/nodes.js";
|
|
4
4
|
import { type GenericFnInfo, type ParamShape } from "./lower-calls.js";
|
|
5
|
+
import { type EmitOverrideRec } from "./lower-emitter.js";
|
|
5
6
|
import { type MixinInstanceInfo } from "./lower-mixins.js";
|
|
6
7
|
export interface ClassInfo {
|
|
7
8
|
def: IrClassDef;
|
|
@@ -81,6 +82,12 @@ export interface ClassInfo {
|
|
|
81
82
|
* the base chain. The value names which SIDES the class carries. User
|
|
82
83
|
* `extends` of these classes is fenced at the declaration (phase 1). */
|
|
83
84
|
builtinStream?: "r" | "w" | "rw";
|
|
85
|
+
/** This class's own `emit` override in the FORWARDING SHAPE (the one
|
|
86
|
+
* EventEmitter member a subclass may re-declare): never in `methods` —
|
|
87
|
+
* emit calls keep routing through the emitter spoke, which lowers the
|
|
88
|
+
* body once per event name as the specialization method `emit:<event>`
|
|
89
|
+
* (lower-emitter.ts's emit-overrides block has the whole story). */
|
|
90
|
+
emitOverride?: EmitOverrideRec;
|
|
84
91
|
ctor: ts.ConstructorDeclaration | null;
|
|
85
92
|
/** PARAMETER PROPERTIES (`constructor(public x: number)`), in parameter
|
|
86
93
|
* order: each declares a field (placed BEFORE the class's declared
|
|
@@ -14,6 +14,7 @@ import { pureReemittable } from "./lower-exprs.js";
|
|
|
14
14
|
import { lowerSearchParamsNew } from "./lower-builtins.js";
|
|
15
15
|
import { requiresDynamicPackageDiag, unsupportedDiag } from "../../diagnostics/diagnostic.js";
|
|
16
16
|
import { STREAM_API_MEMBERS, STREAM_PROP_MEMBERS, UNDERSCORE_METHODS, lowerStreamNew, lowerStreamSuperCall, streamCtorShape } from "./lower-stream.js";
|
|
17
|
+
import { emitOverrideShapeReason, emitSpecSuperForward, emitterRooted, lowerEmitterSuperCall } from "./lower-emitter.js";
|
|
17
18
|
import { declSymbolOf } from "./lower-modules.js";
|
|
18
19
|
import { uniqueSymbolKeyOf } from "./lower-exprs.js";
|
|
19
20
|
import { lowerHttpServerNew } from "./lower-server.js";
|
|
@@ -473,6 +474,32 @@ export function collectClassShape(L, decl) {
|
|
|
473
474
|
}
|
|
474
475
|
}
|
|
475
476
|
}
|
|
477
|
+
// A poisoned BASE this class EXTENDS must report EAGERLY for the same
|
|
478
|
+
// reason: the derived statement evaluates its heritage when module
|
|
479
|
+
// init reaches it (these are top-level declarations), and the base's
|
|
480
|
+
// fence is the COMPILER's, not Node's — Node defines the base fine and
|
|
481
|
+
// runs on — so a deferred trap there is a manufactured divergence, not
|
|
482
|
+
// the Node-parity deferral is licensed by (classFieldSuperAccessibleJs2:
|
|
483
|
+
// the binary refused at `class D extends C` where Node prints five
|
|
484
|
+
// lines). Leaf poisoned classes stay deferred — only the extends edge
|
|
485
|
+
// reports. Resolution runs under the collect pass's guard (this is
|
|
486
|
+
// collectProgram), so the lookup neither flushes nor fences.
|
|
487
|
+
{
|
|
488
|
+
const baseIdent = decl.heritageClauses
|
|
489
|
+
?.find((h) => h.token === ts.SyntaxKind.ExtendsKeyword)
|
|
490
|
+
?.types.map((t) => t.expression)
|
|
491
|
+
.filter(ts.isIdentifier)[0];
|
|
492
|
+
const baseSym = baseIdent ? L.resolveValueSymbol(baseIdent) : null;
|
|
493
|
+
const baseDiags = baseSym ? L.deferredDiags.get(baseSym) : undefined;
|
|
494
|
+
if (baseSym && baseDiags) {
|
|
495
|
+
L.deferredDiags.delete(baseSym);
|
|
496
|
+
if (!L.alreadyFlushed.has(baseSym)) {
|
|
497
|
+
L.flushedSymbols.add(baseSym);
|
|
498
|
+
for (const d of baseDiags)
|
|
499
|
+
L.pushDiag(d);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
476
503
|
}
|
|
477
504
|
export function collectClassShapeInner(L, decl, jsNameOverride, inst,
|
|
478
505
|
/** MIXIN instantiation mode (lower-mixins.ts): the class inside a
|
|
@@ -814,6 +841,10 @@ mixin) {
|
|
|
814
841
|
* symbol-slot refinement retries them after the constructor scan
|
|
815
842
|
* declares this class's OWN symbol-keyed slots. */
|
|
816
843
|
const dynRetMethods = new Map();
|
|
844
|
+
/** The class's own `emit` override in the forwarding shape (emitter-
|
|
845
|
+
* rooted classes only) — recorded here, NEVER in `methods`, so emit
|
|
846
|
+
* calls keep routing through the emitter spoke's dispatch. */
|
|
847
|
+
let emitOverride;
|
|
817
848
|
let ctor = null;
|
|
818
849
|
/** Initializer-less fields whose type cannot hold undefined and whose
|
|
819
850
|
* definite assignment tsc did NOT verify (a `!` assertion, or
|
|
@@ -1011,7 +1042,13 @@ mixin) {
|
|
|
1011
1042
|
// The EventEmitter API surface is runtime-provided: a subclass
|
|
1012
1043
|
// member with one of its names would shadow behavior the runtime
|
|
1013
1044
|
// dispatches internally (meta events, once removal), so the
|
|
1014
|
-
// override is fenced rather than silently split-brained
|
|
1045
|
+
// override is fenced rather than silently split-brained — with ONE
|
|
1046
|
+
// exception: `emit` in the forwarding shape on a plain (non-
|
|
1047
|
+
// stream) emitter-rooted class monomorphizes per event name
|
|
1048
|
+
// (lower-emitter.ts's emit-overrides block). Stream-rooted classes
|
|
1049
|
+
// keep the fence for emit too: the runtime stream machinery emits
|
|
1050
|
+
// 'data'/'end'/... internally, which could never route through
|
|
1051
|
+
// the override.
|
|
1015
1052
|
if (memberName && ts.isIdentifier(memberName) &&
|
|
1016
1053
|
EMITTER_API_MEMBERS.has(memberName.text) &&
|
|
1017
1054
|
(() => {
|
|
@@ -1020,6 +1057,26 @@ mixin) {
|
|
|
1020
1057
|
return true;
|
|
1021
1058
|
return false;
|
|
1022
1059
|
})()) {
|
|
1060
|
+
const streamRooted = (() => {
|
|
1061
|
+
for (let c = base; c; c = c.base)
|
|
1062
|
+
if (c.builtinStream !== undefined)
|
|
1063
|
+
return true;
|
|
1064
|
+
return false;
|
|
1065
|
+
})();
|
|
1066
|
+
if (memberName.text === "emit" && !streamRooted && !inst && !mixin &&
|
|
1067
|
+
ts.isMethodDeclaration(member) &&
|
|
1068
|
+
!member.modifiers?.some((m) => m.kind === ts.SyntaxKind.StaticKeyword)) {
|
|
1069
|
+
const reason = emitOverrideShapeReason(L, member);
|
|
1070
|
+
if (reason === null) {
|
|
1071
|
+
const eventSym = L.checker.getSymbolAtLocation(member.parameters[0].name);
|
|
1072
|
+
const restSym = L.checker.getSymbolAtLocation(member.parameters[1].name);
|
|
1073
|
+
if (eventSym && restSym) {
|
|
1074
|
+
emitOverride = { decl: member, eventSym, restSym };
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
L.unsupported("SC1090", memberName, `overriding EventEmitter's 'emit' outside the forwarding shape (${reason ?? "its parameters do not resolve statically"}; the compiled form is \`emit(event: string, ...args: unknown[]): boolean\`)`);
|
|
1079
|
+
}
|
|
1023
1080
|
L.unsupported("SC1090", memberName, `overriding the EventEmitter member '${memberName.text}' (the runtime owns the emitter surface)`);
|
|
1024
1081
|
}
|
|
1025
1082
|
// The stream surface is likewise runtime-provided on stream-rooted
|
|
@@ -1838,6 +1895,7 @@ mixin) {
|
|
|
1838
1895
|
fieldOrder,
|
|
1839
1896
|
methods,
|
|
1840
1897
|
decl,
|
|
1898
|
+
...(emitOverride !== undefined ? { emitOverride } : {}),
|
|
1841
1899
|
ctor,
|
|
1842
1900
|
ctorParams,
|
|
1843
1901
|
...(paramProps.length > 0 ? { paramProps } : {}),
|
|
@@ -3925,6 +3983,13 @@ export function lowerSuperMethodCall(L, call, access) {
|
|
|
3925
3983
|
// tsc rejects super outside derived-class bodies first; defensive.
|
|
3926
3984
|
L.unsupported("SC1090", access, "'super' outside a derived class");
|
|
3927
3985
|
}
|
|
3986
|
+
// An emit-override SPECIALIZATION body's forward — `super.emit(event,
|
|
3987
|
+
// ...args)` — carries no literal event name; the specialization's own
|
|
3988
|
+
// context answers it (matched before any lookup: neither identifier
|
|
3989
|
+
// resolves through the ordinary lowering).
|
|
3990
|
+
const forward = emitSpecSuperForward(L, call, access);
|
|
3991
|
+
if (forward)
|
|
3992
|
+
return forward;
|
|
3928
3993
|
const found = L.findMethodOn(cls.base, access.name.text);
|
|
3929
3994
|
if (!found) {
|
|
3930
3995
|
// `super.m(...)` of a GENERIC method: super dispatch is static in JS
|
|
@@ -3947,6 +4012,17 @@ export function lowerSuperMethodCall(L, call, access) {
|
|
|
3947
4012
|
loc,
|
|
3948
4013
|
};
|
|
3949
4014
|
}
|
|
4015
|
+
// The runtime-provided emitter surface through `super` —
|
|
4016
|
+
// `super.emit('x', v)`, `super.on(...)`: Node's prototype-chain rule
|
|
4017
|
+
// is STATIC dispatch above the lexical class, which the emitter
|
|
4018
|
+
// spoke lowers with this method's own `this` as the receiver (an
|
|
4019
|
+
// emit override at-or-below `cls` never answers; the nearest one
|
|
4020
|
+
// strictly above does).
|
|
4021
|
+
if (EMITTER_API_MEMBERS.has(access.name.text) && emitterRooted(L, cls.base)) {
|
|
4022
|
+
const viaEmitter = lowerEmitterSuperCall(L, call, access, cls);
|
|
4023
|
+
if (viaEmitter)
|
|
4024
|
+
return viaEmitter;
|
|
4025
|
+
}
|
|
3950
4026
|
L.unsupported("SC1090", access, `'super.${access.name.text}' (no base class declares it)`);
|
|
3951
4027
|
}
|
|
3952
4028
|
// tsc rejects super-access of abstract members (TS2513); defensive —
|
|
@@ -4312,7 +4388,7 @@ export function lowerNew(L, expr) {
|
|
|
4312
4388
|
// like Node's message property default.
|
|
4313
4389
|
const errInfo = L.builtinErrorInfoOf(symbol);
|
|
4314
4390
|
// `new DOMException(message?, nameOrOptions?)`: both arguments cross
|
|
4315
|
-
// as
|
|
4391
|
+
// as dyn values (absent → the dyn undefined), and the runtime owns
|
|
4316
4392
|
// WebIDL's resolution — ToString of the message ("" for undefined),
|
|
4317
4393
|
// name from a string / an options object's `name` member (with the
|
|
4318
4394
|
// `cause` own-property record) / "Error" for absent, and the legacy
|
|
@@ -4573,7 +4649,7 @@ export function lowerNew(L, expr) {
|
|
|
4573
4649
|
const targs = L.checker.getTypeArguments(tsType);
|
|
4574
4650
|
// JAVASCRIPT `new Map()` whose arguments never resolved past
|
|
4575
4651
|
// Map<any, any> (no annotation, no contextual type, no seed): the
|
|
4576
|
-
// WeakMap stance below — the VALUE lowers as an opaque
|
|
4652
|
+
// WeakMap stance below — the VALUE lowers as an opaque dyn object
|
|
4577
4653
|
// (identity and truthiness are real), and every reached METHOD use
|
|
4578
4654
|
// meets its own per-site fence at runtime. The formatter's
|
|
4579
4655
|
// config-cache shape: module init constructs the caches
|
|
@@ -4606,7 +4682,7 @@ export function lowerNew(L, expr) {
|
|
|
4606
4682
|
// `new WeakMap()` / `new WeakSet()` in JAVASCRIPT sources: no weak
|
|
4607
4683
|
// container exists in the value model, but harness code constructs
|
|
4608
4684
|
// one unconditionally and touches it only on paths tests don't
|
|
4609
|
-
// reach — the value lowers as an opaque
|
|
4685
|
+
// reach — the value lowers as an opaque dyn object (identity only;
|
|
4610
4686
|
// every reached METHOD use meets its own per-site fence → runtime
|
|
4611
4687
|
// fence). TypeScript keeps the compile fence.
|
|
4612
4688
|
if ((symbol?.name === "WeakMap" || symbol?.name === "WeakSet") &&
|
|
@@ -4706,14 +4782,14 @@ export function lowerNew(L, expr) {
|
|
|
4706
4782
|
// `new Promise(setImmediate)` (the Node-suite early-exit shape):
|
|
4707
4783
|
// the executor IS the stdlib setImmediate, so resolve rides the
|
|
4708
4784
|
// immediate queue — a dedicated runtime constructor arms an
|
|
4709
|
-
// immediate that fulfills with the undefined
|
|
4785
|
+
// immediate that fulfills with the undefined dyn value.
|
|
4710
4786
|
{
|
|
4711
4787
|
const a0 = args[0];
|
|
4712
4788
|
if (ts.isIdentifier(a0) && a0.text === "setImmediate") {
|
|
4713
4789
|
const sym = L.checker.getSymbolAtLocation(a0);
|
|
4714
4790
|
const decls = sym ? L.checker.declarationsOf(sym) : [];
|
|
4715
4791
|
if (decls.length > 0 && decls.every((d) => L.isStdlibFile(d.getSourceFile()))) {
|
|
4716
|
-
// The settled value is the undefined
|
|
4792
|
+
// The settled value is the undefined dyn value — the result
|
|
4717
4793
|
// is promise<dyn> whatever T the checker inferred for the
|
|
4718
4794
|
// unusual executor (Promise<unknown> in the suite's shape).
|
|
4719
4795
|
return {
|