@oseo/compiler 0.0.0-stage → 0.1.0-canary.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.
Files changed (105) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +172 -2
  3. package/dist/agent-programs.d.ts +28 -0
  4. package/dist/agent-programs.d.ts.map +1 -0
  5. package/dist/agent-programs.js +134 -0
  6. package/dist/agent-programs.js.map +1 -0
  7. package/dist/agent-templates.d.ts +33 -0
  8. package/dist/agent-templates.d.ts.map +1 -0
  9. package/dist/agent-templates.js +45 -0
  10. package/dist/agent-templates.js.map +1 -0
  11. package/dist/compile.d.ts +20 -0
  12. package/dist/compile.d.ts.map +1 -0
  13. package/dist/compile.js +75 -0
  14. package/dist/compile.js.map +1 -0
  15. package/dist/fragments.d.ts +72 -0
  16. package/dist/fragments.d.ts.map +1 -0
  17. package/dist/fragments.js +158 -0
  18. package/dist/fragments.js.map +1 -0
  19. package/dist/hir-build.d.ts +80 -0
  20. package/dist/hir-build.d.ts.map +1 -0
  21. package/dist/hir-build.js +3077 -0
  22. package/dist/hir-build.js.map +1 -0
  23. package/dist/hir-print.d.ts +10 -0
  24. package/dist/hir-print.d.ts.map +1 -0
  25. package/dist/hir-print.js +271 -0
  26. package/dist/hir-print.js.map +1 -0
  27. package/dist/hir.d.ts +1246 -0
  28. package/dist/hir.d.ts.map +1 -0
  29. package/dist/hir.js +147 -0
  30. package/dist/hir.js.map +1 -0
  31. package/dist/host-scripts.d.ts +14 -0
  32. package/dist/host-scripts.d.ts.map +1 -0
  33. package/dist/host-scripts.js +204 -0
  34. package/dist/host-scripts.js.map +1 -0
  35. package/dist/index.d.ts +26 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +27 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/mir-build.d.ts +8 -0
  40. package/dist/mir-build.d.ts.map +1 -0
  41. package/dist/mir-build.js +5113 -0
  42. package/dist/mir-build.js.map +1 -0
  43. package/dist/mir-print.d.ts +7 -0
  44. package/dist/mir-print.d.ts.map +1 -0
  45. package/dist/mir-print.js +65 -0
  46. package/dist/mir-print.js.map +1 -0
  47. package/dist/mir-specialize.d.ts +7 -0
  48. package/dist/mir-specialize.d.ts.map +1 -0
  49. package/dist/mir-specialize.js +182 -0
  50. package/dist/mir-specialize.js.map +1 -0
  51. package/dist/mir.d.ts +571 -0
  52. package/dist/mir.d.ts.map +1 -0
  53. package/dist/mir.js +1 -0
  54. package/dist/module-builtin.d.ts +20 -0
  55. package/dist/module-builtin.d.ts.map +1 -0
  56. package/dist/module-builtin.js +57 -0
  57. package/dist/module-builtin.js.map +1 -0
  58. package/dist/module-compile.d.ts +64 -0
  59. package/dist/module-compile.d.ts.map +1 -0
  60. package/dist/module-compile.js +690 -0
  61. package/dist/module-compile.js.map +1 -0
  62. package/dist/module-json.d.ts +7 -0
  63. package/dist/module-json.d.ts.map +1 -0
  64. package/dist/module-json.js +88 -0
  65. package/dist/module-json.js.map +1 -0
  66. package/dist/modules.d.ts +87 -0
  67. package/dist/modules.d.ts.map +1 -0
  68. package/dist/modules.js +734 -0
  69. package/dist/modules.js.map +1 -0
  70. package/dist/native-fragments.d.ts +36 -0
  71. package/dist/native-fragments.d.ts.map +1 -0
  72. package/dist/native-fragments.js +110 -0
  73. package/dist/native-fragments.js.map +1 -0
  74. package/dist/native.d.ts +282 -0
  75. package/dist/native.d.ts.map +1 -0
  76. package/dist/native.js +47 -0
  77. package/dist/native.js.map +1 -0
  78. package/dist/regexp-execute.d.ts +74 -0
  79. package/dist/regexp-execute.d.ts.map +1 -0
  80. package/dist/regexp-execute.js +480 -0
  81. package/dist/regexp-execute.js.map +1 -0
  82. package/dist/regexp-matcher.d.ts +279 -0
  83. package/dist/regexp-matcher.d.ts.map +1 -0
  84. package/dist/regexp-matcher.js +1098 -0
  85. package/dist/regexp-matcher.js.map +1 -0
  86. package/dist/regexp-parse.d.ts +22 -0
  87. package/dist/regexp-parse.d.ts.map +1 -0
  88. package/dist/regexp-parse.js +1440 -0
  89. package/dist/regexp-parse.js.map +1 -0
  90. package/dist/regexp-print.d.ts +24 -0
  91. package/dist/regexp-print.d.ts.map +1 -0
  92. package/dist/regexp-print.js +147 -0
  93. package/dist/regexp-print.js.map +1 -0
  94. package/dist/regexp.d.ts +324 -0
  95. package/dist/regexp.d.ts.map +1 -0
  96. package/dist/regexp.js +22 -0
  97. package/dist/regexp.js.map +1 -0
  98. package/dist/source.d.ts +38 -0
  99. package/dist/source.d.ts.map +1 -0
  100. package/dist/source.js +10 -0
  101. package/dist/source.js.map +1 -0
  102. package/dist/syntax.d.ts +1232 -0
  103. package/dist/syntax.d.ts.map +1 -0
  104. package/dist/syntax.js +1 -0
  105. package/package.json +32 -3
package/dist/mir.d.ts ADDED
@@ -0,0 +1,571 @@
1
+ import { SourceRange } from "./source.js";
2
+ import { RegExpMatcherProgram } from "./regexp-matcher.js";
3
+ import { BinaryOperator, FunctionKind, HintName, HintProvenance, LocatedSyntax, UnaryOperator } from "./syntax.js";
4
+ import { ErrorIntrinsicName, HirExpression } from "./hir.js";
5
+ //#region src/mir.d.ts
6
+ /** A primitive constant retained without lossy textual serialization. */
7
+ type MirConstant = {
8
+ readonly digits: string;
9
+ readonly kind: "bigint";
10
+ readonly radix: 2 | 8 | 10 | 16;
11
+ } | {
12
+ readonly kind: "boolean";
13
+ readonly value: boolean;
14
+ } | {
15
+ readonly kind: "null";
16
+ } | {
17
+ readonly kind: "number";
18
+ readonly value: number;
19
+ } | {
20
+ readonly kind: "string";
21
+ readonly value: string;
22
+ } | {
23
+ readonly kind: "undefined";
24
+ };
25
+ /** A direct call target independent of HIR and source syntax. */
26
+ type MirCallTarget = {
27
+ readonly kind: "builtin-export";
28
+ } | {
29
+ readonly kind: "console-log";
30
+ } | {
31
+ readonly kind: "dynamic";
32
+ } | {
33
+ readonly kind: "super";
34
+ } | {
35
+ readonly kind: "promise-intrinsic";
36
+ readonly method: "all" | "asyncCall" | "awaitThen" | "resolve" | "then";
37
+ } | {
38
+ readonly kind: "timer-intrinsic";
39
+ readonly method: "clearTimeout" | "setTimeout";
40
+ } | {
41
+ readonly kind: "module-evaluate";
42
+ } | {
43
+ readonly kind: "module-import";
44
+ } | {
45
+ readonly functionId: number;
46
+ readonly kind: "function";
47
+ };
48
+ /** Hint data copied into MIR without retaining a HIR or syntax object. */
49
+ interface MirHint {
50
+ readonly name: HintName;
51
+ readonly provenance: HintProvenance;
52
+ readonly range: SourceRange;
53
+ }
54
+ /** Compiler-owned policy for removable guarded specialization. */
55
+ type SpecializationMode = "disabled" | "enabled";
56
+ /**
57
+ * The host decision at a rejection checkpoint that finds an unhandled
58
+ * rejection. `"fatal"` ends the program with the first reason, the M4
59
+ * event-loop profile every ordinary executable keeps. `"observe"` records
60
+ * the report and continues, the tolerant test262 host contract that only
61
+ * a test262 harness run selects (ADR 0030).
62
+ */
63
+ type UnhandledRejectionPolicy = "fatal" | "observe";
64
+ /** Explicit compiler orchestration options, independent of process globals. */
65
+ interface CompilerOptions {
66
+ /** Main test262 agent's [[CanBlock]]; omitted means true. */
67
+ readonly mainAgentCanBlock?: boolean;
68
+ readonly observeSpecialization?: boolean;
69
+ readonly specialization?: SpecializationMode;
70
+ /**
71
+ * Rejection checkpoint policy of the generated program; omitted means
72
+ * `"fatal"`. It is independent of `test262Host`, so a Script, a module
73
+ * graph, and a split fragment build can select it without host bindings.
74
+ */
75
+ readonly unhandledRejectionPolicy?: UnhandledRejectionPolicy;
76
+ /**
77
+ * Compile the Script for the test262 host: `$262` reads the host object
78
+ * the runtime installs, and every `$262.agent.start` source template the
79
+ * Script contains becomes an agent program compiled beside it. Literal
80
+ * evalScript sources join its dispatcher as ahead-of-time evaluators.
81
+ */
82
+ readonly test262Host?: boolean;
83
+ }
84
+ /**
85
+ * One `$262.agent.start` source template: the cooked literal text around
86
+ * each numeric hole, and the source identity its agent program reports.
87
+ */
88
+ interface MirAgentTemplate {
89
+ readonly segments: readonly string[];
90
+ readonly sourceId: string;
91
+ }
92
+ /** One source in the closed set of ahead-of-time host Scripts. */
93
+ interface MirHostScript {
94
+ readonly source: string;
95
+ readonly functionId?: number;
96
+ readonly error?: "syntax" | "unsupported";
97
+ readonly message?: string;
98
+ }
99
+ /** The test262 host a main program installs before its Script runs. */
100
+ interface MirTest262Host {
101
+ /** Agent policy shared by every realm of the main context. */
102
+ readonly mainAgentCanBlock?: boolean;
103
+ readonly scripts?: readonly MirHostScript[];
104
+ /** Agent program templates, indexed as each agent program's entry. */
105
+ readonly agents: readonly MirAgentTemplate[];
106
+ }
107
+ /** One MIR-owned function parameter and its specialization hints. */
108
+ interface MirParameter {
109
+ readonly bindingId: number;
110
+ readonly hints: readonly MirHint[];
111
+ readonly name: string;
112
+ readonly range: SourceRange;
113
+ /** Collect every remaining call argument into a fresh array. */
114
+ readonly rest?: true;
115
+ }
116
+ /** One script-owned lexical binding shared by declared functions. */
117
+ interface MirGlobalBinding {
118
+ readonly id: number;
119
+ readonly name: string;
120
+ /**
121
+ * The source name whose unresolvable reference this hidden binding
122
+ * reports, carried from HIR so the backend can emit the cell that
123
+ * throws that exact ReferenceError.
124
+ */
125
+ readonly unresolvableName?: string;
126
+ }
127
+ /** One source-located Script lexical name checked against the global object. */
128
+ interface MirGlobalLexicalName {
129
+ readonly id?: number;
130
+ readonly mutable?: boolean;
131
+ readonly name: string;
132
+ readonly range: SourceRange;
133
+ }
134
+ /**
135
+ * One global-object property and the declaration that creates it. A
136
+ * backend passes the declaration kind through so the runtime can apply
137
+ * CreateGlobalVarBinding or CreateGlobalFunctionBinding when the name
138
+ * already names an intrinsic global property.
139
+ */
140
+ interface MirGlobalObjectBinding extends MirGlobalBinding {
141
+ readonly declaration: "annexb" | "function" | "var";
142
+ readonly range: SourceRange;
143
+ }
144
+ /** One control destination and the cleanup nesting active at that point. */
145
+ interface MirControlTarget {
146
+ readonly blockId: number;
147
+ readonly cleanupDepth: number;
148
+ }
149
+ /** One inspectable backend-neutral MIR operation. */
150
+ interface MirOperation {
151
+ /**
152
+ * Selects the accessor slot for `property-define-accessor` and
153
+ * `class-private-method-define`,
154
+ * `class-static-private-method-define`, and the `SetFunctionName`
155
+ * prefix for the accessor closure created by `function-create`.
156
+ */
157
+ readonly accessorKind?: "get" | "set";
158
+ /**
159
+ * A default derived super construction forwards the running function's
160
+ * incoming argument list directly, without reading an iterator.
161
+ */
162
+ readonly forwardArguments?: true;
163
+ readonly argumentListId?: number;
164
+ readonly arguments: readonly number[];
165
+ /** The hole an `agent-hole` operation reads. */
166
+ readonly agentHole?: number;
167
+ readonly arrayLength?: number;
168
+ /**
169
+ * Binding accessed by the operation. A private-name-create replaces this
170
+ * binding with a fresh cell initialized to its new private identity.
171
+ */
172
+ readonly bindingId?: number;
173
+ readonly cacheId?: number;
174
+ readonly constant?: MirConstant;
175
+ readonly detail: string;
176
+ /**
177
+ * Enumerability of the property a `property-define-accessor` defines.
178
+ * A class body's accessor is non-enumerable, unlike an object literal's
179
+ * accessor clause; absent means the enumerable object literal default.
180
+ */
181
+ readonly enumerable?: boolean;
182
+ readonly id: number;
183
+ readonly kind: "add-smi-checked" | "argument-list-append" | "argument-list-create" | "array-append" | "array-append-hole" | "array-create" | "binary" | "binding-reset" | "box-smi" | "branch" | "call" | "check-status" | "class-field-define" | "class-heritage" | "class-private-field-define" | "class-private-method-define" | "class-prototype" | "class-static-field-define" | "class-static-private-field-define" | "class-static-private-method-define" | "constant" | "caught" | "completion-set" | "construct" | "construct-receiver" | "derived-return" | "delete-object-coercible" | "dispose-scope-add" | "dispose-scope-await-value" | "dispose-scope-awaiting" | "dispose-scope-begin" | "dispose-scope-continue" | "dispose-scope-create" | "dispose-scope-dispose" | "dispose-scope-result" | "error-intrinsic" | "symbol-intrinsic" | "function-intrinsic" | "iterator-intrinsic" | "agent-hole" | "template-object" | "regexp-literal" | "count-guard-hit" | "count-guard-miss" | "count-overflow-miss" | "enumerate-get" | "enumerate-next" | "function-create" | "global-environment" | "global-this" | "guard-object" | "guard-shape" | "guard-smi" | "home-object-bind" | "initialize" | "instance-elements-init" | "is-object" | "iterator-close" | "iterator-close-result" | "iterator-close-start" | "iterator-await-result" | "iterator-await-start" | "iterator-delegate-next" | "iterator-delegate-return" | "iterator-delegate-throw" | "iterator-get" | "iterator-next" | "join" | "load-fixed-slot" | "module-namespace-create" | "new-target" | "to-object" | "object-coercible" | "object-create" | "object-rest" | "object-set-prototype" | "object-spread" | "private-get" | "private-in" | "private-name-create" | "private-set" | "property-key" | "property-define-accessor" | "property-define-data" | "property-define-method" | "property-delete" | "property-get" | "property-set" | "read" | "receiver" | "root-store" | "super-base" | "super-constructor" | "super-property-delete" | "safepoint" | "this-bind" | "unbox-smi" | "unary" | "update-property-cache" | "write";
184
+ readonly mutable?: boolean;
185
+ readonly namespaceBindingIds?: readonly number[];
186
+ readonly namespaceNames?: readonly string[];
187
+ /**
188
+ * Marks a `call` in tail position (ECMA-262 15.10). Its block returns
189
+ * its value directly, with only `check-status` and `root-store`
190
+ * metadata between, so the backend may discard the frame before the
191
+ * call runs. Dynamic, console, and timer targets carry it; host targets
192
+ * use the host tail-call ABI without a first-class callable value.
193
+ */
194
+ readonly tail?: true;
195
+ /**
196
+ * The `this` binding of the derived class constructor a tail `call`
197
+ * leaves. The constructor's result rules then apply to the value the
198
+ * whole tail call chain returns, in place of the `derived-return` the
199
+ * frame can no longer run.
200
+ */
201
+ readonly tailThisBindingId?: number;
202
+ /** Cooked strings for one cached tagged-template object. */
203
+ readonly templateCooked?: readonly (string | undefined)[];
204
+ /** Raw strings paired with `templateCooked`. */
205
+ readonly templateRaw?: readonly string[];
206
+ /**
207
+ * The immutable matcher artifact one regular expression literal
208
+ * compiled to during the build. A backend emits it as generated data;
209
+ * evaluating the operation allocates a fresh object over it rather than
210
+ * compiling a pattern.
211
+ */
212
+ readonly regexpProgram?: RegExpMatcherProgram;
213
+ readonly checkedResult?: number;
214
+ readonly abruptTarget?: MirControlTarget;
215
+ readonly completionKind?: "jump" | "normal" | "return" | "throw";
216
+ readonly completionSlot?: number;
217
+ readonly completionTarget?: MirControlTarget;
218
+ readonly errorName?: ErrorIntrinsicName;
219
+ readonly functionId?: number;
220
+ readonly functionKind?: FunctionKind;
221
+ readonly functionLength?: number;
222
+ readonly functionName?: string;
223
+ readonly functionSource?: string;
224
+ /**
225
+ * An agent program's `functionSource` split at its numeric holes: the
226
+ * literal runs around each hole and the hole each gap reads. The source
227
+ * a started agent reflects holds the literal text its start source had
228
+ * at each hole, not the placeholder the compiler resolved.
229
+ */
230
+ readonly functionSourceHoles?: {
231
+ readonly holes: readonly number[];
232
+ readonly runs: readonly string[];
233
+ };
234
+ readonly functionNameBinding?: boolean;
235
+ readonly importedBinding?: boolean;
236
+ readonly hint?: MirHint;
237
+ /**
238
+ * Marks one iterator operation as an asynchronous iteration step,
239
+ * which reads `Symbol.asyncIterator` before falling back to a wrapped
240
+ * synchronous iterator and awaits every result. A `for await` head and
241
+ * a `yield*` inside an asynchronous generator produce these operations,
242
+ * so the synchronous protocol keeps its unconditional lowering.
243
+ */
244
+ readonly iteratorAsync?: true;
245
+ /**
246
+ * A `dispose-scope-create` or `dispose-scope-add` of an `await using`
247
+ * declaration, whose capability or resource carries the async-dispose
248
+ * hint; the synchronous hint leaves it absent.
249
+ */
250
+ readonly disposalAsync?: true;
251
+ /** A `dispose-scope-continue` after its Await rejected. */
252
+ readonly disposalRejected?: true;
253
+ readonly iteratorNextMethodResult?: number;
254
+ readonly iteratorDoneState?: number;
255
+ /** Skip outer AsyncIteratorClose result validation owned by a wrapper. */
256
+ readonly iteratorCloseResultMode?: number;
257
+ /**
258
+ * The asynchronous iterator action started before a traced-frame await.
259
+ * Its promise settles to an iterator result object, except that a
260
+ * delegation return with no asynchronous `return` method settles to the
261
+ * directly awaited return value and records that mode separately.
262
+ */
263
+ readonly iteratorStepKind?: "delegate-next" | "delegate-return" | "delegate-throw" | "next";
264
+ /** Root slot retaining the direct-value result mode across suspension. */
265
+ readonly iteratorValueOnlyResult?: number;
266
+ /** Read `IteratorValue` even when the settled result reports done. */
267
+ readonly iteratorValueWhenDone?: true;
268
+ /**
269
+ * The slot receiving the stepped value. `iterator-next` leaves it
270
+ * `undefined` once the iterator reports exhaustion, while the two
271
+ * delegation operations always store `IteratorValue`, because `yield*`
272
+ * reports the final value as the delegating expression's result.
273
+ */
274
+ readonly iteratorValueResult?: number;
275
+ /**
276
+ * The slot receiving the for-in enumeration record `enumerate-get`
277
+ * creates. The operation's own result is the boolean the head branches
278
+ * on, because ForIn/OfHeadEvaluation reports a break completion for a
279
+ * nullish subject instead of an iterator, so the record slot stays
280
+ * `undefined` in that case and the loop never steps.
281
+ */
282
+ readonly enumerateRecordResult?: number;
283
+ /**
284
+ * The slot receiving the enumerated property key string. Like
285
+ * `iteratorValueResult` it is left `undefined` once the enumeration
286
+ * reports exhaustion.
287
+ */
288
+ readonly enumerateKeyResult?: number;
289
+ readonly operator?: BinaryOperator | UnaryOperator;
290
+ readonly range: SourceRange;
291
+ /**
292
+ * Forces strict-mode property assignment and deletion for one
293
+ * operation lowered inline into a possibly non-strict function. A
294
+ * class body's computed element keys are the only such region: they
295
+ * are strict code even when the enclosing script is not.
296
+ */
297
+ readonly strict?: true;
298
+ /**
299
+ * Marks one `property-get` or `property-set` as a `super` reference,
300
+ * which starts its lookup at the object the operation's first argument
301
+ * names and passes a distinct receiver as its last argument. A getter
302
+ * or setter therefore runs against the enclosing element's `this`, and
303
+ * an assignment that reaches no setter creates its own property on
304
+ * that receiver instead of on the object it looked through.
305
+ */
306
+ readonly superReference?: true;
307
+ readonly target?: MirCallTarget;
308
+ }
309
+ /** A MIR block terminator. */
310
+ type MirTerminator = {
311
+ readonly kind: "branch";
312
+ readonly test: number;
313
+ readonly whenFalse: number;
314
+ readonly whenTrue: number;
315
+ } | {
316
+ readonly kind: "jump";
317
+ readonly target: number;
318
+ readonly values?: readonly number[];
319
+ } | {
320
+ readonly kind: "return";
321
+ readonly value: number;
322
+ } | {
323
+ /**
324
+ * Suspends the enclosing generator: the saved state records `resume`
325
+ * as the block that continues execution, `value` leaves the generator
326
+ * as the yielded value, and the next resumption stores the sent value
327
+ * in `sent` before running `resume`.
328
+ *
329
+ * A resumption that delivers a return completion, as
330
+ * `%GeneratorPrototype%.return` and an implicit `IteratorClose` do,
331
+ * continues at `returnResume` instead. That block leaves the body the
332
+ * way a `return` statement written at the suspension point would, so
333
+ * every enclosing `finally` and iterator close still runs. A
334
+ * resumption that delivers a throw completion continues at
335
+ * `throwResume`, which raises the sent value at the suspension point.
336
+ *
337
+ * Every yield suspension names both blocks: the synchronous and
338
+ * asynchronous prototype methods deliver either resumption to
339
+ * their body kind. An `awaited` suspension names no
340
+ * `returnResume`, because a rejection is the only abrupt
341
+ * resumption an awaited operand delivers.
342
+ */
343
+ readonly kind: "generator-yield";
344
+ /**
345
+ * True when the suspension is an Await rather than a Yield: `value`
346
+ * is the operand the driver resolves, and the resumption delivers
347
+ * the fulfilled value to `resume` or the rejection to `throwResume`.
348
+ * The suspension leaves no iteration step, so no consumer observes
349
+ * it. Only an asynchronous generator body suspends this way.
350
+ */
351
+ readonly awaited?: true;
352
+ readonly resume: number;
353
+ /**
354
+ * True when `value` already is a complete iterator result object
355
+ * that the resumption reports unchanged. `yield*` suspends this
356
+ * way, because `GeneratorYield` receives the inner iterator's own
357
+ * result object rather than a freshly created one.
358
+ */
359
+ readonly resultObject?: true;
360
+ readonly returnResume?: number;
361
+ readonly sent: number;
362
+ readonly throwResume?: number;
363
+ readonly value: number;
364
+ } | {
365
+ readonly completionSlot: number;
366
+ readonly kind: "resume-completion";
367
+ readonly outerAbrupt?: MirControlTarget;
368
+ readonly outerFinalizer?: MirControlTarget;
369
+ } | {
370
+ readonly kind: "unreachable";
371
+ };
372
+ /** One deterministic control-flow block. */
373
+ interface MirBlock {
374
+ readonly id: number;
375
+ readonly operations: readonly MirOperation[];
376
+ readonly parameters?: readonly number[];
377
+ readonly terminator: MirTerminator;
378
+ }
379
+ /** Inspectable identity and control-flow anchors for one specialization. */
380
+ interface MirSpecialization {
381
+ readonly genericBlock: number;
382
+ readonly hints: readonly MirHint[];
383
+ readonly joinBlock: number;
384
+ readonly kind: "smi-add";
385
+ readonly range: SourceRange;
386
+ }
387
+ /** MIR for one declared function or script. */
388
+ interface MirFunction extends LocatedSyntax {
389
+ /** Declaration set for a host Script evaluator with a fresh environment. */
390
+ readonly hostScript?: {
391
+ readonly lexical: readonly MirGlobalLexicalName[];
392
+ readonly objects: readonly MirGlobalObjectBinding[];
393
+ };
394
+ /**
395
+ * The implicit `arguments` binding initialized by the backend from the
396
+ * generic call ABI, present for every function form except an arrow.
397
+ */
398
+ readonly argumentsBindingId?: number;
399
+ /**
400
+ * True when `argumentsBindingId`'s object is the mapped arguments
401
+ * exotic object rather than the ordinary unmapped snapshot, mirroring
402
+ * `HirFunction.argumentsMapped`. The backend uses it to select which
403
+ * runtime constructor the prologue calls.
404
+ */
405
+ readonly argumentsMapped?: true;
406
+ /**
407
+ * An ordinary asynchronous body backed by a traced suspension frame.
408
+ * Calling it still returns one capability promise rather than exposing
409
+ * the frame.
410
+ */
411
+ readonly asyncFunction?: true;
412
+ readonly blocks: readonly MirBlock[];
413
+ /**
414
+ * The `this` binding of a derived class constructor. Every `return`
415
+ * leaves through a `derived-return` operation against this binding, so
416
+ * the constructor cannot produce a receiver that `super()` never bound.
417
+ */
418
+ readonly derivedThisBindingId?: number;
419
+ /** JavaScript `length`, independent from the call ABI parameter count. */
420
+ readonly functionLength: number;
421
+ /**
422
+ * An asynchronous generator body, which is also a `generator` body.
423
+ * Its `await` operands suspend through `generator-yield` as well, so
424
+ * the driver owns every step the body takes and reports each one
425
+ * through a promise.
426
+ */
427
+ readonly asyncGenerator?: true;
428
+ /**
429
+ * A generator body. Calling the function runs only the parameter and
430
+ * environment prologue and returns a suspended generator; the blocks
431
+ * run on resumption and may leave through `generator-yield`.
432
+ */
433
+ readonly generator?: true;
434
+ /**
435
+ * First block executed when a newly created generator is resumed. Blocks
436
+ * reachable before this one initialize non-simple parameters at call time.
437
+ */
438
+ readonly generatorBodyStart?: number;
439
+ readonly id: number;
440
+ readonly kind: "mir-function";
441
+ readonly localBindingIds?: readonly number[];
442
+ readonly name: string;
443
+ /** Number of positional parameters consumed by the generated function. */
444
+ readonly parameterCount: number;
445
+ readonly parameters: readonly MirParameter[];
446
+ /**
447
+ * Logical root identity capacity, including reserved slots above the
448
+ * value and operation identity range. A backend may compact annotation
449
+ * identities that store no value while preserving reserved capacity.
450
+ */
451
+ readonly rootSlotCount: number;
452
+ readonly selfBindingId?: number;
453
+ readonly specialization?: MirSpecialization;
454
+ readonly strict?: boolean;
455
+ }
456
+ /** Backend-neutral MIR for one source script. */
457
+ interface MirProgram {
458
+ /** Other host Script global binding identities for shared emission. */
459
+ readonly hostObjectBindings?: readonly MirGlobalObjectBinding[];
460
+ readonly functions: readonly MirFunction[];
461
+ readonly globalBindings: readonly MirGlobalBinding[];
462
+ /** Script lexical names checked against restricted global properties. */
463
+ readonly globalLexicalNames?: readonly MirGlobalLexicalName[];
464
+ /**
465
+ * The script bindings the global object also binds as properties, in
466
+ * GlobalDeclarationInstantiation order. A backend installs them once,
467
+ * before the script body runs, so that the property and the binding
468
+ * share one storage location for the whole execution. The list is
469
+ * empty for module code, which adds nothing to the global object.
470
+ */
471
+ readonly globalObjectBindings: readonly MirGlobalObjectBinding[];
472
+ readonly kind: "mir-program";
473
+ readonly script: MirFunction;
474
+ readonly sourceId: string;
475
+ readonly specialization: SpecializationMode;
476
+ readonly observeSpecialization: boolean;
477
+ /** Present on a main program compiled for the test262 host. */
478
+ readonly test262Host?: MirTest262Host;
479
+ /**
480
+ * Present only when the program observes unhandled rejections; absent
481
+ * means the fatal policy, so ordinary programs emit no policy setup.
482
+ */
483
+ readonly unhandledRejectionPolicy?: "observe";
484
+ /**
485
+ * Present on an agent program: its index in the main program's agent
486
+ * table, which names its generated entry.
487
+ */
488
+ readonly agentProgram?: number;
489
+ }
490
+ interface MutableMirBlock {
491
+ readonly id: number;
492
+ readonly operations: MirOperation[];
493
+ parameters?: number[];
494
+ terminator: MirTerminator | undefined;
495
+ }
496
+ interface MirBuilder {
497
+ readonly abruptTargets: MirControlTarget[];
498
+ /**
499
+ * True while lowering an ordinary asynchronous body. Its `await`
500
+ * operands suspend through the traced frame, while `return` resolves
501
+ * the function capability without AsyncGeneratorAwaitReturn.
502
+ */
503
+ readonly asyncFunction: boolean;
504
+ readonly blocks: MutableMirBlock[];
505
+ readonly loops: {
506
+ readonly breakTarget: MirControlTarget;
507
+ readonly continueTarget: MirControlTarget;
508
+ }[];
509
+ readonly labels: {
510
+ readonly breakTarget: MirControlTarget;
511
+ readonly continueTarget?: MirControlTarget;
512
+ readonly name: string;
513
+ }[];
514
+ /** Labels waiting for the next loop lowering to claim their targets. */
515
+ readonly pendingLabels: string[];
516
+ readonly finalizers: MirControlTarget[];
517
+ /**
518
+ * The capability values of the `using` scopes being lowered, innermost
519
+ * last. A `using` or `await using` declaration adds its value to the
520
+ * innermost one.
521
+ */
522
+ readonly disposalScopes: number[];
523
+ /**
524
+ * True while lowering an asynchronous generator body, whose `await`
525
+ * operands and `yield` operands both suspend rather than drain the
526
+ * scheduler in place. Such a body is always a `generator` body too.
527
+ */
528
+ readonly asyncGenerator: boolean;
529
+ /**
530
+ * The binding holding the key that names the anonymous definition a
531
+ * class field initializer body returns. Set only while lowering such
532
+ * an initializer.
533
+ */
534
+ readonly fieldKeyBindingId?: number;
535
+ /**
536
+ * True while lowering a generator body. Only such a body may end a
537
+ * block with `generator-yield`, because only its root slots survive
538
+ * suspension.
539
+ */
540
+ readonly generator: boolean;
541
+ /**
542
+ * True while lowering a class constructor whose class declares
543
+ * instance fields, so `super()` initializes them where it returns.
544
+ */
545
+ readonly initializesInstanceElements: boolean;
546
+ current: MutableMirBlock;
547
+ nextValue: number;
548
+ readonly specialization: SpecializationMode;
549
+ /**
550
+ * True while lowering code that is strict regardless of the enclosing
551
+ * function's own strictness, so property assignment and deletion report
552
+ * their failures instead of ignoring them.
553
+ */
554
+ strictCode: boolean;
555
+ /** True while lowering a body whose HIR function admits tail calls. */
556
+ readonly tailCalls: boolean;
557
+ /**
558
+ * The derived class constructor `this` binding a tail call carries,
559
+ * set only while lowering such a constructor.
560
+ */
561
+ readonly derivedThisBindingId?: number;
562
+ /**
563
+ * The HIR call and optional-chain expressions the current `return`
564
+ * lowers in tail position. Lowering one of those exact nodes marks its
565
+ * `call` as `tail`.
566
+ */
567
+ readonly pendingTailCalls: Set<HirExpression>;
568
+ }
569
+ //#endregion
570
+ export { CompilerOptions, MirAgentTemplate, MirBlock, MirBuilder, MirCallTarget, MirConstant, MirControlTarget, MirFunction, MirGlobalBinding, MirGlobalLexicalName, MirGlobalObjectBinding, MirHint, MirHostScript, MirOperation, MirParameter, MirProgram, MirSpecialization, MirTerminator, MirTest262Host, MutableMirBlock, SpecializationMode, UnhandledRejectionPolicy };
571
+ //# sourceMappingURL=mir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mir.d.ts","names":[],"sources":["../src/mir.ts"],"mappings":";;;;;;KAYY;WAEG;WACA;WACA;;WAEA;WAA0B;;WAC1B;;WACA;WAAyB;;WACzB;WAAyB;;WACzB;;;KAGH;WACG;;WACA;;WACA;;WACA;;WAEA;WACA;;WAGA;WACA;;WAEA;;WACA;;WACA;WAA6B;;;UAG3B;WACN,MAAM;WACN,YAAY;WACZ,OAAO;;;KAIN;;;;;;;;KASA;;UAGK;;WAEN;WACA;WACA,iBAAiB;;;;;;WAMjB,2BAA2B;;;;;;;WAO3B;;;;;;UAOM;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;UAIM;;WAEN;WACA,mBAAmB;;WAEnB,iBAAiB;;;UAIX;WACN;WACA,gBAAgB;WAChB;WACA,OAAO;;WAEP;;;UAIM;WACN;WACA;;;;;;WAMA;;;UAIM;WACN;WACA;WACA;WACA,OAAO;;;;;;;;UASD,+BAA+B;WACrC;WACA,OAAO;;;UAID;WACN;WACA;;;UAIM;;;;;;;WAON;;;;;WAKA;WACA;WACA;;WAEA;WACA;;;;;WAKA;WACA;WACA,WAAW;WACX;;;;;;WAMA;WACA;WACA;WAqGA;WACA;WACA;;;;;;;;WAQA;;;;;;;WAOA;;WAEA;;WAEA;;;;;;;WAOA,gBAAgB;WAChB;WACA,eAAe;WACf;WACA;WACA,mBAAmB;WACnB,YAAY;WACZ;WACA,eAAe;WACf;WACA;WACA;;;;;;;WAOA;aACE;aACA;;WAEF;WACA;WACA,OAAO;;;;;;;;WAQP;;;;;;WAMA;;WAEA;WACA;WACA;;WAEA;;;;;;;WAOA;;WAMA;;WAEA;;;;;;;WAOA;;;;;;;;WAQA;;;;;;WAMA;WACA,WAAW,iBAAiB;WAC5B,OAAO;;;;;;;WAOP;;;;;;;;;WASA;WACA,SAAS;;;KAIR;WAEG;WACA;WACA;WACA;;WAGA;WACA;WACA;;WAGA;WACA;;;;;;;;;;;;;;;;;;;;;;WAuBA;;;;;;;;WAQA;WACA;;;;;;;WAOA;WACA;WACA;WACA;WACA;;WAGA;WACA;WACA,cAAc;WACd,iBAAiB;;WAGjB;;;UAIE;WACN;WACA,qBAAqB;WACrB;WACA,YAAY;;;UAIN;WACN;WACA,gBAAgB;WAChB;WACA;WACA,OAAO;;;UAID,oBAAoB;;WAE1B;aACE,kBAAkB;aAClB,kBAAkB;;;;;;WAMpB;;;;;;;WAOA;;;;;;WAMA;WACA,iBAAiB;;;;;;WAMjB;;WAEA;;;;;;;WAOA;;;;;;WAMA;;;;;WAKA;WACA;WACA;WACA;WACA;;WAEA;WACA,qBAAqB;;;;;;WAMrB;WACA;WACA,iBAAiB;WACjB;;;UAIM;;WAEN,8BAA8B;WAC9B,oBAAoB;WACpB,yBAAyB;;WAEzB,8BAA8B;;;;;;;;WAQ9B,+BAA+B;WAC/B;WACA,QAAQ;WACR;WACA,gBAAgB;WAChB;;WAEA,cAAc;;;;;WAKd;;;;;WAKA;;UAGM;WACN;WACA,YAAY;EACrB;EACA,YAAY;;UAGG;WACN,eAAe;;;;;;WAMf;WACA,QAAQ;WACR;aACE,aAAa;aACb,gBAAgB;;WAElB;aACE,aAAa;aACb,iBAAiB;aACjB;;;WAGF;WACA,YAAY;;;;;;WAMZ;;;;;;WAMA;;;;;;WAMA;;;;;;WAMA;;;;;WAKA;EACT,SAAS;EACT;WACS,gBAAgB;;;;;;EAMzB;;WAES;;;;;WAKA;;;;;;WAMA,kBAAkB,IAAI"}
package/dist/mir.js ADDED
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,20 @@
1
+ import { SourceRange } from "./source.js";
2
+ import { BuiltinModuleSpecifier, ModuleGraphNode, SyntaxModule } from "./syntax.js";
3
+ //#region src/module-builtin.d.ts
4
+ /** The closed export table implemented by the process runtime ABI. */
5
+ declare const builtinModuleExports: {
6
+ readonly "node:process": readonly ["default", "argv", "env", "exit", "stdout", "stderr"];
7
+ readonly "node:fs": readonly ["default", "readFileSync"];
8
+ };
9
+ /** Bare names remain package specifiers rather than builtin aliases. */
10
+ declare function isBuiltinModuleSpecifier(specifier: string): specifier is BuiltinModuleSpecifier;
11
+ /** Builtins have a stable location for compiler-generated declarations. */
12
+ declare function moduleNodeRange(node: ModuleGraphNode): SourceRange;
13
+ /**
14
+ * A private linking view of the export table. A builtin graph node never
15
+ * carries source syntax and never passes through a source frontend.
16
+ */
17
+ declare function moduleNodeSyntax(node: ModuleGraphNode): SyntaxModule;
18
+ //#endregion
19
+ export { builtinModuleExports, isBuiltinModuleSpecifier, moduleNodeRange, moduleNodeSyntax };
20
+ //# sourceMappingURL=module-builtin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-builtin.d.ts","names":[],"sources":["../src/module-builtin.ts"],"mappings":";;;;cAQa;WACX;WACA;;;iBAIc,yBACd,oBACC,aAAa;;iBAKA,gBAAgB,MAAM,kBAAkB;;;;;iBAcxC,iBAAiB,MAAM,kBAAkB"}
@@ -0,0 +1,57 @@
1
+ //#region src/module-builtin.ts
2
+ /** The closed export table implemented by the process runtime ABI. */
3
+ const builtinModuleExports = {
4
+ "node:process": [
5
+ "default",
6
+ "argv",
7
+ "env",
8
+ "exit",
9
+ "stdout",
10
+ "stderr"
11
+ ],
12
+ "node:fs": ["default", "readFileSync"]
13
+ };
14
+ /** Bare names remain package specifiers rather than builtin aliases. */
15
+ function isBuiltinModuleSpecifier(specifier) {
16
+ return specifier === "node:process" || specifier === "node:fs";
17
+ }
18
+ /** Builtins have a stable location for compiler-generated declarations. */
19
+ function moduleNodeRange(node) {
20
+ return node.moduleKind === "builtin" ? {
21
+ sourceId: node.canonicalId,
22
+ start: {
23
+ line: 1,
24
+ column: 1
25
+ },
26
+ end: {
27
+ line: 1,
28
+ column: 1
29
+ }
30
+ } : node.syntax.range;
31
+ }
32
+ /**
33
+ * A private linking view of the export table. A builtin graph node never
34
+ * carries source syntax and never passes through a source frontend.
35
+ */
36
+ function moduleNodeSyntax(node) {
37
+ if (node.moduleKind !== "builtin") return node.syntax;
38
+ const range = moduleNodeRange(node);
39
+ return {
40
+ kind: "module",
41
+ sourceId: node.canonicalId,
42
+ range,
43
+ body: [],
44
+ imports: [],
45
+ exports: builtinModuleExports[node.builtin].map((name) => ({
46
+ kind: "local",
47
+ exportedName: name,
48
+ localName: name,
49
+ range
50
+ })),
51
+ varNames: []
52
+ };
53
+ }
54
+
55
+ //#endregion
56
+ export { builtinModuleExports, isBuiltinModuleSpecifier, moduleNodeRange, moduleNodeSyntax };
57
+ //# sourceMappingURL=module-builtin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-builtin.js","names":[],"sources":["../src/module-builtin.ts"],"sourcesContent":["import type { SourceRange } from \"./source.ts\";\nimport type {\n BuiltinModuleSpecifier,\n ModuleGraphNode,\n SyntaxModule,\n} from \"./syntax.ts\";\n\n/** The closed export table implemented by the process runtime ABI. */\nexport const builtinModuleExports = {\n \"node:process\": [\"default\", \"argv\", \"env\", \"exit\", \"stdout\", \"stderr\"],\n \"node:fs\": [\"default\", \"readFileSync\"],\n} as const;\n\n/** Bare names remain package specifiers rather than builtin aliases. */\nexport function isBuiltinModuleSpecifier(\n specifier: string,\n): specifier is BuiltinModuleSpecifier {\n return specifier === \"node:process\" || specifier === \"node:fs\";\n}\n\n/** Builtins have a stable location for compiler-generated declarations. */\nexport function moduleNodeRange(node: ModuleGraphNode): SourceRange {\n return node.moduleKind === \"builtin\"\n ? {\n sourceId: node.canonicalId,\n start: { line: 1, column: 1 },\n end: { line: 1, column: 1 },\n }\n : node.syntax.range;\n}\n\n/**\n * A private linking view of the export table. A builtin graph node never\n * carries source syntax and never passes through a source frontend.\n */\nexport function moduleNodeSyntax(node: ModuleGraphNode): SyntaxModule {\n if (node.moduleKind !== \"builtin\") return node.syntax;\n const range = moduleNodeRange(node);\n return {\n kind: \"module\",\n sourceId: node.canonicalId,\n range,\n body: [],\n imports: [],\n exports: builtinModuleExports[node.builtin].map((name) => ({\n kind: \"local\",\n exportedName: name,\n localName: name,\n range,\n })),\n varNames: [],\n };\n}\n"],"mappings":";;AAQA,MAAa,uBAAuB;CAClC,gBAAgB;EAAC;EAAW;EAAQ;EAAO;EAAQ;EAAU;CAAQ;CACrE,WAAW,CAAC,WAAW,cAAc;AACvC;;AAGA,SAAgB,yBACd,WACqC;CACrC,OAAO,cAAc,kBAAkB,cAAc;AACvD;;AAGA,SAAgB,gBAAgB,MAAoC;CAClE,OAAO,KAAK,eAAe,YACvB;EACE,UAAU,KAAK;EACf,OAAO;GAAE,MAAM;GAAG,QAAQ;EAAE;EAC5B,KAAK;GAAE,MAAM;GAAG,QAAQ;EAAE;CAC5B,IACA,KAAK,OAAO;AAClB;;;;;AAMA,SAAgB,iBAAiB,MAAqC;CACpE,IAAI,KAAK,eAAe,WAAW,OAAO,KAAK;CAC/C,MAAM,QAAQ,gBAAgB,IAAI;CAClC,OAAO;EACL,MAAM;EACN,UAAU,KAAK;EACf;EACA,MAAM,CAAC;EACP,SAAS,CAAC;EACV,SAAS,qBAAqB,KAAK,QAAQ,CAAC,KAAK,UAAU;GACzD,MAAM;GACN,cAAc;GACd,WAAW;GACX;EACF,EAAE;EACF,UAAU,CAAC;CACb;AACF"}