@loopdive/js2 0.57.0
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/CHANGELOG.md +1425 -0
- package/LICENSE +189 -0
- package/README.md +451 -0
- package/dist/checker/index.d.ts +117 -0
- package/dist/checker/language-service.d.ts +39 -0
- package/dist/checker/node-capability-map.d.ts +63 -0
- package/dist/checker/type-mapper.d.ts +84 -0
- package/dist/cjs-rewrite.d.ts +19 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +363 -0
- package/dist/codegen/accessor-driver.d.ts +97 -0
- package/dist/codegen/any-helpers.d.ts +72 -0
- package/dist/codegen/array-element-typing.d.ts +46 -0
- package/dist/codegen/array-holes.d.ts +69 -0
- package/dist/codegen/array-methods.d.ts +68 -0
- package/dist/codegen/array-object-proto.d.ts +64 -0
- package/dist/codegen/array-reduce-fusion.d.ts +31 -0
- package/dist/codegen/array-to-primitive.d.ts +28 -0
- package/dist/codegen/async-cps.d.ts +239 -0
- package/dist/codegen/async-scheduler.d.ts +349 -0
- package/dist/codegen/binary-ops.d.ts +78 -0
- package/dist/codegen/binding-info.d.ts +31 -0
- package/dist/codegen/builtin-scaffold.d.ts +98 -0
- package/dist/codegen/builtin-static-globals.d.ts +8 -0
- package/dist/codegen/builtin-tags.d.ts +189 -0
- package/dist/codegen/case-convert-native.d.ts +12 -0
- package/dist/codegen/case-tables.d.ts +4 -0
- package/dist/codegen/class-bodies.d.ts +41 -0
- package/dist/codegen/class-member-keys.d.ts +33 -0
- package/dist/codegen/class-to-primitive.d.ts +39 -0
- package/dist/codegen/closed-method-dispatch.d.ts +42 -0
- package/dist/codegen/closures.d.ts +285 -0
- package/dist/codegen/coercion-engine.d.ts +154 -0
- package/dist/codegen/coercion-plan.d.ts +29 -0
- package/dist/codegen/context/bodies.d.ts +4 -0
- package/dist/codegen/context/create-context.d.ts +4 -0
- package/dist/codegen/context/errors.d.ts +39 -0
- package/dist/codegen/context/locals.d.ts +69 -0
- package/dist/codegen/context/source-pos.d.ts +5 -0
- package/dist/codegen/context/speculative.d.ts +95 -0
- package/dist/codegen/context/types.d.ts +1936 -0
- package/dist/codegen/custom-iterable.d.ts +34 -0
- package/dist/codegen/dataview-native.d.ts +51 -0
- package/dist/codegen/date-parse-native.d.ts +13 -0
- package/dist/codegen/dead-elimination.d.ts +26 -0
- package/dist/codegen/declarations.d.ts +147 -0
- package/dist/codegen/deno-api.d.ts +11 -0
- package/dist/codegen/destructuring-params.d.ts +102 -0
- package/dist/codegen/dyn-read.d.ts +26 -0
- package/dist/codegen/eval-tiering.d.ts +19 -0
- package/dist/codegen/expressions/assignment.d.ts +61 -0
- package/dist/codegen/expressions/builtins.d.ts +26 -0
- package/dist/codegen/expressions/calls-closures.d.ts +54 -0
- package/dist/codegen/expressions/calls-guards.d.ts +49 -0
- package/dist/codegen/expressions/calls-optional.d.ts +4 -0
- package/dist/codegen/expressions/calls.d.ts +83 -0
- package/dist/codegen/expressions/eval-inline.d.ts +24 -0
- package/dist/codegen/expressions/extern.d.ts +67 -0
- package/dist/codegen/expressions/fnctor-prototype.d.ts +52 -0
- package/dist/codegen/expressions/helpers.d.ts +212 -0
- package/dist/codegen/expressions/identifiers.d.ts +57 -0
- package/dist/codegen/expressions/late-imports.d.ts +81 -0
- package/dist/codegen/expressions/logical-ops.d.ts +18 -0
- package/dist/codegen/expressions/misc.d.ts +27 -0
- package/dist/codegen/expressions/new-super.d.ts +25 -0
- package/dist/codegen/expressions/promise-subclass.d.ts +38 -0
- package/dist/codegen/expressions/proto-override.d.ts +63 -0
- package/dist/codegen/expressions/unary-updates.d.ts +21 -0
- package/dist/codegen/expressions/unary.d.ts +6 -0
- package/dist/codegen/expressions.d.ts +31 -0
- package/dist/codegen/fallback-telemetry.d.ts +53 -0
- package/dist/codegen/fixups.d.ts +80 -0
- package/dist/codegen/fmod.d.ts +10 -0
- package/dist/codegen/fnctor-escape-gate.d.ts +92 -0
- package/dist/codegen/function-body.d.ts +52 -0
- package/dist/codegen/generators-native.d.ts +92 -0
- package/dist/codegen/helpers/body-references-own-this.d.ts +22 -0
- package/dist/codegen/helpers/body-uses-arguments.d.ts +12 -0
- package/dist/codegen/helpers/is-strict-function.d.ts +52 -0
- package/dist/codegen/host-import-allowlist.d.ts +140 -0
- package/dist/codegen/index.d.ts +500 -0
- package/dist/codegen/ir-tail-call.d.ts +8 -0
- package/dist/codegen/iterator-native.d.ts +44 -0
- package/dist/codegen/json-codec-native.d.ts +78 -0
- package/dist/codegen/json-runtime.d.ts +35 -0
- package/dist/codegen/json-standalone.d.ts +25 -0
- package/dist/codegen/linear-uint8-analysis.d.ts +46 -0
- package/dist/codegen/linear-uint8-arena.d.ts +7 -0
- package/dist/codegen/linear-uint8-codegen.d.ts +103 -0
- package/dist/codegen/linear-uint8-signatures.d.ts +26 -0
- package/dist/codegen/literals.d.ts +115 -0
- package/dist/codegen/map-runtime.d.ts +142 -0
- package/dist/codegen/math-helpers.d.ts +7 -0
- package/dist/codegen/member-get-dispatch.d.ts +42 -0
- package/dist/codegen/member-set-dispatch.d.ts +28 -0
- package/dist/codegen/native-proto.d.ts +98 -0
- package/dist/codegen/native-regex.d.ts +158 -0
- package/dist/codegen/native-strings.d.ts +146 -0
- package/dist/codegen/new-target.d.ts +30 -0
- package/dist/codegen/node-fs-api.d.ts +47 -0
- package/dist/codegen/number-format-native.d.ts +9 -0
- package/dist/codegen/number-ryu.d.ts +27 -0
- package/dist/codegen/object-ops.d.ts +94 -0
- package/dist/codegen/object-runtime.d.ts +171 -0
- package/dist/codegen/parse-number-native.d.ts +10 -0
- package/dist/codegen/peephole.d.ts +6 -0
- package/dist/codegen/property-access.d.ts +294 -0
- package/dist/codegen/raw-wasi-api.d.ts +13 -0
- package/dist/codegen/regex/bytecode.d.ts +140 -0
- package/dist/codegen/regex/casefold.d.ts +41 -0
- package/dist/codegen/regex/compile.d.ts +51 -0
- package/dist/codegen/regex/parse.d.ts +76 -0
- package/dist/codegen/regex/unicode.d.ts +42 -0
- package/dist/codegen/regex/vm.d.ts +24 -0
- package/dist/codegen/regexp-standalone.d.ts +350 -0
- package/dist/codegen/registry/error-types.d.ts +38 -0
- package/dist/codegen/registry/imports.d.ts +46 -0
- package/dist/codegen/registry/types.d.ts +59 -0
- package/dist/codegen/set-algebra.d.ts +17 -0
- package/dist/codegen/set-runtime.d.ts +74 -0
- package/dist/codegen/shared.d.ts +111 -0
- package/dist/codegen/stack-balance.d.ts +43 -0
- package/dist/codegen/statements/control-flow.d.ts +25 -0
- package/dist/codegen/statements/destructuring.d.ts +177 -0
- package/dist/codegen/statements/exceptions.d.ts +11 -0
- package/dist/codegen/statements/functions.d.ts +1 -0
- package/dist/codegen/statements/index.d.ts +1 -0
- package/dist/codegen/statements/loops.d.ts +7 -0
- package/dist/codegen/statements/nested-declarations.d.ts +78 -0
- package/dist/codegen/statements/shared.d.ts +38 -0
- package/dist/codegen/statements/tdz.d.ts +43 -0
- package/dist/codegen/statements/variables.d.ts +3 -0
- package/dist/codegen/statements.d.ts +9 -0
- package/dist/codegen/string-builder.d.ts +131 -0
- package/dist/codegen/string-ops.d.ts +87 -0
- package/dist/codegen/struct-accessor-closure.d.ts +36 -0
- package/dist/codegen/symbol-native.d.ts +55 -0
- package/dist/codegen/temporal-native.d.ts +8 -0
- package/dist/codegen/timsort.d.ts +2 -0
- package/dist/codegen/type-coercion.d.ts +123 -0
- package/dist/codegen/typeof-delete.d.ts +38 -0
- package/dist/codegen/uri-encoding-native.d.ts +33 -0
- package/dist/codegen/value-tags.d.ts +74 -0
- package/dist/codegen/walk-instructions.d.ts +20 -0
- package/dist/codegen/weak-collections-runtime.d.ts +16 -0
- package/dist/codegen/with-scope.d.ts +106 -0
- package/dist/codegen-linear/c-abi.d.ts +74 -0
- package/dist/codegen-linear/context.d.ts +86 -0
- package/dist/codegen-linear/index.d.ts +28 -0
- package/dist/codegen-linear/layout.d.ts +39 -0
- package/dist/codegen-linear/runtime.d.ts +161 -0
- package/dist/codegen-linear/simd.d.ts +7 -0
- package/dist/compiler/define-substitution.d.ts +27 -0
- package/dist/compiler/early-errors/assignment.d.ts +26 -0
- package/dist/compiler/early-errors/context.d.ts +17 -0
- package/dist/compiler/early-errors/duplicates.d.ts +20 -0
- package/dist/compiler/early-errors/index.d.ts +11 -0
- package/dist/compiler/early-errors/labels.d.ts +13 -0
- package/dist/compiler/early-errors/module-rules.d.ts +36 -0
- package/dist/compiler/early-errors/node-checks.d.ts +7 -0
- package/dist/compiler/early-errors/predicates.d.ts +140 -0
- package/dist/compiler/early-errors/tdz.d.ts +17 -0
- package/dist/compiler/import-manifest.d.ts +18 -0
- package/dist/compiler/output.d.ts +46 -0
- package/dist/compiler/validation.d.ts +45 -0
- package/dist/compiler.d.ts +48 -0
- package/dist/define-substitution-BcUeKC2A.js +109 -0
- package/dist/emit/binary.d.ts +50 -0
- package/dist/emit/c-header.d.ts +23 -0
- package/dist/emit/canonical-recgroup.d.ts +86 -0
- package/dist/emit/encoder.d.ts +28 -0
- package/dist/emit/object.d.ts +14 -0
- package/dist/emit/opcodes.d.ts +464 -0
- package/dist/emit/sourcemap.d.ts +33 -0
- package/dist/emit/wat.d.ts +6 -0
- package/dist/env.d.ts +46 -0
- package/dist/import-resolver.d.ts +68 -0
- package/dist/index.d.ts +486 -0
- package/dist/index.js +755 -0
- package/dist/ir/alloc-registry.d.ts +75 -0
- package/dist/ir/analysis/encoding.d.ts +38 -0
- package/dist/ir/analysis/escape.d.ts +32 -0
- package/dist/ir/analysis/lattice.d.ts +72 -0
- package/dist/ir/analysis/ownership.d.ts +31 -0
- package/dist/ir/analysis/stack-alloc.d.ts +20 -0
- package/dist/ir/backend/bytecode-emitter.d.ts +237 -0
- package/dist/ir/backend/bytecode-vm.d.ts +74 -0
- package/dist/ir/backend/emitter.d.ts +121 -0
- package/dist/ir/backend/handles.d.ts +133 -0
- package/dist/ir/backend/legality.d.ts +9 -0
- package/dist/ir/backend/linear-emitter.d.ts +41 -0
- package/dist/ir/backend/wasmgc-emitter.d.ts +43 -0
- package/dist/ir/builder.d.ts +401 -0
- package/dist/ir/from-ast.d.ts +192 -0
- package/dist/ir/index.d.ts +16 -0
- package/dist/ir/integration.d.ts +27 -0
- package/dist/ir/lower.d.ts +203 -0
- package/dist/ir/nodes.d.ts +1452 -0
- package/dist/ir/passes/alloc-discipline.d.ts +19 -0
- package/dist/ir/passes/constant-fold.d.ts +7 -0
- package/dist/ir/passes/dead-code.d.ts +18 -0
- package/dist/ir/passes/inline-small.d.ts +7 -0
- package/dist/ir/passes/monomorphize.d.ts +21 -0
- package/dist/ir/passes/simplify-cfg.d.ts +19 -0
- package/dist/ir/passes/tagged-union-types.d.ts +45 -0
- package/dist/ir/passes/tagged-unions.d.ts +22 -0
- package/dist/ir/propagate.d.ts +135 -0
- package/dist/ir/select.d.ts +81 -0
- package/dist/ir/types.d.ts +832 -0
- package/dist/ir/verify-alloc.d.ts +18 -0
- package/dist/ir/verify.d.ts +7 -0
- package/dist/link/index.d.ts +11 -0
- package/dist/link/isolation.d.ts +24 -0
- package/dist/link/linker.d.ts +37 -0
- package/dist/link/reader.d.ts +158 -0
- package/dist/link/resolver.d.ts +19 -0
- package/dist/optimize.d.ts +54 -0
- package/dist/optimize.js +262 -0
- package/dist/position-map.d.ts +64 -0
- package/dist/process-stdin-prelude.d.ts +16 -0
- package/dist/resolve.d.ts +82 -0
- package/dist/runtime/builtins.d.ts +1 -0
- package/dist/runtime-C-4q_KwU.js +164438 -0
- package/dist/runtime-containment.d.ts +6 -0
- package/dist/runtime-eval.d.ts +132 -0
- package/dist/runtime-instantiate.d.ts +16 -0
- package/dist/runtime.d.ts +128 -0
- package/dist/runtime.js +12 -0
- package/dist/shape-inference.d.ts +20 -0
- package/dist/treeshake.d.ts +17 -0
- package/dist/ts-api.d.ts +30 -0
- package/dist/wit-generator.d.ts +18 -0
- package/package.json +187 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { BackendEmitter } from './backend/emitter.js';
|
|
2
|
+
import { IrBoxedLowering, IrClassLowering, IrClosureLowering, IrObjectStructLowering, IrRefCellLowering, IrUnionLowering, IrVecLowering } from './backend/handles.js';
|
|
3
|
+
import { IrClassShape, IrClosureSignature, IrFuncRef, IrFunction, IrGlobalRef, IrInstr, IrObjectShape, IrType, IrTypeRef, IrValueId } from './nodes.js';
|
|
4
|
+
import { FuncTypeDef, Instr, LocalDef, ValType, WasmFunction } from './types.js';
|
|
5
|
+
export type { IrBoxedLowering, IrClassLowering, IrClosureLowering, IrObjectStructLowering, IrRefCellLowering, IrUnionLowering, IrVecLowering, };
|
|
6
|
+
export interface IrLowerResolver {
|
|
7
|
+
resolveFunc(ref: IrFuncRef): number;
|
|
8
|
+
resolveGlobal(ref: IrGlobalRef): number;
|
|
9
|
+
resolveType(ref: IrTypeRef): number;
|
|
10
|
+
internFuncType(type: FuncTypeDef): number;
|
|
11
|
+
/**
|
|
12
|
+
* Resolve (and memoise) the WasmGC struct type for a `union` IrType. V1
|
|
13
|
+
* scope: homogeneous-width unions only — see
|
|
14
|
+
* `passes/tagged-union-types.ts`. Returns `null` when the union is not
|
|
15
|
+
* representable (heterogeneous, or contains reference members); callers
|
|
16
|
+
* must treat that as `dynamic` upstream.
|
|
17
|
+
*
|
|
18
|
+
* Optional so Phase-1 resolvers without tagged-union support can omit it;
|
|
19
|
+
* a Phase-3 function that actually emits `box`/`unbox`/`tag.test` will
|
|
20
|
+
* fail at lowering time when it's missing, which is the correct behavior
|
|
21
|
+
* (caller should have rejected the IR earlier).
|
|
22
|
+
*/
|
|
23
|
+
resolveUnion?(members: readonly ValType[]): IrUnionLowering | null;
|
|
24
|
+
/**
|
|
25
|
+
* Resolve (and memoise) the WasmGC struct type for a `boxed` IrType.
|
|
26
|
+
* Optional for the same reason as `resolveUnion`.
|
|
27
|
+
*/
|
|
28
|
+
resolveBoxed?(inner: ValType): IrBoxedLowering | null;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve (and memoise) the WasmGC struct type for an `IrType.object`
|
|
31
|
+
* shape. Returns `null` if the shape contains a field type the backend
|
|
32
|
+
* can't lower (e.g. a nested boxed-IrType the V1 boxed registry doesn't
|
|
33
|
+
* support).
|
|
34
|
+
*
|
|
35
|
+
* The slice-2 implementation in `integration.ts` delegates to a shared
|
|
36
|
+
* `ObjectStructRegistry` that hashes shapes against
|
|
37
|
+
* `ctx.anonStructHash`, so legacy `ensureStructForType` and the IR path
|
|
38
|
+
* converge on a single WasmGC struct for any given shape.
|
|
39
|
+
*/
|
|
40
|
+
resolveObject?(shape: IrObjectShape): IrObjectStructLowering | null;
|
|
41
|
+
/**
|
|
42
|
+
* Slice 3 (#1169c): resolve the SUPERTYPE WasmGC struct for a closure
|
|
43
|
+
* signature. Carried by the IrType.closure ValType so all
|
|
44
|
+
* same-signature closures share one Wasm type. Returns `null` if the
|
|
45
|
+
* signature contains an IrType the backend can't lower (e.g. a
|
|
46
|
+
* nested object shape the slice-2 resolver hasn't pre-walked).
|
|
47
|
+
*/
|
|
48
|
+
resolveClosure?(signature: IrClosureSignature): IrClosureLowering | null;
|
|
49
|
+
/**
|
|
50
|
+
* Slice 3 (#1169c): resolve the SUBTYPE WasmGC struct for a specific
|
|
51
|
+
* closure-construction site. Different `(signature, captureFieldTypes)`
|
|
52
|
+
* pairs produce different subtypes of the supertype struct, so the
|
|
53
|
+
* lifted body's `ref.cast` recovers capture-field positions.
|
|
54
|
+
*/
|
|
55
|
+
resolveClosureSubtype?(signature: IrClosureSignature, captureFieldTypes: readonly IrType[]): IrClosureLowering | null;
|
|
56
|
+
/**
|
|
57
|
+
* Slice 3 (#1169c): resolve the WasmGC struct type for a ref cell
|
|
58
|
+
* over a primitive ValType. Delegates to the legacy
|
|
59
|
+
* `getOrRegisterRefCellType` so legacy and IR ref cells share one
|
|
60
|
+
* type per inner ValType.
|
|
61
|
+
*/
|
|
62
|
+
resolveRefCell?(inner: ValType): IrRefCellLowering | null;
|
|
63
|
+
/**
|
|
64
|
+
* Slice 4 (#1169d): resolve the WasmGC struct + constructor + method
|
|
65
|
+
* funcs for a class declared in the compilation unit. Returns `null`
|
|
66
|
+
* if `shape.className` was not registered by the legacy class
|
|
67
|
+
* collection pass — that's a selector bug.
|
|
68
|
+
*/
|
|
69
|
+
resolveClass?(shape: IrClassShape): IrClassLowering | null;
|
|
70
|
+
/**
|
|
71
|
+
* Slice 6 (#1169e): resolve a vec struct given its top-level Wasm
|
|
72
|
+
* ValType. The IR carries the vec's value as a `ref`/`ref_null` to a
|
|
73
|
+
* registered vec struct; the resolver inspects the struct's fields to
|
|
74
|
+
* verify the layout is `{ length: i32, data: (ref $arr) }` and returns
|
|
75
|
+
* the typeIdx + field indices + element ValType. Returns `null` when
|
|
76
|
+
* the type isn't a recognisable vec — caller treats that as a bug
|
|
77
|
+
* (selector should have rejected the for-of).
|
|
78
|
+
*/
|
|
79
|
+
resolveVec?(valType: ValType): IrVecLowering | null;
|
|
80
|
+
/**
|
|
81
|
+
* #1804 — resolve (registering if needed) the vec struct for an *element*
|
|
82
|
+
* ValType, used by `vec.new_fixed` construction where a fresh literal has no
|
|
83
|
+
* vec typeIdx yet. Unlike `resolveVec` (read-only — recognizes an existing
|
|
84
|
+
* `(ref $vec)`), this get-or-creates the `$arr`/`$vec` types for the element
|
|
85
|
+
* via the legacy registry so the constructed vec shares identity with the
|
|
86
|
+
* legacy `compileArrayLiteral` output (===, instanceof Array, the for-of fast
|
|
87
|
+
* path). Returns the same `IrVecLowering` shape as `resolveVec`.
|
|
88
|
+
*/
|
|
89
|
+
resolveVecForElement?(elementValType: ValType): IrVecLowering | null;
|
|
90
|
+
/**
|
|
91
|
+
* Resolve the Wasm value type used for `IrType.string` in the active
|
|
92
|
+
* backend.
|
|
93
|
+
* - `wasm:js-string` mode → `{ kind: "externref" }`.
|
|
94
|
+
* - `nativeStrings` mode → `{ kind: "ref", typeIdx: ctx.anyStrTypeIdx }`.
|
|
95
|
+
* Optional so Phase-1 resolvers without string support can omit it; a
|
|
96
|
+
* function that actually emits a `string.*` instr will fail at lowering
|
|
97
|
+
* time when it's missing.
|
|
98
|
+
*/
|
|
99
|
+
resolveString?(): ValType;
|
|
100
|
+
/**
|
|
101
|
+
* Slice 6 part 4 (#1183) refactored in #1185: returns whether the
|
|
102
|
+
* compiler is in native-strings mode. Drives the for-of strategy
|
|
103
|
+
* switch for `string`-typed iterables in `lowerForOfStatement`.
|
|
104
|
+
* Optional for the same reason as `resolveString` — Phase-1
|
|
105
|
+
* resolvers without string support can omit it.
|
|
106
|
+
*/
|
|
107
|
+
nativeStrings?(): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Emit the Wasm op sequence that materializes a string literal.
|
|
110
|
+
* - host strings → register a `string_constants.<value>` global import
|
|
111
|
+
* and emit `[global.get]`.
|
|
112
|
+
* - native → inline `i32.const len`, `i32.const 0`, code-unit
|
|
113
|
+
* `i32.const`s, `array.new_fixed`, `struct.new`.
|
|
114
|
+
*/
|
|
115
|
+
emitStringConst?(value: string, alloc?: import('./nodes.js').AllocSiteId): readonly Instr[];
|
|
116
|
+
/** `[call concat]` (host) or `[call __str_concat]` (native). */
|
|
117
|
+
emitStringConcat?(): readonly Instr[];
|
|
118
|
+
/** `[call equals]` (host) or `[call __str_equals]` (native). */
|
|
119
|
+
emitStringEquals?(): readonly Instr[];
|
|
120
|
+
/**
|
|
121
|
+
* `[call length]` (host) or `[struct.get $AnyString $len]` (native).
|
|
122
|
+
* Result is i32 — the `string.len` IR instr appends an
|
|
123
|
+
* `f64.convert_i32_s` after this.
|
|
124
|
+
*/
|
|
125
|
+
emitStringLen?(): readonly Instr[];
|
|
126
|
+
/**
|
|
127
|
+
* Slice 9 (#1169h): resolve (and lazily register) the shared `__exn`
|
|
128
|
+
* exception tag. The tag carries an `externref` payload — every
|
|
129
|
+
* thrown value is coerced to externref upstream. Returning the
|
|
130
|
+
* `tagIdx` lets the lowerer emit `throw $exnTagIdx` and `try ...
|
|
131
|
+
* catch $exnTagIdx`. IR-compiled throws are catchable by
|
|
132
|
+
* legacy-compiled handlers (and vice versa) because both paths go
|
|
133
|
+
* through the same single tag.
|
|
134
|
+
*/
|
|
135
|
+
ensureExnTag?(): number;
|
|
136
|
+
/**
|
|
137
|
+
* #1373b Phase C scaffolding — resolve (and lazily register) the
|
|
138
|
+
* standalone `$Promise` WasmGC struct type. The struct's layout is
|
|
139
|
+
* `{ state: i32, value: externref, callbacks: externref }` (see
|
|
140
|
+
* `src/codegen/async-scheduler.ts` for the canonical registration).
|
|
141
|
+
*
|
|
142
|
+
* Returns the struct's typeIdx. Used by IR's `async.return`,
|
|
143
|
+
* `async.throw`, and `await` lowering to construct or inspect
|
|
144
|
+
* Promise values without going through the JS-host `Promise.resolve`
|
|
145
|
+
* / `Promise.reject` imports.
|
|
146
|
+
*
|
|
147
|
+
* Optional — Phase-1 resolvers (pre-#1373b) can omit it; lowering
|
|
148
|
+
* falls back to a throw stub when missing.
|
|
149
|
+
*/
|
|
150
|
+
resolvePromiseType?(): number;
|
|
151
|
+
}
|
|
152
|
+
export interface IrLowerResult {
|
|
153
|
+
readonly func: WasmFunction;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* #1584 (a0-tail): the backend-agnostic lowering result. `lowerIrFunctionBody`
|
|
157
|
+
* is generic over the emitter sink `S`; it returns the lowered body in that
|
|
158
|
+
* sink plus the backend-independent function metadata (`typeIdx`, `locals`,
|
|
159
|
+
* `name`, `exported`). The WasmGC wrapper (`lowerIrFunctionToWasm`, `S =
|
|
160
|
+
* Instr[]`) assembles the concrete `WasmFunction` from this; a bytecode driver
|
|
161
|
+
* consumes `body: BytecodeSink` directly. The `typeIdx`, `locals`, `name`, and
|
|
162
|
+
* `exported` fields are identical regardless of `S` — only `body` changes
|
|
163
|
+
* representation, which is exactly the #1715 sink-is-the-one-seam finding.
|
|
164
|
+
*/
|
|
165
|
+
export interface IrLoweredBody<S> {
|
|
166
|
+
readonly name: string;
|
|
167
|
+
readonly body: S;
|
|
168
|
+
readonly locals: LocalDef[];
|
|
169
|
+
readonly typeIdx: number;
|
|
170
|
+
readonly exported: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* #1584 (a0-tail): thin WasmGC wrapper. Every pre-#1584 caller is unchanged —
|
|
174
|
+
* it still returns `IrLowerResult` (`{ func: WasmFunction }`) with `S = Instr[]`
|
|
175
|
+
* lowering, byte-identical to the previous monolithic body. The generic body
|
|
176
|
+
* does all the work; this only assembles the `WasmFunction` shape from the
|
|
177
|
+
* `Instr[]` sink.
|
|
178
|
+
*/
|
|
179
|
+
export declare function lowerIrFunctionToWasm(func: IrFunction, resolver: IrLowerResolver, emitter?: BackendEmitter): IrLowerResult;
|
|
180
|
+
/**
|
|
181
|
+
* #1584 (a0-tail): the real lowering, generic over the emitter sink `S`. With
|
|
182
|
+
* `S = Instr[]` (WasmGC, the default) the emitted stream is byte-identical to
|
|
183
|
+
* the pre-#1584 monolith. With `S = BytecodeSink` the SAME drive shape produces
|
|
184
|
+
* a flat opcode stream — the bytecode arm is then produced by the REAL
|
|
185
|
+
* `lower.ts`, not a hand-lowerer (the (a0) acceptance criterion).
|
|
186
|
+
*
|
|
187
|
+
* Op families that structurally embed nested `Instr[]` sub-buffers into a raw
|
|
188
|
+
* WasmGC `Instr` (loop / try / await — see `requireInstrSink` below) are still
|
|
189
|
+
* WasmGC-only: on a non-`Instr[]` sink they throw the not-yet-migrated boundary
|
|
190
|
+
* loudly. Each migrates behind a typed trait primitive in §2a (a1..a6).
|
|
191
|
+
*/
|
|
192
|
+
export declare function lowerIrFunctionBody<S>(func: IrFunction, resolver: IrLowerResolver, emitter?: BackendEmitter<S>): IrLoweredBody<S>;
|
|
193
|
+
/**
|
|
194
|
+
* Slice 6 (#1169e): walk a `forof.vec` body recursively and collect every
|
|
195
|
+
* SSA value referenced. Used by the cross-block use counter to ensure
|
|
196
|
+
* outer-scope values used inside the loop body are materialised in Wasm
|
|
197
|
+
* locals before the loop starts.
|
|
198
|
+
*/
|
|
199
|
+
export declare function collectForOfBodyUses(body: readonly IrInstr[]): IrValueId[];
|
|
200
|
+
export declare function lowerIrTypeToValType(t: IrType, resolver: IrLowerResolver, funcName: string): ValType;
|
|
201
|
+
export declare function emitConstInstr(instr: Extract<IrInstr, {
|
|
202
|
+
kind: "const";
|
|
203
|
+
}>, out: Instr[], funcName: string): void;
|