@scriptc/compiler 0.0.28 → 0.0.30
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 +5 -13
- package/dist/backend/cc.d.ts +23 -2
- package/dist/backend/cc.js +250 -9
- package/dist/backend/cc.js.map +1 -1
- package/dist/backend/emission/emit-async.d.ts +1 -0
- package/dist/backend/emission/emit-async.js +27 -1
- package/dist/backend/emission/emit-async.js.map +1 -1
- package/dist/backend/emission/emit-exprs.js +109 -18
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emitter.d.ts +1 -0
- package/dist/backend/emission/emitter.js +25 -3
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.js +152 -0
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/mangle.d.ts +1 -0
- package/dist/backend/mangle.js +3 -0
- package/dist/backend/mangle.js.map +1 -1
- package/dist/coverage/surface-manifest.js +1 -0
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +23 -1
- package/dist/diagnostics/diagnostic.js +34 -0
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +3 -1
- package/dist/frontend/lowering/lower-calls.js +196 -33
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +6 -5
- package/dist/frontend/lowering/lower-containers.js +15 -11
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +11 -1
- package/dist/frontend/lowering/lower-exprs.js +366 -25
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +5 -0
- package/dist/frontend/lowering/lower-server.js +105 -55
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +71 -9
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +24 -5
- package/dist/frontend/lowering/lowerer.js +28 -4
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +84 -5
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +52 -19
- package/dist/ir/nodes.js +2 -2
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +67 -9
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/profile.d.ts +33 -0
- package/dist/library/profile.js +178 -4
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar.d.ts +3 -2
- package/dist/library/sidecar.js +7 -3
- package/dist/library/sidecar.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +2 -1
|
@@ -215,6 +215,14 @@ export interface LowerOptions {
|
|
|
215
215
|
* imports; without this option ambient declarations keep Node's ordinary
|
|
216
216
|
* ReferenceError behavior. */
|
|
217
217
|
ffiImports?: readonly IrFfiImport[];
|
|
218
|
+
/** LIBRARY mode's host-callback surface marker: the `ffiImports` above
|
|
219
|
+
* are profile-declared callback channels, not native-manifest bindings.
|
|
220
|
+
* Flips the binding diagnostics to the library flavor (SC4024), keeps a
|
|
221
|
+
* channel legal when no program declaration references it (an unused
|
|
222
|
+
* channel is capacity, not an error), and refuses a CALL of any other
|
|
223
|
+
* program-authored signature-only ambient function with the callback
|
|
224
|
+
* teaching instead of the ambient ReferenceError lowering. */
|
|
225
|
+
libraryCallbacks?: boolean;
|
|
218
226
|
/** Coverage-only external host type surfaces. Their declarations inform
|
|
219
227
|
* the checker, while every runtime value use remains an SC1010 fence. */
|
|
220
228
|
externalTypes?: ReadonlyMap<string, string>;
|
|
@@ -243,6 +251,8 @@ export interface LowererMode {
|
|
|
243
251
|
startupCrash?: StartupCrash | null;
|
|
244
252
|
/** The build's outbound native FFI declarations. */
|
|
245
253
|
ffiImports?: readonly IrFfiImport[];
|
|
254
|
+
/** LowerOptions.libraryCallbacks (see there). */
|
|
255
|
+
libraryCallbacks?: boolean;
|
|
246
256
|
/** Program-validated ambient declaration symbols for each FFI name.
|
|
247
257
|
* Undefined in discovery's legacy call-local validation path. */
|
|
248
258
|
ffiBindingSymbols?: ReadonlyMap<string, ReadonlySet<ts.Symbol>>;
|
|
@@ -446,6 +456,17 @@ export declare class Lowerer {
|
|
|
446
456
|
* aliases, so this carries the var/let form the checker cannot.
|
|
447
457
|
* Scoped strictly by narrowingAliases (lowerIf / lowerCondition). */
|
|
448
458
|
readonly aliasNarrowTypes: Map<ts.Symbol, ts.Type>;
|
|
459
|
+
/** Locals widened beyond the checker's type because an inferred indexed
|
|
460
|
+
* read can be absent at runtime. Bare reads preserve that union until a
|
|
461
|
+
* surrounding JavaScript guard/default consumes it. */
|
|
462
|
+
readonly runtimeOptionalLocals: Set<IrLocal>;
|
|
463
|
+
/** All storage slots widened for runtime absence, including slots whose
|
|
464
|
+
* current control-flow branch has temporarily narrowed the value. */
|
|
465
|
+
readonly runtimeOptionalStorageLocals: Set<IrLocal>;
|
|
466
|
+
/** Capture entries and their origin share one mutable box. Normalize each
|
|
467
|
+
* entry to the origin so writes and flow proofs stay synchronized. */
|
|
468
|
+
readonly runtimeOptionalRoots: Map<IrLocal, IrLocal>;
|
|
469
|
+
runtimeOptionalRootOf(local: IrLocal): IrLocal;
|
|
449
470
|
/** Runs `fn` with the given aliased-typeof narrows applied (and restored
|
|
450
471
|
* after) — the branch-scoping primitive. */
|
|
451
472
|
narrowingAliases<T>(narrows: readonly {
|
|
@@ -759,6 +780,7 @@ export declare class Lowerer {
|
|
|
759
780
|
readonly startupCrash: StartupCrash | null;
|
|
760
781
|
/** Outbound native bindings by their source-level ambient name. */
|
|
761
782
|
readonly ffiImports: readonly IrFfiImport[];
|
|
783
|
+
readonly libraryCallbacks: boolean;
|
|
762
784
|
readonly ffiImportsByName: ReadonlyMap<string, IrFfiImport>;
|
|
763
785
|
/** Non-null after whole-program FFI declaration validation. */
|
|
764
786
|
readonly ffiBindingSymbols: ReadonlyMap<string, ReadonlySet<ts.Symbol>> | null;
|
|
@@ -883,10 +905,7 @@ export declare class Lowerer {
|
|
|
883
905
|
cjsLocalModuleBindingOf(expr: ts.Expression): boolean;
|
|
884
906
|
/** Assignment-target resolution: a function local (possibly captured) or
|
|
885
907
|
* a module global. tsc has already rejected writes to consts. */
|
|
886
|
-
resolveWritable(ident: ts.Identifier):
|
|
887
|
-
id: string;
|
|
888
|
-
type: IrType;
|
|
889
|
-
} | null;
|
|
908
|
+
resolveWritable(ident: ts.Identifier): IrLocal | null;
|
|
890
909
|
fnSigOf(ident: ts.Identifier): FnSig | null;
|
|
891
910
|
globalOf(ident: ts.Identifier): IrGlobal | null;
|
|
892
911
|
splitFiles(): FileParts[];
|
|
@@ -1836,7 +1855,7 @@ export declare class Lowerer {
|
|
|
1836
1855
|
lowerShorthandValue(prop: ts.ShorthandPropertyAssignment): IrExpr;
|
|
1837
1856
|
rejectThisInObjectMethod(node: ts.Node): void;
|
|
1838
1857
|
lowerElementAccess(expr: ts.ElementAccessExpression): IrExpr;
|
|
1839
|
-
lowerRecordKeyRead(expr: ts.ElementAccessExpression, shapeId: string, shape: IrRecordShape): IrExpr;
|
|
1858
|
+
lowerRecordKeyRead(expr: ts.ElementAccessExpression, shapeId: string, shape: IrRecordShape, includeUndefined?: boolean): IrExpr;
|
|
1840
1859
|
lowerElementWrite(expr: ts.BinaryExpression): IrStmt;
|
|
1841
1860
|
ensureString(e: IrExpr, node: ts.Node): IrExpr;
|
|
1842
1861
|
lowerTemplate(expr: ts.TemplateExpression): IrExpr;
|
|
@@ -177,12 +177,14 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
const ffiImports = options.ffiImports ?? [];
|
|
180
|
+
const libraryCallbacks = options.libraryCallbacks ?? false;
|
|
180
181
|
const externalTypes = options.externalTypes ?? new Map();
|
|
181
182
|
const externalTypeSpecifiersByFile = options.externalTypeSpecifiersByFile ??
|
|
182
183
|
directExternalTypeSpecifiersByFile(externalTypes);
|
|
183
184
|
const validation = new Lowerer(program, entry, moduleOrder, dynamic, {
|
|
184
185
|
targetPlatform,
|
|
185
186
|
ffiImports,
|
|
187
|
+
libraryCallbacks,
|
|
186
188
|
externalTypes,
|
|
187
189
|
externalTypeSpecifiersByFile,
|
|
188
190
|
});
|
|
@@ -198,6 +200,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
198
200
|
: new Lowerer(program, entry, moduleOrder, dynamic, {
|
|
199
201
|
targetPlatform,
|
|
200
202
|
ffiImports,
|
|
203
|
+
libraryCallbacks,
|
|
201
204
|
externalTypes,
|
|
202
205
|
externalTypeSpecifiersByFile,
|
|
203
206
|
ffiBindingSymbols: ffiValidation.symbolsByName,
|
|
@@ -208,6 +211,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
208
211
|
targetPlatform,
|
|
209
212
|
startupCrash,
|
|
210
213
|
ffiImports,
|
|
214
|
+
libraryCallbacks,
|
|
211
215
|
ffiBindingSymbols: ffiValidation.symbolsByName,
|
|
212
216
|
externalTypes,
|
|
213
217
|
externalTypeSpecifiersByFile,
|
|
@@ -225,6 +229,7 @@ export function lowerToIr(program, entry, moduleOrder, options = {}) {
|
|
|
225
229
|
alreadyFlushed: emit.flushedSymbols,
|
|
226
230
|
targetPlatform,
|
|
227
231
|
ffiImports,
|
|
232
|
+
libraryCallbacks,
|
|
228
233
|
ffiBindingSymbols: ffiValidation.symbolsByName,
|
|
229
234
|
externalTypes,
|
|
230
235
|
externalTypeSpecifiersByFile,
|
|
@@ -624,6 +629,19 @@ export class Lowerer {
|
|
|
624
629
|
* aliases, so this carries the var/let form the checker cannot.
|
|
625
630
|
* Scoped strictly by narrowingAliases (lowerIf / lowerCondition). */
|
|
626
631
|
aliasNarrowTypes = new Map();
|
|
632
|
+
/** Locals widened beyond the checker's type because an inferred indexed
|
|
633
|
+
* read can be absent at runtime. Bare reads preserve that union until a
|
|
634
|
+
* surrounding JavaScript guard/default consumes it. */
|
|
635
|
+
runtimeOptionalLocals = new Set();
|
|
636
|
+
/** All storage slots widened for runtime absence, including slots whose
|
|
637
|
+
* current control-flow branch has temporarily narrowed the value. */
|
|
638
|
+
runtimeOptionalStorageLocals = new Set();
|
|
639
|
+
/** Capture entries and their origin share one mutable box. Normalize each
|
|
640
|
+
* entry to the origin so writes and flow proofs stay synchronized. */
|
|
641
|
+
runtimeOptionalRoots = new Map();
|
|
642
|
+
runtimeOptionalRootOf(local) {
|
|
643
|
+
return this.runtimeOptionalRoots.get(local) ?? local;
|
|
644
|
+
}
|
|
627
645
|
/** Runs `fn` with the given aliased-typeof narrows applied (and restored
|
|
628
646
|
* after) — the branch-scoping primitive. */
|
|
629
647
|
narrowingAliases(narrows, fn) {
|
|
@@ -939,6 +957,7 @@ export class Lowerer {
|
|
|
939
957
|
startupCrash;
|
|
940
958
|
/** Outbound native bindings by their source-level ambient name. */
|
|
941
959
|
ffiImports;
|
|
960
|
+
libraryCallbacks;
|
|
942
961
|
ffiImportsByName;
|
|
943
962
|
/** Non-null after whole-program FFI declaration validation. */
|
|
944
963
|
ffiBindingSymbols;
|
|
@@ -996,6 +1015,7 @@ export class Lowerer {
|
|
|
996
1015
|
this.targetPlatform = mode.targetPlatform ?? process.platform;
|
|
997
1016
|
this.startupCrash = mode.startupCrash ?? null;
|
|
998
1017
|
this.ffiImports = mode.ffiImports ?? [];
|
|
1018
|
+
this.libraryCallbacks = mode.libraryCallbacks ?? false;
|
|
999
1019
|
this.ffiImportsByName = new Map(this.ffiImports.map((entry) => [entry.name, entry]));
|
|
1000
1020
|
this.ffiBindingSymbols = mode.ffiBindingSymbols ?? null;
|
|
1001
1021
|
this.externalTypes = mode.externalTypes ?? new Map();
|
|
@@ -1545,10 +1565,10 @@ export class Lowerer {
|
|
|
1545
1565
|
this.unsupported("SC1090", ident, "assignments to catch bindings");
|
|
1546
1566
|
}
|
|
1547
1567
|
if (local)
|
|
1548
|
-
return
|
|
1568
|
+
return local;
|
|
1549
1569
|
const g = this.globalOf(ident);
|
|
1550
1570
|
if (g)
|
|
1551
|
-
return
|
|
1571
|
+
return g;
|
|
1552
1572
|
return null;
|
|
1553
1573
|
}
|
|
1554
1574
|
fnSigOf(ident) {
|
|
@@ -6575,6 +6595,10 @@ export class Lowerer {
|
|
|
6575
6595
|
ctx.captureBySymbol.set(symbol, entry);
|
|
6576
6596
|
ctx.captures.push({ localId: entry.id, name: entry.name, type: entry.type });
|
|
6577
6597
|
ctx.captureSources.push(parentEntry.id);
|
|
6598
|
+
const runtimeOptionalRoot = this.runtimeOptionalRootOf(parentEntry);
|
|
6599
|
+
if (this.runtimeOptionalStorageLocals.has(runtimeOptionalRoot)) {
|
|
6600
|
+
this.runtimeOptionalRoots.set(entry, runtimeOptionalRoot);
|
|
6601
|
+
}
|
|
6578
6602
|
}
|
|
6579
6603
|
parentEntry = entry;
|
|
6580
6604
|
}
|
|
@@ -6995,8 +7019,8 @@ export class Lowerer {
|
|
|
6995
7019
|
lowerElementAccess(expr) {
|
|
6996
7020
|
return lowerElementAccess(this, expr);
|
|
6997
7021
|
}
|
|
6998
|
-
lowerRecordKeyRead(expr, shapeId, shape) {
|
|
6999
|
-
return lowerRecordKeyRead(this, expr, shapeId, shape);
|
|
7022
|
+
lowerRecordKeyRead(expr, shapeId, shape, includeUndefined = false) {
|
|
7023
|
+
return lowerRecordKeyRead(this, expr, shapeId, shape, includeUndefined);
|
|
7000
7024
|
}
|
|
7001
7025
|
lowerElementWrite(expr) {
|
|
7002
7026
|
return lowerElementWrite(this, expr);
|