@scriptc/compiler 0.4.3 → 0.4.4
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 +73 -29
- package/dist/backend/llvm/bytes-loop-versions.js +6 -0
- package/dist/backend/llvm/bytes-loop-versions.js.map +1 -1
- package/dist/backend/llvm/bytes-loop-versions.test.js +7 -2
- package/dist/backend/llvm/bytes-loop-versions.test.js.map +1 -1
- package/dist/backend/llvm/debug-info.js +2 -5
- package/dist/backend/llvm/debug-info.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +4 -0
- package/dist/backend/llvm/dyn.js +21 -9
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emit-function.js +2 -8
- package/dist/backend/llvm/emit-function.js.map +1 -1
- package/dist/backend/llvm/emit-module.js +16 -6
- package/dist/backend/llvm/emit-module.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +10 -0
- package/dist/backend/llvm/emitter.js +9 -5
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +11 -2
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-async.js +11 -13
- package/dist/backend/llvm/expr-async.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +14 -8
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +14 -0
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +20 -11
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +16 -4
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/integer-values.d.ts +5 -0
- package/dist/backend/llvm/integer-values.js +27 -3
- package/dist/backend/llvm/integer-values.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +133 -3
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +37 -1
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +21 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/publish.js +3 -3
- package/dist/backend/llvm/publish.js.map +1 -1
- package/dist/backend/llvm/reference-effects.js +3 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/shapes.js +2 -7
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/stack-captures.js +1 -5
- package/dist/backend/llvm/stack-captures.js.map +1 -1
- package/dist/backend/llvm/union-repr.d.ts +4 -3
- package/dist/backend/llvm/union-repr.js +6 -5
- package/dist/backend/llvm/union-repr.js.map +1 -1
- package/dist/backend/llvm/walkers.js +13 -0
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +5 -3
- package/dist/backend/native-codegen-core.js +13 -6
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.test.js +6 -4
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/target-cpu.d.ts +26 -0
- package/dist/backend/target-cpu.js +98 -0
- package/dist/backend/target-cpu.js.map +1 -0
- package/dist/backend/target-cpu.test.d.ts +1 -0
- package/dist/backend/target-cpu.test.js +38 -0
- package/dist/backend/target-cpu.test.js.map +1 -0
- package/dist/cli/command.js +20 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/usage.d.ts +4 -1
- package/dist/cli/usage.js +7 -0
- package/dist/cli/usage.js.map +1 -1
- package/dist/compile-types.d.ts +7 -0
- package/dist/diagnostics/diagnostic.js +1 -1
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -0
- package/dist/executable/executable-cache.js +4 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +2 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/decl-projection.js +105 -10
- package/dist/frontend/decl-projection.js.map +1 -1
- package/dist/frontend/lowering/builtins/async-context.d.ts +8 -2
- package/dist/frontend/lowering/builtins/async-context.js +62 -3
- package/dist/frontend/lowering/builtins/async-context.js.map +1 -1
- package/dist/frontend/lowering/builtins/crypto.js +3 -1
- package/dist/frontend/lowering/builtins/crypto.js.map +1 -1
- package/dist/frontend/lowering/builtins/dates.js +4 -1
- package/dist/frontend/lowering/builtins/dates.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.js +3 -3
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-glob.js +6 -3
- package/dist/frontend/lowering/builtins/fs-glob.js.map +1 -1
- package/dist/frontend/lowering/builtins/fs-paths.d.ts +43 -5
- package/dist/frontend/lowering/builtins/fs-paths.js +245 -93
- package/dist/frontend/lowering/builtins/fs-paths.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +6 -3
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/promises.d.ts +1 -1
- package/dist/frontend/lowering/builtins/promises.js +149 -138
- package/dist/frontend/lowering/builtins/promises.js.map +1 -1
- package/dist/frontend/lowering/call-signatures.js +0 -1
- package/dist/frontend/lowering/call-signatures.js.map +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js +1 -1
- package/dist/frontend/lowering/cjs-exports-object.js.map +1 -1
- package/dist/frontend/lowering/cjs-inline-require.d.ts +32 -0
- package/dist/frontend/lowering/cjs-inline-require.js +307 -4
- package/dist/frontend/lowering/cjs-inline-require.js.map +1 -1
- package/dist/frontend/lowering/class-dynamic-dispatch.d.ts +10 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js +114 -0
- package/dist/frontend/lowering/class-dynamic-dispatch.js.map +1 -1
- package/dist/frontend/lowering/class-method-mutations.js +54 -18
- package/dist/frontend/lowering/class-method-mutations.js.map +1 -1
- package/dist/frontend/lowering/class-protocols.d.ts +25 -0
- package/dist/frontend/lowering/class-protocols.js +183 -1
- package/dist/frontend/lowering/class-protocols.js.map +1 -1
- package/dist/frontend/lowering/completion-callbacks.d.ts +4 -0
- package/dist/frontend/lowering/completion-callbacks.js +146 -0
- package/dist/frontend/lowering/completion-callbacks.js.map +1 -0
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +5 -4
- package/dist/frontend/lowering/containers/array-callbacks.js +7 -6
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/array-construction.js +5 -0
- package/dist/frontend/lowering/containers/array-construction.js.map +1 -1
- package/dist/frontend/lowering/containers/array-methods.js +11 -3
- package/dist/frontend/lowering/containers/array-methods.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.d.ts +25 -17
- package/dist/frontend/lowering/containers/bytes.js +453 -45
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/date-values.d.ts +11 -0
- package/dist/frontend/lowering/date-values.js +207 -0
- package/dist/frontend/lowering/date-values.js.map +1 -0
- package/dist/frontend/lowering/expressions/array-literals.js +6 -0
- package/dist/frontend/lowering/expressions/array-literals.js.map +1 -1
- package/dist/frontend/lowering/expressions/binary.js +64 -26
- package/dist/frontend/lowering/expressions/binary.js.map +1 -1
- package/dist/frontend/lowering/expressions/element-access.js +79 -0
- package/dist/frontend/lowering/expressions/element-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/identifiers.js +31 -1
- package/dist/frontend/lowering/expressions/identifiers.js.map +1 -1
- package/dist/frontend/lowering/expressions/property-access.js +56 -0
- package/dist/frontend/lowering/expressions/property-access.js.map +1 -1
- package/dist/frontend/lowering/expressions/typeof.js +6 -0
- package/dist/frontend/lowering/expressions/typeof.js.map +1 -1
- package/dist/frontend/lowering/expressions/updates.js +17 -0
- package/dist/frontend/lowering/expressions/updates.js.map +1 -1
- package/dist/frontend/lowering/function-returns.js +15 -0
- package/dist/frontend/lowering/function-returns.js.map +1 -1
- package/dist/frontend/lowering/indexed-unions.d.ts +54 -0
- package/dist/frontend/lowering/indexed-unions.js +401 -0
- package/dist/frontend/lowering/indexed-unions.js.map +1 -0
- package/dist/frontend/lowering/key-order-witness.js +210 -32
- package/dist/frontend/lowering/key-order-witness.js.map +1 -1
- package/dist/frontend/lowering/key-order-witness.test.js +104 -4
- package/dist/frontend/lowering/key-order-witness.test.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +15 -3
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +19 -3
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +22 -47
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +205 -1
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-generators.js +1 -1
- package/dist/frontend/lowering/lower-generators.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +1 -1
- package/dist/frontend/lowering/lower-inspect.js +35 -11
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +21 -5
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +100 -34
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +30 -2
- package/dist/frontend/lowering/lowerer.js +68 -7
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/object-factory-new.d.ts +5 -0
- package/dist/frontend/lowering/object-factory-new.js +20 -6
- package/dist/frontend/lowering/object-factory-new.js.map +1 -1
- package/dist/frontend/lowering/overload-choice.d.ts +33 -0
- package/dist/frontend/lowering/overload-choice.js +190 -0
- package/dist/frontend/lowering/overload-choice.js.map +1 -0
- package/dist/frontend/lowering/surfaces.js +55 -2
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/pipeline.js +1 -1
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +5 -1
- package/dist/frontend/program-analysis.js +5 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.d.ts +13 -5
- package/dist/frontend/program.js +197 -14
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.d.ts +3 -0
- package/dist/frontend/ts7/semantic-model.js +5 -0
- package/dist/frontend/ts7/semantic-model.js.map +1 -1
- package/dist/frontend/ts7/semantic-model.test.js +6 -1
- package/dist/frontend/ts7/semantic-model.test.js.map +1 -1
- package/dist/frontend/ts7/semantic-types.d.ts +1 -1
- package/dist/frontend/ts7/semantic-types.js +1 -1
- package/dist/frontend/ts7/semantic-types.js.map +1 -1
- package/dist/frontend/type-mapper.js +45 -16
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +8 -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 +56 -0
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/int32-slots.js +7 -0
- package/dist/ir/int32-slots.js.map +1 -1
- package/dist/ir/int32-slots.test.js +33 -0
- package/dist/ir/int32-slots.test.js.map +1 -1
- package/dist/ir/integer-loops.js +14 -4
- package/dist/ir/integer-loops.js.map +1 -1
- package/dist/ir/ir.d.ts +13 -3
- package/dist/ir/ir.js +19 -5
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +2 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/js-ic.d.ts +2 -15
- package/dist/ir/js-ic.js +11 -79
- package/dist/ir/js-ic.js.map +1 -1
- package/dist/ir/js-ic.test.js +0 -142
- package/dist/ir/js-ic.test.js.map +1 -1
- package/dist/ir/runtime-features.js +25 -1
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/validate.js +46 -5
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/ir-policy.js +1 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/native/prepare.d.ts +1 -1
- package/dist/native/prepare.js +11 -1
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/prepare.test.js +18 -2
- package/dist/native/prepare.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +2 -4
|
@@ -15,6 +15,7 @@ import { type ContractAnnotations } from "../contract-types.js";
|
|
|
15
15
|
import type { WidthLift } from "./width-lift.js";
|
|
16
16
|
import { type FnCtx } from "./function-context.js";
|
|
17
17
|
import type { FrontendServices } from "../services.js";
|
|
18
|
+
import type { FsPathPlan } from "./builtins/fs-paths.js";
|
|
18
19
|
import { type ProtocolDispatch } from "./class-protocol-dispatch.js";
|
|
19
20
|
import { type DynamicFunction } from "../../ir/tiers.js";
|
|
20
21
|
import { type TierMode, type TierReport } from "../tier-analysis.js";
|
|
@@ -33,6 +34,7 @@ import { ShapeRegistry, type TypeMapperCtx, UnionRegistry } from "../type-mapper
|
|
|
33
34
|
import { type CompoundOp, type StdlibFnEntry, type BuiltinModuleFn } from "./surfaces.js";
|
|
34
35
|
import { type BuiltinClassRef } from "./builtins/class-values.js";
|
|
35
36
|
import { type FileParts } from "./lower-modules.js";
|
|
37
|
+
import { type SplitRequireBinding } from "./cjs-inline-require.js";
|
|
36
38
|
import { type ClassInfo, type ClassIteratorInfo, type GenericClassInfo, findStaticOn } from "./lower-classes.js";
|
|
37
39
|
import { type MixinFnShape } from "./lower-mixins.js";
|
|
38
40
|
import { type ParamShape, type FnSig } from "./call-signatures.js";
|
|
@@ -576,6 +578,14 @@ export declare class Lowerer {
|
|
|
576
578
|
/** Per CommonJS file using top-level `this`: the global holding the
|
|
577
579
|
* object that stands for its original exports (lowerCjsTopLevelThis). */
|
|
578
580
|
readonly cjsExportsThis: Map<ts.SourceFile, IrGlobal>;
|
|
581
|
+
/** `var m; m = require("./x")` alias bindings (cjs-inline-require.ts).
|
|
582
|
+
* Null entries cache declarations that keep ordinary storage. */
|
|
583
|
+
readonly cjsSplitRequireBindings: Map<ts.VariableDeclaration, SplitRequireBinding | null>;
|
|
584
|
+
/** Per-module whole-export symbol (cjs-inline-require.ts). Null means the
|
|
585
|
+
* module's exports are a table. */
|
|
586
|
+
readonly cjsWholeExportSymbols: Map<ts.SourceFile, ts.Symbol | null>;
|
|
587
|
+
/** Per-module live member-export classification (cjs-inline-require.ts). */
|
|
588
|
+
readonly cjsLiveMemberExports: Map<ts.SourceFile, boolean>;
|
|
579
589
|
/** Inline program-module require calls whose %init the enclosing member
|
|
580
590
|
* read or member call is already sequencing (cjs-inline-require.ts). */
|
|
581
591
|
readonly inlineRequireInitDone: Set<ts.CallExpression>;
|
|
@@ -630,6 +640,10 @@ export declare class Lowerer {
|
|
|
630
640
|
readonly runtimeOptionalFields: Set<string>;
|
|
631
641
|
/** Bindings initialized by a Date's `toJSON()` (analyzeDateJsonResults). */
|
|
632
642
|
readonly dateJsonBindings: Set<ts.Symbol>;
|
|
643
|
+
/** isTimeValueDateDeclaration's answers, and the locals that hold a
|
|
644
|
+
* Date's time value instead of a Date object (date-values.ts). */
|
|
645
|
+
readonly timeValueDateDecisions: Map<import("../ts7/ast-node.js").AstNode, boolean>;
|
|
646
|
+
readonly timeValueDateLocals: Set<IrLocal>;
|
|
633
647
|
/** Record bindings whose flow class reaches storage outside the class:
|
|
634
648
|
* they keep the declared layout, so an initializer from unchecked reads
|
|
635
649
|
* converts once instead of the binding adopting the widened variant. */
|
|
@@ -743,6 +757,8 @@ export declare class Lowerer {
|
|
|
743
757
|
/** Parameters read as `any` in the error-path copy of an error-first
|
|
744
758
|
* callback. */
|
|
745
759
|
readonly anySymbols: Set<ts.Symbol>;
|
|
760
|
+
/** overload-choice's answers per call, binding and function. */
|
|
761
|
+
readonly dynamicOverloadAnswers: Map<import("../ts7/ast-node.js").AstNode, boolean>;
|
|
746
762
|
/** Error parameters of an error-first callback with a known value in
|
|
747
763
|
* the copy being lowered: true while it holds an Error, false while it
|
|
748
764
|
* holds null (staticCondition folds conditions on them). */
|
|
@@ -817,6 +833,9 @@ export declare class Lowerer {
|
|
|
817
833
|
/** util.inspect's per-type traversal helpers (%util.insp.N), interned
|
|
818
834
|
* by typeKey — the assertHelpers pattern with its own namespace. */
|
|
819
835
|
readonly inspectHelpers: Map<string, string>;
|
|
836
|
+
/** Indexed-union safe-read helpers mapped to their numeric twins, for the
|
|
837
|
+
* fusion of an immediate ToNumber (tryLowerNumericIndexRead). */
|
|
838
|
+
readonly indexedUnionNumericTwins: Map<string, string>;
|
|
820
839
|
private readonly unionLiteralOwners;
|
|
821
840
|
private readonly strippedUndefinedArms;
|
|
822
841
|
private readonly addedUndefinedArms;
|
|
@@ -851,6 +870,10 @@ export declare class Lowerer {
|
|
|
851
870
|
* checks resolve through this map (stdlibGlobalNameOf), declarations
|
|
852
871
|
* emit nothing. */
|
|
853
872
|
readonly stdlibGlobalAliases: Map<ts.Symbol, string>;
|
|
873
|
+
/** The stdlibGlobalAliases bound through a cast of the global object
|
|
874
|
+
* (`(globalThis as { Buffer?: B }).Buffer`). Their static type is the
|
|
875
|
+
* cast's, so their value reads are refused (identifiers.ts). */
|
|
876
|
+
readonly castGlobalAliases: Set<ts.Symbol>;
|
|
854
877
|
/** CJS export-table ACCESSORS (`module.exports = { get path() {...} }`),
|
|
855
878
|
* lifted lazily as module-level functions and interned per accessor
|
|
856
879
|
* declaration: member reads call the getter (lower-exprs). */
|
|
@@ -1048,8 +1071,13 @@ export declare class Lowerer {
|
|
|
1048
1071
|
localId: string;
|
|
1049
1072
|
type: IrType;
|
|
1050
1073
|
} | null>;
|
|
1051
|
-
/**
|
|
1052
|
-
|
|
1074
|
+
/** What each fs path argument of a URL-path call lowers to (the plans
|
|
1075
|
+
* of builtins/fs-paths.ts). */
|
|
1076
|
+
readonly fsPathPlans: Map<ts.ExpressionBase, FsPathPlan>;
|
|
1077
|
+
/** The existsSync/fs.promises calls whose converted URL paths are being
|
|
1078
|
+
* lowered into the call itself (lowerFallibleFsUrlCall). A call may be
|
|
1079
|
+
* lowered more than once, and each lowering converts again. */
|
|
1080
|
+
readonly fallibleFsCalls: Set<ts.CallExpression>;
|
|
1053
1081
|
readonly moduleNsParamOverrides: Map<ts.ParameterDeclaration, {
|
|
1054
1082
|
kind: "moduleNs";
|
|
1055
1083
|
moduleId: string;
|
|
@@ -14,6 +14,7 @@ import { internTableType, lowerInternTableCall, lowerInternTableNew } from "./in
|
|
|
14
14
|
import { lowerThreadSlotsCall, lowerThreadSlotsNew, threadSlotsType } from "./thread-slots.js";
|
|
15
15
|
import { isExperimentalDeclarationFile } from "../experimental-import.js";
|
|
16
16
|
import { checkCycleBindingAccesses, refuseUncheckedCycleReads, } from "./cycle-initialization.js";
|
|
17
|
+
import { bindCompletionCallbacks } from "./completion-callbacks.js";
|
|
17
18
|
import { isJsonRequireDecl } from "./json-require.js";
|
|
18
19
|
import { checkRequireBindingAccesses, } from "./require-initialization.js";
|
|
19
20
|
import { identityPreservingWidening } from "./coercions/identity.js";
|
|
@@ -69,10 +70,11 @@ import { bindingInContext, captureContextBinding, declareContextLocal, declareCo
|
|
|
69
70
|
import { InternalCompilerError } from "../../errors.js";
|
|
70
71
|
import { defaultAfterUndefined, lowerStaticallyUndefinedArgument } from "./optional-arguments.js";
|
|
71
72
|
import {} from "./class-protocol-dispatch.js";
|
|
72
|
-
import { ClassDynamicDispatch, trackClassFieldCreation } from "./class-dynamic-dispatch.js";
|
|
73
|
+
import { ClassDynamicDispatch, boxClassInstancesExactly, trackClassFieldCreation, } from "./class-dynamic-dispatch.js";
|
|
73
74
|
import { guardClassAttributeWrites } from "./class-attributes.js";
|
|
74
75
|
import { guardFrozenWrites, markSloppyRecordWrites } from "./frozen-records.js";
|
|
75
76
|
import { applyHandleProperties } from "./handle-properties.js";
|
|
77
|
+
import { installBufferValue } from "./containers/bytes.js";
|
|
76
78
|
import { ClassProtocols } from "./class-protocols.js";
|
|
77
79
|
import { earlyReadVarSymbols } from "./var-hoisting.js";
|
|
78
80
|
import { recordTextCodecClass } from "../../ir/ir.js";
|
|
@@ -116,7 +118,7 @@ import { builtinConstLit, builtinModuleConstOf, builtinModulesArrayLit, builtinF
|
|
|
116
118
|
import { builtinClassAliasOf, runtimeClassValueOfType, } from "./builtins/class-values.js";
|
|
117
119
|
import { splitFiles, collectProgram, collectNpmImports, collectJsonImports, moduleArtifacts, collectGlobals, declSymbolOf, defaultExportSymbolOf, lowerFileInit, lowerDefaultExport, buildMain, appendDynamicImportModules, appendForkModules, appendWorkerModules, } from "./lower-modules.js";
|
|
118
120
|
import { prepareCjsModuleGraph, usesCjsTopLevelThis } from "./lower-node-module.js";
|
|
119
|
-
import { cjsNamespaceModule, cjsWholeExportValueOf, inlineNamespaceRequireOf, inlineProgramRequireOf, } from "./cjs-inline-require.js";
|
|
121
|
+
import { cjsNamespaceModule, cjsWholeExportValueOf, inlineNamespaceRequireOf, inlineProgramRequireOf, splitRequireBindingOf, splitWholeExportAliasTargetOf, } from "./cjs-inline-require.js";
|
|
120
122
|
import { tscInteropModuleOf } from "./cjs-tsc-interop.js";
|
|
121
123
|
import { usesCjsExportsIdentity } from "./cjs-exports-object.js";
|
|
122
124
|
import { registerBuiltinEventTargetClasses } from "./lower-event-target.js";
|
|
@@ -124,6 +126,7 @@ import { registerBuiltinErrorClasses, defineClassValueConstruct, runtimeClassCon
|
|
|
124
126
|
import { mixinCallClassInfoOf, mixinIntersectionInstanceType, } from "./lower-mixins.js";
|
|
125
127
|
import { tryLowerExpression } from "./expressions/try-lower-expression.js";
|
|
126
128
|
import { funcTypeFromParamShapes, isThisParameter, paramShape, paramShapes, checkDefaultParamBodyType, requireExactArityValue, collectSignature, collectSignatureInner, lambdaSignature, } from "./call-signatures.js";
|
|
129
|
+
import { dynamicOverloadChoice, guessedOverloadIdentifier } from "./overload-choice.js";
|
|
127
130
|
import { implicitAnyParamSymbolsOf, implicitLocalFnNodeOf, implicitMonoFile, collectGenericSignature, genericFnOf, lowerGenericCall, lowerGenericFnValue, inferTypeParamBindings, lowerGenericInstance, genericLocalClassBinding, } from "./generic-functions.js";
|
|
128
131
|
import { bindingNeverReassigned } from "./binding-analysis.js";
|
|
129
132
|
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
@@ -1519,6 +1522,14 @@ export class Lowerer {
|
|
|
1519
1522
|
/** Per CommonJS file using top-level `this`: the global holding the
|
|
1520
1523
|
* object that stands for its original exports (lowerCjsTopLevelThis). */
|
|
1521
1524
|
cjsExportsThis = new Map();
|
|
1525
|
+
/** `var m; m = require("./x")` alias bindings (cjs-inline-require.ts).
|
|
1526
|
+
* Null entries cache declarations that keep ordinary storage. */
|
|
1527
|
+
cjsSplitRequireBindings = new Map();
|
|
1528
|
+
/** Per-module whole-export symbol (cjs-inline-require.ts). Null means the
|
|
1529
|
+
* module's exports are a table. */
|
|
1530
|
+
cjsWholeExportSymbols = new Map();
|
|
1531
|
+
/** Per-module live member-export classification (cjs-inline-require.ts). */
|
|
1532
|
+
cjsLiveMemberExports = new Map();
|
|
1522
1533
|
/** Inline program-module require calls whose %init the enclosing member
|
|
1523
1534
|
* read or member call is already sequencing (cjs-inline-require.ts). */
|
|
1524
1535
|
inlineRequireInitDone = new Set();
|
|
@@ -1569,6 +1580,10 @@ export class Lowerer {
|
|
|
1569
1580
|
runtimeOptionalFields = new Set();
|
|
1570
1581
|
/** Bindings initialized by a Date's `toJSON()` (analyzeDateJsonResults). */
|
|
1571
1582
|
dateJsonBindings = new Set();
|
|
1583
|
+
/** isTimeValueDateDeclaration's answers, and the locals that hold a
|
|
1584
|
+
* Date's time value instead of a Date object (date-values.ts). */
|
|
1585
|
+
timeValueDateDecisions = new Map();
|
|
1586
|
+
timeValueDateLocals = new Set();
|
|
1572
1587
|
/** Record bindings whose flow class reaches storage outside the class:
|
|
1573
1588
|
* they keep the declared layout, so an initializer from unchecked reads
|
|
1574
1589
|
* converts once instead of the binding adopting the widened variant. */
|
|
@@ -2016,6 +2031,8 @@ export class Lowerer {
|
|
|
2016
2031
|
/** Parameters read as `any` in the error-path copy of an error-first
|
|
2017
2032
|
* callback. */
|
|
2018
2033
|
anySymbols = new Set();
|
|
2034
|
+
/** overload-choice's answers per call, binding and function. */
|
|
2035
|
+
dynamicOverloadAnswers = new Map();
|
|
2019
2036
|
/** Error parameters of an error-first callback with a known value in
|
|
2020
2037
|
* the copy being lowered: true while it holds an Error, false while it
|
|
2021
2038
|
* holds null (staticCondition folds conditions on them). */
|
|
@@ -2090,6 +2107,9 @@ export class Lowerer {
|
|
|
2090
2107
|
/** util.inspect's per-type traversal helpers (%util.insp.N), interned
|
|
2091
2108
|
* by typeKey — the assertHelpers pattern with its own namespace. */
|
|
2092
2109
|
inspectHelpers = new Map();
|
|
2110
|
+
/** Indexed-union safe-read helpers mapped to their numeric twins, for the
|
|
2111
|
+
* fusion of an immediate ToNumber (tryLowerNumericIndexRead). */
|
|
2112
|
+
indexedUnionNumericTwins = new Map();
|
|
2093
2113
|
unionLiteralOwners = new Map();
|
|
2094
2114
|
strippedUndefinedArms = new Map();
|
|
2095
2115
|
addedUndefinedArms = new Map();
|
|
@@ -2120,6 +2140,10 @@ export class Lowerer {
|
|
|
2120
2140
|
* checks resolve through this map (stdlibGlobalNameOf), declarations
|
|
2121
2141
|
* emit nothing. */
|
|
2122
2142
|
stdlibGlobalAliases = new Map();
|
|
2143
|
+
/** The stdlibGlobalAliases bound through a cast of the global object
|
|
2144
|
+
* (`(globalThis as { Buffer?: B }).Buffer`). Their static type is the
|
|
2145
|
+
* cast's, so their value reads are refused (identifiers.ts). */
|
|
2146
|
+
castGlobalAliases = new Set();
|
|
2123
2147
|
/** CJS export-table ACCESSORS (`module.exports = { get path() {...} }`),
|
|
2124
2148
|
* lifted lazily as module-level functions and interned per accessor
|
|
2125
2149
|
* declaration: member reads call the getter (lower-exprs). */
|
|
@@ -2292,8 +2316,13 @@ export class Lowerer {
|
|
|
2292
2316
|
* (builtins/fs-paths.ts): each lowers to the hidden local that holds its
|
|
2293
2317
|
* value, which is null until the path's lowering has saved it. */
|
|
2294
2318
|
stagedArguments = new Map();
|
|
2295
|
-
/**
|
|
2296
|
-
|
|
2319
|
+
/** What each fs path argument of a URL-path call lowers to (the plans
|
|
2320
|
+
* of builtins/fs-paths.ts). */
|
|
2321
|
+
fsPathPlans = new Map();
|
|
2322
|
+
/** The existsSync/fs.promises calls whose converted URL paths are being
|
|
2323
|
+
* lowered into the call itself (lowerFallibleFsUrlCall). A call may be
|
|
2324
|
+
* lowered more than once, and each lowering converts again. */
|
|
2325
|
+
fallibleFsCalls = new Set();
|
|
2297
2326
|
moduleNsParamOverrides = new Map();
|
|
2298
2327
|
/** File → qualifier prefix: "" for the entry, "%mI." otherwise. */
|
|
2299
2328
|
fileTag = new Map();
|
|
@@ -3197,6 +3226,12 @@ export class Lowerer {
|
|
|
3197
3226
|
const cjsValue = this.cjsExportValueSymbol(symbol);
|
|
3198
3227
|
if (cjsValue)
|
|
3199
3228
|
symbol = cjsValue;
|
|
3229
|
+
// `var m; m = require("./x"); module.exports = m` over a whole-export
|
|
3230
|
+
// target: TS types the wrapper's export= as `any`, so reconnect it to
|
|
3231
|
+
// the target's value symbol explicitly.
|
|
3232
|
+
const splitAlias = splitWholeExportAliasTargetOf(this, symbol);
|
|
3233
|
+
if (splitAlias)
|
|
3234
|
+
symbol = splitAlias;
|
|
3200
3235
|
this.flushDeferred(symbol);
|
|
3201
3236
|
return symbol;
|
|
3202
3237
|
}
|
|
@@ -3310,7 +3345,7 @@ export class Lowerer {
|
|
|
3310
3345
|
// exact mappings, while star exports resolve to the mapped declaration
|
|
3311
3346
|
// owner through externalTypeSpecifiersByFile.
|
|
3312
3347
|
const moduleSymbol = this.checker.getSymbolAtLocation(sf);
|
|
3313
|
-
const exported = moduleSymbol?.getExports().get(exportName);
|
|
3348
|
+
const exported = moduleSymbol?.getExports().get(ts.escapedSymbolName(exportName));
|
|
3314
3349
|
return this.externalTypeSpecifierOfSymbol(exported, seenSymbols, seenExports);
|
|
3315
3350
|
}
|
|
3316
3351
|
externalTypeSpecifierOfNamespaceMember(expr, member) {
|
|
@@ -3451,7 +3486,7 @@ export class Lowerer {
|
|
|
3451
3486
|
cjsModuleExportSymbol(sf, name) {
|
|
3452
3487
|
const moduleSym = this.checker.getSymbolAtLocation(sf);
|
|
3453
3488
|
const exports = moduleSym?.getExports();
|
|
3454
|
-
const direct = exports?.get(name);
|
|
3489
|
+
const direct = exports?.get(ts.escapedSymbolName(name));
|
|
3455
3490
|
if (direct)
|
|
3456
3491
|
return direct;
|
|
3457
3492
|
// tsgo represents `module.exports = { ... }` as one `export=` symbol
|
|
@@ -3601,8 +3636,10 @@ export class Lowerer {
|
|
|
3601
3636
|
return null;
|
|
3602
3637
|
if (ts.isImportClause(decl))
|
|
3603
3638
|
return this.cjsDefaultImportDepOf(decl);
|
|
3604
|
-
if (!ts.isVariableDeclaration(decl) || !ts.isIdentifier(decl.name)
|
|
3639
|
+
if (!ts.isVariableDeclaration(decl) || !ts.isIdentifier(decl.name))
|
|
3605
3640
|
return null;
|
|
3641
|
+
if (decl.initializer === undefined)
|
|
3642
|
+
return splitRequireBindingOf(this, decl)?.dep ?? null;
|
|
3606
3643
|
{
|
|
3607
3644
|
const interop = tscInteropModuleOf(this, expr);
|
|
3608
3645
|
if (interop !== null)
|
|
@@ -3705,6 +3742,10 @@ export class Lowerer {
|
|
|
3705
3742
|
if (!ts.isIdentifier(expr))
|
|
3706
3743
|
return this.cjsModuleRefDepOf(expr) !== null;
|
|
3707
3744
|
const sym = this.checker.getSymbolAtLocation(expr);
|
|
3745
|
+
const splitDecl = sym?.declarations.find(ts.isVariableDeclaration);
|
|
3746
|
+
const split = splitDecl === undefined ? null : splitRequireBindingOf(this, splitDecl);
|
|
3747
|
+
if (split !== null)
|
|
3748
|
+
return cjsNamespaceModule(this, split.dep);
|
|
3708
3749
|
if (this.localModuleBindingDepOf(expr) === null)
|
|
3709
3750
|
return false;
|
|
3710
3751
|
if (this.createRequireWholeExportSymbolOf(expr) !== null)
|
|
@@ -4012,6 +4053,9 @@ export class Lowerer {
|
|
|
4012
4053
|
* their external dependencies by name). Null for everything else
|
|
4013
4054
|
* (builtins load nothing; the rest kept its preflight fence). */
|
|
4014
4055
|
requireInitStmt(spec, node) {
|
|
4056
|
+
if (this.inlineRequireCycleCalls.has(node)) {
|
|
4057
|
+
this.unsupported("SC1090", node, `require() of '${spec}' while it is still evaluating (a require cycle: Node answers its partial exports, which the static export table does not model)`);
|
|
4058
|
+
}
|
|
4015
4059
|
if (canonicalBuiltinModule(spec) === "punycode")
|
|
4016
4060
|
return this.punycodeRequireWarning(node);
|
|
4017
4061
|
// Project requires resolve within the program; another bare require can
|
|
@@ -6830,9 +6874,11 @@ export class Lowerer {
|
|
|
6830
6874
|
finalizeClassMethodValues(this, functions);
|
|
6831
6875
|
finalizePrivateBrands(this, functions);
|
|
6832
6876
|
trackClassFieldCreation(this, functions);
|
|
6877
|
+
boxClassInstancesExactly(this, functions);
|
|
6833
6878
|
guardClassAttributeWrites(this, functions);
|
|
6834
6879
|
guardFrozenWrites(this, functions);
|
|
6835
6880
|
applyHandleProperties(this, functions);
|
|
6881
|
+
installBufferValue(functions);
|
|
6836
6882
|
// Globals typed by a class that never REGISTERED (a JS class whose
|
|
6837
6883
|
// collection fenced — Symbol-keyed fields, an unsupported base): the
|
|
6838
6884
|
// declaration statement and every use compiled to runtime fences, but
|
|
@@ -6948,6 +6994,8 @@ export class Lowerer {
|
|
|
6948
6994
|
sanitizeUnregisteredClassTypes(module, (name) => this.classes.has(name));
|
|
6949
6995
|
if (module)
|
|
6950
6996
|
checkCycleBindingAccesses(this, module);
|
|
6997
|
+
if (module)
|
|
6998
|
+
bindCompletionCallbacks(module);
|
|
6951
6999
|
// Execution tiers from the final bodies (ir/tiers.ts). Assigned with or
|
|
6952
7000
|
// without a module: coverage reports the dynamic tier of programs that
|
|
6953
7001
|
// still have blockers.
|
|
@@ -7925,6 +7973,16 @@ export class Lowerer {
|
|
|
7925
7973
|
typeOf(node) {
|
|
7926
7974
|
if (this.anySymbols.size > 0 && this.readsAnySymbol(node))
|
|
7927
7975
|
return this.checker.getAnyType();
|
|
7976
|
+
// A checked-dynamic argument that another overload could take at run
|
|
7977
|
+
// time leaves the resolved overload's return a guess, and JS bindings
|
|
7978
|
+
// initialized with that result hold whatever it was.
|
|
7979
|
+
if ((ts.isCallExpression(node) || ts.isNewExpression(node)) &&
|
|
7980
|
+
dynamicOverloadChoice(this, node))
|
|
7981
|
+
return this.checker.getAnyType();
|
|
7982
|
+
if (ts.isIdentifier(node) &&
|
|
7983
|
+
isJsSourceFile(ts.getSourceFileOfNode(node)) &&
|
|
7984
|
+
guessedOverloadIdentifier(this, node))
|
|
7985
|
+
return this.checker.getAnyType();
|
|
7928
7986
|
if (ts.isPropertyAccessExpression(node) && isJsSourceFile(ts.getSourceFileOfNode(node))) {
|
|
7929
7987
|
const receiver = node.expression.kind === ts.SyntaxKind.ThisKeyword && this.fnStack.length > 0
|
|
7930
7988
|
? this.resolveThis()?.type
|
|
@@ -12080,6 +12138,9 @@ export class Lowerer {
|
|
|
12080
12138
|
loc,
|
|
12081
12139
|
};
|
|
12082
12140
|
}
|
|
12141
|
+
// The buffer module's Buffer is the global constructor's value.
|
|
12142
|
+
if (bi.module === "buffer" && bi.member === "Buffer")
|
|
12143
|
+
return { kind: "libCall", fn: "buffer.constructor", args: [], type: DYN, loc };
|
|
12083
12144
|
if (bi.module === "fs" && (bi.member === "realpathSync" || bi.member === "realpathSync.native"))
|
|
12084
12145
|
return fsRealpathValue(this, bi.member === "realpathSync.native", loc);
|
|
12085
12146
|
const fn = builtinModuleFnOf(this, bi.module, bi.member);
|