@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.
- package/LICENSE +674 -0
- package/README.md +172 -2
- package/dist/agent-programs.d.ts +28 -0
- package/dist/agent-programs.d.ts.map +1 -0
- package/dist/agent-programs.js +134 -0
- package/dist/agent-programs.js.map +1 -0
- package/dist/agent-templates.d.ts +33 -0
- package/dist/agent-templates.d.ts.map +1 -0
- package/dist/agent-templates.js +45 -0
- package/dist/agent-templates.js.map +1 -0
- package/dist/compile.d.ts +20 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +75 -0
- package/dist/compile.js.map +1 -0
- package/dist/fragments.d.ts +72 -0
- package/dist/fragments.d.ts.map +1 -0
- package/dist/fragments.js +158 -0
- package/dist/fragments.js.map +1 -0
- package/dist/hir-build.d.ts +80 -0
- package/dist/hir-build.d.ts.map +1 -0
- package/dist/hir-build.js +3077 -0
- package/dist/hir-build.js.map +1 -0
- package/dist/hir-print.d.ts +10 -0
- package/dist/hir-print.d.ts.map +1 -0
- package/dist/hir-print.js +271 -0
- package/dist/hir-print.js.map +1 -0
- package/dist/hir.d.ts +1246 -0
- package/dist/hir.d.ts.map +1 -0
- package/dist/hir.js +147 -0
- package/dist/hir.js.map +1 -0
- package/dist/host-scripts.d.ts +14 -0
- package/dist/host-scripts.d.ts.map +1 -0
- package/dist/host-scripts.js +204 -0
- package/dist/host-scripts.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/mir-build.d.ts +8 -0
- package/dist/mir-build.d.ts.map +1 -0
- package/dist/mir-build.js +5113 -0
- package/dist/mir-build.js.map +1 -0
- package/dist/mir-print.d.ts +7 -0
- package/dist/mir-print.d.ts.map +1 -0
- package/dist/mir-print.js +65 -0
- package/dist/mir-print.js.map +1 -0
- package/dist/mir-specialize.d.ts +7 -0
- package/dist/mir-specialize.d.ts.map +1 -0
- package/dist/mir-specialize.js +182 -0
- package/dist/mir-specialize.js.map +1 -0
- package/dist/mir.d.ts +571 -0
- package/dist/mir.d.ts.map +1 -0
- package/dist/mir.js +1 -0
- package/dist/module-builtin.d.ts +20 -0
- package/dist/module-builtin.d.ts.map +1 -0
- package/dist/module-builtin.js +57 -0
- package/dist/module-builtin.js.map +1 -0
- package/dist/module-compile.d.ts +64 -0
- package/dist/module-compile.d.ts.map +1 -0
- package/dist/module-compile.js +690 -0
- package/dist/module-compile.js.map +1 -0
- package/dist/module-json.d.ts +7 -0
- package/dist/module-json.d.ts.map +1 -0
- package/dist/module-json.js +88 -0
- package/dist/module-json.js.map +1 -0
- package/dist/modules.d.ts +87 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +734 -0
- package/dist/modules.js.map +1 -0
- package/dist/native-fragments.d.ts +36 -0
- package/dist/native-fragments.d.ts.map +1 -0
- package/dist/native-fragments.js +110 -0
- package/dist/native-fragments.js.map +1 -0
- package/dist/native.d.ts +282 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +47 -0
- package/dist/native.js.map +1 -0
- package/dist/regexp-execute.d.ts +74 -0
- package/dist/regexp-execute.d.ts.map +1 -0
- package/dist/regexp-execute.js +480 -0
- package/dist/regexp-execute.js.map +1 -0
- package/dist/regexp-matcher.d.ts +279 -0
- package/dist/regexp-matcher.d.ts.map +1 -0
- package/dist/regexp-matcher.js +1098 -0
- package/dist/regexp-matcher.js.map +1 -0
- package/dist/regexp-parse.d.ts +22 -0
- package/dist/regexp-parse.d.ts.map +1 -0
- package/dist/regexp-parse.js +1440 -0
- package/dist/regexp-parse.js.map +1 -0
- package/dist/regexp-print.d.ts +24 -0
- package/dist/regexp-print.d.ts.map +1 -0
- package/dist/regexp-print.js +147 -0
- package/dist/regexp-print.js.map +1 -0
- package/dist/regexp.d.ts +324 -0
- package/dist/regexp.d.ts.map +1 -0
- package/dist/regexp.js +22 -0
- package/dist/regexp.js.map +1 -0
- package/dist/source.d.ts +38 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +10 -0
- package/dist/source.js.map +1 -0
- package/dist/syntax.d.ts +1232 -0
- package/dist/syntax.d.ts.map +1 -0
- package/dist/syntax.js +1 -0
- package/package.json +32 -3
package/dist/syntax.d.ts
ADDED
|
@@ -0,0 +1,1232 @@
|
|
|
1
|
+
import { ByteRange, Diagnostic, SourceInput, SourceRange } from "./source.js";
|
|
2
|
+
import { RegExpMatcherProgram } from "./regexp-matcher.js";
|
|
3
|
+
//#region src/syntax.d.ts
|
|
4
|
+
/** Provenance retained for an optimization hint. */
|
|
5
|
+
type HintProvenance = "jsdoc" | "typescript";
|
|
6
|
+
/** Primitive hint names accepted during M1. */
|
|
7
|
+
type HintName = "any" | "bigint" | "boolean" | "null" | "number" | "string" | "undefined" | "unknown";
|
|
8
|
+
/** An owned hint that cannot expose a bootstrap-parser node. */
|
|
9
|
+
interface Hint {
|
|
10
|
+
readonly name: HintName;
|
|
11
|
+
readonly provenance: HintProvenance;
|
|
12
|
+
readonly range: SourceRange;
|
|
13
|
+
}
|
|
14
|
+
interface LocatedSyntax {
|
|
15
|
+
readonly range: SourceRange;
|
|
16
|
+
readonly byteRange?: ByteRange;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* How one `this` expression reaches its value.
|
|
20
|
+
*
|
|
21
|
+
* ECMA-262 resolves `this` through the nearest environment record that
|
|
22
|
+
* has a this binding, so an arrow function carries the mode of the
|
|
23
|
+
* enclosing non-arrow function rather than a mode of its own. `strict`
|
|
24
|
+
* is a function whose [[ThisMode]] is strict: the call-site receiver
|
|
25
|
+
* stands unchanged, including when it is `undefined`. `global` covers
|
|
26
|
+
* both a non-strict function, whose [[ThisMode]] is global, and Script
|
|
27
|
+
* top level, whose Global Environment Record this binding is the realm's
|
|
28
|
+
* global this value; both resolve a nullish receiver to that one value.
|
|
29
|
+
* `module` is a Module Environment Record this binding, which ECMA-262
|
|
30
|
+
* defines as `undefined`.
|
|
31
|
+
*/
|
|
32
|
+
type SyntaxThisMode = "global" | "module" | "strict";
|
|
33
|
+
/** A call target admitted by the M1 language profile. */
|
|
34
|
+
type SyntaxCallTarget = (LocatedSyntax & {
|
|
35
|
+
readonly kind: "console-log";
|
|
36
|
+
}) | (LocatedSyntax & {
|
|
37
|
+
readonly kind: "object-intrinsic";
|
|
38
|
+
readonly method: "create" | "defineProperty" | "getOwnPropertyDescriptor" | "keys";
|
|
39
|
+
}) | (LocatedSyntax & {
|
|
40
|
+
readonly kind: "promise-intrinsic";
|
|
41
|
+
readonly method: "all" | "race" | "reject" | "resolve";
|
|
42
|
+
}) | (LocatedSyntax & {
|
|
43
|
+
readonly kind: "promise-intrinsic-direct";
|
|
44
|
+
readonly method: "asyncCall" | "awaitThen" | "resolve" | "then";
|
|
45
|
+
}) | (LocatedSyntax & {
|
|
46
|
+
readonly kind: "timer-intrinsic";
|
|
47
|
+
readonly method: "clearTimeout" | "setTimeout";
|
|
48
|
+
}) | (LocatedSyntax & {
|
|
49
|
+
readonly kind: "name";
|
|
50
|
+
readonly name: string;
|
|
51
|
+
}) | (LocatedSyntax & {
|
|
52
|
+
readonly callee: SyntaxExpression;
|
|
53
|
+
readonly kind: "dynamic";
|
|
54
|
+
}) | (LocatedSyntax & {
|
|
55
|
+
/**
|
|
56
|
+
* A `super()` call, admitted only directly inside a derived class
|
|
57
|
+
* constructor. The parent constructor is the constructor's own
|
|
58
|
+
* [[Prototype]], so the target carries no callee expression.
|
|
59
|
+
*/
|
|
60
|
+
readonly kind: "super";
|
|
61
|
+
/** Only synthesized default constructors forward the incoming list. */
|
|
62
|
+
readonly forwardArguments?: true;
|
|
63
|
+
}) | (LocatedSyntax & {
|
|
64
|
+
readonly key: SyntaxExpression;
|
|
65
|
+
readonly kind: "property";
|
|
66
|
+
readonly object: SyntaxExpression;
|
|
67
|
+
}) | (LocatedSyntax & {
|
|
68
|
+
/**
|
|
69
|
+
* A private member call, `object.#m()`. The callee is the private
|
|
70
|
+
* element the object carries, and the object stays the receiver,
|
|
71
|
+
* so the base expression is evaluated once.
|
|
72
|
+
*/
|
|
73
|
+
readonly kind: "private-method";
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly object: SyntaxExpression;
|
|
76
|
+
});
|
|
77
|
+
/** Binary operations selected before native backend lowering. */
|
|
78
|
+
type BinaryOperator = "!=" | "!==" | "%" | "&" | "*" | "**" | "+" | "-" | "/" | "<" | "<<" | "<=" | "==" | "===" | ">" | ">=" | ">>" | ">>>" | "^" | "in" | "instanceof" | "|";
|
|
79
|
+
/** Unary operations selected before native backend lowering. */
|
|
80
|
+
/**
|
|
81
|
+
* `to-string` is a frontend-synthesized conversion with ToString's
|
|
82
|
+
* string preference; it has no source spelling and normalized template
|
|
83
|
+
* substitutions are its only producer.
|
|
84
|
+
*/
|
|
85
|
+
type UnaryOperator = "!" | "+" | "-" | "numeric-one" | "to-numeric" | "to-string" | "typeof" | "void" | "~";
|
|
86
|
+
/** Short-circuit operators lowered through explicit control flow. */
|
|
87
|
+
type LogicalOperator = "&&" | "??" | "||";
|
|
88
|
+
/** Operators admitted by compound assignment expressions. */
|
|
89
|
+
type AssignmentOperator = "%" | "&" | "&&" | "*" | "**" | "+" | "-" | "/" | "<<" | ">>" | ">>>" | "??" | "^" | "|" | "||";
|
|
90
|
+
/** Prefix and postfix operators that update one assignment target. */
|
|
91
|
+
type UpdateOperator = "++" | "--";
|
|
92
|
+
/** One spread entry retained inside an owned array literal. */
|
|
93
|
+
interface SyntaxArraySpreadElement extends LocatedSyntax {
|
|
94
|
+
readonly argument: SyntaxExpression;
|
|
95
|
+
readonly kind: "spread";
|
|
96
|
+
}
|
|
97
|
+
/** One ordinary, spread, or elided owned array literal entry. */
|
|
98
|
+
type SyntaxArrayElement = SyntaxArraySpreadElement | SyntaxExpression | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* One regular expression literal retained at the frontend boundary.
|
|
101
|
+
*
|
|
102
|
+
* The frontend records the written pattern text, flag text, and source
|
|
103
|
+
* range instead of retaining a bootstrap-parser node, so the owned parser
|
|
104
|
+
* is the only reader of regular expression syntax.
|
|
105
|
+
*/
|
|
106
|
+
interface RegExpLiteralSyntax extends LocatedSyntax {
|
|
107
|
+
readonly flags: string;
|
|
108
|
+
readonly kind: "regexp-literal";
|
|
109
|
+
readonly pattern: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* One regular expression literal the frontend already compiled.
|
|
113
|
+
*
|
|
114
|
+
* The literal's pattern is parsed and lowered to an immutable matcher
|
|
115
|
+
* artifact during the build, so no owned pattern tree and no
|
|
116
|
+
* bootstrap-parser node survives here. `matcher` retains the written
|
|
117
|
+
* pattern and flag text, so `source`, `flags`, and `toString` never
|
|
118
|
+
* reconstruct them from the artifact's instructions.
|
|
119
|
+
*/
|
|
120
|
+
interface SyntaxRegExpLiteralExpression extends LocatedSyntax {
|
|
121
|
+
readonly kind: "regexp";
|
|
122
|
+
readonly matcher: RegExpMatcherProgram;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* One template object argument synthesized for a tagged template call.
|
|
126
|
+
* A missing cooked entry represents an invalid escape sequence, which
|
|
127
|
+
* tagged templates admit while retaining its raw source text. A frontend
|
|
128
|
+
* produces it only as the first argument of that call. Even when the
|
|
129
|
+
* tag is %eval%, this object is returned unchanged without source parsing.
|
|
130
|
+
*/
|
|
131
|
+
interface SyntaxTemplateObject extends LocatedSyntax {
|
|
132
|
+
readonly cooked: readonly (string | undefined)[];
|
|
133
|
+
readonly kind: "template-object";
|
|
134
|
+
readonly raw: readonly string[];
|
|
135
|
+
}
|
|
136
|
+
/** One spread entry retained inside an owned call argument list. */
|
|
137
|
+
interface SyntaxSpreadArgument extends LocatedSyntax {
|
|
138
|
+
readonly argument: SyntaxExpression;
|
|
139
|
+
readonly kind: "spread";
|
|
140
|
+
}
|
|
141
|
+
/** One ordinary or spread owned call argument. */
|
|
142
|
+
type SyntaxCallArgument = SyntaxExpression | SyntaxSpreadArgument;
|
|
143
|
+
/** One property or call step in an optional chain. */
|
|
144
|
+
type SyntaxOptionalChainLink = (LocatedSyntax & {
|
|
145
|
+
readonly key: SyntaxExpression;
|
|
146
|
+
readonly kind: "member";
|
|
147
|
+
/** Whether this step performs the chain's nullish guard. */
|
|
148
|
+
readonly optional: boolean;
|
|
149
|
+
}) | (LocatedSyntax & {
|
|
150
|
+
/**
|
|
151
|
+
* A private member step. Its name resolves in the declaring class
|
|
152
|
+
* rather than becoming a property key.
|
|
153
|
+
*/
|
|
154
|
+
readonly kind: "private-member";
|
|
155
|
+
readonly name: string;
|
|
156
|
+
/** Whether this step performs the chain's nullish guard. */
|
|
157
|
+
readonly optional: boolean;
|
|
158
|
+
}) | (LocatedSyntax & {
|
|
159
|
+
readonly arguments: readonly SyntaxCallArgument[];
|
|
160
|
+
/**
|
|
161
|
+
* True when parentheses ended the optional chain before this ordinary
|
|
162
|
+
* call. The call retains the member receiver, but a short-circuited
|
|
163
|
+
* chain calls `undefined` instead of skipping it.
|
|
164
|
+
*/
|
|
165
|
+
readonly chainBoundary?: true;
|
|
166
|
+
readonly kind: "call";
|
|
167
|
+
/** Whether this step performs the chain's nullish guard. */
|
|
168
|
+
readonly optional: boolean;
|
|
169
|
+
});
|
|
170
|
+
/** One data, shorthand, method, or accessor owned object literal entry. */
|
|
171
|
+
interface SyntaxObjectDefinition {
|
|
172
|
+
/** A get or set accessor; absent for a data, shorthand, or method
|
|
173
|
+
* property. */
|
|
174
|
+
readonly accessorKind?: "get" | "set";
|
|
175
|
+
readonly key: SyntaxExpression;
|
|
176
|
+
readonly kind: "definition";
|
|
177
|
+
/**
|
|
178
|
+
* Whether this colon-form definition sets [[Prototype]] instead of an
|
|
179
|
+
* own property. A frontend must report a syntax error if one object
|
|
180
|
+
* literal contains more than one such definition.
|
|
181
|
+
*/
|
|
182
|
+
readonly prototypeSetter?: true;
|
|
183
|
+
readonly value: SyntaxExpression;
|
|
184
|
+
}
|
|
185
|
+
/** One spread entry retained inside an owned object literal. */
|
|
186
|
+
interface SyntaxObjectSpreadProperty extends LocatedSyntax {
|
|
187
|
+
readonly argument: SyntaxExpression;
|
|
188
|
+
readonly kind: "spread";
|
|
189
|
+
}
|
|
190
|
+
/** One defined or spread owned object literal property. */
|
|
191
|
+
type SyntaxObjectProperty = SyntaxObjectDefinition | SyntaxObjectSpreadProperty;
|
|
192
|
+
/**
|
|
193
|
+
* One private element name in a class body, such as `#count`. A private
|
|
194
|
+
* name is not a property key: a fresh one exists per class evaluation,
|
|
195
|
+
* only the declaring class body reaches it, and it never becomes a
|
|
196
|
+
* string or symbol an own-property observation can report.
|
|
197
|
+
*/
|
|
198
|
+
interface SyntaxPrivateName extends LocatedSyntax {
|
|
199
|
+
readonly kind: "private-name";
|
|
200
|
+
/** The declared name, including its leading `#`. */
|
|
201
|
+
readonly name: string;
|
|
202
|
+
}
|
|
203
|
+
/** One method or accessor definition in an owned class body. */
|
|
204
|
+
interface SyntaxClassMethod extends LocatedSyntax {
|
|
205
|
+
/** A get or set accessor; absent for an ordinary method definition. */
|
|
206
|
+
readonly accessorKind?: "get" | "set";
|
|
207
|
+
readonly key: SyntaxExpression | SyntaxPrivateName;
|
|
208
|
+
readonly kind: "method";
|
|
209
|
+
/**
|
|
210
|
+
* True for a `static` element, which is defined on the constructor
|
|
211
|
+
* itself instead of on its prototype object.
|
|
212
|
+
*/
|
|
213
|
+
readonly staticPlacement?: true;
|
|
214
|
+
readonly value: SyntaxFunction;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* One field definition in an owned class body. The key is evaluated
|
|
218
|
+
* once, where the element appears, while the initializer runs once per
|
|
219
|
+
* instance, so the two live in different execution contexts.
|
|
220
|
+
*/
|
|
221
|
+
interface SyntaxClassField extends LocatedSyntax {
|
|
222
|
+
/**
|
|
223
|
+
* The initializer expression, absent for a field declared without one,
|
|
224
|
+
* whose value is `undefined`. It is a separate function body: it takes
|
|
225
|
+
* the instance under construction as its receiver and reaches the
|
|
226
|
+
* class scope rather than the constructor's parameters.
|
|
227
|
+
*/
|
|
228
|
+
readonly initializer?: SyntaxExpression;
|
|
229
|
+
readonly key: SyntaxExpression | SyntaxPrivateName;
|
|
230
|
+
readonly kind: "field";
|
|
231
|
+
/**
|
|
232
|
+
* True for a `static` field, which the class definition itself defines
|
|
233
|
+
* on the constructor once rather than on each instance. Its
|
|
234
|
+
* initializer takes the constructor as its receiver.
|
|
235
|
+
*/
|
|
236
|
+
readonly staticPlacement?: true;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* One `static { ... }` initialization block in an owned class body. A
|
|
240
|
+
* block declares no element and evaluates no key: it is a statement list
|
|
241
|
+
* the class definition runs once, in source order among the other static
|
|
242
|
+
* elements.
|
|
243
|
+
*/
|
|
244
|
+
interface SyntaxClassStaticBlock extends LocatedSyntax {
|
|
245
|
+
/**
|
|
246
|
+
* The block's statements as their own parameterless function body. It
|
|
247
|
+
* takes the constructor as its receiver and carries it as the home
|
|
248
|
+
* object, so `this` is the class and `super.x` starts at the parent
|
|
249
|
+
* constructor.
|
|
250
|
+
*/
|
|
251
|
+
readonly body: SyntaxFunction;
|
|
252
|
+
readonly kind: "static-block";
|
|
253
|
+
}
|
|
254
|
+
/** One element admitted by an owned class body. */
|
|
255
|
+
type SyntaxClassElement = SyntaxClassField | SyntaxClassMethod | SyntaxClassStaticBlock;
|
|
256
|
+
/** An expression in the parser-independent M1 syntax tree. */
|
|
257
|
+
type SyntaxExpression = (LocatedSyntax & {
|
|
258
|
+
readonly argument: SyntaxExpression;
|
|
259
|
+
readonly kind: "await";
|
|
260
|
+
}) | (LocatedSyntax & {
|
|
261
|
+
/** Absent for a bare `yield`, which sends `undefined` out. */
|
|
262
|
+
readonly argument?: SyntaxExpression;
|
|
263
|
+
/**
|
|
264
|
+
* True for `yield*`, which delegates every resumption to the
|
|
265
|
+
* operand's iterator. The grammar requires an operand, so a
|
|
266
|
+
* delegating expression always carries an `argument`.
|
|
267
|
+
*/
|
|
268
|
+
readonly delegate?: true;
|
|
269
|
+
readonly kind: "yield";
|
|
270
|
+
}) | (LocatedSyntax & {
|
|
271
|
+
/**
|
|
272
|
+
* A function call used as the target of `=`, a compound
|
|
273
|
+
* assignment, `++`, `--`, or a `for-in` or `for-of` head in
|
|
274
|
+
* non-strict code. Annex B replaces the early error with a
|
|
275
|
+
* ReferenceError that is thrown after the call returns and before
|
|
276
|
+
* the right operand or any conversion runs.
|
|
277
|
+
*/
|
|
278
|
+
readonly call: SyntaxExpression;
|
|
279
|
+
readonly kind: "invalid-assignment-target";
|
|
280
|
+
}) | (LocatedSyntax & {
|
|
281
|
+
readonly kind: "binding-set";
|
|
282
|
+
readonly name: string;
|
|
283
|
+
/**
|
|
284
|
+
* True when the source wrapped the target in parentheses, as in
|
|
285
|
+
* `(f) = function () {}`. IsIdentifierRef is false for a
|
|
286
|
+
* ParenthesizedExpression, so the assignment does not apply
|
|
287
|
+
* NamedEvaluation to an anonymous function or class value.
|
|
288
|
+
*/
|
|
289
|
+
readonly parenthesizedTarget?: true;
|
|
290
|
+
readonly value: SyntaxExpression;
|
|
291
|
+
}) | (LocatedSyntax & {
|
|
292
|
+
readonly kind: "binding-update";
|
|
293
|
+
readonly name: string;
|
|
294
|
+
readonly operator: AssignmentOperator;
|
|
295
|
+
/**
|
|
296
|
+
* True when the source wrapped the target in parentheses, as in
|
|
297
|
+
* `(f) = function () {}`. IsIdentifierRef is false for a
|
|
298
|
+
* ParenthesizedExpression, so the assignment does not apply
|
|
299
|
+
* NamedEvaluation to an anonymous function or class value.
|
|
300
|
+
*/
|
|
301
|
+
readonly parenthesizedTarget?: true;
|
|
302
|
+
readonly value: SyntaxExpression;
|
|
303
|
+
}) | (LocatedSyntax & {
|
|
304
|
+
readonly kind: "binding-step";
|
|
305
|
+
readonly name: string;
|
|
306
|
+
readonly operator: UpdateOperator;
|
|
307
|
+
readonly prefix: boolean;
|
|
308
|
+
}) | (LocatedSyntax & {
|
|
309
|
+
readonly kind: "destructuring-set";
|
|
310
|
+
readonly pattern: SyntaxAssignmentPattern;
|
|
311
|
+
readonly value: SyntaxExpression;
|
|
312
|
+
}) | (LocatedSyntax & {
|
|
313
|
+
readonly elements: readonly SyntaxArrayElement[];
|
|
314
|
+
readonly kind: "array";
|
|
315
|
+
}) | SyntaxTemplateObject | SyntaxImportCall | (LocatedSyntax & {
|
|
316
|
+
readonly kind: "binary";
|
|
317
|
+
readonly left: SyntaxExpression;
|
|
318
|
+
readonly operator: BinaryOperator;
|
|
319
|
+
readonly right: SyntaxExpression;
|
|
320
|
+
}) | (LocatedSyntax & {
|
|
321
|
+
readonly kind: "boolean";
|
|
322
|
+
readonly value: boolean;
|
|
323
|
+
}) | (LocatedSyntax & {
|
|
324
|
+
readonly arguments: readonly SyntaxCallArgument[];
|
|
325
|
+
readonly kind: "call";
|
|
326
|
+
readonly target: SyntaxCallTarget;
|
|
327
|
+
}) | (LocatedSyntax & {
|
|
328
|
+
readonly alternate: SyntaxExpression;
|
|
329
|
+
readonly consequent: SyntaxExpression;
|
|
330
|
+
readonly kind: "conditional";
|
|
331
|
+
readonly test: SyntaxExpression;
|
|
332
|
+
}) | (LocatedSyntax & {
|
|
333
|
+
readonly kind: "logical";
|
|
334
|
+
readonly left: SyntaxExpression;
|
|
335
|
+
readonly operator: LogicalOperator;
|
|
336
|
+
readonly right: SyntaxExpression;
|
|
337
|
+
}) | (LocatedSyntax & {
|
|
338
|
+
readonly expressions: readonly SyntaxExpression[];
|
|
339
|
+
readonly kind: "sequence";
|
|
340
|
+
}) | (LocatedSyntax & {
|
|
341
|
+
readonly functionValue: SyntaxFunction;
|
|
342
|
+
/** Function name inferred independently from a storage binding. */
|
|
343
|
+
readonly inferredName?: string;
|
|
344
|
+
readonly kind: "function";
|
|
345
|
+
}) | (LocatedSyntax & {
|
|
346
|
+
readonly kind: "identifier";
|
|
347
|
+
readonly name: string;
|
|
348
|
+
}) | (LocatedSyntax & {
|
|
349
|
+
readonly kind: "null";
|
|
350
|
+
}) | (LocatedSyntax & {
|
|
351
|
+
readonly arguments: readonly SyntaxCallArgument[];
|
|
352
|
+
readonly callee: SyntaxExpression;
|
|
353
|
+
readonly kind: "new";
|
|
354
|
+
}) | (LocatedSyntax & {
|
|
355
|
+
/**
|
|
356
|
+
* The class constructor, synthesized with an empty body when the
|
|
357
|
+
* class body omits one. Its function value carries the class name
|
|
358
|
+
* and becomes the class itself.
|
|
359
|
+
*/
|
|
360
|
+
readonly constructorFunction: SyntaxFunction;
|
|
361
|
+
readonly elements: readonly SyntaxClassElement[];
|
|
362
|
+
/**
|
|
363
|
+
* The `extends` operand. Its presence makes the class derived, so
|
|
364
|
+
* the constructor must reach `this` through `super()`, even when
|
|
365
|
+
* the operand evaluates to `null`.
|
|
366
|
+
*/
|
|
367
|
+
readonly heritage?: SyntaxExpression;
|
|
368
|
+
/**
|
|
369
|
+
* NamedEvaluation name supplied by an enclosing default export.
|
|
370
|
+
* It names the constructor without creating a class-scope binding.
|
|
371
|
+
*/
|
|
372
|
+
readonly inferredName?: string;
|
|
373
|
+
readonly kind: "class";
|
|
374
|
+
/**
|
|
375
|
+
* The ClassName bound in the class's own lexical environment. Only
|
|
376
|
+
* the class body reaches it, and it stays immutable there even when
|
|
377
|
+
* an outer declaration binding of the same name is assignable.
|
|
378
|
+
*/
|
|
379
|
+
readonly nameBinding?: string;
|
|
380
|
+
}) | (LocatedSyntax & {
|
|
381
|
+
readonly kind: "object";
|
|
382
|
+
readonly properties: readonly SyntaxObjectProperty[];
|
|
383
|
+
}) | (LocatedSyntax & {
|
|
384
|
+
/**
|
|
385
|
+
* The base and left-to-right property or call steps of one optional
|
|
386
|
+
* chain. Keeping the chain intact lets one guarded step skip every
|
|
387
|
+
* following unguarded step without evaluating the base twice.
|
|
388
|
+
*/
|
|
389
|
+
readonly base: SyntaxExpression;
|
|
390
|
+
readonly kind: "optional-chain";
|
|
391
|
+
readonly links: readonly SyntaxOptionalChainLink[];
|
|
392
|
+
}) | (LocatedSyntax & {
|
|
393
|
+
/**
|
|
394
|
+
* An operand whose reference category must survive name resolution.
|
|
395
|
+
* Property references keep their existing dedicated representation.
|
|
396
|
+
*/
|
|
397
|
+
readonly argument: SyntaxExpression;
|
|
398
|
+
readonly kind: "delete";
|
|
399
|
+
}) | (LocatedSyntax & {
|
|
400
|
+
readonly key: SyntaxExpression;
|
|
401
|
+
readonly kind: "property-delete";
|
|
402
|
+
readonly object: SyntaxExpression;
|
|
403
|
+
}) | (LocatedSyntax & {
|
|
404
|
+
readonly key: SyntaxExpression;
|
|
405
|
+
readonly kind: "property-get";
|
|
406
|
+
readonly object: SyntaxExpression;
|
|
407
|
+
}) | (LocatedSyntax & {
|
|
408
|
+
readonly key: SyntaxExpression;
|
|
409
|
+
readonly kind: "property-set";
|
|
410
|
+
readonly object: SyntaxExpression;
|
|
411
|
+
readonly value: SyntaxExpression;
|
|
412
|
+
}) | (LocatedSyntax & {
|
|
413
|
+
readonly key: SyntaxExpression;
|
|
414
|
+
readonly kind: "property-update";
|
|
415
|
+
readonly object: SyntaxExpression;
|
|
416
|
+
readonly operator: AssignmentOperator;
|
|
417
|
+
readonly value: SyntaxExpression;
|
|
418
|
+
}) | (LocatedSyntax & {
|
|
419
|
+
readonly key: SyntaxExpression;
|
|
420
|
+
readonly kind: "property-step";
|
|
421
|
+
readonly object: SyntaxExpression;
|
|
422
|
+
readonly operator: UpdateOperator;
|
|
423
|
+
readonly prefix: boolean;
|
|
424
|
+
}) | (LocatedSyntax & {
|
|
425
|
+
/**
|
|
426
|
+
* A private member reference, `object.#x`. The name resolves in
|
|
427
|
+
* the class body that declares it rather than against the object,
|
|
428
|
+
* so it carries the declared name instead of a key expression,
|
|
429
|
+
* and the selected object is checked for the element at run time.
|
|
430
|
+
*/
|
|
431
|
+
readonly kind: "private-get";
|
|
432
|
+
readonly name: string;
|
|
433
|
+
readonly object: SyntaxExpression;
|
|
434
|
+
}) | (LocatedSyntax & {
|
|
435
|
+
/**
|
|
436
|
+
* A private brand check, `#x in object`. The name resolves in the
|
|
437
|
+
* class body that declares it, while the object is evaluated once
|
|
438
|
+
* and checked for the corresponding private element at run time.
|
|
439
|
+
*/
|
|
440
|
+
readonly kind: "private-in";
|
|
441
|
+
readonly name: string;
|
|
442
|
+
readonly object: SyntaxExpression;
|
|
443
|
+
}) | (LocatedSyntax & {
|
|
444
|
+
readonly kind: "private-set";
|
|
445
|
+
readonly name: string;
|
|
446
|
+
readonly object: SyntaxExpression;
|
|
447
|
+
readonly value: SyntaxExpression;
|
|
448
|
+
}) | (LocatedSyntax & {
|
|
449
|
+
readonly kind: "private-update";
|
|
450
|
+
readonly name: string;
|
|
451
|
+
readonly object: SyntaxExpression;
|
|
452
|
+
readonly operator: AssignmentOperator;
|
|
453
|
+
readonly value: SyntaxExpression;
|
|
454
|
+
}) | (LocatedSyntax & {
|
|
455
|
+
readonly kind: "private-step";
|
|
456
|
+
readonly name: string;
|
|
457
|
+
readonly object: SyntaxExpression;
|
|
458
|
+
readonly operator: UpdateOperator;
|
|
459
|
+
readonly prefix: boolean;
|
|
460
|
+
}) | (LocatedSyntax & {
|
|
461
|
+
/** Separator-free source digits, without the radix prefix or `n`. */
|
|
462
|
+
readonly digits: string;
|
|
463
|
+
readonly kind: "bigint";
|
|
464
|
+
readonly radix: 2 | 8 | 10 | 16;
|
|
465
|
+
}) | SyntaxRegExpLiteralExpression | (LocatedSyntax & {
|
|
466
|
+
readonly kind: "number";
|
|
467
|
+
readonly value: number;
|
|
468
|
+
}) | (LocatedSyntax & {
|
|
469
|
+
readonly kind: "string";
|
|
470
|
+
readonly value: string;
|
|
471
|
+
}) | (LocatedSyntax & {
|
|
472
|
+
readonly kind: "this";
|
|
473
|
+
readonly thisMode: SyntaxThisMode;
|
|
474
|
+
}) | (LocatedSyntax & {
|
|
475
|
+
/**
|
|
476
|
+
* The `super` operand of a property reference. It stands only as
|
|
477
|
+
* the `object` of a property get, delete, set, update, or step
|
|
478
|
+
* expression, of a `property` call target, of an
|
|
479
|
+
* `assignment-member` destructuring leaf, or of a `property`
|
|
480
|
+
* for-of or for-in head target: the reference reads or writes
|
|
481
|
+
* through the running function's home object while keeping `this`
|
|
482
|
+
* as its receiver, so an operand that escaped those positions
|
|
483
|
+
* would have no receiver to carry. The two target positions hold
|
|
484
|
+
* the evaluated reference until PutValue stores through it, which
|
|
485
|
+
* is why they carry the operand rather than an already-read
|
|
486
|
+
* object; the for-in head reuses the same target shape. The delete
|
|
487
|
+
* position carries no
|
|
488
|
+
* receiver anywhere, because ECMA-262 rejects a `super` reference
|
|
489
|
+
* after evaluating it; the operand is still admitted so that
|
|
490
|
+
* receiver read and key evaluation happen.
|
|
491
|
+
*/
|
|
492
|
+
readonly kind: "super-base";
|
|
493
|
+
/** The lexical receiver mode, including sloppy object methods. */
|
|
494
|
+
readonly thisMode: SyntaxThisMode;
|
|
495
|
+
}) | (LocatedSyntax & {
|
|
496
|
+
readonly kind: "new-target";
|
|
497
|
+
}) | (LocatedSyntax & {
|
|
498
|
+
/**
|
|
499
|
+
* The `import.meta` meta property. A frontend produces it only in
|
|
500
|
+
* Module code, where the module compiler gives each module one
|
|
501
|
+
* object that every evaluation in that module observes.
|
|
502
|
+
*/
|
|
503
|
+
readonly kind: "import-meta";
|
|
504
|
+
}) | (LocatedSyntax & {
|
|
505
|
+
readonly argument: SyntaxExpression;
|
|
506
|
+
readonly kind: "unary";
|
|
507
|
+
readonly operator: UnaryOperator;
|
|
508
|
+
}) | (LocatedSyntax & {
|
|
509
|
+
readonly kind: "undefined";
|
|
510
|
+
});
|
|
511
|
+
/** One plain function parameter and its retained hints. */
|
|
512
|
+
interface SyntaxParameter extends LocatedSyntax {
|
|
513
|
+
readonly hints: readonly Hint[];
|
|
514
|
+
readonly name: string;
|
|
515
|
+
/** Collect every remaining call argument into a fresh array. */
|
|
516
|
+
readonly rest?: true;
|
|
517
|
+
}
|
|
518
|
+
/** One identifier leaf in an owned binding pattern. */
|
|
519
|
+
interface SyntaxBindingIdentifier extends LocatedSyntax {
|
|
520
|
+
readonly hints: readonly Hint[];
|
|
521
|
+
readonly kind: "binding-identifier";
|
|
522
|
+
readonly name: string;
|
|
523
|
+
}
|
|
524
|
+
/** One member reference used as a destructuring assignment target. */
|
|
525
|
+
interface SyntaxAssignmentMemberTarget extends LocatedSyntax {
|
|
526
|
+
readonly key: SyntaxExpression;
|
|
527
|
+
readonly kind: "assignment-member";
|
|
528
|
+
readonly object: SyntaxExpression;
|
|
529
|
+
}
|
|
530
|
+
/** One private reference used as a destructuring assignment target. */
|
|
531
|
+
interface SyntaxAssignmentPrivateTarget extends LocatedSyntax {
|
|
532
|
+
readonly kind: "assignment-private";
|
|
533
|
+
readonly name: string;
|
|
534
|
+
readonly object: SyntaxExpression;
|
|
535
|
+
}
|
|
536
|
+
/** One initialized element in an owned recursive pattern. */
|
|
537
|
+
interface SyntaxBindingElement<Pattern = SyntaxBindingPattern> extends LocatedSyntax {
|
|
538
|
+
readonly initializer?: SyntaxExpression;
|
|
539
|
+
/**
|
|
540
|
+
* True when a destructuring assignment target is parenthesized, as in
|
|
541
|
+
* `[(f) = function () {}] = []`. IsIdentifierRef is false for a
|
|
542
|
+
* ParenthesizedExpression, so the initializer is not named after it.
|
|
543
|
+
*/
|
|
544
|
+
readonly parenthesizedTarget?: true;
|
|
545
|
+
readonly pattern: Pattern;
|
|
546
|
+
}
|
|
547
|
+
/** One parser-independent array binding pattern. */
|
|
548
|
+
interface SyntaxArrayBindingPattern<Pattern = SyntaxBindingPattern> extends LocatedSyntax {
|
|
549
|
+
readonly elements: readonly (SyntaxBindingElement<Pattern> | undefined)[];
|
|
550
|
+
readonly kind: "array-binding-pattern";
|
|
551
|
+
readonly rest?: Pattern;
|
|
552
|
+
}
|
|
553
|
+
/** One named or computed property in an owned recursive pattern. */
|
|
554
|
+
interface SyntaxObjectBindingProperty<Pattern = SyntaxBindingPattern> extends LocatedSyntax {
|
|
555
|
+
/** Preserve whether the source property name used computed syntax. */
|
|
556
|
+
readonly computed?: true;
|
|
557
|
+
readonly initializer?: SyntaxExpression;
|
|
558
|
+
readonly key: SyntaxExpression;
|
|
559
|
+
/**
|
|
560
|
+
* True when a destructuring assignment target is parenthesized, as in
|
|
561
|
+
* `[(f) = function () {}] = []`. IsIdentifierRef is false for a
|
|
562
|
+
* ParenthesizedExpression, so the initializer is not named after it.
|
|
563
|
+
*/
|
|
564
|
+
readonly parenthesizedTarget?: true;
|
|
565
|
+
readonly pattern: Pattern;
|
|
566
|
+
}
|
|
567
|
+
/** One parser-independent object binding pattern. */
|
|
568
|
+
interface SyntaxObjectBindingPattern<Pattern = SyntaxBindingPattern, Rest = SyntaxBindingIdentifier> extends LocatedSyntax {
|
|
569
|
+
readonly kind: "object-binding-pattern";
|
|
570
|
+
readonly properties: readonly SyntaxObjectBindingProperty<Pattern>[];
|
|
571
|
+
readonly rest?: Rest;
|
|
572
|
+
}
|
|
573
|
+
/** One identifier leaf admitted by a declaration binding pattern. */
|
|
574
|
+
type SyntaxBindingTarget = SyntaxBindingIdentifier;
|
|
575
|
+
/** One leaf admitted by a destructuring assignment pattern. */
|
|
576
|
+
type SyntaxAssignmentTarget = SyntaxAssignmentMemberTarget | SyntaxAssignmentPrivateTarget | SyntaxBindingIdentifier;
|
|
577
|
+
/** One recursively owned declaration binding pattern. */
|
|
578
|
+
type SyntaxBindingPattern = SyntaxArrayBindingPattern<SyntaxBindingPattern> | SyntaxBindingTarget | SyntaxObjectBindingPattern<SyntaxBindingPattern, SyntaxBindingTarget>;
|
|
579
|
+
/** One recursively owned destructuring assignment pattern. */
|
|
580
|
+
type SyntaxAssignmentPattern = SyntaxArrayBindingPattern<SyntaxAssignmentPattern> | SyntaxAssignmentTarget | SyntaxObjectBindingPattern<SyntaxAssignmentPattern, SyntaxAssignmentTarget>;
|
|
581
|
+
/** How a resolved binding pattern stores each identifier leaf. */
|
|
582
|
+
type BindingPatternMode = "declare" | "initialize" | "write";
|
|
583
|
+
/**
|
|
584
|
+
* One switch clause; a missing test marks the default clause.
|
|
585
|
+
*
|
|
586
|
+
* A function declaration is admitted in `body` alongside ordinary
|
|
587
|
+
* statements, matching a block's own body shape. HIR construction hoists
|
|
588
|
+
* every clause's function declarations into one CaseBlock-wide
|
|
589
|
+
* instantiation shared by the whole switch, the same way it already
|
|
590
|
+
* shares one lexical scope for `let`, `const`, and class declarations
|
|
591
|
+
* across clauses.
|
|
592
|
+
*/
|
|
593
|
+
interface SyntaxSwitchCase {
|
|
594
|
+
readonly body: readonly (SyntaxFunction | SyntaxStatement)[];
|
|
595
|
+
readonly range: SourceRange;
|
|
596
|
+
readonly test?: SyntaxExpression;
|
|
597
|
+
}
|
|
598
|
+
/** One identifier binding declared by a classic for statement head. */
|
|
599
|
+
interface SyntaxForBindingDeclaration {
|
|
600
|
+
readonly declarationKind: "const" | "let" | "var";
|
|
601
|
+
/** Present on a `using` or `await using` head; see the const statement. */
|
|
602
|
+
readonly disposal?: "async" | "sync";
|
|
603
|
+
readonly hint: Hint | undefined;
|
|
604
|
+
readonly initializer: SyntaxExpression;
|
|
605
|
+
readonly kind: "binding";
|
|
606
|
+
readonly name: string;
|
|
607
|
+
readonly range: SourceRange;
|
|
608
|
+
}
|
|
609
|
+
/** One recursive binding pattern declared by a classic for statement head. */
|
|
610
|
+
interface SyntaxForPatternDeclaration {
|
|
611
|
+
readonly declarationKind: "const" | "let" | "var";
|
|
612
|
+
readonly initializer: SyntaxExpression;
|
|
613
|
+
readonly kind: "pattern";
|
|
614
|
+
readonly pattern: SyntaxBindingPattern;
|
|
615
|
+
readonly range: SourceRange;
|
|
616
|
+
}
|
|
617
|
+
/** One binding declaration in a classic for statement head. */
|
|
618
|
+
type SyntaxForDeclaration = SyntaxForBindingDeclaration | SyntaxForPatternDeclaration;
|
|
619
|
+
/** One source-level assignment or declaration target in a for-of head. */
|
|
620
|
+
type SyntaxForOfTarget = {
|
|
621
|
+
readonly declarationKind: "const" | "let" | "var";
|
|
622
|
+
/** Present on a `using` or `await using` head. */
|
|
623
|
+
readonly disposal?: "async" | "sync";
|
|
624
|
+
readonly hint: Hint | undefined;
|
|
625
|
+
readonly kind: "declaration";
|
|
626
|
+
readonly name: string;
|
|
627
|
+
readonly range: SourceRange;
|
|
628
|
+
} | {
|
|
629
|
+
readonly declarationKind: "const" | "let" | "var";
|
|
630
|
+
readonly kind: "pattern-declaration";
|
|
631
|
+
readonly pattern: SyntaxBindingPattern;
|
|
632
|
+
readonly range: SourceRange;
|
|
633
|
+
} | {
|
|
634
|
+
readonly kind: "assignment-pattern";
|
|
635
|
+
readonly pattern: SyntaxAssignmentPattern;
|
|
636
|
+
readonly range: SourceRange;
|
|
637
|
+
} | {
|
|
638
|
+
readonly kind: "binding";
|
|
639
|
+
readonly name: string;
|
|
640
|
+
readonly range: SourceRange;
|
|
641
|
+
} | {
|
|
642
|
+
readonly key: SyntaxExpression;
|
|
643
|
+
readonly kind: "property";
|
|
644
|
+
readonly object: SyntaxExpression;
|
|
645
|
+
readonly range: SourceRange;
|
|
646
|
+
} | {
|
|
647
|
+
readonly kind: "private";
|
|
648
|
+
readonly name: string;
|
|
649
|
+
readonly object: SyntaxExpression;
|
|
650
|
+
readonly range: SourceRange;
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* One source-level assignment or declaration target in a for-in head.
|
|
654
|
+
*
|
|
655
|
+
* ForIn/OfBodyEvaluation gives an enumerate head the same target shapes
|
|
656
|
+
* an iterate head has, so the two heads share one representation rather
|
|
657
|
+
* than describing the store twice. The enumerated key is always a String,
|
|
658
|
+
* and the realm's String iterator lets an array pattern consume its code
|
|
659
|
+
* points through the same recursive binding machinery a for-of head uses.
|
|
660
|
+
*/
|
|
661
|
+
type SyntaxForInTarget = SyntaxForOfTarget;
|
|
662
|
+
/** Runtime call and construction identity retained for every function. */
|
|
663
|
+
type FunctionKind = "arrow" | "async" | "async-arrow" | "async-generator" | "class" | "generator" | "method" | "ordinary";
|
|
664
|
+
/** One non-strict `with` statement in the owned syntax tree. */
|
|
665
|
+
interface SyntaxWithStatement extends LocatedSyntax {
|
|
666
|
+
readonly body: SyntaxStatement;
|
|
667
|
+
readonly kind: "with";
|
|
668
|
+
readonly object: SyntaxExpression;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* One declarator of a `const` or `let` declaration, either a single
|
|
672
|
+
* identifier binding or a recursive binding pattern.
|
|
673
|
+
*
|
|
674
|
+
* The shapes repeat the corresponding `SyntaxStatement` members rather
|
|
675
|
+
* than being extracted from them, because a declarator is also a
|
|
676
|
+
* statement in its own right when a declaration list holds exactly one.
|
|
677
|
+
* A statement-list consumer may therefore lower a declarator with the
|
|
678
|
+
* same code path either way.
|
|
679
|
+
*/
|
|
680
|
+
type SyntaxLexicalDeclarator = (LocatedSyntax & {
|
|
681
|
+
readonly declarationKind: "const" | "let";
|
|
682
|
+
readonly initializer: SyntaxExpression;
|
|
683
|
+
readonly kind: "binding-pattern";
|
|
684
|
+
readonly mode: "declare";
|
|
685
|
+
readonly pattern: SyntaxBindingPattern;
|
|
686
|
+
}) | (LocatedSyntax & {
|
|
687
|
+
readonly hint: Hint | undefined;
|
|
688
|
+
readonly initializer: SyntaxExpression;
|
|
689
|
+
/**
|
|
690
|
+
* Present on a `using` (`"sync"`) or `await using` (`"async"`)
|
|
691
|
+
* declaration, which binds like `const` and also adds its value to
|
|
692
|
+
* the enclosing scope's DisposeCapability.
|
|
693
|
+
*/
|
|
694
|
+
readonly disposal?: "async" | "sync";
|
|
695
|
+
readonly kind: "const";
|
|
696
|
+
readonly name: string;
|
|
697
|
+
}) | (LocatedSyntax & {
|
|
698
|
+
readonly hint: Hint | undefined;
|
|
699
|
+
readonly initializer: SyntaxExpression;
|
|
700
|
+
readonly kind: "let";
|
|
701
|
+
readonly name: string;
|
|
702
|
+
});
|
|
703
|
+
/** A statement in the parser-independent M1 syntax tree. */
|
|
704
|
+
type SyntaxStatement = (LocatedSyntax & {
|
|
705
|
+
readonly body: readonly (SyntaxFunction | SyntaxStatement)[];
|
|
706
|
+
readonly kind: "block";
|
|
707
|
+
/**
|
|
708
|
+
* True only for the synthetic block a parameter-environment
|
|
709
|
+
* function's own FunctionBody is wrapped in to give it a scope
|
|
710
|
+
* distinct from its separate parameter scope. It carries no source
|
|
711
|
+
* block of its own, so its FunctionDeclarations stay the
|
|
712
|
+
* FunctionBody's own var-like top-level declarations rather than
|
|
713
|
+
* becoming a genuine nested Block's LexicallyDeclaredNames.
|
|
714
|
+
*/
|
|
715
|
+
readonly parameterEnvironmentBody?: true;
|
|
716
|
+
}) | (LocatedSyntax & {
|
|
717
|
+
/**
|
|
718
|
+
* One `const` or `let` declaration that binds more than one
|
|
719
|
+
* declarator, kept as one declaration rather than as separate
|
|
720
|
+
* statements so that its source shape survives into owned syntax.
|
|
721
|
+
*
|
|
722
|
+
* ECMAScript admits a lexical declaration only where a
|
|
723
|
+
* StatementList is admitted, so a consumer expands the declarators
|
|
724
|
+
* into the enclosing list. Wrapping them in a block instead would
|
|
725
|
+
* create a lexical scope the source does not have and would reset
|
|
726
|
+
* the declared cells a second time.
|
|
727
|
+
*
|
|
728
|
+
* The tuple shape keeps a list of fewer than two declarators
|
|
729
|
+
* unrepresentable, because a one-declarator declaration stays the
|
|
730
|
+
* declarator statement it has always been. One LetOrConst covers
|
|
731
|
+
* the whole BindingList, so every declarator declares the same
|
|
732
|
+
* kind; HIR construction rejects a mixed list rather than choosing
|
|
733
|
+
* a mutability for it.
|
|
734
|
+
*/
|
|
735
|
+
readonly declarations: readonly [SyntaxLexicalDeclarator, SyntaxLexicalDeclarator, ...SyntaxLexicalDeclarator[]];
|
|
736
|
+
readonly kind: "declaration-list";
|
|
737
|
+
}) | (LocatedSyntax & {
|
|
738
|
+
/**
|
|
739
|
+
* The Annex B.3.2 evaluation of a block-level function declaration
|
|
740
|
+
* that qualifies for web legacy semantics: the value of the
|
|
741
|
+
* enclosing Block's binding of `name` is written to the var-scoped
|
|
742
|
+
* binding of the same name, bypassing every scope in between. It
|
|
743
|
+
* follows the declaration in its statement list and has an empty
|
|
744
|
+
* completion.
|
|
745
|
+
*/
|
|
746
|
+
readonly kind: "annexb-function-copy";
|
|
747
|
+
readonly name: string;
|
|
748
|
+
}) | (LocatedSyntax & {
|
|
749
|
+
readonly kind: "break";
|
|
750
|
+
readonly label?: string;
|
|
751
|
+
}) | (LocatedSyntax & {
|
|
752
|
+
readonly kind: "continue";
|
|
753
|
+
readonly label?: string;
|
|
754
|
+
}) | (LocatedSyntax & {
|
|
755
|
+
readonly body: SyntaxStatement;
|
|
756
|
+
readonly kind: "do-while";
|
|
757
|
+
readonly test: SyntaxExpression;
|
|
758
|
+
}) | (LocatedSyntax & {
|
|
759
|
+
readonly body: SyntaxStatement;
|
|
760
|
+
readonly kind: "labeled";
|
|
761
|
+
readonly label: string;
|
|
762
|
+
}) | (LocatedSyntax & {
|
|
763
|
+
readonly body: SyntaxStatement;
|
|
764
|
+
readonly declarations?: readonly SyntaxForDeclaration[];
|
|
765
|
+
readonly init?: SyntaxExpression;
|
|
766
|
+
readonly kind: "for";
|
|
767
|
+
readonly test?: SyntaxExpression;
|
|
768
|
+
readonly update?: SyntaxExpression;
|
|
769
|
+
}) | (LocatedSyntax & {
|
|
770
|
+
/**
|
|
771
|
+
* `for (... in ...)`, whose head enumerates the subject's own and
|
|
772
|
+
* inherited enumerable string keys. It is a separate statement
|
|
773
|
+
* from the iterate head because ForIn/OfHeadEvaluation skips the
|
|
774
|
+
* whole loop for a nullish subject and ForIn/OfBodyEvaluation
|
|
775
|
+
* never closes an enumerate iterator.
|
|
776
|
+
*/
|
|
777
|
+
readonly body: SyntaxStatement;
|
|
778
|
+
readonly kind: "for-in";
|
|
779
|
+
readonly subject: SyntaxExpression;
|
|
780
|
+
readonly target: SyntaxForInTarget;
|
|
781
|
+
}) | (LocatedSyntax & {
|
|
782
|
+
/**
|
|
783
|
+
* `for await (... of ...)`, which acquires the iterator through
|
|
784
|
+
* `Symbol.asyncIterator` and awaits every step. The flag is absent
|
|
785
|
+
* on a synchronous head rather than `false`, so the two heads stay
|
|
786
|
+
* distinguishable by presence in printed and structural evidence.
|
|
787
|
+
*/
|
|
788
|
+
readonly awaited?: true;
|
|
789
|
+
readonly body: SyntaxStatement;
|
|
790
|
+
readonly iterable: SyntaxExpression;
|
|
791
|
+
readonly kind: "for-of";
|
|
792
|
+
readonly target: SyntaxForOfTarget;
|
|
793
|
+
}) | (LocatedSyntax & {
|
|
794
|
+
readonly cases: readonly SyntaxSwitchCase[];
|
|
795
|
+
readonly discriminant: SyntaxExpression;
|
|
796
|
+
readonly kind: "switch";
|
|
797
|
+
}) | (LocatedSyntax & {
|
|
798
|
+
readonly declarationKind: "const" | "let" | "var";
|
|
799
|
+
readonly initializer: SyntaxExpression;
|
|
800
|
+
readonly kind: "binding-pattern";
|
|
801
|
+
readonly mode: BindingPatternMode;
|
|
802
|
+
readonly pattern: SyntaxBindingPattern;
|
|
803
|
+
}) | (LocatedSyntax & {
|
|
804
|
+
readonly hint: Hint | undefined;
|
|
805
|
+
readonly initializer: SyntaxExpression;
|
|
806
|
+
readonly kind: "binding-init";
|
|
807
|
+
readonly name: string;
|
|
808
|
+
}) | (LocatedSyntax & {
|
|
809
|
+
readonly hint: Hint | undefined;
|
|
810
|
+
readonly initializer: SyntaxExpression;
|
|
811
|
+
/**
|
|
812
|
+
* Present on a `using` (`"sync"`) or `await using` (`"async"`)
|
|
813
|
+
* declaration, which binds like `const` and also adds its value to
|
|
814
|
+
* the enclosing scope's DisposeCapability.
|
|
815
|
+
*/
|
|
816
|
+
readonly disposal?: "async" | "sync";
|
|
817
|
+
readonly kind: "const";
|
|
818
|
+
readonly name: string;
|
|
819
|
+
}) | (LocatedSyntax & {
|
|
820
|
+
readonly hint: Hint | undefined;
|
|
821
|
+
readonly initializer: SyntaxExpression;
|
|
822
|
+
readonly kind: "let";
|
|
823
|
+
readonly name: string;
|
|
824
|
+
}) | (LocatedSyntax & {
|
|
825
|
+
readonly expression: SyntaxExpression;
|
|
826
|
+
/** A lowered var initializer has an empty Statement completion. */
|
|
827
|
+
readonly emptyCompletion?: true;
|
|
828
|
+
readonly kind: "expression";
|
|
829
|
+
}) | (LocatedSyntax & {
|
|
830
|
+
readonly alternate: SyntaxStatement | undefined;
|
|
831
|
+
readonly consequent: SyntaxStatement;
|
|
832
|
+
readonly kind: "if";
|
|
833
|
+
readonly test: SyntaxExpression;
|
|
834
|
+
}) | (LocatedSyntax & {
|
|
835
|
+
readonly expression: SyntaxExpression | undefined;
|
|
836
|
+
readonly kind: "return";
|
|
837
|
+
}) | (LocatedSyntax & {
|
|
838
|
+
readonly expression: SyntaxExpression;
|
|
839
|
+
readonly kind: "throw";
|
|
840
|
+
}) | (LocatedSyntax & {
|
|
841
|
+
readonly block: SyntaxStatement;
|
|
842
|
+
readonly handler: {
|
|
843
|
+
readonly body: SyntaxStatement;
|
|
844
|
+
/**
|
|
845
|
+
* The CatchParameter binding, or explicitly `undefined` for
|
|
846
|
+
* the optional catch binding form `catch Block`, which
|
|
847
|
+
* discards the thrown value and creates no catch-parameter
|
|
848
|
+
* environment. When the pattern is absent, `range` covers
|
|
849
|
+
* the catch clause instead of a parameter.
|
|
850
|
+
*/
|
|
851
|
+
readonly pattern: SyntaxBindingPattern | undefined;
|
|
852
|
+
readonly range: SourceRange;
|
|
853
|
+
} | undefined;
|
|
854
|
+
readonly finalizer: SyntaxStatement | undefined;
|
|
855
|
+
readonly kind: "try";
|
|
856
|
+
}) | (LocatedSyntax & {
|
|
857
|
+
readonly body: SyntaxStatement;
|
|
858
|
+
readonly kind: "while";
|
|
859
|
+
readonly test: SyntaxExpression;
|
|
860
|
+
}) | SyntaxWithStatement;
|
|
861
|
+
/** A top-level function declaration in owned syntax. */
|
|
862
|
+
interface SyntaxFunction extends LocatedSyntax {
|
|
863
|
+
/**
|
|
864
|
+
* True when BoundNames of the formal parameters contains `arguments`,
|
|
865
|
+
* which is what FunctionDeclarationInstantiation tests before creating
|
|
866
|
+
* the implicit object. It is recorded here rather than recovered from
|
|
867
|
+
* `parameters`, because a defaulted or destructured formal is lowered
|
|
868
|
+
* to a synthetic parameter name and its own binding is created by a
|
|
869
|
+
* parameter initializer instead.
|
|
870
|
+
*/
|
|
871
|
+
readonly argumentsFormal?: true;
|
|
872
|
+
/** Internal declaration binding when it differs from the function name. */
|
|
873
|
+
readonly bindingName?: string;
|
|
874
|
+
readonly body: readonly (SyntaxFunction | SyntaxStatement)[];
|
|
875
|
+
/**
|
|
876
|
+
* Number of leading body statements that initialize a generator's
|
|
877
|
+
* non-simple parameters at call time, before its body is suspended.
|
|
878
|
+
*/
|
|
879
|
+
readonly generatorCallStatementCount?: number;
|
|
880
|
+
/** JavaScript `length`, which can differ from the ABI parameter count. */
|
|
881
|
+
readonly functionLength?: number;
|
|
882
|
+
readonly functionKind?: FunctionKind;
|
|
883
|
+
/**
|
|
884
|
+
* True on a class constructor whose class body declares at least one
|
|
885
|
+
* instance field. Such a constructor runs the field initializers its
|
|
886
|
+
* class recorded: a base constructor before its body, and a derived
|
|
887
|
+
* one where `super()` returns.
|
|
888
|
+
*/
|
|
889
|
+
readonly initializesInstanceElements?: true;
|
|
890
|
+
readonly kind: "function";
|
|
891
|
+
readonly name: string | undefined;
|
|
892
|
+
readonly parameters: readonly SyntaxParameter[];
|
|
893
|
+
readonly returnHints: readonly Hint[];
|
|
894
|
+
/**
|
|
895
|
+
* Original source text returned by `Function.prototype.toString`.
|
|
896
|
+
*/
|
|
897
|
+
readonly sourceText?: string;
|
|
898
|
+
/**
|
|
899
|
+
* ECMA-262's IsSimpleParameterList: every parameter is a single
|
|
900
|
+
* `BindingIdentifier` with no initializer, and no parameter is a rest
|
|
901
|
+
* parameter. A mapped arguments object is admitted only when this is
|
|
902
|
+
* true and the function is non-strict, so it is computed once at the
|
|
903
|
+
* frontend boundary rather than reconstructed later from the parameter
|
|
904
|
+
* list's shape.
|
|
905
|
+
*/
|
|
906
|
+
readonly simpleParameterList?: true;
|
|
907
|
+
readonly strict?: boolean;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* One var-scoped top-level name a Script's global object binds as a
|
|
911
|
+
* property. The declaration kind decides what happens when the global
|
|
912
|
+
* object already has a property of that name: ECMA-262's
|
|
913
|
+
* CreateGlobalVarBinding keeps the existing property untouched, while
|
|
914
|
+
* CreateGlobalFunctionBinding redefines a configurable one.
|
|
915
|
+
*
|
|
916
|
+
* An `annexb` entry is a block-level function name that Annex B.3.2.2
|
|
917
|
+
* binds as a var: CreateGlobalVarBinding applies only when no lexical
|
|
918
|
+
* declaration holds the name and CanDeclareGlobalVar allows it, and
|
|
919
|
+
* otherwise the name is skipped without an error.
|
|
920
|
+
*
|
|
921
|
+
* The range locates the declaration that creates the property, so a
|
|
922
|
+
* later stage can name it in a diagnostic without searching the body
|
|
923
|
+
* for a statement that happens to share the name.
|
|
924
|
+
*/
|
|
925
|
+
interface SyntaxGlobalObjectName extends LocatedSyntax {
|
|
926
|
+
readonly declaration: "annexb" | "function" | "var";
|
|
927
|
+
readonly name: string;
|
|
928
|
+
}
|
|
929
|
+
/** One Script top-level lexical name checked against the global object. */
|
|
930
|
+
interface SyntaxGlobalLexicalName extends LocatedSyntax {
|
|
931
|
+
readonly name: string;
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* One `import()` call in the static-specifier subset of the ADR 0016
|
|
935
|
+
* amendment: its only argument is one string literal, with no options
|
|
936
|
+
* argument and no phase. The range locates the whole call; `specifier`
|
|
937
|
+
* keeps the decoded literal with its own location, as a static import's
|
|
938
|
+
* specifier does.
|
|
939
|
+
*
|
|
940
|
+
* A frontend produces this node only when the caller enables
|
|
941
|
+
* static-specifier imports. Every other ImportCall form stays a profile
|
|
942
|
+
* diagnostic in the frontend.
|
|
943
|
+
*/
|
|
944
|
+
interface SyntaxImportCall extends LocatedSyntax {
|
|
945
|
+
readonly kind: "import-call";
|
|
946
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
947
|
+
}
|
|
948
|
+
/** One owned M1 script, with no parser-specific values. */
|
|
949
|
+
interface SyntaxProgram extends LocatedSyntax {
|
|
950
|
+
readonly body: readonly (SyntaxFunction | SyntaxStatement)[];
|
|
951
|
+
/** Last directive's cooked value, retained for host Script completion. */
|
|
952
|
+
readonly directiveCompletion?: Extract<SyntaxExpression, {
|
|
953
|
+
kind: "string";
|
|
954
|
+
}>;
|
|
955
|
+
/**
|
|
956
|
+
* Script lexical names that HasRestrictedGlobalProperty checks before
|
|
957
|
+
* creating any binding. A module frontend leaves this absent.
|
|
958
|
+
*/
|
|
959
|
+
readonly globalLexicalNames?: readonly SyntaxGlobalLexicalName[];
|
|
960
|
+
/**
|
|
961
|
+
* The var-scoped top-level names a Script's Global Environment Record
|
|
962
|
+
* must also bind as properties of its global object, in the order
|
|
963
|
+
* ECMA-262's GlobalDeclarationInstantiation creates them: every
|
|
964
|
+
* top-level function declaration in source order, then every hoisted
|
|
965
|
+
* `var` name that no function declaration already owns.
|
|
966
|
+
*
|
|
967
|
+
* Lexical top-level names are absent, because a Script's `let`,
|
|
968
|
+
* `const`, and `class` declarations live in the global declarative
|
|
969
|
+
* record and are never global-object properties. A module frontend
|
|
970
|
+
* leaves this absent: module code adds nothing to the global object.
|
|
971
|
+
*/
|
|
972
|
+
readonly globalObjectNames?: readonly SyntaxGlobalObjectName[];
|
|
973
|
+
/**
|
|
974
|
+
* Every `import-call` node in the program, in source order. A frontend
|
|
975
|
+
* that does not produce `import-call` nodes leaves this absent.
|
|
976
|
+
*/
|
|
977
|
+
readonly importCalls?: readonly SyntaxImportCall[];
|
|
978
|
+
readonly kind: "program";
|
|
979
|
+
readonly sourceId: string;
|
|
980
|
+
readonly strict?: boolean;
|
|
981
|
+
}
|
|
982
|
+
/** Production frontend output for owned M1 syntax. */
|
|
983
|
+
interface FrontendResult {
|
|
984
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
985
|
+
readonly parsed: boolean;
|
|
986
|
+
readonly program?: SyntaxProgram;
|
|
987
|
+
readonly sourceId: string;
|
|
988
|
+
}
|
|
989
|
+
/** Replaceable source frontend boundary owned by compiler core. */
|
|
990
|
+
interface SourceFrontend {
|
|
991
|
+
parse(input: SourceInput): FrontendResult;
|
|
992
|
+
}
|
|
993
|
+
/** One source-located module specifier retained outside a bootstrap AST. */
|
|
994
|
+
interface SyntaxModuleSpecifier extends LocatedSyntax {
|
|
995
|
+
/** Static request metadata, absent when no with clause was written. */
|
|
996
|
+
readonly attributes?: readonly SyntaxImportAttribute[];
|
|
997
|
+
readonly byteRange: ByteRange;
|
|
998
|
+
readonly value: string;
|
|
999
|
+
}
|
|
1000
|
+
/** One static attribute with its original diagnostic location. */
|
|
1001
|
+
interface SyntaxImportAttribute extends LocatedSyntax {
|
|
1002
|
+
readonly byteRange: ByteRange;
|
|
1003
|
+
readonly key: string;
|
|
1004
|
+
readonly value: string;
|
|
1005
|
+
}
|
|
1006
|
+
/** One imported binding or side-effect-only dependency. */
|
|
1007
|
+
interface SyntaxImportEntry extends LocatedSyntax {
|
|
1008
|
+
readonly byteRange: ByteRange;
|
|
1009
|
+
/**
|
|
1010
|
+
* The requested export name, or `"*"` for a namespace import. A string
|
|
1011
|
+
* ModuleExportName may itself be `"*"`, so only `namespace` decides
|
|
1012
|
+
* whether the entry imports the module namespace object.
|
|
1013
|
+
*/
|
|
1014
|
+
readonly importedName: string | undefined;
|
|
1015
|
+
readonly localName: string | undefined;
|
|
1016
|
+
/** Present only on an `import * as name` entry. */
|
|
1017
|
+
readonly namespace?: true;
|
|
1018
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
1019
|
+
}
|
|
1020
|
+
/** One exported name before graph linking. */
|
|
1021
|
+
type SyntaxExportEntry = (LocatedSyntax & {
|
|
1022
|
+
readonly exportedName: string;
|
|
1023
|
+
readonly kind: "local";
|
|
1024
|
+
readonly localName: string;
|
|
1025
|
+
}) | (LocatedSyntax & {
|
|
1026
|
+
readonly exportedName: string;
|
|
1027
|
+
readonly importedName: string;
|
|
1028
|
+
readonly kind: "indirect";
|
|
1029
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
1030
|
+
}) | (LocatedSyntax & {
|
|
1031
|
+
/**
|
|
1032
|
+
* `export * as name from "m"`, which exports the namespace object of
|
|
1033
|
+
* the requested module under one explicit name.
|
|
1034
|
+
*/
|
|
1035
|
+
readonly exportedName: string;
|
|
1036
|
+
readonly kind: "namespace";
|
|
1037
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
1038
|
+
}) | (LocatedSyntax & {
|
|
1039
|
+
readonly kind: "star";
|
|
1040
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
1041
|
+
}) | (LocatedSyntax & {
|
|
1042
|
+
readonly declaration: SyntaxExpression | SyntaxFunction;
|
|
1043
|
+
readonly exportedName: "default";
|
|
1044
|
+
readonly kind: "default";
|
|
1045
|
+
});
|
|
1046
|
+
/** Parser-independent syntax for one M4 ECMAScript module. */
|
|
1047
|
+
interface SyntaxModule extends LocatedSyntax {
|
|
1048
|
+
readonly body: readonly (SyntaxFunction | SyntaxStatement)[];
|
|
1049
|
+
readonly exports: readonly SyntaxExportEntry[];
|
|
1050
|
+
/**
|
|
1051
|
+
* Every `import-call` node in the module, in source order. A frontend
|
|
1052
|
+
* that does not produce `import-call` nodes leaves this absent.
|
|
1053
|
+
*/
|
|
1054
|
+
readonly importCalls?: readonly SyntaxImportCall[];
|
|
1055
|
+
readonly imports: readonly SyntaxImportEntry[];
|
|
1056
|
+
readonly kind: "module";
|
|
1057
|
+
readonly sourceId: string;
|
|
1058
|
+
/**
|
|
1059
|
+
* VarDeclaredNames of the module body that are not also function
|
|
1060
|
+
* declarations. The frontend hoists each to a top-level `let` initialized
|
|
1061
|
+
* to `undefined`; module compilation runs those initializers while
|
|
1062
|
+
* linking, so a cyclic importer or a hoisted function reads `undefined`
|
|
1063
|
+
* rather than a temporal dead zone before the module evaluates.
|
|
1064
|
+
*/
|
|
1065
|
+
readonly varNames: readonly string[];
|
|
1066
|
+
}
|
|
1067
|
+
/** Production frontend output for owned module syntax. */
|
|
1068
|
+
interface ModuleFrontendResult {
|
|
1069
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
1070
|
+
readonly module?: SyntaxModule;
|
|
1071
|
+
readonly parsed: boolean;
|
|
1072
|
+
readonly sourceId: string;
|
|
1073
|
+
}
|
|
1074
|
+
/** Replaceable module frontend boundary owned by compiler core. */
|
|
1075
|
+
interface ModuleSourceFrontend {
|
|
1076
|
+
parseModule(input: SourceInput): ModuleFrontendResult;
|
|
1077
|
+
}
|
|
1078
|
+
/** Source and stable content identity supplied by a compiler host. */
|
|
1079
|
+
interface LoadedModuleSource extends SourceInput {
|
|
1080
|
+
/** Omitted by older source-only loaders; omission means JavaScript. */
|
|
1081
|
+
readonly kind?: "javascript";
|
|
1082
|
+
readonly sourceHash: string;
|
|
1083
|
+
}
|
|
1084
|
+
/** Original JSON bytes, validated by the compiler during graph discovery. */
|
|
1085
|
+
interface LoadedJsonModule extends SourceInput {
|
|
1086
|
+
readonly kind: "json";
|
|
1087
|
+
readonly sourceHash: string;
|
|
1088
|
+
}
|
|
1089
|
+
/** Canonical identities of the preview's two source-free modules. */
|
|
1090
|
+
type BuiltinModuleSpecifier = "node:process" | "node:fs";
|
|
1091
|
+
/** Export-table and runtime-ABI digest supplied by the loader. */
|
|
1092
|
+
interface LoadedBuiltinModule {
|
|
1093
|
+
readonly kind: "builtin";
|
|
1094
|
+
readonly specifier: BuiltinModuleSpecifier;
|
|
1095
|
+
readonly sourceHash: string;
|
|
1096
|
+
}
|
|
1097
|
+
/** Owned result of loading one canonical module identifier. */
|
|
1098
|
+
interface ModuleLoadResult {
|
|
1099
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
1100
|
+
readonly source?: LoadedModuleSource | LoadedJsonModule;
|
|
1101
|
+
readonly builtin?: LoadedBuiltinModule;
|
|
1102
|
+
}
|
|
1103
|
+
/** Import site that caused a dependency module to be loaded. */
|
|
1104
|
+
interface ModuleLoadReferrer {
|
|
1105
|
+
readonly importerId: string;
|
|
1106
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
1107
|
+
}
|
|
1108
|
+
/** Host-neutral source loader used during graph discovery. */
|
|
1109
|
+
interface ModuleLoader {
|
|
1110
|
+
load(canonicalId: string, referrer?: ModuleLoadReferrer): Promise<ModuleLoadResult>;
|
|
1111
|
+
}
|
|
1112
|
+
/** Owned result of resolving one source specifier. */
|
|
1113
|
+
interface ModuleResolutionResult {
|
|
1114
|
+
readonly canonicalId?: string;
|
|
1115
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
1116
|
+
}
|
|
1117
|
+
/** Host-neutral module resolution policy. */
|
|
1118
|
+
interface ModuleResolver {
|
|
1119
|
+
resolve(importerId: string, specifier: SyntaxModuleSpecifier): ModuleResolutionResult;
|
|
1120
|
+
}
|
|
1121
|
+
/** One resolved dependency edge in source order. */
|
|
1122
|
+
interface ModuleDependency {
|
|
1123
|
+
readonly canonicalId: string;
|
|
1124
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
1125
|
+
}
|
|
1126
|
+
/** One resolved source occurrence before dependency deduplication. */
|
|
1127
|
+
interface ModuleResolution extends ModuleDependency {}
|
|
1128
|
+
/** One uniquely identified node in a closed module graph. */
|
|
1129
|
+
interface ModuleGraphNodeBase {
|
|
1130
|
+
readonly canonicalId: string;
|
|
1131
|
+
/**
|
|
1132
|
+
* The index in {@link ModuleGraph.requests} of the request that first
|
|
1133
|
+
* brought this module into the build. The entry has none.
|
|
1134
|
+
*/
|
|
1135
|
+
readonly discoveredBy?: number;
|
|
1136
|
+
readonly dependencies: readonly ModuleDependency[];
|
|
1137
|
+
readonly resolutions: readonly ModuleResolution[];
|
|
1138
|
+
readonly sourceHash: string;
|
|
1139
|
+
}
|
|
1140
|
+
/** Source syntax and source-free builtin records remain distinct. */
|
|
1141
|
+
type ModuleGraphNode = ModuleGraphNodeBase & ({
|
|
1142
|
+
readonly moduleKind?: "javascript" | "json";
|
|
1143
|
+
readonly syntax: SyntaxModule;
|
|
1144
|
+
} | {
|
|
1145
|
+
readonly moduleKind: "builtin";
|
|
1146
|
+
readonly builtin: BuiltinModuleSpecifier;
|
|
1147
|
+
});
|
|
1148
|
+
/**
|
|
1149
|
+
* The source that contains a module request. A Script referrer is not a
|
|
1150
|
+
* module record: a module whose canonical identity equals a Script's
|
|
1151
|
+
* identity is a separate record with its own evaluation.
|
|
1152
|
+
*/
|
|
1153
|
+
interface ModuleRequestReferrer {
|
|
1154
|
+
readonly id: string;
|
|
1155
|
+
readonly kind: "module" | "script";
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* One resolved request retained by the build, under the static-specifier
|
|
1159
|
+
* import design. An `evaluation` edge is a static `import` or
|
|
1160
|
+
* `export ... from` request; a `discovery` edge is an `import-call` site,
|
|
1161
|
+
* which loads its target's closure into the build but never makes the
|
|
1162
|
+
* target a startup dependency.
|
|
1163
|
+
*
|
|
1164
|
+
* `index` is the record's position in {@link ModuleGraph.requests}, the
|
|
1165
|
+
* constant a compiled site names instead of looking up a specifier at
|
|
1166
|
+
* run time. `location` covers the static specifier or the whole
|
|
1167
|
+
* `import()` call; `specifier` keeps the decoded literal and its own
|
|
1168
|
+
* location.
|
|
1169
|
+
*/
|
|
1170
|
+
interface ModuleRequestRecord extends LocatedSyntax {
|
|
1171
|
+
readonly byteRange: ByteRange;
|
|
1172
|
+
readonly edgeKind: "discovery" | "evaluation";
|
|
1173
|
+
readonly index: number;
|
|
1174
|
+
readonly referrer: ModuleRequestReferrer;
|
|
1175
|
+
readonly specifier: SyntaxModuleSpecifier;
|
|
1176
|
+
readonly targetId: string;
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* A Script that may contain `import-call` sites, with the canonical
|
|
1180
|
+
* identity its requests resolve against. The identity is explicit
|
|
1181
|
+
* because a Script has no module record to supply one.
|
|
1182
|
+
*/
|
|
1183
|
+
interface ScriptRequestReferrer {
|
|
1184
|
+
readonly canonicalId: string;
|
|
1185
|
+
readonly program: SyntaxProgram;
|
|
1186
|
+
}
|
|
1187
|
+
/** Optional referrers that graph discovery reads besides the entry. */
|
|
1188
|
+
interface ModuleGraphOptions {
|
|
1189
|
+
/**
|
|
1190
|
+
* Scripts whose `import-call` sites join the build. Their requests are
|
|
1191
|
+
* discovered after the entry's static closure and before any request
|
|
1192
|
+
* that a module makes with `import()`.
|
|
1193
|
+
*/
|
|
1194
|
+
readonly scripts?: readonly ScriptRequestReferrer[];
|
|
1195
|
+
}
|
|
1196
|
+
/** Deterministic closed graph rooted at one canonical entry. */
|
|
1197
|
+
interface ModuleGraph {
|
|
1198
|
+
readonly entryId: string;
|
|
1199
|
+
readonly kind: "module-graph";
|
|
1200
|
+
/**
|
|
1201
|
+
* Every discovered module. The entry's static closure comes first, in
|
|
1202
|
+
* the order it has always had; modules that only `import()` reaches
|
|
1203
|
+
* follow in discovery order.
|
|
1204
|
+
*/
|
|
1205
|
+
readonly modules: readonly ModuleGraphNode[];
|
|
1206
|
+
/**
|
|
1207
|
+
* Every resolved request in a deterministic order: Script referrers in
|
|
1208
|
+
* the order given, then modules in {@link modules} order, each in
|
|
1209
|
+
* source order. Graphs built by hand may omit it; graph discovery
|
|
1210
|
+
* always supplies it.
|
|
1211
|
+
*/
|
|
1212
|
+
readonly requests?: readonly ModuleRequestRecord[];
|
|
1213
|
+
}
|
|
1214
|
+
/** Result of host-neutral module graph discovery. */
|
|
1215
|
+
interface ModuleGraphResult {
|
|
1216
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
1217
|
+
readonly graph?: ModuleGraph;
|
|
1218
|
+
}
|
|
1219
|
+
/** The modules and requests that Script referrers alone reach. */
|
|
1220
|
+
interface ScriptRequestClosure {
|
|
1221
|
+
readonly kind: "script-request-closure";
|
|
1222
|
+
readonly modules: readonly ModuleGraphNode[];
|
|
1223
|
+
readonly requests: readonly ModuleRequestRecord[];
|
|
1224
|
+
}
|
|
1225
|
+
/** Result of discovering the requests of Script referrers. */
|
|
1226
|
+
interface ScriptRequestResult {
|
|
1227
|
+
readonly closure?: ScriptRequestClosure;
|
|
1228
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
1229
|
+
}
|
|
1230
|
+
//#endregion
|
|
1231
|
+
export { AssignmentOperator, BinaryOperator, BindingPatternMode, BuiltinModuleSpecifier, FrontendResult, FunctionKind, Hint, HintName, HintProvenance, LoadedBuiltinModule, LoadedJsonModule, LoadedModuleSource, LocatedSyntax, LogicalOperator, ModuleDependency, ModuleFrontendResult, ModuleGraph, ModuleGraphNode, ModuleGraphOptions, ModuleGraphResult, ModuleLoadReferrer, ModuleLoadResult, ModuleLoader, ModuleRequestRecord, ModuleRequestReferrer, ModuleResolution, ModuleResolutionResult, ModuleResolver, ModuleSourceFrontend, RegExpLiteralSyntax, ScriptRequestClosure, ScriptRequestReferrer, ScriptRequestResult, SourceFrontend, SyntaxArrayBindingPattern, SyntaxArrayElement, SyntaxArraySpreadElement, SyntaxAssignmentMemberTarget, SyntaxAssignmentPattern, SyntaxAssignmentPrivateTarget, SyntaxAssignmentTarget, SyntaxBindingElement, SyntaxBindingIdentifier, SyntaxBindingPattern, SyntaxBindingTarget, SyntaxCallArgument, SyntaxCallTarget, SyntaxClassElement, SyntaxClassField, SyntaxClassMethod, SyntaxClassStaticBlock, SyntaxExportEntry, SyntaxExpression, SyntaxForBindingDeclaration, SyntaxForDeclaration, SyntaxForInTarget, SyntaxForOfTarget, SyntaxForPatternDeclaration, SyntaxFunction, SyntaxGlobalLexicalName, SyntaxGlobalObjectName, SyntaxImportAttribute, SyntaxImportCall, SyntaxImportEntry, SyntaxLexicalDeclarator, SyntaxModule, SyntaxModuleSpecifier, SyntaxObjectBindingPattern, SyntaxObjectBindingProperty, SyntaxObjectDefinition, SyntaxObjectProperty, SyntaxObjectSpreadProperty, SyntaxOptionalChainLink, SyntaxParameter, SyntaxPrivateName, SyntaxProgram, SyntaxRegExpLiteralExpression, SyntaxSpreadArgument, SyntaxStatement, SyntaxSwitchCase, SyntaxTemplateObject, SyntaxThisMode, SyntaxWithStatement, UnaryOperator, UpdateOperator };
|
|
1232
|
+
//# sourceMappingURL=syntax.d.ts.map
|