hermes-parser 0.4.6 → 0.6.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 +1 -1
- package/dist/HermesAST.js.flow +57 -0
- package/dist/HermesASTAdapter.js +134 -146
- package/dist/HermesASTAdapter.js.flow +178 -0
- package/dist/HermesParser.js +39 -25
- package/dist/HermesParser.js.flow +123 -0
- package/dist/HermesParserDecodeUTF8String.js +17 -12
- package/dist/HermesParserDecodeUTF8String.js.flow +65 -0
- package/dist/HermesParserDeserializer.js +200 -207
- package/dist/HermesParserDeserializer.js.flow +261 -0
- package/dist/HermesParserNodeDeserializers.js +60 -28
- package/dist/HermesParserNodeDeserializers.js.flow +16 -0
- package/dist/HermesParserWASM.js +2 -2
- package/dist/HermesParserWASM.js.flow +75 -0
- package/dist/HermesToBabelAdapter.js +332 -346
- package/dist/HermesToBabelAdapter.js.flow +383 -0
- package/dist/HermesToESTreeAdapter.js +186 -161
- package/dist/HermesToESTreeAdapter.js.flow +220 -0
- package/dist/ParserOptions.js.flow +18 -0
- package/dist/generated/visitor-keys.js +605 -0
- package/dist/generated/visitor-keys.js.flow +17 -0
- package/dist/index.js +32 -19
- package/dist/index.js.flow +72 -13
- package/package.json +7 -1
- package/dist/HermesParserVisitorKeys.js +0 -729
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
HermesSourceLocation,
|
|
15
|
+
HermesNode,
|
|
16
|
+
HermesToken,
|
|
17
|
+
HermesComment,
|
|
18
|
+
} from './HermesAST';
|
|
19
|
+
import typeof HermesParserWASM from './HermesParserWASM';
|
|
20
|
+
import type {ParserOptions} from './ParserOptions';
|
|
21
|
+
|
|
22
|
+
import HermesParserDecodeUTF8String from './HermesParserDecodeUTF8String';
|
|
23
|
+
import NODE_DESERIALIZERS from './HermesParserNodeDeserializers';
|
|
24
|
+
|
|
25
|
+
export default class HermesParserDeserializer {
|
|
26
|
+
programBufferIdx: number;
|
|
27
|
+
positionBufferIdx: number;
|
|
28
|
+
+positionBufferSize: number;
|
|
29
|
+
+locMap: {[number]: HermesSourceLocation};
|
|
30
|
+
+HEAPU8: HermesParserWASM['HEAPU8'];
|
|
31
|
+
+HEAPU32: HermesParserWASM['HEAPU32'];
|
|
32
|
+
+HEAPF64: HermesParserWASM['HEAPF64'];
|
|
33
|
+
+options: ParserOptions;
|
|
34
|
+
|
|
35
|
+
// Matches StoredComment::Kind enum in JSLexer.h
|
|
36
|
+
+commentTypes: $ReadOnlyArray<HermesComment['type']> = [
|
|
37
|
+
'CommentLine',
|
|
38
|
+
'CommentBlock',
|
|
39
|
+
'InterpreterDirective',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
// Matches TokenType enum in HermesParserJSSerializer.h
|
|
43
|
+
+tokenTypes: $ReadOnlyArray<HermesToken['type']> = [
|
|
44
|
+
'Boolean',
|
|
45
|
+
'Identifier',
|
|
46
|
+
'Keyword',
|
|
47
|
+
'Null',
|
|
48
|
+
'Numeric',
|
|
49
|
+
'BigInt',
|
|
50
|
+
'Punctuator',
|
|
51
|
+
'String',
|
|
52
|
+
'RegularExpression',
|
|
53
|
+
'Template',
|
|
54
|
+
'JSXText',
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
constructor(
|
|
58
|
+
programBuffer: number,
|
|
59
|
+
positionBuffer: number,
|
|
60
|
+
positionBufferSize: number,
|
|
61
|
+
wasmParser: HermesParserWASM,
|
|
62
|
+
options: ParserOptions,
|
|
63
|
+
) {
|
|
64
|
+
// Program and position buffer are memory addresses, so we must convert
|
|
65
|
+
// into indices into HEAPU32 (an array of 4-byte integers).
|
|
66
|
+
this.programBufferIdx = programBuffer / 4;
|
|
67
|
+
this.positionBufferIdx = positionBuffer / 4;
|
|
68
|
+
|
|
69
|
+
this.positionBufferSize = positionBufferSize;
|
|
70
|
+
this.locMap = {};
|
|
71
|
+
|
|
72
|
+
this.HEAPU8 = wasmParser.HEAPU8;
|
|
73
|
+
this.HEAPU32 = wasmParser.HEAPU32;
|
|
74
|
+
this.HEAPF64 = wasmParser.HEAPF64;
|
|
75
|
+
|
|
76
|
+
this.options = options;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Consume and return the next 4 bytes in the program buffer.
|
|
81
|
+
*/
|
|
82
|
+
next(): number {
|
|
83
|
+
const num = this.HEAPU32[this.programBufferIdx++];
|
|
84
|
+
return num;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
deserialize(): HermesNode {
|
|
88
|
+
const program: HermesNode = {
|
|
89
|
+
type: 'Program',
|
|
90
|
+
loc: this.addEmptyLoc(),
|
|
91
|
+
body: this.deserializeNodeList(),
|
|
92
|
+
comments: this.deserializeComments(),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
if (this.options.tokens === true) {
|
|
96
|
+
program.tokens = this.deserializeTokens();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this.fillLocs();
|
|
100
|
+
|
|
101
|
+
return program;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Booleans are serialized as a single 4-byte integer.
|
|
106
|
+
*/
|
|
107
|
+
deserializeBoolean(): boolean {
|
|
108
|
+
return Boolean(this.next());
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Numbers are serialized directly into program buffer, taking up 8 bytes
|
|
113
|
+
* preceded by 4 bytes of alignment padding if necessary.
|
|
114
|
+
*/
|
|
115
|
+
deserializeNumber(): number {
|
|
116
|
+
let floatIdx;
|
|
117
|
+
|
|
118
|
+
// Numbers are aligned on 8-byte boundaries, so skip padding if we are at
|
|
119
|
+
// an odd index into the 4-byte aligned program buffer.
|
|
120
|
+
if (this.programBufferIdx % 2 === 0) {
|
|
121
|
+
floatIdx = this.programBufferIdx / 2;
|
|
122
|
+
this.programBufferIdx += 2;
|
|
123
|
+
} else {
|
|
124
|
+
floatIdx = (this.programBufferIdx + 1) / 2;
|
|
125
|
+
this.programBufferIdx += 3;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return this.HEAPF64[floatIdx];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Strings are serialized as a 4-byte pointer into the heap, followed
|
|
133
|
+
* by their size as a 4-byte integer. The size is only present if the
|
|
134
|
+
* pointer is non-null.
|
|
135
|
+
*/
|
|
136
|
+
deserializeString(): ?string {
|
|
137
|
+
const ptr = this.next();
|
|
138
|
+
if (ptr === 0) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const size = this.next();
|
|
143
|
+
|
|
144
|
+
return HermesParserDecodeUTF8String(ptr, size, this.HEAPU8);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Nodes are serialized as a 4-byte integer denoting their node kind,
|
|
149
|
+
* followed by a 4-byte loc ID, followed by serialized node properties.
|
|
150
|
+
*
|
|
151
|
+
* If the node kind is 0 the node is null, otherwise the node kind - 1 is an
|
|
152
|
+
* index into the array of node deserialization functions.
|
|
153
|
+
*/
|
|
154
|
+
deserializeNode(): ?HermesNode {
|
|
155
|
+
const nodeType = this.next();
|
|
156
|
+
if (nodeType === 0) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const nodeDeserializer = NODE_DESERIALIZERS[nodeType - 1].bind(this);
|
|
161
|
+
return nodeDeserializer();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Node lists are serialized as a 4-byte integer denoting the number of
|
|
166
|
+
* elements in the list, followed by the serialized elements.
|
|
167
|
+
*/
|
|
168
|
+
deserializeNodeList(): Array<?HermesNode> {
|
|
169
|
+
const size = this.next();
|
|
170
|
+
const nodeList = [];
|
|
171
|
+
|
|
172
|
+
for (let i = 0; i < size; i++) {
|
|
173
|
+
nodeList.push(this.deserializeNode());
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return nodeList;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Comments are serialized as a node list, where each comment is serialized
|
|
181
|
+
* as a 4-byte integer denoting comment type, followed by a 4-byte value
|
|
182
|
+
* denoting the loc ID, followed by a serialized string for the comment value.
|
|
183
|
+
*/
|
|
184
|
+
deserializeComments(): Array<HermesComment> {
|
|
185
|
+
const size = this.next();
|
|
186
|
+
const comments = [];
|
|
187
|
+
|
|
188
|
+
for (let i = 0; i < size; i++) {
|
|
189
|
+
const commentType = this.commentTypes[this.next()];
|
|
190
|
+
const loc = this.addEmptyLoc();
|
|
191
|
+
const value = this.deserializeString();
|
|
192
|
+
comments.push({
|
|
193
|
+
type: commentType,
|
|
194
|
+
loc,
|
|
195
|
+
value,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return comments;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
deserializeTokens(): Array<HermesToken> {
|
|
203
|
+
const size = this.next();
|
|
204
|
+
const tokens = [];
|
|
205
|
+
|
|
206
|
+
for (let i = 0; i < size; i++) {
|
|
207
|
+
const tokenType = this.tokenTypes[this.next()];
|
|
208
|
+
const loc = this.addEmptyLoc();
|
|
209
|
+
const value = this.deserializeString();
|
|
210
|
+
tokens.push({
|
|
211
|
+
type: tokenType,
|
|
212
|
+
loc,
|
|
213
|
+
value,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return tokens;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* While deserializing the AST locations are represented by
|
|
222
|
+
* a 4-byte loc ID. This is used to create a map of loc IDs to empty loc
|
|
223
|
+
* objects that are filled after the AST has been deserialized.
|
|
224
|
+
*/
|
|
225
|
+
addEmptyLoc(): HermesSourceLocation {
|
|
226
|
+
// $FlowExpectedError
|
|
227
|
+
const loc: HermesSourceLocation = {};
|
|
228
|
+
this.locMap[this.next()] = loc;
|
|
229
|
+
return loc;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Positions are serialized as a loc ID which denotes which loc it is associated with,
|
|
234
|
+
* followed by kind which denotes whether it is a start or end position,
|
|
235
|
+
* followed by line, column, and offset (4-bytes each).
|
|
236
|
+
*/
|
|
237
|
+
fillLocs(): void {
|
|
238
|
+
for (let i = 0; i < this.positionBufferSize; i++) {
|
|
239
|
+
const locId = this.HEAPU32[this.positionBufferIdx++];
|
|
240
|
+
const kind = this.HEAPU32[this.positionBufferIdx++];
|
|
241
|
+
const line = this.HEAPU32[this.positionBufferIdx++];
|
|
242
|
+
const column = this.HEAPU32[this.positionBufferIdx++];
|
|
243
|
+
const offset = this.HEAPU32[this.positionBufferIdx++];
|
|
244
|
+
|
|
245
|
+
const loc = this.locMap[locId];
|
|
246
|
+
if (kind === 0) {
|
|
247
|
+
loc.start = {
|
|
248
|
+
line,
|
|
249
|
+
column,
|
|
250
|
+
};
|
|
251
|
+
loc.rangeStart = offset;
|
|
252
|
+
} else {
|
|
253
|
+
loc.end = {
|
|
254
|
+
line,
|
|
255
|
+
column,
|
|
256
|
+
};
|
|
257
|
+
loc.rangeEnd = offset;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c)
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
+
*
|
|
7
8
|
* @format
|
|
8
9
|
*/
|
|
10
|
+
// lint directives to let us do some basic validation of generated files
|
|
11
|
+
|
|
12
|
+
/* eslint no-undef: 'error', no-unused-vars: ['error', {vars: "local"}], no-redeclare: 'error' */
|
|
13
|
+
|
|
14
|
+
/* global $NonMaybeType, $Partial, $ReadOnly, $ReadOnlyArray */
|
|
9
15
|
'use strict';
|
|
10
16
|
|
|
11
17
|
function deserializeEmpty() {
|
|
@@ -126,7 +132,7 @@ function deserializeForOfStatement() {
|
|
|
126
132
|
left: this.deserializeNode(),
|
|
127
133
|
right: this.deserializeNode(),
|
|
128
134
|
body: this.deserializeNode(),
|
|
129
|
-
|
|
135
|
+
await: this.deserializeBoolean()
|
|
130
136
|
};
|
|
131
137
|
}
|
|
132
138
|
|
|
@@ -299,6 +305,14 @@ function deserializeRegExpLiteral() {
|
|
|
299
305
|
};
|
|
300
306
|
}
|
|
301
307
|
|
|
308
|
+
function deserializeBigIntLiteral() {
|
|
309
|
+
return {
|
|
310
|
+
type: 'BigIntLiteral',
|
|
311
|
+
loc: this.addEmptyLoc(),
|
|
312
|
+
bigint: this.deserializeString()
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
302
316
|
function deserializeThisExpression() {
|
|
303
317
|
return {
|
|
304
318
|
type: 'ThisExpression',
|
|
@@ -628,7 +642,7 @@ function deserializeClassDeclaration() {
|
|
|
628
642
|
typeParameters: this.deserializeNode(),
|
|
629
643
|
superClass: this.deserializeNode(),
|
|
630
644
|
superTypeParameters: this.deserializeNode(),
|
|
631
|
-
|
|
645
|
+
implements: this.deserializeNodeList(),
|
|
632
646
|
decorators: this.deserializeNodeList(),
|
|
633
647
|
body: this.deserializeNode()
|
|
634
648
|
};
|
|
@@ -642,7 +656,7 @@ function deserializeClassExpression() {
|
|
|
642
656
|
typeParameters: this.deserializeNode(),
|
|
643
657
|
superClass: this.deserializeNode(),
|
|
644
658
|
superTypeParameters: this.deserializeNode(),
|
|
645
|
-
|
|
659
|
+
implements: this.deserializeNodeList(),
|
|
646
660
|
decorators: this.deserializeNodeList(),
|
|
647
661
|
body: this.deserializeNode()
|
|
648
662
|
};
|
|
@@ -663,7 +677,7 @@ function deserializeClassProperty() {
|
|
|
663
677
|
key: this.deserializeNode(),
|
|
664
678
|
value: this.deserializeNode(),
|
|
665
679
|
computed: this.deserializeBoolean(),
|
|
666
|
-
|
|
680
|
+
static: this.deserializeBoolean(),
|
|
667
681
|
declare: this.deserializeBoolean(),
|
|
668
682
|
optional: this.deserializeBoolean(),
|
|
669
683
|
variance: this.deserializeNode(),
|
|
@@ -677,7 +691,7 @@ function deserializeClassPrivateProperty() {
|
|
|
677
691
|
loc: this.addEmptyLoc(),
|
|
678
692
|
key: this.deserializeNode(),
|
|
679
693
|
value: this.deserializeNode(),
|
|
680
|
-
|
|
694
|
+
static: this.deserializeBoolean(),
|
|
681
695
|
declare: this.deserializeBoolean(),
|
|
682
696
|
optional: this.deserializeBoolean(),
|
|
683
697
|
variance: this.deserializeNode(),
|
|
@@ -693,7 +707,7 @@ function deserializeMethodDefinition() {
|
|
|
693
707
|
value: this.deserializeNode(),
|
|
694
708
|
kind: this.deserializeString(),
|
|
695
709
|
computed: this.deserializeBoolean(),
|
|
696
|
-
|
|
710
|
+
static: this.deserializeBoolean()
|
|
697
711
|
};
|
|
698
712
|
}
|
|
699
713
|
|
|
@@ -703,7 +717,7 @@ function deserializeImportDeclaration() {
|
|
|
703
717
|
loc: this.addEmptyLoc(),
|
|
704
718
|
specifiers: this.deserializeNodeList(),
|
|
705
719
|
source: this.deserializeNode(),
|
|
706
|
-
|
|
720
|
+
assertions: this.deserializeNodeList(),
|
|
707
721
|
importKind: this.deserializeString()
|
|
708
722
|
};
|
|
709
723
|
}
|
|
@@ -915,6 +929,15 @@ function deserializeJSXSpreadAttribute() {
|
|
|
915
929
|
};
|
|
916
930
|
}
|
|
917
931
|
|
|
932
|
+
function deserializeJSXStringLiteral() {
|
|
933
|
+
return {
|
|
934
|
+
type: 'JSXStringLiteral',
|
|
935
|
+
loc: this.addEmptyLoc(),
|
|
936
|
+
value: this.deserializeString(),
|
|
937
|
+
raw: this.deserializeString()
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
|
|
918
941
|
function deserializeJSXText() {
|
|
919
942
|
return {
|
|
920
943
|
type: 'JSXText',
|
|
@@ -990,7 +1013,8 @@ function deserializeStringLiteralTypeAnnotation() {
|
|
|
990
1013
|
return {
|
|
991
1014
|
type: 'StringLiteralTypeAnnotation',
|
|
992
1015
|
loc: this.addEmptyLoc(),
|
|
993
|
-
value: this.deserializeString()
|
|
1016
|
+
value: this.deserializeString(),
|
|
1017
|
+
raw: this.deserializeString()
|
|
994
1018
|
};
|
|
995
1019
|
}
|
|
996
1020
|
|
|
@@ -1003,6 +1027,14 @@ function deserializeNumberLiteralTypeAnnotation() {
|
|
|
1003
1027
|
};
|
|
1004
1028
|
}
|
|
1005
1029
|
|
|
1030
|
+
function deserializeBigIntLiteralTypeAnnotation() {
|
|
1031
|
+
return {
|
|
1032
|
+
type: 'BigIntLiteralTypeAnnotation',
|
|
1033
|
+
loc: this.addEmptyLoc(),
|
|
1034
|
+
raw: this.deserializeString()
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1006
1038
|
function deserializeBooleanTypeAnnotation() {
|
|
1007
1039
|
return {
|
|
1008
1040
|
type: 'BooleanTypeAnnotation',
|
|
@@ -1059,7 +1091,7 @@ function deserializeFunctionTypeAnnotation() {
|
|
|
1059
1091
|
type: 'FunctionTypeAnnotation',
|
|
1060
1092
|
loc: this.addEmptyLoc(),
|
|
1061
1093
|
params: this.deserializeNodeList(),
|
|
1062
|
-
|
|
1094
|
+
this: this.deserializeNode(),
|
|
1063
1095
|
returnType: this.deserializeNode(),
|
|
1064
1096
|
rest: this.deserializeNode(),
|
|
1065
1097
|
typeParameters: this.deserializeNode()
|
|
@@ -1165,7 +1197,7 @@ function deserializeInterfaceTypeAnnotation() {
|
|
|
1165
1197
|
return {
|
|
1166
1198
|
type: 'InterfaceTypeAnnotation',
|
|
1167
1199
|
loc: this.addEmptyLoc(),
|
|
1168
|
-
|
|
1200
|
+
extends: this.deserializeNodeList(),
|
|
1169
1201
|
body: this.deserializeNode()
|
|
1170
1202
|
};
|
|
1171
1203
|
}
|
|
@@ -1197,7 +1229,7 @@ function deserializeInterfaceDeclaration() {
|
|
|
1197
1229
|
loc: this.addEmptyLoc(),
|
|
1198
1230
|
id: this.deserializeNode(),
|
|
1199
1231
|
typeParameters: this.deserializeNode(),
|
|
1200
|
-
|
|
1232
|
+
extends: this.deserializeNodeList(),
|
|
1201
1233
|
body: this.deserializeNode()
|
|
1202
1234
|
};
|
|
1203
1235
|
}
|
|
@@ -1229,7 +1261,7 @@ function deserializeDeclareInterface() {
|
|
|
1229
1261
|
loc: this.addEmptyLoc(),
|
|
1230
1262
|
id: this.deserializeNode(),
|
|
1231
1263
|
typeParameters: this.deserializeNode(),
|
|
1232
|
-
|
|
1264
|
+
extends: this.deserializeNodeList(),
|
|
1233
1265
|
body: this.deserializeNode()
|
|
1234
1266
|
};
|
|
1235
1267
|
}
|
|
@@ -1240,8 +1272,8 @@ function deserializeDeclareClass() {
|
|
|
1240
1272
|
loc: this.addEmptyLoc(),
|
|
1241
1273
|
id: this.deserializeNode(),
|
|
1242
1274
|
typeParameters: this.deserializeNode(),
|
|
1243
|
-
|
|
1244
|
-
|
|
1275
|
+
extends: this.deserializeNodeList(),
|
|
1276
|
+
implements: this.deserializeNodeList(),
|
|
1245
1277
|
mixins: this.deserializeNodeList(),
|
|
1246
1278
|
body: this.deserializeNode()
|
|
1247
1279
|
};
|
|
@@ -1271,7 +1303,7 @@ function deserializeDeclareExportDeclaration() {
|
|
|
1271
1303
|
declaration: this.deserializeNode(),
|
|
1272
1304
|
specifiers: this.deserializeNodeList(),
|
|
1273
1305
|
source: this.deserializeNode(),
|
|
1274
|
-
|
|
1306
|
+
default: this.deserializeBoolean()
|
|
1275
1307
|
};
|
|
1276
1308
|
}
|
|
1277
1309
|
|
|
@@ -1348,7 +1380,7 @@ function deserializeObjectTypeProperty() {
|
|
|
1348
1380
|
value: this.deserializeNode(),
|
|
1349
1381
|
method: this.deserializeBoolean(),
|
|
1350
1382
|
optional: this.deserializeBoolean(),
|
|
1351
|
-
|
|
1383
|
+
static: this.deserializeBoolean(),
|
|
1352
1384
|
proto: this.deserializeBoolean(),
|
|
1353
1385
|
variance: this.deserializeNode(),
|
|
1354
1386
|
kind: this.deserializeString()
|
|
@@ -1370,7 +1402,7 @@ function deserializeObjectTypeInternalSlot() {
|
|
|
1370
1402
|
id: this.deserializeNode(),
|
|
1371
1403
|
value: this.deserializeNode(),
|
|
1372
1404
|
optional: this.deserializeBoolean(),
|
|
1373
|
-
|
|
1405
|
+
static: this.deserializeBoolean(),
|
|
1374
1406
|
method: this.deserializeBoolean()
|
|
1375
1407
|
};
|
|
1376
1408
|
}
|
|
@@ -1380,7 +1412,7 @@ function deserializeObjectTypeCallProperty() {
|
|
|
1380
1412
|
type: 'ObjectTypeCallProperty',
|
|
1381
1413
|
loc: this.addEmptyLoc(),
|
|
1382
1414
|
value: this.deserializeNode(),
|
|
1383
|
-
|
|
1415
|
+
static: this.deserializeBoolean()
|
|
1384
1416
|
};
|
|
1385
1417
|
}
|
|
1386
1418
|
|
|
@@ -1391,7 +1423,7 @@ function deserializeObjectTypeIndexer() {
|
|
|
1391
1423
|
id: this.deserializeNode(),
|
|
1392
1424
|
key: this.deserializeNode(),
|
|
1393
1425
|
value: this.deserializeNode(),
|
|
1394
|
-
|
|
1426
|
+
static: this.deserializeBoolean(),
|
|
1395
1427
|
variance: this.deserializeNode()
|
|
1396
1428
|
};
|
|
1397
1429
|
}
|
|
@@ -1419,7 +1451,7 @@ function deserializeTypeParameter() {
|
|
|
1419
1451
|
name: this.deserializeString(),
|
|
1420
1452
|
bound: this.deserializeNode(),
|
|
1421
1453
|
variance: this.deserializeNode(),
|
|
1422
|
-
|
|
1454
|
+
default: this.deserializeNode()
|
|
1423
1455
|
};
|
|
1424
1456
|
}
|
|
1425
1457
|
|
|
@@ -1700,8 +1732,8 @@ function deserializeTSParameterProperty() {
|
|
|
1700
1732
|
parameter: this.deserializeNode(),
|
|
1701
1733
|
accessibility: this.deserializeString(),
|
|
1702
1734
|
readonly: this.deserializeBoolean(),
|
|
1703
|
-
|
|
1704
|
-
|
|
1735
|
+
static: this.deserializeBoolean(),
|
|
1736
|
+
export: this.deserializeBoolean()
|
|
1705
1737
|
};
|
|
1706
1738
|
}
|
|
1707
1739
|
|
|
@@ -1721,7 +1753,7 @@ function deserializeTSInterfaceDeclaration() {
|
|
|
1721
1753
|
loc: this.addEmptyLoc(),
|
|
1722
1754
|
id: this.deserializeNode(),
|
|
1723
1755
|
body: this.deserializeNode(),
|
|
1724
|
-
|
|
1756
|
+
extends: this.deserializeNodeList(),
|
|
1725
1757
|
typeParameters: this.deserializeNode()
|
|
1726
1758
|
};
|
|
1727
1759
|
}
|
|
@@ -1801,7 +1833,7 @@ function deserializeTSTypeParameter() {
|
|
|
1801
1833
|
loc: this.addEmptyLoc(),
|
|
1802
1834
|
name: this.deserializeNode(),
|
|
1803
1835
|
constraint: this.deserializeNode(),
|
|
1804
|
-
|
|
1836
|
+
default: this.deserializeNode()
|
|
1805
1837
|
};
|
|
1806
1838
|
}
|
|
1807
1839
|
|
|
@@ -1866,8 +1898,8 @@ function deserializeTSPropertySignature() {
|
|
|
1866
1898
|
optional: this.deserializeBoolean(),
|
|
1867
1899
|
computed: this.deserializeBoolean(),
|
|
1868
1900
|
readonly: this.deserializeBoolean(),
|
|
1869
|
-
|
|
1870
|
-
|
|
1901
|
+
static: this.deserializeBoolean(),
|
|
1902
|
+
export: this.deserializeBoolean()
|
|
1871
1903
|
};
|
|
1872
1904
|
}
|
|
1873
1905
|
|
|
@@ -1948,4 +1980,4 @@ function deserializeCoverLast() {
|
|
|
1948
1980
|
throw new Error('Cover' + ' should not appear in program buffer');
|
|
1949
1981
|
}
|
|
1950
1982
|
|
|
1951
|
-
module.exports = [deserializeEmpty, deserializeMetadata, deserializeFunctionLikeFirst, deserializeProgram, deserializeFunctionExpression, deserializeArrowFunctionExpression, deserializeFunctionDeclaration, deserializeFunctionLikeLast, deserializeStatementFirst, deserializeLoopStatementFirst, deserializeWhileStatement, deserializeDoWhileStatement, deserializeForInStatement, deserializeForOfStatement, deserializeForStatement, deserializeLoopStatementLast, deserializeDebuggerStatement, deserializeEmptyStatement, deserializeBlockStatement, deserializeBreakStatement, deserializeContinueStatement, deserializeThrowStatement, deserializeReturnStatement, deserializeWithStatement, deserializeSwitchStatement, deserializeLabeledStatement, deserializeExpressionStatement, deserializeTryStatement, deserializeIfStatement, deserializeStatementLast, deserializeNullLiteral, deserializeBooleanLiteral, deserializeStringLiteral, deserializeNumericLiteral, deserializeRegExpLiteral, deserializeThisExpression, deserializeSuper, deserializeSequenceExpression, deserializeObjectExpression, deserializeArrayExpression, deserializeSpreadElement, deserializeNewExpression, deserializeYieldExpression, deserializeAwaitExpression, deserializeImportExpression, deserializeCallExpressionLikeFirst, deserializeCallExpression, deserializeOptionalCallExpression, deserializeCallExpressionLikeLast, deserializeAssignmentExpression, deserializeUnaryExpression, deserializeUpdateExpression, deserializeMemberExpressionLikeFirst, deserializeMemberExpression, deserializeOptionalMemberExpression, deserializeMemberExpressionLikeLast, deserializeLogicalExpression, deserializeConditionalExpression, deserializeBinaryExpression, deserializeDirective, deserializeDirectiveLiteral, deserializeIdentifier, deserializePrivateName, deserializeMetaProperty, deserializeSwitchCase, deserializeCatchClause, deserializeVariableDeclarator, deserializeVariableDeclaration, deserializeTemplateLiteral, deserializeTaggedTemplateExpression, deserializeTemplateElement, deserializeProperty, deserializeClassDeclaration, deserializeClassExpression, deserializeClassBody, deserializeClassProperty, deserializeClassPrivateProperty, deserializeMethodDefinition, deserializeImportDeclaration, deserializeImportSpecifier, deserializeImportDefaultSpecifier, deserializeImportNamespaceSpecifier, deserializeImportAttribute, deserializeExportNamedDeclaration, deserializeExportSpecifier, deserializeExportNamespaceSpecifier, deserializeExportDefaultDeclaration, deserializeExportAllDeclaration, deserializePatternFirst, deserializeObjectPattern, deserializeArrayPattern, deserializeRestElement, deserializeAssignmentPattern, deserializePatternLast, deserializeJSXIdentifier, deserializeJSXMemberExpression, deserializeJSXNamespacedName, deserializeJSXEmptyExpression, deserializeJSXExpressionContainer, deserializeJSXSpreadChild, deserializeJSXOpeningElement, deserializeJSXClosingElement, deserializeJSXAttribute, deserializeJSXSpreadAttribute, deserializeJSXText, deserializeJSXElement, deserializeJSXFragment, deserializeJSXOpeningFragment, deserializeJSXClosingFragment, deserializeExistsTypeAnnotation, deserializeEmptyTypeAnnotation, deserializeStringTypeAnnotation, deserializeNumberTypeAnnotation, deserializeStringLiteralTypeAnnotation, deserializeNumberLiteralTypeAnnotation, deserializeBooleanTypeAnnotation, deserializeBooleanLiteralTypeAnnotation, deserializeNullLiteralTypeAnnotation, deserializeSymbolTypeAnnotation, deserializeAnyTypeAnnotation, deserializeMixedTypeAnnotation, deserializeVoidTypeAnnotation, deserializeFunctionTypeAnnotation, deserializeFunctionTypeParam, deserializeNullableTypeAnnotation, deserializeQualifiedTypeIdentifier, deserializeTypeofTypeAnnotation, deserializeTupleTypeAnnotation, deserializeArrayTypeAnnotation, deserializeUnionTypeAnnotation, deserializeIntersectionTypeAnnotation, deserializeGenericTypeAnnotation, deserializeIndexedAccessType, deserializeOptionalIndexedAccessType, deserializeInterfaceTypeAnnotation, deserializeTypeAlias, deserializeOpaqueType, deserializeInterfaceDeclaration, deserializeDeclareTypeAlias, deserializeDeclareOpaqueType, deserializeDeclareInterface, deserializeDeclareClass, deserializeDeclareFunction, deserializeDeclareVariable, deserializeDeclareExportDeclaration, deserializeDeclareExportAllDeclaration, deserializeDeclareModule, deserializeDeclareModuleExports, deserializeInterfaceExtends, deserializeClassImplements, deserializeTypeAnnotation, deserializeObjectTypeAnnotation, deserializeObjectTypeProperty, deserializeObjectTypeSpreadProperty, deserializeObjectTypeInternalSlot, deserializeObjectTypeCallProperty, deserializeObjectTypeIndexer, deserializeVariance, deserializeTypeParameterDeclaration, deserializeTypeParameter, deserializeTypeParameterInstantiation, deserializeTypeCastExpression, deserializeInferredPredicate, deserializeDeclaredPredicate, deserializeEnumDeclaration, deserializeEnumStringBody, deserializeEnumNumberBody, deserializeEnumBooleanBody, deserializeEnumSymbolBody, deserializeEnumDefaultedMember, deserializeEnumStringMember, deserializeEnumNumberMember, deserializeEnumBooleanMember, deserializeTSTypeAnnotation, deserializeTSAnyKeyword, deserializeTSNumberKeyword, deserializeTSBooleanKeyword, deserializeTSStringKeyword, deserializeTSSymbolKeyword, deserializeTSVoidKeyword, deserializeTSThisType, deserializeTSLiteralType, deserializeTSIndexedAccessType, deserializeTSArrayType, deserializeTSTypeReference, deserializeTSQualifiedName, deserializeTSFunctionType, deserializeTSConstructorType, deserializeTSTypePredicate, deserializeTSTupleType, deserializeTSTypeAssertion, deserializeTSAsExpression, deserializeTSParameterProperty, deserializeTSTypeAliasDeclaration, deserializeTSInterfaceDeclaration, deserializeTSInterfaceHeritage, deserializeTSInterfaceBody, deserializeTSEnumDeclaration, deserializeTSEnumMember, deserializeTSModuleDeclaration, deserializeTSModuleBlock, deserializeTSModuleMember, deserializeTSTypeParameterDeclaration, deserializeTSTypeParameter, deserializeTSTypeParameterInstantiation, deserializeTSUnionType, deserializeTSIntersectionType, deserializeTSTypeQuery, deserializeTSConditionalType, deserializeTSTypeLiteral, deserializeTSPropertySignature, deserializeTSMethodSignature, deserializeTSIndexSignature, deserializeTSCallSignatureDeclaration, deserializeCoverFirst, deserializeCoverEmptyArgs, deserializeCoverTrailingComma, deserializeCoverInitializer, deserializeCoverRestElement, deserializeCoverTypedIdentifier, deserializeCoverLast];
|
|
1983
|
+
module.exports = [deserializeEmpty, deserializeMetadata, deserializeFunctionLikeFirst, deserializeProgram, deserializeFunctionExpression, deserializeArrowFunctionExpression, deserializeFunctionDeclaration, deserializeFunctionLikeLast, deserializeStatementFirst, deserializeLoopStatementFirst, deserializeWhileStatement, deserializeDoWhileStatement, deserializeForInStatement, deserializeForOfStatement, deserializeForStatement, deserializeLoopStatementLast, deserializeDebuggerStatement, deserializeEmptyStatement, deserializeBlockStatement, deserializeBreakStatement, deserializeContinueStatement, deserializeThrowStatement, deserializeReturnStatement, deserializeWithStatement, deserializeSwitchStatement, deserializeLabeledStatement, deserializeExpressionStatement, deserializeTryStatement, deserializeIfStatement, deserializeStatementLast, deserializeNullLiteral, deserializeBooleanLiteral, deserializeStringLiteral, deserializeNumericLiteral, deserializeRegExpLiteral, deserializeBigIntLiteral, deserializeThisExpression, deserializeSuper, deserializeSequenceExpression, deserializeObjectExpression, deserializeArrayExpression, deserializeSpreadElement, deserializeNewExpression, deserializeYieldExpression, deserializeAwaitExpression, deserializeImportExpression, deserializeCallExpressionLikeFirst, deserializeCallExpression, deserializeOptionalCallExpression, deserializeCallExpressionLikeLast, deserializeAssignmentExpression, deserializeUnaryExpression, deserializeUpdateExpression, deserializeMemberExpressionLikeFirst, deserializeMemberExpression, deserializeOptionalMemberExpression, deserializeMemberExpressionLikeLast, deserializeLogicalExpression, deserializeConditionalExpression, deserializeBinaryExpression, deserializeDirective, deserializeDirectiveLiteral, deserializeIdentifier, deserializePrivateName, deserializeMetaProperty, deserializeSwitchCase, deserializeCatchClause, deserializeVariableDeclarator, deserializeVariableDeclaration, deserializeTemplateLiteral, deserializeTaggedTemplateExpression, deserializeTemplateElement, deserializeProperty, deserializeClassDeclaration, deserializeClassExpression, deserializeClassBody, deserializeClassProperty, deserializeClassPrivateProperty, deserializeMethodDefinition, deserializeImportDeclaration, deserializeImportSpecifier, deserializeImportDefaultSpecifier, deserializeImportNamespaceSpecifier, deserializeImportAttribute, deserializeExportNamedDeclaration, deserializeExportSpecifier, deserializeExportNamespaceSpecifier, deserializeExportDefaultDeclaration, deserializeExportAllDeclaration, deserializePatternFirst, deserializeObjectPattern, deserializeArrayPattern, deserializeRestElement, deserializeAssignmentPattern, deserializePatternLast, deserializeJSXIdentifier, deserializeJSXMemberExpression, deserializeJSXNamespacedName, deserializeJSXEmptyExpression, deserializeJSXExpressionContainer, deserializeJSXSpreadChild, deserializeJSXOpeningElement, deserializeJSXClosingElement, deserializeJSXAttribute, deserializeJSXSpreadAttribute, deserializeJSXStringLiteral, deserializeJSXText, deserializeJSXElement, deserializeJSXFragment, deserializeJSXOpeningFragment, deserializeJSXClosingFragment, deserializeExistsTypeAnnotation, deserializeEmptyTypeAnnotation, deserializeStringTypeAnnotation, deserializeNumberTypeAnnotation, deserializeStringLiteralTypeAnnotation, deserializeNumberLiteralTypeAnnotation, deserializeBigIntLiteralTypeAnnotation, deserializeBooleanTypeAnnotation, deserializeBooleanLiteralTypeAnnotation, deserializeNullLiteralTypeAnnotation, deserializeSymbolTypeAnnotation, deserializeAnyTypeAnnotation, deserializeMixedTypeAnnotation, deserializeVoidTypeAnnotation, deserializeFunctionTypeAnnotation, deserializeFunctionTypeParam, deserializeNullableTypeAnnotation, deserializeQualifiedTypeIdentifier, deserializeTypeofTypeAnnotation, deserializeTupleTypeAnnotation, deserializeArrayTypeAnnotation, deserializeUnionTypeAnnotation, deserializeIntersectionTypeAnnotation, deserializeGenericTypeAnnotation, deserializeIndexedAccessType, deserializeOptionalIndexedAccessType, deserializeInterfaceTypeAnnotation, deserializeTypeAlias, deserializeOpaqueType, deserializeInterfaceDeclaration, deserializeDeclareTypeAlias, deserializeDeclareOpaqueType, deserializeDeclareInterface, deserializeDeclareClass, deserializeDeclareFunction, deserializeDeclareVariable, deserializeDeclareExportDeclaration, deserializeDeclareExportAllDeclaration, deserializeDeclareModule, deserializeDeclareModuleExports, deserializeInterfaceExtends, deserializeClassImplements, deserializeTypeAnnotation, deserializeObjectTypeAnnotation, deserializeObjectTypeProperty, deserializeObjectTypeSpreadProperty, deserializeObjectTypeInternalSlot, deserializeObjectTypeCallProperty, deserializeObjectTypeIndexer, deserializeVariance, deserializeTypeParameterDeclaration, deserializeTypeParameter, deserializeTypeParameterInstantiation, deserializeTypeCastExpression, deserializeInferredPredicate, deserializeDeclaredPredicate, deserializeEnumDeclaration, deserializeEnumStringBody, deserializeEnumNumberBody, deserializeEnumBooleanBody, deserializeEnumSymbolBody, deserializeEnumDefaultedMember, deserializeEnumStringMember, deserializeEnumNumberMember, deserializeEnumBooleanMember, deserializeTSTypeAnnotation, deserializeTSAnyKeyword, deserializeTSNumberKeyword, deserializeTSBooleanKeyword, deserializeTSStringKeyword, deserializeTSSymbolKeyword, deserializeTSVoidKeyword, deserializeTSThisType, deserializeTSLiteralType, deserializeTSIndexedAccessType, deserializeTSArrayType, deserializeTSTypeReference, deserializeTSQualifiedName, deserializeTSFunctionType, deserializeTSConstructorType, deserializeTSTypePredicate, deserializeTSTupleType, deserializeTSTypeAssertion, deserializeTSAsExpression, deserializeTSParameterProperty, deserializeTSTypeAliasDeclaration, deserializeTSInterfaceDeclaration, deserializeTSInterfaceHeritage, deserializeTSInterfaceBody, deserializeTSEnumDeclaration, deserializeTSEnumMember, deserializeTSModuleDeclaration, deserializeTSModuleBlock, deserializeTSModuleMember, deserializeTSTypeParameterDeclaration, deserializeTSTypeParameter, deserializeTSTypeParameterInstantiation, deserializeTSUnionType, deserializeTSIntersectionType, deserializeTSTypeQuery, deserializeTSConditionalType, deserializeTSTypeLiteral, deserializeTSPropertySignature, deserializeTSMethodSignature, deserializeTSIndexSignature, deserializeTSCallSignatureDeclaration, deserializeCoverFirst, deserializeCoverEmptyArgs, deserializeCoverTrailingComma, deserializeCoverInitializer, deserializeCoverRestElement, deserializeCoverTypedIdentifier, deserializeCoverLast];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {HermesNode} from './HermesAST';
|
|
12
|
+
import type HermesParserDeserializer from './HermesParserDeserializer';
|
|
13
|
+
|
|
14
|
+
declare module.exports: $ReadOnlyArray<
|
|
15
|
+
(this: HermesParserDeserializer) => HermesNode,
|
|
16
|
+
>;
|