@yuku-parser/wasm 0.5.21
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/README.md +35 -0
- package/decode.js +693 -0
- package/index.d.ts +2034 -0
- package/index.js +60 -0
- package/package.json +43 -0
- package/yuku-parser.wasm +0 -0
package/decode.js
ADDED
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
// generated by tools/gen_estree_decoder.zig, do not edit
|
|
2
|
+
const NULL = -1;
|
|
3
|
+
const _td = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
4
|
+
const BINARY_OPS = ["==", "!=", "===", "!==", "<", "<=", ">", ">=", "+", "-", "*", "/", "%", "**", "|", "^", "&", "<<", ">>", ">>>", "in", "instanceof"];
|
|
5
|
+
const LOGICAL_OPS = ["&&", "||", "??"];
|
|
6
|
+
const UNARY_OPS = ["-", "+", "!", "~", "typeof", "void", "delete"];
|
|
7
|
+
const UPDATE_OPS = ["++", "--"];
|
|
8
|
+
const ASSIGNMENT_OPS = ["=", "+=", "-=", "*=", "/=", "%=", "**=", "<<=", ">>=", ">>>=", "|=", "^=", "&=", "||=", "&&=", "??="];
|
|
9
|
+
const VAR_KINDS = ["var", "let", "const", "using", "await using"];
|
|
10
|
+
const PROPERTY_KINDS = ["init", "get", "set"];
|
|
11
|
+
const METHOD_KINDS = ["constructor", "method", "get", "set"];
|
|
12
|
+
const FUNCTION_TYPES = ["FunctionDeclaration", "FunctionExpression", "TSDeclareFunction", "TSEmptyBodyFunctionExpression"];
|
|
13
|
+
const CLASS_TYPES = ["ClassDeclaration", "ClassExpression"];
|
|
14
|
+
const SEVERITY = ["error", "warning", "hint", "info"];
|
|
15
|
+
const IMPORT_EXPORT_KINDS = ["value", "type"];
|
|
16
|
+
const ACCESSIBILITY = [null, "public", "private", "protected"];
|
|
17
|
+
const TS_TYPE_OPERATORS = ["keyof", "unique", "readonly"];
|
|
18
|
+
const TS_METHOD_SIGNATURE_KINDS = ["method", "get", "set"];
|
|
19
|
+
const TS_MODULE_KINDS = ["namespace", "module"];
|
|
20
|
+
const TS_MAPPED_OPTIONAL = [false, true, "+", "-"];
|
|
21
|
+
const TS_MAPPED_READONLY = [null, true, "+", "-"];
|
|
22
|
+
function buildPosMap(src, byteLen, startByte) {
|
|
23
|
+
const m = new Uint32Array(byteLen - startByte + 1);
|
|
24
|
+
const len = src.length;
|
|
25
|
+
let bp = 0, u16p = startByte, i = startByte;
|
|
26
|
+
while (i < len) {
|
|
27
|
+
if (i + 16 <= len) {
|
|
28
|
+
let allAscii = true;
|
|
29
|
+
for (let k = 0; k < 16; k++) {
|
|
30
|
+
if (src.charCodeAt(i + k) >= 0x80) { allAscii = false; break; }
|
|
31
|
+
}
|
|
32
|
+
if (allAscii) {
|
|
33
|
+
for (let k = 0; k < 16; k++) m[bp + k] = u16p + k;
|
|
34
|
+
bp += 16; u16p += 16; i += 16;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const cu = src.charCodeAt(i);
|
|
39
|
+
m[bp] = u16p;
|
|
40
|
+
if (cu < 0x80) { bp++; u16p++; i++; }
|
|
41
|
+
else if (cu < 0x800) { m[bp + 1] = u16p + 1; bp += 2; u16p++; i++; }
|
|
42
|
+
else if (cu < 0xD800 || cu >= 0xE000) {
|
|
43
|
+
m[bp + 1] = u16p + 1; m[bp + 2] = u16p + 1;
|
|
44
|
+
bp += 3; u16p++; i++;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
m[bp + 1] = u16p + 1; m[bp + 2] = u16p + 2; m[bp + 3] = u16p + 2;
|
|
48
|
+
bp += 4; u16p += 2; i += 2;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
m[byteLen - startByte] = u16p;
|
|
52
|
+
return m;
|
|
53
|
+
}
|
|
54
|
+
function decode(buffer, source) {
|
|
55
|
+
const _u8 = new Uint8Array(buffer);
|
|
56
|
+
const aLen = (buffer.byteLength >> 2) << 2;
|
|
57
|
+
const _u32 = new Int32Array(buffer, 0, aLen >> 2);
|
|
58
|
+
const _src = source;
|
|
59
|
+
const _srcLen = _u32[3];
|
|
60
|
+
const nodeCount = _u32[0],
|
|
61
|
+
extraCount = _u32[1],
|
|
62
|
+
spLen = _u32[2];
|
|
63
|
+
const commentCount = _u32[4],
|
|
64
|
+
lineStartsCount = _u32[6],
|
|
65
|
+
diagCount = _u32[7],
|
|
66
|
+
progIdx = _u32[8];
|
|
67
|
+
const attachedCommentCount = _u32[5];
|
|
68
|
+
const _flags = _u32[9];
|
|
69
|
+
const _isTs = !!(_flags & 1);
|
|
70
|
+
const _attached = !!(_flags & 2);
|
|
71
|
+
const _firstNa = _u32[10];
|
|
72
|
+
const _nodesOff = 44;
|
|
73
|
+
const eOff = _nodesOff + nodeCount * 48;
|
|
74
|
+
const _extraBase = eOff >> 2;
|
|
75
|
+
const _spOff = eOff + extraCount * 4;
|
|
76
|
+
const dv = new DataView(buffer);
|
|
77
|
+
const _aoOff = _spOff + spLen;
|
|
78
|
+
const _acOff = _attached ? _aoOff + (nodeCount + 1) * 4 : _aoOff;
|
|
79
|
+
const _cOff = _acOff + attachedCommentCount * 12;
|
|
80
|
+
function _poolDecode(s, e) {
|
|
81
|
+
const a = _spOff + s - _srcLen, b = _spOff + e - _srcLen;
|
|
82
|
+
let hasEd = false;
|
|
83
|
+
for (let i = a; i < b; i++) if (_u8[i] === 0xED) { hasEd = true; break; }
|
|
84
|
+
if (!hasEd) return _td.decode(_u8.subarray(a, b));
|
|
85
|
+
let r = "";
|
|
86
|
+
for (let i = a; i < b; ) {
|
|
87
|
+
const c = _u8[i];
|
|
88
|
+
if (c < 0x80) { r += String.fromCharCode(c); i++; }
|
|
89
|
+
else if (c < 0xE0) {
|
|
90
|
+
r += String.fromCharCode(((c & 0x1F) << 6) | (_u8[i+1] & 0x3F));
|
|
91
|
+
i += 2;
|
|
92
|
+
}
|
|
93
|
+
else if (c < 0xF0) {
|
|
94
|
+
r += String.fromCharCode(
|
|
95
|
+
((c & 0x0F) << 12) | ((_u8[i+1] & 0x3F) << 6) | (_u8[i+2] & 0x3F)
|
|
96
|
+
);
|
|
97
|
+
i += 3;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
r += String.fromCodePoint(
|
|
101
|
+
((c & 0x07) << 18) | ((_u8[i+1] & 0x3F) << 12) |
|
|
102
|
+
((_u8[i+2] & 0x3F) << 6) | (_u8[i+3] & 0x3F)
|
|
103
|
+
);
|
|
104
|
+
i += 4;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return r;
|
|
108
|
+
}
|
|
109
|
+
const pm = _firstNa < _srcLen ? buildPosMap(_src, _srcLen, _firstNa) : null;
|
|
110
|
+
const _p = v => v <= _firstNa ? v : pm[v - _firstNa];
|
|
111
|
+
const str = (s, e) => {
|
|
112
|
+
if (s === e) return "";
|
|
113
|
+
if (s >= _srcLen) return _poolDecode(s, e);
|
|
114
|
+
if (e <= _firstNa) return _src.slice(s, e);
|
|
115
|
+
const ss = s < _firstNa ? s : pm[s - _firstNa];
|
|
116
|
+
return _src.slice(ss, pm[e - _firstNa]);
|
|
117
|
+
};
|
|
118
|
+
function nodeArr(s, len) {
|
|
119
|
+
const r = new Array(len);
|
|
120
|
+
for (let j = 0; j < len; j++) r[j] = node(_u32[_extraBase + s + j]);
|
|
121
|
+
return r;
|
|
122
|
+
}
|
|
123
|
+
function nodeArrHoles(s, len) {
|
|
124
|
+
const r = new Array(len);
|
|
125
|
+
for (let j = 0; j < len; j++) {
|
|
126
|
+
const x = _u32[_extraBase + s + j];
|
|
127
|
+
r[j] = x !== NULL ? node(x) : null;
|
|
128
|
+
}
|
|
129
|
+
return r;
|
|
130
|
+
}
|
|
131
|
+
function fnParams(idx) {
|
|
132
|
+
const po = _nodesOff + idx * 48;
|
|
133
|
+
const len = _u8[po + 4] | (_u8[po + 5] << 8);
|
|
134
|
+
const pb = po >> 2;
|
|
135
|
+
const iStart = _u32[pb + 2], rest = _u32[pb + 3];
|
|
136
|
+
const p = [];
|
|
137
|
+
for (let j = 0; j < len; j++) p.push(node(_u32[_extraBase + iStart + j]));
|
|
138
|
+
if (rest !== NULL) p.push(node(rest));
|
|
139
|
+
return p;
|
|
140
|
+
}
|
|
141
|
+
function _attachedCommentsOf(a, e) {
|
|
142
|
+
const out = new Array(e - a);
|
|
143
|
+
for (let j = a; j < e; j++) {
|
|
144
|
+
const o = _acOff + j * 12;
|
|
145
|
+
const cf = _u8[o + 0];
|
|
146
|
+
const vs = dv.getUint32(o + 4, true),
|
|
147
|
+
ve = dv.getUint32(o + 8, true);
|
|
148
|
+
out[j - a] = {
|
|
149
|
+
type: (cf & 1) ? "Block" : "Line",
|
|
150
|
+
position: ["before", "after", "inside"][(cf >> 1) & 3],
|
|
151
|
+
sameLine: (cf & 8) !== 0,
|
|
152
|
+
value: str(vs, ve),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
function nodeWithComments(i) {
|
|
158
|
+
const r = _decode(i);
|
|
159
|
+
if (r && r.type !== undefined && r.comments === undefined) {
|
|
160
|
+
const off = _aoOff + i * 4;
|
|
161
|
+
const a = dv.getUint32(off, true), e = dv.getUint32(off + 4, true);
|
|
162
|
+
if (a !== e) r.comments = _attachedCommentsOf(a, e);
|
|
163
|
+
}
|
|
164
|
+
return r;
|
|
165
|
+
}
|
|
166
|
+
function _decode(i) {
|
|
167
|
+
const o = _nodesOff + i * 48;
|
|
168
|
+
const tag = _u8[o];
|
|
169
|
+
const flags = _u8[o + 2] | (_u8[o + 3] << 8);
|
|
170
|
+
const f0 = _u8[o + 4] | (_u8[o + 5] << 8);
|
|
171
|
+
const b = o >> 2;
|
|
172
|
+
const f1 = _u32[b + 2], f2 = _u32[b + 3],
|
|
173
|
+
f3 = _u32[b + 4], f4 = _u32[b + 5],
|
|
174
|
+
f5 = _u32[b + 6], f6 = _u32[b + 7],
|
|
175
|
+
f7 = _u32[b + 8], f8 = _u32[b + 9];
|
|
176
|
+
const _ss = _u32[b + 10], _se = _u32[b + 11];
|
|
177
|
+
const start = _ss <= _firstNa ? _ss : pm[_ss - _firstNa];
|
|
178
|
+
const end = _se <= _firstNa ? _se : pm[_se - _firstNa];
|
|
179
|
+
switch (tag) {
|
|
180
|
+
case 0: return { type: "SequenceExpression", start, end, expressions: nodeArr(f1, f0) };
|
|
181
|
+
case 1: return { type: "ParenthesizedExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
182
|
+
case 2: {
|
|
183
|
+
const r = {
|
|
184
|
+
type: "ArrowFunctionExpression", start, end,
|
|
185
|
+
id: null, generator: false, async: !!(flags & 2),
|
|
186
|
+
params: f1 !== NULL ? fnParams(f1) : [],
|
|
187
|
+
body: node(f2), expression: !!(flags & 1),
|
|
188
|
+
};
|
|
189
|
+
if (_isTs) {
|
|
190
|
+
r.typeParameters = f3 !== NULL ? node(f3) : null;
|
|
191
|
+
r.returnType = f4 !== NULL ? node(f4) : null;
|
|
192
|
+
}
|
|
193
|
+
return r;
|
|
194
|
+
}
|
|
195
|
+
case 3: {
|
|
196
|
+
const ft = flags & 3;
|
|
197
|
+
const r = {
|
|
198
|
+
type: FUNCTION_TYPES[ft], start, end,
|
|
199
|
+
id: f1 !== NULL ? node(f1) : null,
|
|
200
|
+
generator: !!(flags & 4), async: !!(flags & 8),
|
|
201
|
+
params: f2 !== NULL ? fnParams(f2) : [],
|
|
202
|
+
body: f3 !== NULL ? node(f3) : null,
|
|
203
|
+
expression: false,
|
|
204
|
+
};
|
|
205
|
+
if (_isTs) {
|
|
206
|
+
r.typeParameters = f4 !== NULL ? node(f4) : null;
|
|
207
|
+
r.returnType = f5 !== NULL ? node(f5) : null;
|
|
208
|
+
r.declare = !!(flags & 16);
|
|
209
|
+
}
|
|
210
|
+
return r;
|
|
211
|
+
}
|
|
212
|
+
case 4: return { type: "BlockStatement", start, end, body: nodeArr(f1, f0) };
|
|
213
|
+
case 5: return { type: "BlockStatement", start, end, body: nodeArr(f1, f0) };
|
|
214
|
+
case 6: return { params: fnParams(i) };
|
|
215
|
+
case 7: return node(f1);
|
|
216
|
+
case 8: return { type: "BinaryExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: BINARY_OPS[flags & 31] };
|
|
217
|
+
case 9: return { type: "LogicalExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: LOGICAL_OPS[flags & 3] };
|
|
218
|
+
case 10: return { type: "ConditionalExpression", start, end, test: f1 !== NULL ? node(f1) : null, consequent: f2 !== NULL ? node(f2) : null, alternate: f3 !== NULL ? node(f3) : null };
|
|
219
|
+
case 11: return {
|
|
220
|
+
type: "UnaryExpression", start, end,
|
|
221
|
+
operator: UNARY_OPS[flags & 7], prefix: true,
|
|
222
|
+
argument: f1 !== NULL ? node(f1) : null,
|
|
223
|
+
};
|
|
224
|
+
case 12: return { type: "UpdateExpression", start, end, argument: f1 !== NULL ? node(f1) : null, operator: UPDATE_OPS[flags & 1], prefix: !!(flags & 2) };
|
|
225
|
+
case 13: return { type: "AssignmentExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: ASSIGNMENT_OPS[flags & 15] };
|
|
226
|
+
case 14: return { type: "ArrayExpression", start, end, elements: nodeArrHoles(f1, f0) };
|
|
227
|
+
case 15: return { type: "ObjectExpression", start, end, properties: nodeArr(f1, f0) };
|
|
228
|
+
case 16: return { type: "SpreadElement", start, end, argument: f1 !== NULL ? node(f1) : null };
|
|
229
|
+
case 17: { const r = { type: "Property", start, end, key: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null, kind: PROPERTY_KINDS[flags & 3], method: !!(flags & 4), shorthand: !!(flags & 8), computed: !!(flags & 16) }; if (_isTs) { r.optional = false; } return r; }
|
|
230
|
+
case 18: return { type: "MemberExpression", start, end, object: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1), optional: !!(flags & 2) };
|
|
231
|
+
case 19: { const r = { type: "CallExpression", start, end, callee: f1 !== NULL ? node(f1) : null, arguments: nodeArr(f2, f0), optional: !!(flags & 1) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
|
|
232
|
+
case 20: return { type: "ChainExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
233
|
+
case 21: { const r = { type: "TaggedTemplateExpression", start, end, tag: f1 !== NULL ? node(f1) : null, quasi: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
|
|
234
|
+
case 22: { const r = { type: "NewExpression", start, end, callee: f1 !== NULL ? node(f1) : null, arguments: nodeArr(f2, f0) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
|
|
235
|
+
case 23: return { type: "AwaitExpression", start, end, argument: f1 !== NULL ? node(f1) : null };
|
|
236
|
+
case 24: return { type: "YieldExpression", start, end, argument: f1 !== NULL ? node(f1) : null, delegate: !!(flags & 1) };
|
|
237
|
+
case 25: return { type: "MetaProperty", start, end, meta: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null };
|
|
238
|
+
case 26: return { type: "Decorator", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
239
|
+
case 27: {
|
|
240
|
+
const r = {
|
|
241
|
+
type: CLASS_TYPES[flags & 1], start, end,
|
|
242
|
+
decorators: nodeArr(f1, f0),
|
|
243
|
+
id: f2 !== NULL ? node(f2) : null,
|
|
244
|
+
superClass: f3 !== NULL ? node(f3) : null,
|
|
245
|
+
body: node(f4),
|
|
246
|
+
};
|
|
247
|
+
if (_isTs) {
|
|
248
|
+
r.typeParameters = f5 !== NULL ? node(f5) : null;
|
|
249
|
+
r.superTypeArguments = f6 !== NULL ? node(f6) : null;
|
|
250
|
+
r.implements = nodeArr(f7, f8);
|
|
251
|
+
r.abstract = !!(flags & 2);
|
|
252
|
+
r.declare = !!(flags & 4);
|
|
253
|
+
}
|
|
254
|
+
return r;
|
|
255
|
+
}
|
|
256
|
+
case 28: return { type: "ClassBody", start, end, body: nodeArr(f1, f0) };
|
|
257
|
+
case 29: {
|
|
258
|
+
const r = {
|
|
259
|
+
type: "MethodDefinition", start, end,
|
|
260
|
+
decorators: nodeArr(f1, f0),
|
|
261
|
+
key: node(f2), value: node(f3),
|
|
262
|
+
kind: METHOD_KINDS[flags & 3],
|
|
263
|
+
computed: !!(flags & 4), static: !!(flags & 8),
|
|
264
|
+
};
|
|
265
|
+
if (_isTs) {
|
|
266
|
+
r.override = !!(flags & 16);
|
|
267
|
+
r.optional = !!(flags & 32);
|
|
268
|
+
const _abs = !!(flags & 64);
|
|
269
|
+
r.accessibility = ACCESSIBILITY[(flags >> 7) & 3];
|
|
270
|
+
if (_abs) r.type = "TSAbstractMethodDefinition";
|
|
271
|
+
}
|
|
272
|
+
return r;
|
|
273
|
+
}
|
|
274
|
+
case 30: {
|
|
275
|
+
const _acc = !!(flags & 4);
|
|
276
|
+
const r = {
|
|
277
|
+
type: _acc ? "AccessorProperty" : "PropertyDefinition",
|
|
278
|
+
start, end,
|
|
279
|
+
decorators: nodeArr(f1, f0),
|
|
280
|
+
key: node(f2),
|
|
281
|
+
value: f3 !== NULL ? node(f3) : null,
|
|
282
|
+
computed: !!(flags & 1), static: !!(flags & 2),
|
|
283
|
+
};
|
|
284
|
+
if (_isTs) {
|
|
285
|
+
r.typeAnnotation = f4 !== NULL ? node(f4) : null;
|
|
286
|
+
r.declare = !!(flags & 8);
|
|
287
|
+
r.override = !!(flags & 16);
|
|
288
|
+
r.optional = !!(flags & 32);
|
|
289
|
+
r.definite = !!(flags & 64);
|
|
290
|
+
r.readonly = !!(flags & 128);
|
|
291
|
+
const _abs = !!(flags & 256);
|
|
292
|
+
r.accessibility = ACCESSIBILITY[(flags >> 9) & 3];
|
|
293
|
+
if (_abs)
|
|
294
|
+
r.type = _acc
|
|
295
|
+
? "TSAbstractAccessorProperty"
|
|
296
|
+
: "TSAbstractPropertyDefinition";
|
|
297
|
+
}
|
|
298
|
+
return r;
|
|
299
|
+
}
|
|
300
|
+
case 31: return { type: "StaticBlock", start, end, body: nodeArr(f1, f0) };
|
|
301
|
+
case 32: return { type: "Super", start, end };
|
|
302
|
+
case 33: return {
|
|
303
|
+
type: "Literal", start, end,
|
|
304
|
+
value: str(f1, f2), raw: _src.slice(start, end),
|
|
305
|
+
};
|
|
306
|
+
case 34: {
|
|
307
|
+
const r = _src.slice(start, end);
|
|
308
|
+
const s = r.indexOf("_") === -1 ? r : r.replace(/_/g, "");
|
|
309
|
+
const v = (flags & 3) === 2 && s[1] !== "o" && s[1] !== "O"
|
|
310
|
+
? parseInt(s.slice(1), 8)
|
|
311
|
+
: +s;
|
|
312
|
+
return {
|
|
313
|
+
type: "Literal", start, end,
|
|
314
|
+
value: v === v && isFinite(v) ? v : null,
|
|
315
|
+
raw: r,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
case 35: {
|
|
319
|
+
const r = _src.slice(start, end);
|
|
320
|
+
const d = str(f1, f2).replace(/_/g, "");
|
|
321
|
+
const v = BigInt(d);
|
|
322
|
+
return {
|
|
323
|
+
type: "Literal", start, end,
|
|
324
|
+
value: v, raw: r, bigint: v.toString(),
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
case 36: {
|
|
328
|
+
const v = !!(flags & 1);
|
|
329
|
+
return {
|
|
330
|
+
type: "Literal", start, end,
|
|
331
|
+
value: v, raw: v ? "true" : "false",
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
case 37: return { type: "Literal", start, end, value: null, raw: "null" };
|
|
335
|
+
case 38: return { type: "ThisExpression", start, end };
|
|
336
|
+
case 39: {
|
|
337
|
+
const p = str(f1, f2), fl = str(f3, f4);
|
|
338
|
+
let v = null;
|
|
339
|
+
try { v = new RegExp(p, fl); } catch {}
|
|
340
|
+
return {
|
|
341
|
+
type: "Literal", start, end,
|
|
342
|
+
value: v, raw: "/" + p + "/" + fl,
|
|
343
|
+
regex: { pattern: p, flags: fl.split("").sort().join("") },
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
case 40: return { type: "TemplateLiteral", start, end, quasis: nodeArr(f1, f0), expressions: nodeArr(f2, f3) };
|
|
347
|
+
case 41: {
|
|
348
|
+
const raw = _src.slice(start, end).replace(/\r\n?/g, "\n");
|
|
349
|
+
const tl = !!(flags & 1);
|
|
350
|
+
const s = _isTs ? start - 1 : start;
|
|
351
|
+
const e = _isTs ? (tl ? end + 1 : end + 2) : end;
|
|
352
|
+
return {
|
|
353
|
+
type: "TemplateElement", start: s, end: e,
|
|
354
|
+
value: {
|
|
355
|
+
raw,
|
|
356
|
+
cooked: (flags & 2) ? null : str(f1, f2),
|
|
357
|
+
},
|
|
358
|
+
tail: tl,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
case 42: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
|
|
362
|
+
case 43: return { type: "PrivateIdentifier", start, end, name: str(f1, f2) };
|
|
363
|
+
case 44: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = nodeArr(f3, f0); r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.optional = !!(flags & 1); } return r; }
|
|
364
|
+
case 45: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
|
|
365
|
+
case 46: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
|
|
366
|
+
case 47: { const r = { type: "ExpressionStatement", start, end, expression: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.directive = null; } return r; }
|
|
367
|
+
case 48: return { type: "IfStatement", start, end, test: f1 !== NULL ? node(f1) : null, consequent: f2 !== NULL ? node(f2) : null, alternate: f3 !== NULL ? node(f3) : null };
|
|
368
|
+
case 49: return { type: "SwitchStatement", start, end, discriminant: f1 !== NULL ? node(f1) : null, cases: nodeArr(f2, f0) };
|
|
369
|
+
case 50: return { type: "SwitchCase", start, end, test: f1 !== NULL ? node(f1) : null, consequent: nodeArr(f2, f0) };
|
|
370
|
+
case 51: return { type: "ForStatement", start, end, init: f1 !== NULL ? node(f1) : null, test: f2 !== NULL ? node(f2) : null, update: f3 !== NULL ? node(f3) : null, body: f4 !== NULL ? node(f4) : null };
|
|
371
|
+
case 52: return { type: "ForInStatement", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, body: f3 !== NULL ? node(f3) : null };
|
|
372
|
+
case 53: return { type: "ForOfStatement", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, body: f3 !== NULL ? node(f3) : null, await: !!(flags & 1) };
|
|
373
|
+
case 54: return { type: "WhileStatement", start, end, test: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
|
|
374
|
+
case 55: return { type: "DoWhileStatement", start, end, body: f1 !== NULL ? node(f1) : null, test: f2 !== NULL ? node(f2) : null };
|
|
375
|
+
case 56: return { type: "BreakStatement", start, end, label: f1 !== NULL ? node(f1) : null };
|
|
376
|
+
case 57: return { type: "ContinueStatement", start, end, label: f1 !== NULL ? node(f1) : null };
|
|
377
|
+
case 58: return { type: "LabeledStatement", start, end, label: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
|
|
378
|
+
case 59: return { type: "WithStatement", start, end, object: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
|
|
379
|
+
case 60: return { type: "ReturnStatement", start, end, argument: f1 !== NULL ? node(f1) : null };
|
|
380
|
+
case 61: return { type: "ThrowStatement", start, end, argument: f1 !== NULL ? node(f1) : null };
|
|
381
|
+
case 62: return { type: "TryStatement", start, end, block: f1 !== NULL ? node(f1) : null, handler: f2 !== NULL ? node(f2) : null, finalizer: f3 !== NULL ? node(f3) : null };
|
|
382
|
+
case 63: return { type: "CatchClause", start, end, param: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
|
|
383
|
+
case 64: return { type: "DebuggerStatement", start, end };
|
|
384
|
+
case 65: return { type: "EmptyStatement", start, end };
|
|
385
|
+
case 66: { const r = { type: "VariableDeclaration", start, end, kind: VAR_KINDS[flags & 7], declarations: nodeArr(f1, f0) }; if (_isTs) { r.declare = !!(flags & 8); } return r; }
|
|
386
|
+
case 67: { const r = { type: "VariableDeclarator", start, end, id: f1 !== NULL ? node(f1) : null, init: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.definite = !!(flags & 1); } return r; }
|
|
387
|
+
case 68: return {
|
|
388
|
+
type: "ExpressionStatement", start, end,
|
|
389
|
+
expression: node(f1), directive: str(f2, f3),
|
|
390
|
+
};
|
|
391
|
+
case 69: { const r = { type: "AssignmentPattern", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.decorators = nodeArr(f3, f0); r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.optional = !!(flags & 1); } return r; }
|
|
392
|
+
case 70: { const r = { type: "RestElement", start, end, argument: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.decorators = nodeArr(f2, f0); r.typeAnnotation = f3 !== NULL ? node(f3) : null; r.optional = !!(flags & 1); r.value = null; } return r; }
|
|
393
|
+
case 71: {
|
|
394
|
+
const el = nodeArrHoles(f1, f0);
|
|
395
|
+
if (f2 !== NULL) el.push(node(f2));
|
|
396
|
+
const r = { type: "ArrayPattern", start, end, elements: el };
|
|
397
|
+
if (_isTs) {
|
|
398
|
+
r.decorators = nodeArr(f3, f4);
|
|
399
|
+
r.optional = !!(flags & 1);
|
|
400
|
+
r.typeAnnotation = f5 !== NULL ? node(f5) : null;
|
|
401
|
+
}
|
|
402
|
+
return r;
|
|
403
|
+
}
|
|
404
|
+
case 72: {
|
|
405
|
+
const pr = nodeArr(f1, f0);
|
|
406
|
+
if (f2 !== NULL) pr.push(node(f2));
|
|
407
|
+
const r = { type: "ObjectPattern", start, end, properties: pr };
|
|
408
|
+
if (_isTs) {
|
|
409
|
+
r.decorators = nodeArr(f3, f4);
|
|
410
|
+
r.optional = !!(flags & 1);
|
|
411
|
+
r.typeAnnotation = f5 !== NULL ? node(f5) : null;
|
|
412
|
+
}
|
|
413
|
+
return r;
|
|
414
|
+
}
|
|
415
|
+
case 73: {
|
|
416
|
+
const r = {
|
|
417
|
+
type: "Property", start, end,
|
|
418
|
+
kind: "init",
|
|
419
|
+
key: node(f1), value: node(f2),
|
|
420
|
+
method: false,
|
|
421
|
+
shorthand: !!(flags & 1),
|
|
422
|
+
computed: !!(flags & 2),
|
|
423
|
+
}; if (_isTs) { r.optional = false; } return r; }
|
|
424
|
+
case 74: return {
|
|
425
|
+
type: "Program", start, end,
|
|
426
|
+
sourceType: (flags & 1) ? "module" : "script",
|
|
427
|
+
hashbang: (flags & 2) ? {
|
|
428
|
+
type: "Hashbang",
|
|
429
|
+
start: _p(f2 - 2), end: _p(f3),
|
|
430
|
+
value: str(f2, f3),
|
|
431
|
+
} : null,
|
|
432
|
+
body: nodeArr(f1, f0),
|
|
433
|
+
};
|
|
434
|
+
case 75: return { type: "ImportExpression", start, end, source: f1 !== NULL ? node(f1) : null, options: f2 !== NULL ? node(f2) : null, phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null };
|
|
435
|
+
case 76: { const r = { type: "ImportDeclaration", start, end, specifiers: nodeArr(f1, f0), source: f2 !== NULL ? node(f2) : null, attributes: nodeArr(f3, f4), phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[(flags >> 2) & 1]; } return r; }
|
|
436
|
+
case 77: { const r = { type: "ImportSpecifier", start, end, imported: f1 !== NULL ? node(f1) : null, local: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
|
|
437
|
+
case 78: return { type: "ImportDefaultSpecifier", start, end, local: f1 !== NULL ? node(f1) : null };
|
|
438
|
+
case 79: return { type: "ImportNamespaceSpecifier", start, end, local: f1 !== NULL ? node(f1) : null };
|
|
439
|
+
case 80: return { type: "ImportAttribute", start, end, key: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null };
|
|
440
|
+
case 81: { const r = { type: "ExportNamedDeclaration", start, end, declaration: f1 !== NULL ? node(f1) : null, specifiers: nodeArr(f2, f0), source: f3 !== NULL ? node(f3) : null, attributes: nodeArr(f4, f5) }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
|
|
441
|
+
case 82: { const r = { type: "ExportDefaultDeclaration", start, end, declaration: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.exportKind = "value"; } return r; }
|
|
442
|
+
case 83: { const r = { type: "ExportAllDeclaration", start, end, exported: f1 !== NULL ? node(f1) : null, source: f2 !== NULL ? node(f2) : null, attributes: nodeArr(f3, f0) }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
|
|
443
|
+
case 84: { const r = { type: "ExportSpecifier", start, end, local: f1 !== NULL ? node(f1) : null, exported: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
|
|
444
|
+
case 85: return { type: "TSTypeAnnotation", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
|
|
445
|
+
case 86: return { type: "TSAnyKeyword", start, end };
|
|
446
|
+
case 87: return { type: "TSUnknownKeyword", start, end };
|
|
447
|
+
case 88: return { type: "TSNeverKeyword", start, end };
|
|
448
|
+
case 89: return { type: "TSVoidKeyword", start, end };
|
|
449
|
+
case 90: return { type: "TSNullKeyword", start, end };
|
|
450
|
+
case 91: return { type: "TSUndefinedKeyword", start, end };
|
|
451
|
+
case 92: return { type: "TSStringKeyword", start, end };
|
|
452
|
+
case 93: return { type: "TSNumberKeyword", start, end };
|
|
453
|
+
case 94: return { type: "TSBigIntKeyword", start, end };
|
|
454
|
+
case 95: return { type: "TSBooleanKeyword", start, end };
|
|
455
|
+
case 96: return { type: "TSSymbolKeyword", start, end };
|
|
456
|
+
case 97: return { type: "TSObjectKeyword", start, end };
|
|
457
|
+
case 98: return { type: "TSIntrinsicKeyword", start, end };
|
|
458
|
+
case 99: return { type: "TSThisType", start, end };
|
|
459
|
+
case 100: return { type: "TSTypeReference", start, end, typeName: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
|
|
460
|
+
case 101: return { type: "TSQualifiedName", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null };
|
|
461
|
+
case 102: return { type: "TSTypeQuery", start, end, exprName: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
|
|
462
|
+
case 103: return { type: "TSImportType", start, end, source: f1 !== NULL ? node(f1) : null, options: f2 !== NULL ? node(f2) : null, qualifier: f3 !== NULL ? node(f3) : null, typeArguments: f4 !== NULL ? node(f4) : null };
|
|
463
|
+
case 104: return { type: "TSTypeParameter", start, end, name: f1 !== NULL ? node(f1) : null, constraint: f2 !== NULL ? node(f2) : null, default: f3 !== NULL ? node(f3) : null, in: !!(flags & 1), out: !!(flags & 2), const: !!(flags & 4) };
|
|
464
|
+
case 105: return { type: "TSTypeParameterDeclaration", start, end, params: nodeArr(f1, f0) };
|
|
465
|
+
case 106: return { type: "TSTypeParameterInstantiation", start, end, params: nodeArr(f1, f0) };
|
|
466
|
+
case 107: return { type: "TSLiteralType", start, end, literal: f1 !== NULL ? node(f1) : null };
|
|
467
|
+
case 108: return { type: "TSTemplateLiteralType", start, end, quasis: nodeArr(f1, f0), types: nodeArr(f2, f3) };
|
|
468
|
+
case 109: return { type: "TSArrayType", start, end, elementType: f1 !== NULL ? node(f1) : null };
|
|
469
|
+
case 110: return { type: "TSIndexedAccessType", start, end, objectType: f1 !== NULL ? node(f1) : null, indexType: f2 !== NULL ? node(f2) : null };
|
|
470
|
+
case 111: return { type: "TSTupleType", start, end, elementTypes: nodeArr(f1, f0) };
|
|
471
|
+
case 112: return { type: "TSNamedTupleMember", start, end, label: f1 !== NULL ? node(f1) : null, elementType: f2 !== NULL ? node(f2) : null, optional: !!(flags & 1) };
|
|
472
|
+
case 113: return { type: "TSOptionalType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
|
|
473
|
+
case 114: return { type: "TSRestType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
|
|
474
|
+
case 115: return { type: "TSJSDocNullableType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, postfix: !!(flags & 1) };
|
|
475
|
+
case 116: return { type: "TSJSDocNonNullableType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, postfix: !!(flags & 1) };
|
|
476
|
+
case 117: return { type: "TSJSDocUnknownType", start, end };
|
|
477
|
+
case 118: return { type: "TSUnionType", start, end, types: nodeArr(f1, f0) };
|
|
478
|
+
case 119: return { type: "TSIntersectionType", start, end, types: nodeArr(f1, f0) };
|
|
479
|
+
case 120: return { type: "TSConditionalType", start, end, checkType: f1 !== NULL ? node(f1) : null, extendsType: f2 !== NULL ? node(f2) : null, trueType: f3 !== NULL ? node(f3) : null, falseType: f4 !== NULL ? node(f4) : null };
|
|
480
|
+
case 121: return { type: "TSInferType", start, end, typeParameter: f1 !== NULL ? node(f1) : null };
|
|
481
|
+
case 122: return { type: "TSTypeOperator", start, end, operator: TS_TYPE_OPERATORS[flags & 3], typeAnnotation: f1 !== NULL ? node(f1) : null };
|
|
482
|
+
case 123: return { type: "TSParenthesizedType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
|
|
483
|
+
case 124: return {
|
|
484
|
+
type: "TSFunctionType", start, end,
|
|
485
|
+
typeParameters: f1 !== NULL ? node(f1) : null,
|
|
486
|
+
params: f2 !== NULL ? fnParams(f2) : [],
|
|
487
|
+
returnType: f3 !== NULL ? node(f3) : null,
|
|
488
|
+
};
|
|
489
|
+
case 125: return {
|
|
490
|
+
type: "TSConstructorType", start, end,
|
|
491
|
+
abstract: !!(flags & 1),
|
|
492
|
+
typeParameters: f1 !== NULL ? node(f1) : null,
|
|
493
|
+
params: f2 !== NULL ? fnParams(f2) : [],
|
|
494
|
+
returnType: f3 !== NULL ? node(f3) : null,
|
|
495
|
+
};
|
|
496
|
+
case 126: return { type: "TSTypePredicate", start, end, parameterName: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null, asserts: !!(flags & 1) };
|
|
497
|
+
case 127: return { type: "TSTypeLiteral", start, end, members: nodeArr(f1, f0) };
|
|
498
|
+
case 128: return {
|
|
499
|
+
type: "TSMappedType", start, end,
|
|
500
|
+
key: node(f1),
|
|
501
|
+
constraint: node(f2),
|
|
502
|
+
nameType: f3 !== NULL ? node(f3) : null,
|
|
503
|
+
typeAnnotation: f4 !== NULL ? node(f4) : null,
|
|
504
|
+
optional: TS_MAPPED_OPTIONAL[(flags >> 0) & 3],
|
|
505
|
+
readonly: TS_MAPPED_READONLY[(flags >> 2) & 3],
|
|
506
|
+
};
|
|
507
|
+
case 129: { const r = { type: "TSPropertySignature", start, end, key: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1), optional: !!(flags & 2), readonly: !!(flags & 4) }; if (_isTs) { r.accessibility = null; r.static = false; } return r; }
|
|
508
|
+
case 130: return {
|
|
509
|
+
type: "TSMethodSignature", start, end,
|
|
510
|
+
key: node(f1),
|
|
511
|
+
computed: !!(flags & 4),
|
|
512
|
+
optional: !!(flags & 8),
|
|
513
|
+
kind: TS_METHOD_SIGNATURE_KINDS[(flags >> 0) & 3],
|
|
514
|
+
typeParameters: f2 !== NULL ? node(f2) : null,
|
|
515
|
+
params: f3 !== NULL ? fnParams(f3) : [],
|
|
516
|
+
returnType: f4 !== NULL ? node(f4) : null,
|
|
517
|
+
accessibility: null, readonly: false, static: false,
|
|
518
|
+
};
|
|
519
|
+
case 131: return {
|
|
520
|
+
type: "TSCallSignatureDeclaration", start, end,
|
|
521
|
+
typeParameters: f1 !== NULL ? node(f1) : null,
|
|
522
|
+
params: f2 !== NULL ? fnParams(f2) : [],
|
|
523
|
+
returnType: f3 !== NULL ? node(f3) : null,
|
|
524
|
+
};
|
|
525
|
+
case 132: return {
|
|
526
|
+
type: "TSConstructSignatureDeclaration", start, end,
|
|
527
|
+
typeParameters: f1 !== NULL ? node(f1) : null,
|
|
528
|
+
params: f2 !== NULL ? fnParams(f2) : [],
|
|
529
|
+
returnType: f3 !== NULL ? node(f3) : null,
|
|
530
|
+
};
|
|
531
|
+
case 133: { const r = { type: "TSIndexSignature", start, end, parameters: nodeArr(f1, f0), typeAnnotation: f2 !== NULL ? node(f2) : null, readonly: !!(flags & 1) }; if (_isTs) { r.static = !!(flags & 2); r.accessibility = null; } return r; }
|
|
532
|
+
case 134: return { type: "TSTypeAliasDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, typeAnnotation: f3 !== NULL ? node(f3) : null, declare: !!(flags & 1) };
|
|
533
|
+
case 135: return { type: "TSInterfaceDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, extends: nodeArr(f3, f0), body: f4 !== NULL ? node(f4) : null, declare: !!(flags & 1) };
|
|
534
|
+
case 136: return { type: "TSInterfaceBody", start, end, body: nodeArr(f1, f0) };
|
|
535
|
+
case 137: return { type: "TSInterfaceHeritage", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
|
|
536
|
+
case 138: return { type: "TSClassImplements", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
|
|
537
|
+
case 139: return { type: "TSEnumDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null, const: !!(flags & 1), declare: !!(flags & 2) };
|
|
538
|
+
case 140: return { type: "TSEnumBody", start, end, members: nodeArr(f1, f0) };
|
|
539
|
+
case 141: return { type: "TSEnumMember", start, end, id: f1 !== NULL ? node(f1) : null, initializer: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1) };
|
|
540
|
+
case 142: {
|
|
541
|
+
const r = {
|
|
542
|
+
type: "TSModuleDeclaration", start, end,
|
|
543
|
+
id: node(f1),
|
|
544
|
+
kind: TS_MODULE_KINDS[(flags >> 0) & 1],
|
|
545
|
+
declare: !!(flags & 2),
|
|
546
|
+
global: false,
|
|
547
|
+
};
|
|
548
|
+
if (f2 !== NULL) r.body = node(f2);
|
|
549
|
+
return r;
|
|
550
|
+
}
|
|
551
|
+
case 143: return { type: "TSModuleBlock", start, end, body: nodeArr(f1, f0) };
|
|
552
|
+
case 144: return {
|
|
553
|
+
type: "TSModuleDeclaration", start, end,
|
|
554
|
+
id: node(f1), body: node(f2),
|
|
555
|
+
kind: "global",
|
|
556
|
+
declare: !!(flags & 1),
|
|
557
|
+
global: true,
|
|
558
|
+
};
|
|
559
|
+
case 145: { const r = { type: "TSParameterProperty", start, end, decorators: nodeArr(f1, f0), parameter: f2 !== NULL ? node(f2) : null, override: !!(flags & 1), readonly: !!(flags & 2), accessibility: ACCESSIBILITY[(flags >> 2) & 3] }; if (_isTs) { r.static = false; } return r; }
|
|
560
|
+
case 146: return {
|
|
561
|
+
type: "Identifier", start, end,
|
|
562
|
+
decorators: [],
|
|
563
|
+
name: "this", optional: false,
|
|
564
|
+
typeAnnotation: f1 !== NULL ? node(f1) : null,
|
|
565
|
+
};
|
|
566
|
+
case 147: return { type: "TSAsExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null };
|
|
567
|
+
case 148: return { type: "TSSatisfiesExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null };
|
|
568
|
+
case 149: return { type: "TSTypeAssertion", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, expression: f2 !== NULL ? node(f2) : null };
|
|
569
|
+
case 150: return { type: "TSNonNullExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
570
|
+
case 151: return { type: "TSInstantiationExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
|
|
571
|
+
case 152: return { type: "TSExportAssignment", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
572
|
+
case 153: return { type: "TSNamespaceExportDeclaration", start, end, id: f1 !== NULL ? node(f1) : null };
|
|
573
|
+
case 154: return { type: "TSImportEqualsDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, moduleReference: f2 !== NULL ? node(f2) : null, importKind: IMPORT_EXPORT_KINDS[flags & 1] };
|
|
574
|
+
case 155: return { type: "TSExternalModuleReference", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
575
|
+
case 156: return { type: "JSXElement", start, end, openingElement: f1 !== NULL ? node(f1) : null, children: nodeArr(f2, f0), closingElement: f3 !== NULL ? node(f3) : null };
|
|
576
|
+
case 157: { const r = { type: "JSXOpeningElement", start, end, name: f1 !== NULL ? node(f1) : null, attributes: nodeArr(f2, f0), selfClosing: !!(flags & 1) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
|
|
577
|
+
case 158: return { type: "JSXClosingElement", start, end, name: f1 !== NULL ? node(f1) : null };
|
|
578
|
+
case 159: return { type: "JSXFragment", start, end, openingFragment: f1 !== NULL ? node(f1) : null, children: nodeArr(f2, f0), closingFragment: f3 !== NULL ? node(f3) : null };
|
|
579
|
+
case 160: return { type: "JSXOpeningFragment", start, end };
|
|
580
|
+
case 161: return { type: "JSXClosingFragment", start, end };
|
|
581
|
+
case 162: return { type: "JSXIdentifier", start, end, name: str(f1, f2) };
|
|
582
|
+
case 163: return { type: "JSXNamespacedName", start, end, namespace: f1 !== NULL ? node(f1) : null, name: f2 !== NULL ? node(f2) : null };
|
|
583
|
+
case 164: return { type: "JSXMemberExpression", start, end, object: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null };
|
|
584
|
+
case 165: return { type: "JSXAttribute", start, end, name: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null };
|
|
585
|
+
case 166: return { type: "JSXSpreadAttribute", start, end, argument: f1 !== NULL ? node(f1) : null };
|
|
586
|
+
case 167: return { type: "JSXExpressionContainer", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
587
|
+
case 168: return { type: "JSXEmptyExpression", start, end };
|
|
588
|
+
case 169: {
|
|
589
|
+
const t = str(f1, f2);
|
|
590
|
+
return { type: "JSXText", start, end, value: t, raw: t };
|
|
591
|
+
}
|
|
592
|
+
case 170: return { type: "JSXSpreadChild", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
const node = _attached ? nodeWithComments : _decode;
|
|
596
|
+
const lsOff = _cOff + commentCount * 20;
|
|
597
|
+
const dOff = lsOff + lineStartsCount * 4;
|
|
598
|
+
function _decodeComments() {
|
|
599
|
+
const out = new Array(commentCount);
|
|
600
|
+
for (let j = 0; j < commentCount; j++) {
|
|
601
|
+
const o = _cOff + j * 20;
|
|
602
|
+
const cf = _u8[o + 0];
|
|
603
|
+
const vs = dv.getUint32(o + 4, true),
|
|
604
|
+
ve = dv.getUint32(o + 8, true);
|
|
605
|
+
const ss = dv.getUint32(o + 12, true),
|
|
606
|
+
se = dv.getUint32(o + 16, true);
|
|
607
|
+
out[j] = {
|
|
608
|
+
type: (cf & 1) ? "Block" : "Line",
|
|
609
|
+
value: str(vs, ve),
|
|
610
|
+
start: _p(ss),
|
|
611
|
+
end: _p(se),
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
return out;
|
|
615
|
+
}
|
|
616
|
+
function _decodeLineStarts() {
|
|
617
|
+
const out = new Array(lineStartsCount);
|
|
618
|
+
if (_firstNa >= _srcLen) {
|
|
619
|
+
for (let j = 0; j < lineStartsCount; j++) {
|
|
620
|
+
out[j] = dv.getUint32(lsOff + j * 4, true);
|
|
621
|
+
}
|
|
622
|
+
return out;
|
|
623
|
+
}
|
|
624
|
+
for (let j = 0; j < lineStartsCount; j++) {
|
|
625
|
+
const v = dv.getUint32(lsOff + j * 4, true);
|
|
626
|
+
out[j] = v < _firstNa ? v : (v >= _srcLen ? pm[pm.length - 1] : pm[v - _firstNa]);
|
|
627
|
+
}
|
|
628
|
+
return out;
|
|
629
|
+
}
|
|
630
|
+
function _decodeDiagnostics() {
|
|
631
|
+
const out = new Array(diagCount);
|
|
632
|
+
let dp = dOff;
|
|
633
|
+
for (let j = 0; j < diagCount; j++) {
|
|
634
|
+
const sev = SEVERITY[_u8[dp]]; dp++;
|
|
635
|
+
const ds = _p(dv.getUint32(dp, true)); dp += 4;
|
|
636
|
+
const de = _p(dv.getUint32(dp, true)); dp += 4;
|
|
637
|
+
const ml = dv.getUint32(dp, true); dp += 4;
|
|
638
|
+
const msg = _td.decode(_u8.subarray(dp, dp + ml)); dp += ml;
|
|
639
|
+
const hh = _u8[dp]; dp++;
|
|
640
|
+
let help = null;
|
|
641
|
+
if (hh) {
|
|
642
|
+
const hl = dv.getUint32(dp, true); dp += 4;
|
|
643
|
+
help = _td.decode(_u8.subarray(dp, dp + hl)); dp += hl;
|
|
644
|
+
}
|
|
645
|
+
const lc = dv.getUint32(dp, true); dp += 4;
|
|
646
|
+
const labels = new Array(lc);
|
|
647
|
+
for (let k = 0; k < lc; k++) {
|
|
648
|
+
const ls = _p(dv.getUint32(dp, true)); dp += 4;
|
|
649
|
+
const le = _p(dv.getUint32(dp, true)); dp += 4;
|
|
650
|
+
const lml = dv.getUint32(dp, true); dp += 4;
|
|
651
|
+
labels[k] = {
|
|
652
|
+
start: ls,
|
|
653
|
+
end: le,
|
|
654
|
+
message: _td.decode(_u8.subarray(dp, dp + lml)),
|
|
655
|
+
};
|
|
656
|
+
dp += lml;
|
|
657
|
+
}
|
|
658
|
+
out[j] = { severity: sev, message: msg, start: ds, end: de, help, labels };
|
|
659
|
+
}
|
|
660
|
+
return out;
|
|
661
|
+
}
|
|
662
|
+
let _program, _lineStarts, _diagnostics, _comments;
|
|
663
|
+
function _getLineStarts() {
|
|
664
|
+
if (_lineStarts === undefined) _lineStarts = _decodeLineStarts();
|
|
665
|
+
return _lineStarts;
|
|
666
|
+
}
|
|
667
|
+
return {
|
|
668
|
+
get program() {
|
|
669
|
+
return _program !== undefined ? _program : (_program = node(progIdx));
|
|
670
|
+
},
|
|
671
|
+
get comments() {
|
|
672
|
+
return _comments !== undefined
|
|
673
|
+
? _comments
|
|
674
|
+
: (_comments = _decodeComments());
|
|
675
|
+
},
|
|
676
|
+
get diagnostics() {
|
|
677
|
+
return _diagnostics !== undefined
|
|
678
|
+
? _diagnostics
|
|
679
|
+
: (_diagnostics = _decodeDiagnostics());
|
|
680
|
+
},
|
|
681
|
+
get lineStarts() { return _getLineStarts(); },
|
|
682
|
+
locOf(offset) {
|
|
683
|
+
const ls = _getLineStarts();
|
|
684
|
+
let lo = 0, hi = ls.length;
|
|
685
|
+
while (lo < hi) {
|
|
686
|
+
const mid = (lo + hi) >>> 1;
|
|
687
|
+
if (ls[mid] <= offset) lo = mid + 1; else hi = mid;
|
|
688
|
+
}
|
|
689
|
+
return { line: lo, column: offset - ls[lo - 1] };
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
export { decode };
|