@scriptc/compiler 0.0.7 → 0.0.8
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 +47 -1
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-island.js +9 -1
- package/dist/backend/emission/emit-island.js.map +1 -1
- package/dist/backend/emission/emit-stmts.js +3 -1
- package/dist/backend/emission/emit-stmts.js.map +1 -1
- package/dist/backend/emission/emit-walkers.js +22 -8
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/emission/emitter.js +5 -1
- package/dist/backend/emission/emitter.js.map +1 -1
- package/dist/backend/emission/may-throw.js +4 -3
- package/dist/backend/emission/may-throw.js.map +1 -1
- package/dist/backend/llvm/emitter.js +94 -7
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +43 -1
- package/dist/diagnostics/diagnostic.js +103 -5
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/frontend/lib-contract.d.ts +24 -6
- package/dist/frontend/lib-contract.js +125 -44
- package/dist/frontend/lib-contract.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.js +16 -1
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +47 -7
- package/dist/frontend/lowering/lower-calls.js +560 -36
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.d.ts +14 -1
- package/dist/frontend/lowering/lower-classes.js +85 -15
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.js +43 -1
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-emitter.js +1 -1
- package/dist/frontend/lowering/lower-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.d.ts +26 -3
- package/dist/frontend/lowering/lower-exprs.js +455 -40
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +7 -0
- package/dist/frontend/lowering/lower-island.js +71 -10
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-mixins.d.ts +1 -1
- package/dist/frontend/lowering/lower-mixins.js +1 -1
- package/dist/frontend/lowering/lower-modules.js +95 -4
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.js +421 -43
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +19 -3
- package/dist/frontend/lowering/lowerer.js +188 -11
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/types.d.ts +28 -1
- package/dist/frontend/types.js +300 -8
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +37 -7
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +28 -2
- package/dist/ir/nodes.js +35 -3
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +35 -6
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/profile.d.ts +17 -3
- package/dist/library/profile.js +38 -9
- package/dist/library/profile.js.map +1 -1
- package/dist/library/sidecar.js +162 -43
- package/dist/library/sidecar.js.map +1 -1
- package/dist/library/trap-teaching.d.ts +11 -0
- package/dist/library/trap-teaching.js +49 -0
- package/dist/library/trap-teaching.js.map +1 -0
- package/package.json +2 -2
- package/surface-manifest.json +37 -2
|
@@ -9,7 +9,7 @@ import { type ClassInfo } from "./lower-classes.js";
|
|
|
9
9
|
* trailing-suffix call, and the frontend appends the interned undefined arm;
|
|
10
10
|
* `rest` (always last) receives the surplus arguments packed into one array
|
|
11
11
|
* literal at each call site. */
|
|
12
|
-
export type ParamMode = "required" | "omittable" | "rest" | "dynRest";
|
|
12
|
+
export type ParamMode = "required" | "omittable" | "rest" | "dynRest" | "islandRest";
|
|
13
13
|
/** One parameter of a signature, as call sites and callee prologues see it.
|
|
14
14
|
* `type` is the ABI type — what the emitted C parameter carries: the
|
|
15
15
|
* checker's `T | undefined` union for `x?: T`, a synthesized `T | undefined`
|
|
@@ -57,6 +57,12 @@ export interface GenericFnInfo {
|
|
|
57
57
|
qualifiedName: string;
|
|
58
58
|
/** Declaration-order type parameter symbols. */
|
|
59
59
|
typeParams: ts.Symbol[];
|
|
60
|
+
/** Lazily computed (keyofConstrainedTypeParams): the type parameters
|
|
61
|
+
* declared `K extends keyof …`. Their bound LITERAL keys are semantic —
|
|
62
|
+
* the body's `o[k]` reads the named field — so instances key on the
|
|
63
|
+
* literal (no cross-literal sharing) and keep the checker types
|
|
64
|
+
* (tsBindings) the body resolves through. */
|
|
65
|
+
keyofTps?: Set<ts.Symbol>;
|
|
60
66
|
/** Instantiation key (comma-joined typeKeys of the mapped param types +
|
|
61
67
|
* `=>` + return typeKey) → instance. Key identity IS signature identity:
|
|
62
68
|
* two call sites whose inferred types map to the same IR types share one
|
|
@@ -99,6 +105,11 @@ export interface GenericInstance {
|
|
|
99
105
|
/** Type-parameter symbol → concrete IR type, consulted by mapType (via
|
|
100
106
|
* typeParamResolver) while the instance body lowers. */
|
|
101
107
|
bindings: Map<ts.Symbol, IrType>;
|
|
108
|
+
/** Call-keyed instances: type-parameter symbol → the bound CHECKER type
|
|
109
|
+
* (pre-widening), consulted while the body lowers where the IrType
|
|
110
|
+
* binding has already lost what the body needs — `T[K]` and `o[k]` reads
|
|
111
|
+
* whose K is bound to one literal key (typeParamTsBindings). */
|
|
112
|
+
tsBindings?: Map<ts.Symbol, ts.Type>;
|
|
102
113
|
/** Rendered type arguments ("<number, string>") for diagnostics. */
|
|
103
114
|
typeArgsText: string;
|
|
104
115
|
/** Implicit instances only: param symbol → the call site's (widened)
|
|
@@ -242,28 +253,36 @@ export declare function genericCallInstance(L: Lowerer, expr: ts.CallExpression,
|
|
|
242
253
|
* (`const f: (x: number) => number = identity`) reuse one compiled
|
|
243
254
|
* instance. `makeBindings` runs only for a NEW key (binding inference
|
|
244
255
|
* costs checker walks). */
|
|
245
|
-
export declare function internGenericInstance(L: Lowerer, blame: ts.Node, info: GenericFnInfo, params: ParamShape[], returnType: IrType, makeBindings: () => Map<ts.Symbol, IrType
|
|
256
|
+
export declare function internGenericInstance(L: Lowerer, blame: ts.Node, info: GenericFnInfo, params: ParamShape[], returnType: IrType, makeBindings: (tsBindings: Map<ts.Symbol, ts.Type>) => Map<ts.Symbol, IrType>, opts?: {
|
|
257
|
+
extraKey?: string;
|
|
258
|
+
tsBindings?: Map<ts.Symbol, ts.Type>;
|
|
259
|
+
}): GenericInstance;
|
|
260
|
+
/** The type parameters of `info` declared with a `keyof` CONSTRAINT
|
|
261
|
+
* (`K extends keyof T`) — the parameters whose bound literal is semantic
|
|
262
|
+
* (the body's `o[k]` reads the named field), computed once per info from
|
|
263
|
+
* the declaration's syntax. */
|
|
264
|
+
export declare function keyofConstrainedTypeParams(info: GenericFnInfo): Set<ts.Symbol>;
|
|
246
265
|
/** Type-parameter symbol → concrete IR type for one instantiation.
|
|
247
266
|
* Explicit type arguments bind directly; the rest come from structurally
|
|
248
267
|
* matching each DECLARED param/return type (which mentions the type
|
|
249
268
|
* parameters) against the checker's INSTANTIATED one — the latter is the
|
|
250
269
|
* former with the substitution applied, so the shapes are parallel by
|
|
251
270
|
* construction. A type parameter left unbound only matters if the body
|
|
252
|
-
* mentions it, where mapType fails
|
|
253
|
-
* instantiation context). */
|
|
254
|
-
export declare function inferTypeParamBindings(L: Lowerer, expr: ts.CallExpression, info: GenericFnInfo, rsig: ts.Signature): Map<ts.Symbol, IrType>;
|
|
271
|
+
* mentions it, where mapType fails and badType names the shape
|
|
272
|
+
* (carrying the instantiation context). */
|
|
273
|
+
export declare function inferTypeParamBindings(L: Lowerer, expr: ts.CallExpression, info: GenericFnInfo, rsig: ts.Signature, tsBindings?: Map<ts.Symbol, ts.Type>): Map<ts.Symbol, IrType>;
|
|
255
274
|
/** Type parameters still unbound after unification take their declared
|
|
256
275
|
* DEFAULT (`<T = number>`), mapped — the checker already substituted the
|
|
257
276
|
* default into every resolved signature, so this only fills the bindings
|
|
258
277
|
* an instance body's mapType consults. */
|
|
259
|
-
export declare function bindDefaultTypeParams(L: Lowerer, typeParams: readonly ts.Symbol[], typeParamDecls: readonly ts.TypeParameterDeclaration[] | undefined, bindings: Map<ts.Symbol, IrType>): void;
|
|
278
|
+
export declare function bindDefaultTypeParams(L: Lowerer, typeParams: readonly ts.Symbol[], typeParamDecls: readonly ts.TypeParameterDeclaration[] | undefined, bindings: Map<ts.Symbol, IrType>, tsBindings?: Map<ts.Symbol, ts.Type>): void;
|
|
260
279
|
/** The structural half of binding inference: unify the DECLARED signature
|
|
261
280
|
* (whose types mention the type parameters) against a TARGET signature
|
|
262
281
|
* with the substitution applied — a call's resolved signature, or the
|
|
263
282
|
* completed signature a VALUE reference is pinned to (the contextual
|
|
264
283
|
* type's one call signature). Mutates `bindings`; already-bound
|
|
265
284
|
* parameters (explicit type arguments) win. */
|
|
266
|
-
export declare function unifySignatureBindings(L: Lowerer, info: GenericFnInfo, rsig: ts.Signature, bindings: Map<ts.Symbol, IrType>): void;
|
|
285
|
+
export declare function unifySignatureBindings(L: Lowerer, info: GenericFnInfo, rsig: ts.Signature, bindings: Map<ts.Symbol, IrType>, tsBindings?: Map<ts.Symbol, ts.Type>): void;
|
|
267
286
|
/** Lowers ONE monomorphic instance of a generic function: the same body
|
|
268
287
|
* AST, re-lowered with the type parameters bound (threaded into every
|
|
269
288
|
* mapType call via typeParamResolver — the checker keeps reporting the
|
|
@@ -534,6 +553,15 @@ export declare function bindingNeverReassigned(L: Lowerer, sym: ts.Symbol, decl:
|
|
|
534
553
|
* SHAPE only — whether the binding qualifies (module scope, never
|
|
535
554
|
* reassigned) is bindingGenericFnInfoOf's business. */
|
|
536
555
|
export declare function bindingGenericFnNodeOf(decl: ts.VariableDeclaration): ts.FunctionExpression | ts.ArrowFunction | null;
|
|
556
|
+
/** The CONTEXTUAL twin of bindingGenericFnNodeOf: `const g: Mapper = (x)
|
|
557
|
+
* => x` where `type Mapper = <T>(x: T) => T` — the initializer declares
|
|
558
|
+
* no type parameters of its own, but the ANNOTATION's one call signature
|
|
559
|
+
* does, and the checker types the arrow's parameters by those (`x: T`).
|
|
560
|
+
* Such a binding monomorphizes exactly like `const g = <T>(x: T) => x`;
|
|
561
|
+
* bindingGenericFnInfoOf reads the type parameters off the annotation's
|
|
562
|
+
* signature. Null when the shape doesn't match (a concrete annotation, a
|
|
563
|
+
* generic arrow — the syntactic probe's case, an overloaded alias). */
|
|
564
|
+
export declare function bindingContextualGenericFnNodeOf(L: Lowerer, decl: ts.VariableDeclaration): ts.FunctionExpression | ts.ArrowFunction | null;
|
|
537
565
|
/** The interned GenericFnInfo for one generic arrow/function-expression
|
|
538
566
|
* binding initializer, with the supportability fences applied ONCE per
|
|
539
567
|
* declaration: the binding must sit at module scope (the compiled
|
|
@@ -550,6 +578,18 @@ export declare function bindingGenericFnNodeOf(decl: ts.VariableDeclaration): ts
|
|
|
550
578
|
* (calls, pinned values, instantiation expressions, namespace and CJS
|
|
551
579
|
* member paths) resolves it like a top-level generic declaration. */
|
|
552
580
|
export declare function bindingGenericFnInfoOf(L: Lowerer, decl: ts.VariableDeclaration, fnNode: ts.FunctionExpression | ts.ArrowFunction): GenericFnInfo;
|
|
581
|
+
/** `const h = id` — a binding ALIASING a generic function (a top-level
|
|
582
|
+
* declaration, a registered generic binding, or another alias — resolved
|
|
583
|
+
* left to right in declaration order). The alias registers the SAME info
|
|
584
|
+
* under its own symbol, so calls (`h(3)`) and pinned values (`take(h)`)
|
|
585
|
+
* resolve exactly like the target's own name, and the binding itself has
|
|
586
|
+
* no runtime value (a generic function value cannot materialize). Claims
|
|
587
|
+
* only bindings whose OWN type still keeps type parameters — a
|
|
588
|
+
* concrete-annotated alias (`const h: (x: number) => number = id`) is a
|
|
589
|
+
* pinned VALUE, the existing lowerGenericFnValue story. Null when the
|
|
590
|
+
* shape doesn't match or the target isn't a registered generic; fences
|
|
591
|
+
* (reassignment, var redeclaration) report by name inside. */
|
|
592
|
+
export declare function bindingGenericFnAliasInfoOf(L: Lowerer, decl: ts.VariableDeclaration): GenericFnInfo | null;
|
|
553
593
|
/** Static resolution stands in for the receiver's runtime value, so an
|
|
554
594
|
* object-literal generic-method receiver must provably HOLD the defining
|
|
555
595
|
* literal: a direct read of a binding whose initializer IS that literal
|