@scriptc/compiler 0.2.5 → 0.2.6
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 +57 -30
- package/dist/backend/cycle-analysis.test.js +1 -1
- package/dist/backend/executable-features.js +1 -0
- package/dist/backend/executable-features.js.map +1 -1
- package/dist/backend/link-plan-core.d.ts +2 -0
- package/dist/backend/link-plan-core.js +1 -0
- package/dist/backend/link-plan-core.js.map +1 -1
- package/dist/backend/link-plan.d.ts +1 -0
- package/dist/backend/link-plan.js +3 -0
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/byte-numbers.js +32 -4
- package/dist/backend/llvm/byte-numbers.js.map +1 -1
- package/dist/backend/llvm/byte-windows.d.ts +31 -0
- package/dist/backend/llvm/byte-windows.js +334 -0
- package/dist/backend/llvm/byte-windows.js.map +1 -0
- package/dist/backend/llvm/byte-windows.test.d.ts +1 -0
- package/dist/backend/llvm/byte-windows.test.js +244 -0
- package/dist/backend/llvm/byte-windows.test.js.map +1 -0
- package/dist/backend/llvm/call-lifetimes.d.ts +2 -2
- package/dist/backend/llvm/call-lifetimes.js +17 -7
- package/dist/backend/llvm/call-lifetimes.js.map +1 -1
- package/dist/backend/llvm/classes.d.ts +14 -1
- package/dist/backend/llvm/classes.js +80 -9
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/classes.test.d.ts +1 -0
- package/dist/backend/llvm/classes.test.js +99 -0
- package/dist/backend/llvm/classes.test.js.map +1 -0
- package/dist/backend/llvm/constant-callbacks.d.ts +11 -0
- package/dist/backend/llvm/constant-callbacks.js +213 -0
- package/dist/backend/llvm/constant-callbacks.js.map +1 -0
- package/dist/backend/llvm/constant-callbacks.test.d.ts +1 -0
- package/dist/backend/llvm/constant-callbacks.test.js +124 -0
- package/dist/backend/llvm/constant-callbacks.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +1 -1
- package/dist/backend/llvm/dyn.js +7 -34
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.d.ts +19 -0
- package/dist/backend/llvm/emitter.js +274 -46
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/emitter.test.js +17 -11
- package/dist/backend/llvm/emitter.test.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.js +11 -0
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-calls.js +91 -23
- package/dist/backend/llvm/expr-calls.js.map +1 -1
- package/dist/backend/llvm/expr-containers.js +21 -9
- package/dist/backend/llvm/expr-containers.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +36 -3
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.js +7 -0
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.js +1 -1
- package/dist/backend/llvm/expr-stream-bridges.test.js +1 -1
- package/dist/backend/llvm/integer-remainder.d.ts +7 -0
- package/dist/backend/llvm/integer-remainder.js +26 -0
- package/dist/backend/llvm/integer-remainder.js.map +1 -0
- package/dist/backend/llvm/layouts.js +1 -1
- package/dist/backend/llvm/layouts.js.map +1 -1
- package/dist/backend/llvm/lib-abi.js +7 -0
- package/dist/backend/llvm/lib-abi.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +7 -22
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +15 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.d.ts +8 -2
- package/dist/backend/llvm/local-array-reads.js +89 -68
- package/dist/backend/llvm/local-array-reads.js.map +1 -1
- package/dist/backend/llvm/local-array-reads.test.js +28 -4
- package/dist/backend/llvm/local-array-reads.test.js.map +1 -1
- package/dist/backend/llvm/local-union-storage.test.js +1 -1
- package/dist/backend/llvm/loop-array-borrows.d.ts +11 -0
- package/dist/backend/llvm/loop-array-borrows.js +70 -0
- package/dist/backend/llvm/loop-array-borrows.js.map +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.d.ts +1 -0
- package/dist/backend/llvm/loop-array-borrows.test.js +145 -0
- package/dist/backend/llvm/loop-array-borrows.test.js.map +1 -0
- package/dist/backend/llvm/map-read-lifetimes.d.ts +5 -0
- package/dist/backend/llvm/map-read-lifetimes.js +20 -5
- package/dist/backend/llvm/map-read-lifetimes.js.map +1 -1
- package/dist/backend/llvm/map-read-lifetimes.test.js +1 -1
- package/dist/backend/llvm/reference-effects.d.ts +2 -1
- package/dist/backend/llvm/reference-effects.js +7 -0
- package/dist/backend/llvm/reference-effects.js.map +1 -1
- package/dist/backend/llvm/shapes.d.ts +4 -1
- package/dist/backend/llvm/shapes.js +22 -7
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/split-loops.d.ts +48 -0
- package/dist/backend/llvm/split-loops.js +183 -0
- package/dist/backend/llvm/split-loops.js.map +1 -0
- package/dist/backend/llvm/split.js +0 -7
- package/dist/backend/llvm/split.js.map +1 -1
- package/dist/backend/llvm/split.test.js +66 -2
- package/dist/backend/llvm/split.test.js.map +1 -1
- package/dist/backend/llvm/stack-callbacks.d.ts +14 -0
- package/dist/backend/llvm/stack-callbacks.js +73 -0
- package/dist/backend/llvm/stack-callbacks.js.map +1 -0
- package/dist/backend/llvm/stack-captures.d.ts +25 -0
- package/dist/backend/llvm/stack-captures.js +150 -0
- package/dist/backend/llvm/stack-captures.js.map +1 -0
- package/dist/backend/llvm/stack-unions.test.js +1 -1
- package/dist/backend/llvm/string-construction.test.js +1 -1
- package/dist/backend/llvm/string-lifetimes.test.js +8 -4
- package/dist/backend/llvm/string-lifetimes.test.js.map +1 -1
- package/dist/backend/llvm/string-slices.d.ts +20 -0
- package/dist/backend/llvm/string-slices.js +87 -0
- package/dist/backend/llvm/string-slices.js.map +1 -0
- package/dist/backend/llvm/string-slices.test.d.ts +1 -0
- package/dist/backend/llvm/string-slices.test.js +98 -0
- package/dist/backend/llvm/string-slices.test.js.map +1 -0
- package/dist/backend/llvm/switch-dispatch.test.js +1 -1
- package/dist/backend/llvm/walkers.d.ts +4 -14
- package/dist/backend/llvm/walkers.js +53 -311
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/may-throw.js +1 -1
- package/dist/backend/may-throw.js.map +1 -1
- package/dist/backend/may-throw.test.js +1 -1
- package/dist/backend/native/contracts.d.ts +2 -0
- package/dist/backend/native/executable.js +12 -4
- package/dist/backend/native/executable.js.map +1 -1
- package/dist/backend/native/runtime-inputs.d.ts +1 -1
- package/dist/backend/native/runtime-inputs.js +2 -0
- package/dist/backend/native/runtime-inputs.js.map +1 -1
- package/dist/backend/native-codegen-core.d.ts +6 -0
- package/dist/backend/native-codegen-core.js +21 -0
- package/dist/backend/native-codegen-core.js.map +1 -1
- package/dist/backend/native-codegen.d.ts +4 -0
- package/dist/backend/native-codegen.js +34 -18
- package/dist/backend/native-codegen.js.map +1 -1
- package/dist/backend/native-codegen.test.js +47 -2
- package/dist/backend/native-codegen.test.js.map +1 -1
- package/dist/backend/native-link-info-core.d.ts +1 -0
- package/dist/backend/native-link-info-core.js.map +1 -1
- package/dist/backend/native-tools.d.ts +3 -1
- package/dist/backend/native-tools.js +6 -4
- package/dist/backend/native-tools.js.map +1 -1
- package/dist/backend/runtime-abi.d.ts +2 -2
- package/dist/backend/runtime-abi.js +2 -2
- package/dist/backend/runtime-pack-core.d.ts +1 -0
- package/dist/backend/runtime-pack-core.js +8 -1
- package/dist/backend/runtime-pack-core.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +41 -4
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +11 -1
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/target-diagnostics.test.js +1 -1
- package/dist/executable/executable-cache.d.ts +1 -0
- package/dist/executable/executable-cache.js +2 -1
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +15 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/fork-target.d.ts +5 -0
- package/dist/frontend/fork-target.js +40 -8
- package/dist/frontend/fork-target.js.map +1 -1
- package/dist/frontend/fork-target.test.d.ts +1 -0
- package/dist/frontend/fork-target.test.js +59 -0
- package/dist/frontend/fork-target.test.js.map +1 -0
- package/dist/frontend/lowering/binding-analysis.js +2 -2
- package/dist/frontend/lowering/binding-analysis.js.map +1 -1
- package/dist/frontend/lowering/builtins/atomics.d.ts +2 -11
- package/dist/frontend/lowering/builtins/atomics.js +64 -28
- package/dist/frontend/lowering/builtins/atomics.js.map +1 -1
- package/dist/frontend/lowering/builtins/filesystem-calls.d.ts +3 -0
- package/dist/frontend/lowering/builtins/filesystem-calls.js +51 -4
- package/dist/frontend/lowering/builtins/filesystem-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/module-calls.js +6 -1
- package/dist/frontend/lowering/builtins/module-calls.js.map +1 -1
- package/dist/frontend/lowering/builtins/workers.d.ts +5 -0
- package/dist/frontend/lowering/builtins/workers.js +65 -0
- package/dist/frontend/lowering/builtins/workers.js.map +1 -0
- package/dist/frontend/lowering/class-assertions.d.ts +7 -0
- package/dist/frontend/lowering/class-assertions.js +96 -0
- package/dist/frontend/lowering/class-assertions.js.map +1 -0
- package/dist/frontend/lowering/class-protocols.d.ts +17 -0
- package/dist/frontend/lowering/class-protocols.js +126 -0
- package/dist/frontend/lowering/class-protocols.js.map +1 -0
- package/dist/frontend/lowering/containers/array-callbacks.d.ts +7 -11
- package/dist/frontend/lowering/containers/array-callbacks.js +52 -87
- package/dist/frontend/lowering/containers/array-callbacks.js.map +1 -1
- package/dist/frontend/lowering/containers/bytes.js +12 -34
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/containers/string-and-regexp.js +22 -3
- package/dist/frontend/lowering/containers/string-and-regexp.js.map +1 -1
- package/dist/frontend/lowering/expressions/object-literals.js +2 -6
- package/dist/frontend/lowering/expressions/object-literals.js.map +1 -1
- package/dist/frontend/lowering/generic-functions.d.ts +2 -5
- package/dist/frontend/lowering/generic-functions.js +13 -10
- package/dist/frontend/lowering/generic-functions.js.map +1 -1
- package/dist/frontend/lowering/instantiation-path.d.ts +8 -0
- package/dist/frontend/lowering/instantiation-path.js +10 -0
- package/dist/frontend/lowering/instantiation-path.js.map +1 -0
- package/dist/frontend/lowering/instantiation-path.test.d.ts +1 -0
- package/dist/frontend/lowering/instantiation-path.test.js +23 -0
- package/dist/frontend/lowering/instantiation-path.test.js.map +1 -0
- package/dist/frontend/lowering/lower-builtin-values.js +11 -7
- package/dist/frontend/lowering/lower-builtin-values.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.js +36 -3
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +5 -0
- package/dist/frontend/lowering/lower-classes.js +121 -53
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +31 -10
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-functions.d.ts +1 -1
- package/dist/frontend/lowering/lower-functions.js +2 -2
- package/dist/frontend/lowering/lower-functions.js.map +1 -1
- package/dist/frontend/lowering/lower-island.js +1 -1
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +1 -0
- package/dist/frontend/lowering/lower-modules.js +44 -9
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +13 -11
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +1 -1
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +13 -1
- package/dist/frontend/lowering/lowerer.js +51 -9
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/sanitize-class-types.test.js +2 -2
- package/dist/frontend/lowering/split-consumers.d.ts +7 -0
- package/dist/frontend/lowering/split-consumers.js +64 -0
- package/dist/frontend/lowering/split-consumers.js.map +1 -0
- package/dist/frontend/lowering/surfaces.d.ts +3 -4
- package/dist/frontend/lowering/surfaces.js +35 -7
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/module-source-candidates.d.ts +10 -0
- package/dist/frontend/module-source-candidates.js +40 -0
- package/dist/frontend/module-source-candidates.js.map +1 -0
- package/dist/frontend/module-source-candidates.test.d.ts +1 -0
- package/dist/frontend/module-source-candidates.test.js +53 -0
- package/dist/frontend/module-source-candidates.test.js.map +1 -0
- package/dist/frontend/pipeline.js +2 -2
- package/dist/frontend/pipeline.js.map +1 -1
- package/dist/frontend/program-analysis.d.ts +2 -0
- package/dist/frontend/program-analysis.js +2 -0
- package/dist/frontend/program-analysis.js.map +1 -1
- package/dist/frontend/program.js +17 -29
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/ts7/ast-node.js +6 -8
- package/dist/frontend/ts7/ast-node.js.map +1 -1
- package/dist/frontend/ts7/ast-node.test.js +42 -1
- package/dist/frontend/ts7/ast-node.test.js.map +1 -1
- package/dist/frontend/ts7/ast-wire.d.ts +4 -0
- package/dist/frontend/ts7/ast-wire.js +28 -0
- package/dist/frontend/ts7/ast-wire.js.map +1 -1
- package/dist/frontend/ts7/ast.d.ts +2 -1
- package/dist/frontend/ts7/ast.js +8 -4
- package/dist/frontend/ts7/ast.js.map +1 -1
- package/dist/frontend/ts7/checker.d.ts +8 -2
- package/dist/frontend/ts7/checker.js +41 -5
- package/dist/frontend/ts7/checker.js.map +1 -1
- package/dist/frontend/ts7/checker.test.js +42 -0
- package/dist/frontend/ts7/checker.test.js.map +1 -1
- package/dist/frontend/ts7/program-host.d.ts +7 -0
- package/dist/frontend/ts7/program-host.js +26 -2
- package/dist/frontend/ts7/program-host.js.map +1 -1
- package/dist/frontend/ts7/program-host.test.js +29 -0
- package/dist/frontend/ts7/program-host.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +3 -0
- package/dist/frontend/type-mapper.js +44 -2
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/frontend/worker-target.d.ts +6 -0
- package/dist/frontend/worker-target.js +108 -0
- package/dist/frontend/worker-target.js.map +1 -0
- package/dist/frontend/worker-target.test.d.ts +1 -0
- package/dist/frontend/worker-target.test.js +71 -0
- package/dist/frontend/worker-target.test.js.map +1 -0
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/dist/ir/builtin-effects.js +12 -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 +13 -12
- package/dist/ir/builtin-signatures.js.map +1 -1
- package/dist/ir/constant-tables.test.js +1 -1
- package/dist/ir/initializer-bindings.test.js +1 -1
- package/dist/ir/ir.d.ts +9 -10
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/numeric-call-specialization.d.ts +8 -0
- package/dist/ir/numeric-call-specialization.js +198 -0
- package/dist/ir/numeric-call-specialization.js.map +1 -0
- package/dist/ir/runtime-features.js +4 -3
- package/dist/ir/runtime-features.js.map +1 -1
- package/dist/ir/scalar-records.test.js +1 -1
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +3 -3
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.js +89 -23
- package/dist/ir/validate.js.map +1 -1
- package/dist/ir/validate.test.js +91 -4
- package/dist/ir/validate.test.js.map +1 -1
- package/dist/library/fence-eval.test.js +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/ir-policy.js +2 -0
- package/dist/library/ir-policy.js.map +1 -1
- package/dist/library/library-cache.test.js +5 -5
- package/dist/native/compiler.js +24 -11
- package/dist/native/compiler.js.map +1 -1
- package/dist/native/compiler.test.js +7 -3
- package/dist/native/compiler.test.js.map +1 -1
- package/dist/native/prepare.js +2 -0
- package/dist/native/prepare.js.map +1 -1
- package/dist/native/sanitizer.test.js +1 -0
- package/dist/native/sanitizer.test.js.map +1 -1
- package/package.json +20 -20
- package/surface-manifest.json +30 -2
|
@@ -2,6 +2,7 @@ import * as ts from "../ts7/adapter.js";
|
|
|
2
2
|
import type { FnCtx, Lowerer } from "./lowerer.js";
|
|
3
3
|
import { type IrClassDef, type IrExpr, type IrFunction, type IrLocal, type IrStmt, type IrType, type SrcLoc } from "../../ir/ir.js";
|
|
4
4
|
import { type GenericFnInfo } from "./generic-functions.js";
|
|
5
|
+
import { type InstantiationPath } from "./instantiation-path.js";
|
|
5
6
|
import { type ParamShape } from "./call-signatures.js";
|
|
6
7
|
import { type ScrDiagnostic } from "../../diagnostics/diagnostic.js";
|
|
7
8
|
import { type EmitOverrideRec } from "./lower-event-emitter.js";
|
|
@@ -131,6 +132,8 @@ export interface ClassInfo {
|
|
|
131
132
|
* (forwarding the completed ABI values; defaults apply in the base). */
|
|
132
133
|
ctorParams: ParamShape[];
|
|
133
134
|
base: ClassInfo | null;
|
|
135
|
+
/** Family heritage resolves its type arguments separately for each instance. */
|
|
136
|
+
genericBase?: ts.ExpressionWithTypeArguments;
|
|
134
137
|
/** A module class may inherit a compiled ordinary JS constructor. Its
|
|
135
138
|
* callable and prototype are captured when the class declaration runs. */
|
|
136
139
|
callableBase?: {
|
|
@@ -214,6 +217,7 @@ export interface ClassInfo {
|
|
|
214
217
|
* counts statements toward coverage — re-instantiations re-visit the
|
|
215
218
|
* same source lines). */
|
|
216
219
|
genericInstance?: {
|
|
220
|
+
path: InstantiationPath;
|
|
217
221
|
family: ClassInfo;
|
|
218
222
|
bindings: Map<ts.Symbol, IrType>;
|
|
219
223
|
typeArgsText: string;
|
|
@@ -376,6 +380,7 @@ export declare function guaranteedDecorationThrow(lowerer: Lowerer, decl: ts.Cla
|
|
|
376
380
|
} | null;
|
|
377
381
|
export declare function collectClassShape(lowerer: Lowerer, decl: ts.ClassDeclaration): void;
|
|
378
382
|
export declare function collectClassShapeInner(lowerer: Lowerer, decl: ts.ClassLikeDeclaration, jsNameOverride?: string, inst?: {
|
|
383
|
+
path: InstantiationPath;
|
|
379
384
|
family: ClassInfo;
|
|
380
385
|
name: string;
|
|
381
386
|
bindings: Map<ts.Symbol, IrType>;
|
|
@@ -7,7 +7,8 @@ import { InternalCompilerError } from "../../errors.js";
|
|
|
7
7
|
* hierarchy registration. */
|
|
8
8
|
import * as ts from "../ts7/adapter.js";
|
|
9
9
|
import { BOOL, DATE_T, DYN, F64, bytesOf, JSVAL, RUNTIME_EMITTER_CLASS, RUNTIME_ERROR_CLASSES, RUNTIME_STREAM_CLASSES, STRING, UNDEFINED_T, VOID, arrayOf, isSupportedMapKey, isSupportedMapValue, isSupportedSetElem, isUnitType, typeEquals, } from "../../ir/ir.js";
|
|
10
|
-
import {
|
|
10
|
+
import { genericCallInstance, implicitAnyParamSymbolsOf, implicitCallInstance, implicitMonoFile, } from "./generic-functions.js";
|
|
11
|
+
import { extendInstantiationPath, MAX_INSTANTIATION_RECURSION, } from "./instantiation-path.js";
|
|
11
12
|
import { appendImplicitUndefinedReturn, hasExplicitJsDocReturn } from "./function-returns.js";
|
|
12
13
|
import { bodyReadsArguments } from "../arguments-usage.js";
|
|
13
14
|
import { generatorMeta } from "./call-signatures.js";
|
|
@@ -22,6 +23,7 @@ import { bufEncoding } from "./containers/bytes.js";
|
|
|
22
23
|
import { isSafeToRepeat } from "./expressions/evaluation-safety.js";
|
|
23
24
|
import { lowerSearchParamsNew } from "./builtins/url.js";
|
|
24
25
|
import { lowerTextCodecNew } from "./builtins/text-codecs.js";
|
|
26
|
+
import { lowerWorkerNew } from "./builtins/workers.js";
|
|
25
27
|
import { requiresDynamicPackageDiag, unsupportedDiag, } from "../../diagnostics/diagnostic.js";
|
|
26
28
|
import { STREAM_API_MEMBERS, STREAM_PROP_MEMBERS, UNDERSCORE_METHODS, lowerStreamNew, lowerStreamSuperCall, streamCtorShape, } from "./lower-stream.js";
|
|
27
29
|
import { emitOverrideShapeReason, emitSpecSuperForward, emitterRooted, lowerEmitterSuperCall, } from "./lower-event-emitter.js";
|
|
@@ -949,7 +951,36 @@ export function guaranteedDecorationThrow(lowerer, decl) {
|
|
|
949
951
|
return null;
|
|
950
952
|
}
|
|
951
953
|
export function collectClassShape(lowerer, decl) {
|
|
952
|
-
|
|
954
|
+
if (lowerer.classes.has(lowerer.classNamer(decl)) ||
|
|
955
|
+
lowerer.collectingClassDeclarations.has(decl))
|
|
956
|
+
return;
|
|
957
|
+
lowerer.collectingClassDeclarations.add(decl);
|
|
958
|
+
try {
|
|
959
|
+
collectClassShapeDeferring(lowerer, decl);
|
|
960
|
+
}
|
|
961
|
+
finally {
|
|
962
|
+
lowerer.collectingClassDeclarations.delete(decl);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
function collectClassShapeDeferring(lowerer, decl) {
|
|
966
|
+
const symbol = lowerer.collectDeferring(() => declSymbolOf(lowerer, decl), () => {
|
|
967
|
+
// A forward type reference can demand this class before collection
|
|
968
|
+
// reaches its earlier base declaration. Collect that dependency first;
|
|
969
|
+
// a later same-file base remains subject to the runtime order boundary.
|
|
970
|
+
const heritage = decl.heritageClauses?.find((clause) => clause.token === ts.SyntaxKind.ExtendsKeyword)?.types[0]?.expression;
|
|
971
|
+
const reference = heritage && ts.isPropertyAccessExpression(heritage) ? heritage.name : heritage;
|
|
972
|
+
const baseSymbol = reference && ts.isIdentifier(reference) ? lowerer.resolveValueSymbol(reference) : undefined;
|
|
973
|
+
const baseDeclaration = baseSymbol
|
|
974
|
+
? lowerer.checker.declarationsOf(baseSymbol).find(ts.isClassDeclaration)
|
|
975
|
+
: undefined;
|
|
976
|
+
if (baseDeclaration &&
|
|
977
|
+
!lowerer.isStdlibSymbol(baseSymbol ?? undefined) &&
|
|
978
|
+
!baseDeclaration.getSourceFile().isDeclarationFile &&
|
|
979
|
+
(baseDeclaration.getSourceFile() !== decl.getSourceFile() ||
|
|
980
|
+
baseDeclaration.getStart() < decl.getStart()))
|
|
981
|
+
lowerer.collectClassShape(baseDeclaration);
|
|
982
|
+
lowerer.collectClassShapeInner(decl);
|
|
983
|
+
});
|
|
953
984
|
// Typed receivers and module retention know the class only by its
|
|
954
985
|
// qualified IR name — index the deferral under it too.
|
|
955
986
|
if (symbol)
|
|
@@ -1212,18 +1243,16 @@ mixin) {
|
|
|
1212
1243
|
lowerer.unsupported("SC1090", decl, "generic class expressions");
|
|
1213
1244
|
}
|
|
1214
1245
|
const className = inst ? inst.name : mixin ? mixin.name : lowerer.classNamer(decl); // program-wide qualified name
|
|
1215
|
-
//
|
|
1216
|
-
//
|
|
1217
|
-
//
|
|
1218
|
-
// so the base's ClassInfo already exists here. An INSTANTIATION's
|
|
1219
|
-
// base is its family (whose base is the declared one) — the heritage
|
|
1220
|
-
// clause resolved when the family collected.
|
|
1246
|
+
// Collection follows module order for runtime heritage. Ordinary
|
|
1247
|
+
// instances use the family as their storage base; generic heritage
|
|
1248
|
+
// resolves a concrete base under each instance's type bindings.
|
|
1221
1249
|
const computedBase = lowerer.computedClassBases.get(lowerer.classNamer(decl));
|
|
1222
1250
|
let base = inst
|
|
1223
1251
|
? inst.family
|
|
1224
1252
|
: mixin
|
|
1225
1253
|
? mixin.base
|
|
1226
1254
|
: (computedBase?.classInfo ?? null);
|
|
1255
|
+
let genericBase;
|
|
1227
1256
|
let callableBase;
|
|
1228
1257
|
let factoryBaseExpression;
|
|
1229
1258
|
const adoptCallableBase = (expression) => {
|
|
@@ -1250,35 +1279,12 @@ mixin) {
|
|
|
1250
1279
|
};
|
|
1251
1280
|
return true;
|
|
1252
1281
|
};
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
for (const tp of decl.typeParameters) {
|
|
1260
|
-
const s = lowerer.checker.getSymbolAtLocation(tp.name);
|
|
1261
|
-
if (s)
|
|
1262
|
-
tpSyms.add(s);
|
|
1263
|
-
}
|
|
1264
|
-
for (const clause of decl.heritageClauses) {
|
|
1265
|
-
if (clause.token !== ts.SyntaxKind.ExtendsKeyword)
|
|
1266
|
-
continue;
|
|
1267
|
-
for (const t of clause.types) {
|
|
1268
|
-
let mentions = false;
|
|
1269
|
-
ts.walkPreorder(t, (n) => {
|
|
1270
|
-
const s = ts.isIdentifier(n) ? lowerer.checker.getSymbolAtLocation(n) : undefined;
|
|
1271
|
-
if (s && tpSyms.has(s)) {
|
|
1272
|
-
mentions = true;
|
|
1273
|
-
return "stop";
|
|
1274
|
-
}
|
|
1275
|
-
return undefined;
|
|
1276
|
-
});
|
|
1277
|
-
if (mentions) {
|
|
1278
|
-
lowerer.unsupported("SC1090", t, "generic classes whose 'extends' clause mentions their own type parameters (each instantiation would need a different base)");
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
+
const ownGenericBase = inst?.family.genericBase;
|
|
1283
|
+
if (inst && ownGenericBase) {
|
|
1284
|
+
const mapped = lowerer.mapTypeOf(lowerer.checker.getTypeAtLocation(ownGenericBase));
|
|
1285
|
+
base = mapped?.kind === "object" ? (lowerer.classes.get(mapped.className) ?? null) : null;
|
|
1286
|
+
if (!base || base.generic)
|
|
1287
|
+
lowerer.unsupported("SC1090", ownGenericBase, "a generic base whose type arguments have no concrete layout");
|
|
1282
1288
|
}
|
|
1283
1289
|
for (const clause of inst || mixin || computedBase ? [] : (decl.heritageClauses ?? [])) {
|
|
1284
1290
|
// `implements` is pure type-world: tsc checked the conformance and
|
|
@@ -1288,6 +1294,22 @@ mixin) {
|
|
|
1288
1294
|
if (clause.token === ts.SyntaxKind.ImplementsKeyword)
|
|
1289
1295
|
continue;
|
|
1290
1296
|
const t = clause.types[0];
|
|
1297
|
+
if (familyMode && t) {
|
|
1298
|
+
const reference = ts.isPropertyAccessExpression(t.expression)
|
|
1299
|
+
? t.expression.name
|
|
1300
|
+
: t.expression;
|
|
1301
|
+
const symbol = ts.isIdentifier(reference)
|
|
1302
|
+
? lowerer.resolveValueSymbol(reference)
|
|
1303
|
+
: undefined;
|
|
1304
|
+
const familyBase = symbol ? lowerer.classBySymbol.get(symbol) : undefined;
|
|
1305
|
+
if (familyBase?.generic) {
|
|
1306
|
+
if (symbol && ts.isPropertyAccessExpression(t.expression))
|
|
1307
|
+
fenceEarlyNsMemberRef(lowerer, t.expression, symbol);
|
|
1308
|
+
base = familyBase;
|
|
1309
|
+
genericBase = t;
|
|
1310
|
+
continue;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1291
1313
|
// `extends events.EventEmitter` — the namespace-member spelling of
|
|
1292
1314
|
// the ambient emitter base resolves like the named import.
|
|
1293
1315
|
if (t && ts.isPropertyAccessExpression(t.expression) && ts.isIdentifier(t.expression.name)) {
|
|
@@ -1669,6 +1691,7 @@ mixin) {
|
|
|
1669
1691
|
lowerer.badType(member.name, lowerer.typeOf(member.name));
|
|
1670
1692
|
if (type.kind === "dyn" &&
|
|
1671
1693
|
!isJsSourceFile(member.getSourceFile()) &&
|
|
1694
|
+
!lowerer.classImplementedProtocol(lowerer.typeOf(member.name)) &&
|
|
1672
1695
|
(member.type !== undefined ||
|
|
1673
1696
|
(lowerer.typeOf(member.name).flags & ts.TypeFlags.Any) === 0)) {
|
|
1674
1697
|
lowerer.unsupported("SC1090", member.name, "'unknown'-typed static fields");
|
|
@@ -1899,7 +1922,9 @@ mixin) {
|
|
|
1899
1922
|
: null;
|
|
1900
1923
|
if (!type ||
|
|
1901
1924
|
type.kind === "void" ||
|
|
1902
|
-
(type.kind === "dyn" &&
|
|
1925
|
+
(type.kind === "dyn" &&
|
|
1926
|
+
!isJsSourceFile(member.getSourceFile()) &&
|
|
1927
|
+
!lowerer.classImplementedProtocol(inferred)))
|
|
1903
1928
|
lowerer.badType(member, inferred);
|
|
1904
1929
|
if (isJsSourceFile(member.getSourceFile())) {
|
|
1905
1930
|
type = inheritedJsFieldType(lowerer, decl, fieldName, type);
|
|
@@ -2027,7 +2052,9 @@ mixin) {
|
|
|
2027
2052
|
// Bundled JS declares fields without annotations before assigning
|
|
2028
2053
|
// them in the constructor. Use the same native checked-dynamic
|
|
2029
2054
|
// storage as implicit constructor-assigned JS fields.
|
|
2030
|
-
if (type.kind === "dyn" &&
|
|
2055
|
+
if (type.kind === "dyn" &&
|
|
2056
|
+
!isJsSourceFile(member.getSourceFile()) &&
|
|
2057
|
+
!lowerer.classImplementedProtocol(lowerer.typeOf(member.name))) {
|
|
2031
2058
|
lowerer.unsupported("SC1090", member.name, "'unknown'-typed class fields");
|
|
2032
2059
|
}
|
|
2033
2060
|
const undefinedInitializer = type.kind === "dyn" && !member.initializer ? locOf(member) : undefined;
|
|
@@ -2155,7 +2182,7 @@ mixin) {
|
|
|
2155
2182
|
if (type.kind === "void")
|
|
2156
2183
|
lowerer.badType(p.name, lowerer.typeOf(p.name));
|
|
2157
2184
|
// The class-field dyn rule verbatim (KEEP NARROW).
|
|
2158
|
-
if (type.kind === "dyn") {
|
|
2185
|
+
if (type.kind === "dyn" && !lowerer.classImplementedProtocol(lowerer.typeOf(p))) {
|
|
2159
2186
|
lowerer.unsupported("SC1090", p.name, "'unknown'-typed class fields");
|
|
2160
2187
|
}
|
|
2161
2188
|
// `override x` (and any same-named inherited member) would
|
|
@@ -3015,6 +3042,7 @@ mixin) {
|
|
|
3015
3042
|
ctorParams,
|
|
3016
3043
|
...(paramProps.length > 0 ? { paramProps } : {}),
|
|
3017
3044
|
base,
|
|
3045
|
+
...(genericBase ? { genericBase } : {}),
|
|
3018
3046
|
...(callableBase ? { callableBase } : {}),
|
|
3019
3047
|
...(factoryBaseExpression ? { factoryBaseExpression } : {}),
|
|
3020
3048
|
subclasses: [],
|
|
@@ -3044,6 +3072,7 @@ mixin) {
|
|
|
3044
3072
|
}
|
|
3045
3073
|
if (inst) {
|
|
3046
3074
|
info.genericInstance = {
|
|
3075
|
+
path: inst.path,
|
|
3047
3076
|
family: inst.family,
|
|
3048
3077
|
bindings: inst.bindings,
|
|
3049
3078
|
typeArgsText: inst.typeArgsText,
|
|
@@ -3146,7 +3175,14 @@ mixin) {
|
|
|
3146
3175
|
* arguments, the instance cap, an uncollected family) make the whole
|
|
3147
3176
|
* reference unmappable — per-site diagnostics own the fence. */
|
|
3148
3177
|
export function genericClassInstanceType(lowerer, decl, ref, mapArgument) {
|
|
3149
|
-
|
|
3178
|
+
let gci = lowerer.genericClassByDecl.get(decl);
|
|
3179
|
+
if (!gci && ts.isClassDeclaration(decl)) {
|
|
3180
|
+
// A method signature can reference a generic class declared later in
|
|
3181
|
+
// the same module. Resolve its family now rather than freezing the
|
|
3182
|
+
// signature at the erased family layout for the rest of the build.
|
|
3183
|
+
lowerer.collectClassShape(decl);
|
|
3184
|
+
gci = lowerer.genericClassByDecl.get(decl);
|
|
3185
|
+
}
|
|
3150
3186
|
if (!gci) {
|
|
3151
3187
|
// The family never collected (a deferred/poisoned declaration): the
|
|
3152
3188
|
// pre-generics answer — the class's own name, unregistered, so dead
|
|
@@ -3203,12 +3239,12 @@ export function genericClassInstanceType(lowerer, decl, ref, mapArgument) {
|
|
|
3203
3239
|
lowerer.noteGenericClassInstanceDemand(existing.info);
|
|
3204
3240
|
return existing.poisoned ? null : { kind: "object", className: existing.name };
|
|
3205
3241
|
}
|
|
3206
|
-
//
|
|
3207
|
-
//
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3242
|
+
// Recursive class fields and queued member bodies share the function
|
|
3243
|
+
// demand budget. Independent uses do not limit the family size.
|
|
3244
|
+
const path = extendInstantiationPath(lowerer.genericInstantiationPath, decl);
|
|
3245
|
+
if (!path) {
|
|
3246
|
+
lowerer.unsupported("SC1090", decl, `unbounded generic class instantiation ('${gci.baseName}' exceeded ${MAX_INSTANTIATION_RECURSION} recursive specializations on one demand path)`);
|
|
3247
|
+
}
|
|
3212
3248
|
const ordinal = gci.instances.size;
|
|
3213
3249
|
const name = `${gci.family.def.name}%${ordinal}`;
|
|
3214
3250
|
const entry = { name, info: null };
|
|
@@ -3219,10 +3255,13 @@ export function genericClassInstanceType(lowerer, decl, ref, mapArgument) {
|
|
|
3219
3255
|
const typeArgsText = `<${rendered.length > 80 ? rendered.slice(0, 77) + "..." : rendered}>`;
|
|
3220
3256
|
const prevBindings = lowerer.typeParamBindings;
|
|
3221
3257
|
const prevContext = lowerer.instantiationContext;
|
|
3258
|
+
const previousPath = lowerer.genericInstantiationPath;
|
|
3259
|
+
lowerer.genericInstantiationPath = path;
|
|
3222
3260
|
lowerer.typeParamBindings = bindings;
|
|
3223
3261
|
lowerer.instantiationContext = `instantiating class '${gci.baseName}' with ${typeArgsText}`;
|
|
3224
3262
|
try {
|
|
3225
3263
|
lowerer.collectClassShapeInner(decl, undefined, {
|
|
3264
|
+
path,
|
|
3226
3265
|
family: gci.family,
|
|
3227
3266
|
name,
|
|
3228
3267
|
bindings,
|
|
@@ -3241,6 +3280,7 @@ export function genericClassInstanceType(lowerer, decl, ref, mapArgument) {
|
|
|
3241
3280
|
finally {
|
|
3242
3281
|
lowerer.typeParamBindings = prevBindings;
|
|
3243
3282
|
lowerer.instantiationContext = prevContext;
|
|
3283
|
+
lowerer.genericInstantiationPath = previousPath;
|
|
3244
3284
|
}
|
|
3245
3285
|
const info = lowerer.classes.get(name);
|
|
3246
3286
|
if (!info) {
|
|
@@ -3290,6 +3330,8 @@ function withInstanceBindings(lowerer, info, fn) {
|
|
|
3290
3330
|
const prevBindings = lowerer.typeParamBindings;
|
|
3291
3331
|
const prevContext = lowerer.instantiationContext;
|
|
3292
3332
|
const prevSuppress = lowerer.suppressStats;
|
|
3333
|
+
const previousPath = lowerer.genericInstantiationPath;
|
|
3334
|
+
lowerer.genericInstantiationPath = gi.path;
|
|
3293
3335
|
lowerer.typeParamBindings = gi.bindings;
|
|
3294
3336
|
lowerer.instantiationContext = `instantiating class '${gi.family.generic?.baseName ?? info.def.jsName ?? ""}' with ${gi.typeArgsText}`;
|
|
3295
3337
|
lowerer.suppressStats = prevSuppress || gi.ordinal > 0;
|
|
@@ -3300,6 +3342,7 @@ function withInstanceBindings(lowerer, info, fn) {
|
|
|
3300
3342
|
lowerer.typeParamBindings = prevBindings;
|
|
3301
3343
|
lowerer.instantiationContext = prevContext;
|
|
3302
3344
|
lowerer.suppressStats = prevSuppress;
|
|
3345
|
+
lowerer.genericInstantiationPath = previousPath;
|
|
3303
3346
|
}
|
|
3304
3347
|
}
|
|
3305
3348
|
/** The `%init` statements for one class's static readonly fields AND
|
|
@@ -4420,6 +4463,19 @@ export function lowerStaticMethodCall(lowerer, call, access) {
|
|
|
4420
4463
|
if (info)
|
|
4421
4464
|
return staticCallOn(lowerer, call, access, info, false);
|
|
4422
4465
|
}
|
|
4466
|
+
// Namespace exports are immutable bindings to the same declaration as
|
|
4467
|
+
// named imports. Resolve them before asking for a constructor-value ABI:
|
|
4468
|
+
// a generic family has statics but no single constructor signature.
|
|
4469
|
+
if (ts.isPropertyAccessExpression(access.expression) && !access.expression.questionDotToken) {
|
|
4470
|
+
const member = nsMemberIdentOf(lowerer, access.expression);
|
|
4471
|
+
const symbol = member ? lowerer.resolveValueSymbol(member) : null;
|
|
4472
|
+
const info = symbol ? lowerer.classBySymbol.get(symbol) : undefined;
|
|
4473
|
+
if (info && info.classDecorators?.valueGlobalId === undefined) {
|
|
4474
|
+
if (symbol)
|
|
4475
|
+
fenceEarlyNsMemberRef(lowerer, access.expression, symbol);
|
|
4476
|
+
return staticCallOn(lowerer, call, access, info, false);
|
|
4477
|
+
}
|
|
4478
|
+
}
|
|
4423
4479
|
// `module.exports.describe()` in a module whose whole export IS a
|
|
4424
4480
|
// class expression: the receiver is exactly that class (the kept
|
|
4425
4481
|
// export assignment pins it) — the direct-name rules apply.
|
|
@@ -4726,9 +4782,15 @@ export function findMethodOn(lowerer, info, name) {
|
|
|
4726
4782
|
}
|
|
4727
4783
|
/** True when `sub` is a STRICT descendant of `sup` in the class graph. */
|
|
4728
4784
|
export function isSubclassOf(lowerer, sub, sup) {
|
|
4729
|
-
|
|
4730
|
-
|
|
4785
|
+
if (sub === sup)
|
|
4786
|
+
return false;
|
|
4787
|
+
for (let c = lowerer.classes.get(sub); c; c = c.base ?? undefined) {
|
|
4788
|
+
if (c.def.name === sup && c.def.name !== sub)
|
|
4731
4789
|
return true;
|
|
4790
|
+
for (let family = c.genericInstance?.family; family; family = family.base ?? undefined) {
|
|
4791
|
+
if (family.def.name === sup)
|
|
4792
|
+
return true;
|
|
4793
|
+
}
|
|
4732
4794
|
}
|
|
4733
4795
|
return false;
|
|
4734
4796
|
}
|
|
@@ -5065,7 +5127,7 @@ export function exactInstanceClassOf(lowerer, expr) {
|
|
|
5065
5127
|
* Const + direct `new` only — a reassignable binding or a produced
|
|
5066
5128
|
* value keeps today's record story and its fences. */
|
|
5067
5129
|
export function genericIfaceBindingKeepsClass(lowerer, decl, declaredType) {
|
|
5068
|
-
if (declaredType.kind !== "record")
|
|
5130
|
+
if (declaredType.kind !== "record" && declaredType.kind !== "dyn")
|
|
5069
5131
|
return false;
|
|
5070
5132
|
if (!ts.isIdentifier(decl.name) || decl.initializer === undefined || decl.type === undefined)
|
|
5071
5133
|
return false;
|
|
@@ -5076,13 +5138,16 @@ export function genericIfaceBindingKeepsClass(lowerer, decl, declaredType) {
|
|
|
5076
5138
|
init = init.expression;
|
|
5077
5139
|
if (!ts.isNewExpression(init))
|
|
5078
5140
|
return false;
|
|
5079
|
-
const shape = lowerer.shapes.get(declaredType.shapeId);
|
|
5080
|
-
if (!shape || shape.fields.length > 0 || shape.indexValue !== undefined || shape.tuple === true)
|
|
5081
|
-
return false;
|
|
5082
5141
|
const annT = lowerer.typeOf(decl.name);
|
|
5083
5142
|
const props = lowerer.checker.getPropertiesOfType(annT);
|
|
5084
5143
|
if (props.length === 0)
|
|
5085
5144
|
return false;
|
|
5145
|
+
if (declaredType.kind === "dyn")
|
|
5146
|
+
return (lowerer.classImplementedProtocol(annT) &&
|
|
5147
|
+
props.some((property) => isGenericCallableMemberType(lowerer.checker.getTypeOfSymbol(property), lowerer.checker)));
|
|
5148
|
+
const shape = lowerer.shapes.get(declaredType.shapeId);
|
|
5149
|
+
if (!shape || shape.fields.length > 0 || shape.indexValue !== undefined || shape.tuple === true)
|
|
5150
|
+
return false;
|
|
5086
5151
|
return props.every((p) => isGenericCallableMemberType(lowerer.checker.getTypeOfSymbol(p), lowerer.checker));
|
|
5087
5152
|
}
|
|
5088
5153
|
/** `recv.m<T>(args)` — a GENERIC method call, dispatched STATICALLY: the
|
|
@@ -6599,6 +6664,9 @@ function assignedThisFieldType(lowerer, expr) {
|
|
|
6599
6664
|
}
|
|
6600
6665
|
export function lowerNew(lowerer, expr) {
|
|
6601
6666
|
const loc = locOf(expr);
|
|
6667
|
+
const worker = lowerWorkerNew(lowerer, expr);
|
|
6668
|
+
if (worker)
|
|
6669
|
+
return worker;
|
|
6602
6670
|
let intlConstructor = expr.expression;
|
|
6603
6671
|
if (ts.isIdentifier(intlConstructor)) {
|
|
6604
6672
|
const symbol = lowerer.resolveValueSymbol(intlConstructor);
|