@scriptc/compiler 0.0.9 → 0.0.10
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/emission/emit-exprs.js +136 -12
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-walkers.js +29 -2
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +1 -0
- package/dist/backend/llvm/dyn.js +83 -1
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +151 -9
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +21 -7
- package/dist/diagnostics/diagnostic.js +35 -16
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/render.js +8 -0
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +11 -1
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +13 -0
- package/dist/frontend/lowering/lower-builtins.js +146 -1
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +41 -0
- package/dist/frontend/lowering/lower-calls.js +524 -10
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +17 -0
- package/dist/frontend/lowering/lower-containers.js +193 -10
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +92 -17
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +179 -10
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +33 -2
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +25 -11
- package/dist/frontend/lowering/lower-namespaces.js +50 -15
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +211 -4
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +1 -5
- package/dist/frontend/lowering/lower-stmts.js +216 -7
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +65 -4
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +36 -1
- package/dist/frontend/lowering/lowerer.js +106 -3
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/types.d.ts +13 -0
- package/dist/frontend/types.js +84 -7
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +99 -5
- package/dist/ir/nodes.js +44 -3
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +53 -3
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.d.ts +77 -0
- package/dist/library/fence-eval.js +385 -0
- package/dist/library/fence-eval.js.map +1 -0
- package/dist/library/profile.d.ts +11 -1
- package/dist/library/profile.js +102 -18
- package/dist/library/profile.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1 -1
|
@@ -26,7 +26,7 @@ import { mixinCallClassInfoOf, mixinIntersectionInstanceType } from "./lower-mix
|
|
|
26
26
|
import { bindingNeverReassigned, bodyReadsArguments, isThisParameter, paramShape, paramShapes, checkDefaultParamBodyType, completeArgs, wrappedUndefined, undefinedArgFor, requireExactArityValue, bodyReturnType, declaredReturnType, collectSignature, collectSignatureInner, collectGenericSignature, genericFnOf, lowerGenericCall, lowerGenericFnValue, inferTypeParamBindings, lowerGenericInstance, lowerCall, lowerTimersMemberCall, lowerPromiseMethodCall, lowerFilterNarrowCall, isTopLevelFnSymbol, lowerNestedFunctionDecl, lambdaSignature, lowerLambda, lowerFunction } from "./lower-calls.js";
|
|
27
27
|
import { lowerArrayMethodCall, lowerBufferStaticCall, lowerBytesMethodCall, lowerBytesNew, lowerMapMethodCall, lowerMapForEachCall, buildMapForEachFn, lowerRecordOvfCaptureHelper, lowerEnvToPairsHelper, lowerSetMethodCall, lowerSetForEachCall, buildSetForEachFn, lowerRegexMethodCall, lowerStringMethodCall } from "./lower-containers.js";
|
|
28
28
|
import { lowerStreamModuleCall } from "./lower-stream.js";
|
|
29
|
-
import { builtinImportOf, lowerBuiltinModuleCall, lowerFsToUnixTimestampCall, lowerChildArgsArg, lowerSpawnSyncCall, lowerSpawnCall, lowerExecSyncCall, recordToEnvPairs, lowerJsonMethodCall, fencedBuiltinImportOf, lowerCryptoComposedCall, lowerUrlMethodCall, lowerSearchParamsMethodCall, lowerStatsMethodCall, lowerChildMethodCall, lowerAtomicsCall, lowerBuiltinExtraProperty, promisifiedExecFileDecl, lowerExecFileAsyncCall, execFileAsyncHelper, lowerStringDecoderMethodCall, strdecHelper, lowerReadlineMethodCall, lowerDcChannelMethodCall, lowerDcChannelProperty, lowerAlsMethodCall, lowerDcTracingChannelMethodCall, lowerDcTracingChannelProperty, lowerJsonProperty, lowerErrorCodeProperty, lowerProcessProperty, isProcessEnv, envValueType, lowerProcessEnvGet, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerTimeoutMethodCall, envSnapshotHelper, isConsoleLog, consoleCallMember, lowerNumberStaticCall, lowerNumberStaticProperty, lowerDateCall, lowerTextCodecCall, lowerFsConstantsProperty, lowerHttp2ConstantsProperty, http2ConstantBindingOf, http2ConstantsDestructureDecl, lowerProcessStreamProperty, lowerStringStaticCall, lowerStringLastIndexOfCall, lowerPromiseStaticCall } from "./lower-builtins.js";
|
|
29
|
+
import { builtinImportOf, lowerBuiltinModuleCall, lowerFsToUnixTimestampCall, lowerFsLadderCall, lowerChildArgsArg, lowerSpawnSyncCall, lowerSpawnCall, lowerExecSyncCall, recordToEnvPairs, lowerJsonMethodCall, fencedBuiltinImportOf, lowerCryptoComposedCall, lowerUrlMethodCall, lowerSearchParamsMethodCall, lowerStatsMethodCall, lowerChildMethodCall, lowerAtomicsCall, lowerBuiltinExtraProperty, promisifiedExecFileDecl, lowerExecFileAsyncCall, execFileAsyncHelper, lowerStringDecoderMethodCall, strdecHelper, lowerReadlineMethodCall, lowerDcChannelMethodCall, lowerDcChannelProperty, lowerAlsMethodCall, lowerDcTracingChannelMethodCall, lowerDcTracingChannelProperty, lowerJsonProperty, lowerErrorCodeProperty, lowerProcessProperty, isProcessEnv, envValueType, lowerProcessEnvGet, lowerProcessMethodCall, lowerProcessOptionalMethodCall, lowerTimeoutMethodCall, envSnapshotHelper, isConsoleLog, consoleCallMember, lowerNumberStaticCall, lowerNumberStaticProperty, lowerDateCall, lowerTextCodecCall, lowerFsConstantsProperty, lowerHttp2ConstantsProperty, http2ConstantBindingOf, http2ConstantsDestructureDecl, lowerProcessStreamProperty, lowerStringStaticCall, lowerStringLastIndexOfCall, lowerPromiseStaticCall } from "./lower-builtins.js";
|
|
30
30
|
import { isIslandExpr, islandFuncValueFence, islandRegexpOf, jsvalIn, requireDynamicApi, islandGlobalFnOf, lowerDynamicImportCall, lowerFetchCall, lowerIslandMethodCall, lowerMathProperty, npmPackageOf, npmMemberFence, npmPackageOfSymbol } from "./lower-island.js";
|
|
31
31
|
import { lowerHttpHeadersElement, lowerNetModuleCall, lowerServerMethodCall, lowerServerProperty } from "./lower-server.js";
|
|
32
32
|
import { lowerDgramDnsModuleCall, lowerDgramMethodCall } from "./lower-dgram.js";
|
|
@@ -299,6 +299,26 @@ export function nodeThrowExpr(kind, code, message, type, loc) {
|
|
|
299
299
|
loc,
|
|
300
300
|
};
|
|
301
301
|
}
|
|
302
|
+
/** The post-validation fence STRING a validation-ladder Chk libCall
|
|
303
|
+
* throws after its Node-order checks pass: the same SC2020 text the
|
|
304
|
+
* per-statement runtime fence would have thrown (message + "[code at
|
|
305
|
+
* file:line]"), rendered eagerly so the runtime can throw it verbatim
|
|
306
|
+
* (scr_throw_lowering_fence). The diagnostic joins the runtime-fence
|
|
307
|
+
* ledger exactly like a deferred statement fence — nothing silently
|
|
308
|
+
* drops off the coverage report. */
|
|
309
|
+
export function ladderFenceExpr(L, surface, node, hint) {
|
|
310
|
+
const loc = locOf(node);
|
|
311
|
+
const d = noLoweringDiag(surface, loc, hint);
|
|
312
|
+
L.runtimeFences.push(d);
|
|
313
|
+
const sf = node.getSourceFile();
|
|
314
|
+
const pos = ts.getLineAndCharacterOfPosition(sf, loc.start);
|
|
315
|
+
return {
|
|
316
|
+
kind: "strLit",
|
|
317
|
+
value: `${d.message} [${d.code} at ${loc.file}:${pos.line + 1}]`,
|
|
318
|
+
type: STRING,
|
|
319
|
+
loc,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
302
322
|
/** The checked-dynamic declaration fallback for unmappable binding types
|
|
303
323
|
* (see irTypeOf), two gates over one story:
|
|
304
324
|
*
|
|
@@ -477,6 +497,29 @@ export class Lowerer {
|
|
|
477
497
|
/** Per-symbol result of the never-reassigned file scan
|
|
478
498
|
* (bindingNeverReassigned — object-literal generic-method receivers). */
|
|
479
499
|
neverReassignedCache = new Map();
|
|
500
|
+
/** TRAP bindings: declarations whose initializer provably throws before
|
|
501
|
+
* producing a value (its chain roots at an ambient-undefined name —
|
|
502
|
+
* ambientUndefVarRootOf). Module init unwinds at the declaration, so no
|
|
503
|
+
* reference to the binding can ever execute; the statement lowers to the
|
|
504
|
+
* root's throw, no storage exists, and references lower to the same
|
|
505
|
+
* trap shape (never reached — sound whatever the type). */
|
|
506
|
+
trapBindings = new Set();
|
|
507
|
+
/** NULLISH bindings of unmappable (generic-signature) types: `const i:
|
|
508
|
+
* I<A & B> = null as any` — the binding provably holds null/undefined
|
|
509
|
+
* forever (every write's RHS is nullish too), so no storage exists and
|
|
510
|
+
* each READ knows the value. Member reads and method calls through one
|
|
511
|
+
* lower to Node's exact TypeError ("Cannot read properties of null
|
|
512
|
+
* (reading 'fn')"); nullish-to-nullish flows lower to nothing. The map
|
|
513
|
+
* answers which unit the binding holds (the TypeError names it). Null
|
|
514
|
+
* entries cache probed non-qualifiers. */
|
|
515
|
+
nullishBindings = new Map();
|
|
516
|
+
/** DEAD bindings of unmappable types: never READ anywhere in the
|
|
517
|
+
* program, declared with no initializer or a value-only one (a function
|
|
518
|
+
* literal), every write's RHS side-effect-free. Node materializes the
|
|
519
|
+
* value and drops it — zero observable effect — so the declaration and
|
|
520
|
+
* its writes lower to nothing, and no type fence fires for a value the
|
|
521
|
+
* program never consumes. */
|
|
522
|
+
deadBindings = new Set();
|
|
480
523
|
/** IMPLICIT-ANY function-value bindings (npm-static JS — `const knownBy
|
|
481
524
|
* = (cmd) => ...`), by their VariableDeclaration: the registered info,
|
|
482
525
|
* or null for probed non-qualifiers (implicitLocalFnNodeOf). */
|
|
@@ -2361,6 +2404,21 @@ export class Lowerer {
|
|
|
2361
2404
|
return expr;
|
|
2362
2405
|
}
|
|
2363
2406
|
if (expr.type.kind === "jsval" && expected.kind !== "jsval") {
|
|
2407
|
+
// The jsval→DOM crossing (the world unification's engine-handle
|
|
2408
|
+
// kind): an 'any'-typed engine value flowing into an 'unknown'/
|
|
2409
|
+
// 'object'/JS-residue slot wraps BY REFERENCE as the DOM's island
|
|
2410
|
+
// kind — engine scalars normalize to native DOM kinds at wrap time,
|
|
2411
|
+
// typeof/truthiness/String()/=== route to the engine, un-armed DOM
|
|
2412
|
+
// walks fence loudly, and the value unwraps back identity-preserved
|
|
2413
|
+
// (scr_jsval_from_dyn). Monotone under evolution/widening: a value
|
|
2414
|
+
// wraps once at its first dyn edge and stays valid through every
|
|
2415
|
+
// subsequent dyn slot; narrowing never changes representation.
|
|
2416
|
+
// This wrap RETIRES the silent-wrong-answer fence-closure box for
|
|
2417
|
+
// jsval members of DOM object literals (lowerDynObjectLiteral's
|
|
2418
|
+
// coercion lands here first).
|
|
2419
|
+
if (expected.kind === "dyn") {
|
|
2420
|
+
return { kind: "dynFromJsval", value: expr, type: DYN, loc: expr.loc };
|
|
2421
|
+
}
|
|
2364
2422
|
// The exit set: everything round-trippable, plus bare undefined-armed
|
|
2365
2423
|
// unions of JSON-safe data arms (the engine's undefined takes the
|
|
2366
2424
|
// undefined arm before the JSON detour) — canExitIslandToType.
|
|
@@ -5161,6 +5219,11 @@ export class Lowerer {
|
|
|
5161
5219
|
if (value.kind === "unitLit") {
|
|
5162
5220
|
return { kind: "dynFrom", value, type: DYN, loc: value.loc };
|
|
5163
5221
|
}
|
|
5222
|
+
// An ISLAND ('any') value: the by-reference jsval→DOM wrap — the same
|
|
5223
|
+
// edge coerceToExpected converts (dyn slots accept engine values).
|
|
5224
|
+
if (value.type.kind === "jsval") {
|
|
5225
|
+
return { kind: "dynFromJsval", value, type: DYN, loc: value.loc };
|
|
5226
|
+
}
|
|
5164
5227
|
if (!this.dynConvertible(value.type)) {
|
|
5165
5228
|
this.unsupported("SC1100", node, `storing '${this.fmt(value.type)}' values under an 'unknown'-valued index signature (only numbers, strings, booleans, and JSON-safe records/arrays/unions convert)`);
|
|
5166
5229
|
}
|
|
@@ -6116,7 +6179,7 @@ export class Lowerer {
|
|
|
6116
6179
|
lowerDestructuringAssignParts(target, rhs, loc) {
|
|
6117
6180
|
return lowerDestructuringAssignParts(this, target, rhs, loc);
|
|
6118
6181
|
}
|
|
6119
|
-
lowerBindingPattern(pattern, srcRef, srcType, isLet, out) {
|
|
6182
|
+
lowerBindingPattern(pattern, srcRef, srcType, isLet, out, dynSpell) {
|
|
6120
6183
|
// An ISLAND source (`const { readFileSync } = await import("fs")` —
|
|
6121
6184
|
// a namespace handle, or any 'any'-typed object): each bound name is
|
|
6122
6185
|
// an engine property read, mirroring the island property-read rule —
|
|
@@ -6180,7 +6243,7 @@ export class Lowerer {
|
|
|
6180
6243
|
}
|
|
6181
6244
|
return;
|
|
6182
6245
|
}
|
|
6183
|
-
return lowerBindingPattern(this, pattern, srcRef, srcType, isLet, out);
|
|
6246
|
+
return lowerBindingPattern(this, pattern, srcRef, srcType, isLet, out, dynSpell);
|
|
6184
6247
|
}
|
|
6185
6248
|
checkBindingElement(el, allowDefault = false) {
|
|
6186
6249
|
return checkBindingElement(this, el, allowDefault);
|
|
@@ -6261,6 +6324,16 @@ export class Lowerer {
|
|
|
6261
6324
|
const local = this.declareLocal(decl.name, decl.name.text, JSVAL, isLet);
|
|
6262
6325
|
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
6263
6326
|
}
|
|
6327
|
+
// The CHECKED-DYNAMIC twin of the handle rescue (the runtime-world
|
|
6328
|
+
// local rule): an unmappable declared type over a dyn initializer
|
|
6329
|
+
// (`const first = plugins[0]` — the checker spells 'string |
|
|
6330
|
+
// object' while the read is a DOM keyed read) keeps the binding
|
|
6331
|
+
// dyn; typed use sites ride validated extractions and the routed
|
|
6332
|
+
// engine ops, exactly the JSON.parse-binding story.
|
|
6333
|
+
if (mapped === null && init.type.kind === "dyn") {
|
|
6334
|
+
const local = this.declareLocal(decl.name, decl.name.text, DYN, isLet);
|
|
6335
|
+
return { kind: "varDecl", localId: local.id, init, loc: locOf(decl) };
|
|
6336
|
+
}
|
|
6264
6337
|
if (mapped === null)
|
|
6265
6338
|
this.badType(decl.name, this.typeOf(decl.name));
|
|
6266
6339
|
// A mappable declared type with a non-island initializer: the
|
|
@@ -6634,6 +6707,27 @@ export class Lowerer {
|
|
|
6634
6707
|
const spec = requireSpecOf(decl.initializer);
|
|
6635
6708
|
return spec !== null ? canonicalBuiltinModule(spec) : null;
|
|
6636
6709
|
}
|
|
6710
|
+
// A DESTRUCTURED sub-namespace binding — `const { promises } =
|
|
6711
|
+
// fs` / `= require('fs')`: the member is itself a supported module
|
|
6712
|
+
// ("fs/promises"), so the binding carries that module's namespace
|
|
6713
|
+
// surface. canonicalBuiltinModule gates the composition (an
|
|
6714
|
+
// ordinary destructured FUNCTION binding composes to an unknown
|
|
6715
|
+
// name and answers null — builtinImportOf owns those).
|
|
6716
|
+
if (ts.isBindingElement(decl) && ts.isObjectBindingPattern(decl.parent) &&
|
|
6717
|
+
ts.isVariableDeclaration(decl.parent.parent) && decl.parent.parent.initializer !== undefined &&
|
|
6718
|
+
decl.propertyName === undefined && decl.initializer === undefined) {
|
|
6719
|
+
const name = decl.name;
|
|
6720
|
+
if (name === undefined || !ts.isIdentifier(name))
|
|
6721
|
+
return null;
|
|
6722
|
+
const init = decl.parent.parent.initializer;
|
|
6723
|
+
const spec = requireSpecOf(init);
|
|
6724
|
+
const outer = spec !== null
|
|
6725
|
+
? canonicalBuiltinModule(spec)
|
|
6726
|
+
: ts.isIdentifier(init) ? this.builtinNamespaceModuleOf(init) : null;
|
|
6727
|
+
if (outer !== null)
|
|
6728
|
+
return canonicalBuiltinModule(`${outer}/${name.text}`);
|
|
6729
|
+
return null;
|
|
6730
|
+
}
|
|
6637
6731
|
}
|
|
6638
6732
|
// The INLINE CommonJS spelling: `require("cluster").isPrimary` — the
|
|
6639
6733
|
// call expression IS the module namespace (Node evaluates the member
|
|
@@ -6746,6 +6840,12 @@ export class Lowerer {
|
|
|
6746
6840
|
const fsTs = this.lowerFsToUnixTimestampCall(call, bi, locOf(access));
|
|
6747
6841
|
if (fsTs)
|
|
6748
6842
|
return fsTs;
|
|
6843
|
+
// The fs validation-ladder spoke (checked-dynamic lane): misuse of
|
|
6844
|
+
// implemented-namespace members throws Node's typed errors instead
|
|
6845
|
+
// of meeting the table fence.
|
|
6846
|
+
const fsLadder = this.lowerFsLadderCall(call, bi, locOf(access));
|
|
6847
|
+
if (fsLadder)
|
|
6848
|
+
return fsLadder;
|
|
6749
6849
|
const builtinFn = builtinModuleFnOf(this, bi.module, bi.member);
|
|
6750
6850
|
if (!builtinFn) {
|
|
6751
6851
|
this.noLowering(`${bi.module}.${bi.member}`, call, builtinFenceHintOf(bi.module, bi.member), this.checker.getSymbolAtLocation(access.name));
|
|
@@ -6799,6 +6899,9 @@ export class Lowerer {
|
|
|
6799
6899
|
lowerFsToUnixTimestampCall(expr, bi, loc) {
|
|
6800
6900
|
return lowerFsToUnixTimestampCall(this, expr, bi, loc);
|
|
6801
6901
|
}
|
|
6902
|
+
lowerFsLadderCall(expr, bi, loc) {
|
|
6903
|
+
return lowerFsLadderCall(this, expr, bi, loc);
|
|
6904
|
+
}
|
|
6802
6905
|
lowerChildArgsArg(node, loc) {
|
|
6803
6906
|
return lowerChildArgsArg(this, node, loc);
|
|
6804
6907
|
}
|