oxc-parser 0.68.1 → 0.69.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/generated/deserialize/js.js +45 -390
- package/generated/deserialize/ts.js +59 -404
- package/package.json +18 -12
- package/wrap.cjs +28 -17
- package/wrap.mjs +30 -18
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Auto-generated code, DO NOT EDIT DIRECTLY!
|
|
2
|
-
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer.rs
|
|
2
|
+
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer.rs`.
|
|
3
3
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -148,7 +148,7 @@ function deserializeTaggedTemplateExpression(pos) {
|
|
|
148
148
|
start: deserializeU32(pos),
|
|
149
149
|
end: deserializeU32(pos + 4),
|
|
150
150
|
tag: deserializeExpression(pos + 8),
|
|
151
|
-
quasi: deserializeTemplateLiteral(pos +
|
|
151
|
+
quasi: deserializeTemplateLiteral(pos + 32),
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -224,7 +224,7 @@ function deserializeNewExpression(pos) {
|
|
|
224
224
|
start: deserializeU32(pos),
|
|
225
225
|
end: deserializeU32(pos + 4),
|
|
226
226
|
callee: deserializeExpression(pos + 8),
|
|
227
|
-
arguments: deserializeVecArgument(pos +
|
|
227
|
+
arguments: deserializeVecArgument(pos + 32),
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -866,10 +866,10 @@ function deserializePropertyDefinition(pos) {
|
|
|
866
866
|
type: deserializePropertyDefinitionType(pos + 8),
|
|
867
867
|
start: deserializeU32(pos),
|
|
868
868
|
end: deserializeU32(pos + 4),
|
|
869
|
-
static: deserializeBool(pos +
|
|
870
|
-
computed: deserializeBool(pos +
|
|
869
|
+
static: deserializeBool(pos + 89),
|
|
870
|
+
computed: deserializeBool(pos + 88),
|
|
871
871
|
key: deserializePropertyKey(pos + 48),
|
|
872
|
-
value: deserializeOptionExpression(pos +
|
|
872
|
+
value: deserializeOptionExpression(pos + 72),
|
|
873
873
|
};
|
|
874
874
|
}
|
|
875
875
|
|
|
@@ -897,9 +897,9 @@ function deserializeAccessorProperty(pos) {
|
|
|
897
897
|
start: deserializeU32(pos),
|
|
898
898
|
end: deserializeU32(pos + 4),
|
|
899
899
|
key: deserializePropertyKey(pos + 48),
|
|
900
|
-
value: deserializeOptionExpression(pos +
|
|
901
|
-
computed: deserializeBool(pos +
|
|
902
|
-
static: deserializeBool(pos +
|
|
900
|
+
value: deserializeOptionExpression(pos + 72),
|
|
901
|
+
computed: deserializeBool(pos + 88),
|
|
902
|
+
static: deserializeBool(pos + 89),
|
|
903
903
|
};
|
|
904
904
|
}
|
|
905
905
|
|
|
@@ -1109,11 +1109,17 @@ function deserializeRegExpLiteral(pos) {
|
|
|
1109
1109
|
|
|
1110
1110
|
function deserializeRegExp(pos) {
|
|
1111
1111
|
return {
|
|
1112
|
-
pattern:
|
|
1112
|
+
pattern: deserializeStr(pos),
|
|
1113
1113
|
flags: deserializeRegExpFlags(pos + 24),
|
|
1114
1114
|
};
|
|
1115
1115
|
}
|
|
1116
1116
|
|
|
1117
|
+
function deserializeRegExpPattern(pos) {
|
|
1118
|
+
return {
|
|
1119
|
+
pattern: deserializeStr(pos),
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1117
1123
|
function deserializeRegExpFlags(pos) {
|
|
1118
1124
|
const flagBits = deserializeU8(pos);
|
|
1119
1125
|
let flags = '';
|
|
@@ -1130,7 +1136,7 @@ function deserializeRegExpFlags(pos) {
|
|
|
1130
1136
|
}
|
|
1131
1137
|
|
|
1132
1138
|
function deserializeJSXElement(pos) {
|
|
1133
|
-
const closingElement = deserializeOptionBoxJSXClosingElement(pos +
|
|
1139
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 48);
|
|
1134
1140
|
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1135
1141
|
if (closingElement === null) openingElement.selfClosing = true;
|
|
1136
1142
|
return {
|
|
@@ -1139,7 +1145,7 @@ function deserializeJSXElement(pos) {
|
|
|
1139
1145
|
end: deserializeU32(pos + 4),
|
|
1140
1146
|
openingElement,
|
|
1141
1147
|
closingElement,
|
|
1142
|
-
children: deserializeVecJSXChild(pos +
|
|
1148
|
+
children: deserializeVecJSXChild(pos + 16),
|
|
1143
1149
|
};
|
|
1144
1150
|
}
|
|
1145
1151
|
|
|
@@ -1148,7 +1154,7 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1148
1154
|
type: 'JSXOpeningElement',
|
|
1149
1155
|
start: deserializeU32(pos),
|
|
1150
1156
|
end: deserializeU32(pos + 4),
|
|
1151
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1157
|
+
attributes: deserializeVecJSXAttributeItem(pos + 32),
|
|
1152
1158
|
name: deserializeJSXElementName(pos + 8),
|
|
1153
1159
|
selfClosing: false,
|
|
1154
1160
|
};
|
|
@@ -1169,8 +1175,8 @@ function deserializeJSXFragment(pos) {
|
|
|
1169
1175
|
start: deserializeU32(pos),
|
|
1170
1176
|
end: deserializeU32(pos + 4),
|
|
1171
1177
|
openingFragment: deserializeJSXOpeningFragment(pos + 8),
|
|
1172
|
-
closingFragment: deserializeJSXClosingFragment(pos +
|
|
1173
|
-
children: deserializeVecJSXChild(pos +
|
|
1178
|
+
closingFragment: deserializeJSXClosingFragment(pos + 48),
|
|
1179
|
+
children: deserializeVecJSXChild(pos + 16),
|
|
1174
1180
|
};
|
|
1175
1181
|
}
|
|
1176
1182
|
|
|
@@ -1283,9 +1289,9 @@ function deserializeTSThisParameter(pos) {
|
|
|
1283
1289
|
start: deserializeU32(pos),
|
|
1284
1290
|
end: deserializeU32(pos + 4),
|
|
1285
1291
|
name: 'this',
|
|
1286
|
-
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 16),
|
|
1287
1292
|
decorators: [],
|
|
1288
1293
|
optional: false,
|
|
1294
|
+
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 16),
|
|
1289
1295
|
};
|
|
1290
1296
|
}
|
|
1291
1297
|
|
|
@@ -1421,8 +1427,8 @@ function deserializeTSNamedTupleMember(pos) {
|
|
|
1421
1427
|
type: 'TSNamedTupleMember',
|
|
1422
1428
|
start: deserializeU32(pos),
|
|
1423
1429
|
end: deserializeU32(pos + 4),
|
|
1424
|
-
|
|
1425
|
-
|
|
1430
|
+
label: deserializeIdentifierName(pos + 8),
|
|
1431
|
+
elementType: deserializeTSTupleElement(pos + 32),
|
|
1426
1432
|
optional: deserializeBool(pos + 48),
|
|
1427
1433
|
};
|
|
1428
1434
|
}
|
|
@@ -1758,9 +1764,9 @@ function deserializeTSIndexSignatureName(pos) {
|
|
|
1758
1764
|
start: deserializeU32(pos),
|
|
1759
1765
|
end: deserializeU32(pos + 4),
|
|
1760
1766
|
name: deserializeStr(pos + 8),
|
|
1761
|
-
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1762
1767
|
decorators: [],
|
|
1763
1768
|
optional: false,
|
|
1769
|
+
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1764
1770
|
};
|
|
1765
1771
|
}
|
|
1766
1772
|
|
|
@@ -1853,22 +1859,12 @@ function deserializeTSTypeQuery(pos) {
|
|
|
1853
1859
|
}
|
|
1854
1860
|
|
|
1855
1861
|
function deserializeTSImportType(pos) {
|
|
1856
|
-
let options = deserializeOptionBoxObjectExpression(pos + 24);
|
|
1857
|
-
if (options !== null && options.properties.length === 1) {
|
|
1858
|
-
const prop = options.properties[0];
|
|
1859
|
-
if (
|
|
1860
|
-
!prop.method && !prop.shorthand && !prop.computed &&
|
|
1861
|
-
prop.key.type === 'Identifier' && prop.key.name === 'assert'
|
|
1862
|
-
) {
|
|
1863
|
-
prop.key.name = 'with';
|
|
1864
|
-
}
|
|
1865
|
-
}
|
|
1866
1862
|
return {
|
|
1867
1863
|
type: 'TSImportType',
|
|
1868
1864
|
start: deserializeU32(pos),
|
|
1869
1865
|
end: deserializeU32(pos + 4),
|
|
1870
1866
|
argument: deserializeTSType(pos + 8),
|
|
1871
|
-
options,
|
|
1867
|
+
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
1872
1868
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
1873
1869
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
1874
1870
|
};
|
|
@@ -1901,6 +1897,8 @@ function deserializeTSConstructorType(pos) {
|
|
|
1901
1897
|
}
|
|
1902
1898
|
|
|
1903
1899
|
function deserializeTSMappedType(pos) {
|
|
1900
|
+
let optional = deserializeOptionTSMappedTypeModifierOperator(pos + 48) || false;
|
|
1901
|
+
if (optional === null) optional = false;
|
|
1904
1902
|
const typeParameter = deserializeBoxTSTypeParameter(pos + 8);
|
|
1905
1903
|
return {
|
|
1906
1904
|
type: 'TSMappedType',
|
|
@@ -1908,7 +1906,7 @@ function deserializeTSMappedType(pos) {
|
|
|
1908
1906
|
end: deserializeU32(pos + 4),
|
|
1909
1907
|
nameType: deserializeOptionTSType(pos + 16),
|
|
1910
1908
|
typeAnnotation: deserializeOptionTSType(pos + 32),
|
|
1911
|
-
optional
|
|
1909
|
+
optional,
|
|
1912
1910
|
readonly: deserializeOptionTSMappedTypeModifierOperator(pos + 49),
|
|
1913
1911
|
key: typeParameter.name,
|
|
1914
1912
|
constraint: typeParameter.constraint,
|
|
@@ -1950,8 +1948,8 @@ function deserializeTSTypeAssertion(pos) {
|
|
|
1950
1948
|
type: 'TSTypeAssertion',
|
|
1951
1949
|
start: deserializeU32(pos),
|
|
1952
1950
|
end: deserializeU32(pos + 4),
|
|
1953
|
-
|
|
1954
|
-
|
|
1951
|
+
typeAnnotation: deserializeTSType(pos + 8),
|
|
1952
|
+
expression: deserializeExpression(pos + 24),
|
|
1955
1953
|
};
|
|
1956
1954
|
}
|
|
1957
1955
|
|
|
@@ -2111,202 +2109,6 @@ function deserializeSourceType(pos) {
|
|
|
2111
2109
|
};
|
|
2112
2110
|
}
|
|
2113
2111
|
|
|
2114
|
-
function deserializePattern(pos) {
|
|
2115
|
-
return {
|
|
2116
|
-
type: 'Pattern',
|
|
2117
|
-
start: deserializeU32(pos),
|
|
2118
|
-
end: deserializeU32(pos + 4),
|
|
2119
|
-
body: deserializeDisjunction(pos + 8),
|
|
2120
|
-
};
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
function deserializeDisjunction(pos) {
|
|
2124
|
-
return {
|
|
2125
|
-
type: 'Disjunction',
|
|
2126
|
-
start: deserializeU32(pos),
|
|
2127
|
-
end: deserializeU32(pos + 4),
|
|
2128
|
-
body: deserializeVecAlternative(pos + 8),
|
|
2129
|
-
};
|
|
2130
|
-
}
|
|
2131
|
-
|
|
2132
|
-
function deserializeAlternative(pos) {
|
|
2133
|
-
return {
|
|
2134
|
-
type: 'Alternative',
|
|
2135
|
-
start: deserializeU32(pos),
|
|
2136
|
-
end: deserializeU32(pos + 4),
|
|
2137
|
-
body: deserializeVecTerm(pos + 8),
|
|
2138
|
-
};
|
|
2139
|
-
}
|
|
2140
|
-
|
|
2141
|
-
function deserializeBoundaryAssertion(pos) {
|
|
2142
|
-
return {
|
|
2143
|
-
type: 'BoundaryAssertion',
|
|
2144
|
-
start: deserializeU32(pos),
|
|
2145
|
-
end: deserializeU32(pos + 4),
|
|
2146
|
-
kind: deserializeBoundaryAssertionKind(pos + 8),
|
|
2147
|
-
};
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
function deserializeLookAroundAssertion(pos) {
|
|
2151
|
-
return {
|
|
2152
|
-
type: 'LookAroundAssertion',
|
|
2153
|
-
start: deserializeU32(pos),
|
|
2154
|
-
end: deserializeU32(pos + 4),
|
|
2155
|
-
kind: deserializeLookAroundAssertionKind(pos + 8),
|
|
2156
|
-
body: deserializeDisjunction(pos + 16),
|
|
2157
|
-
};
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
function deserializeQuantifier(pos) {
|
|
2161
|
-
return {
|
|
2162
|
-
type: 'Quantifier',
|
|
2163
|
-
start: deserializeU32(pos),
|
|
2164
|
-
end: deserializeU32(pos + 4),
|
|
2165
|
-
min: deserializeU64(pos + 8),
|
|
2166
|
-
max: deserializeOptionU64(pos + 16),
|
|
2167
|
-
greedy: deserializeBool(pos + 32),
|
|
2168
|
-
body: deserializeTerm(pos + 40),
|
|
2169
|
-
};
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
|
-
function deserializeCharacter(pos) {
|
|
2173
|
-
return {
|
|
2174
|
-
type: 'Character',
|
|
2175
|
-
start: deserializeU32(pos),
|
|
2176
|
-
end: deserializeU32(pos + 4),
|
|
2177
|
-
kind: deserializeCharacterKind(pos + 8),
|
|
2178
|
-
value: deserializeU32(pos + 12),
|
|
2179
|
-
};
|
|
2180
|
-
}
|
|
2181
|
-
|
|
2182
|
-
function deserializeCharacterClassEscape(pos) {
|
|
2183
|
-
return {
|
|
2184
|
-
type: 'CharacterClassEscape',
|
|
2185
|
-
start: deserializeU32(pos),
|
|
2186
|
-
end: deserializeU32(pos + 4),
|
|
2187
|
-
kind: deserializeCharacterClassEscapeKind(pos + 8),
|
|
2188
|
-
};
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
function deserializeUnicodePropertyEscape(pos) {
|
|
2192
|
-
return {
|
|
2193
|
-
type: 'UnicodePropertyEscape',
|
|
2194
|
-
start: deserializeU32(pos),
|
|
2195
|
-
end: deserializeU32(pos + 4),
|
|
2196
|
-
negative: deserializeBool(pos + 8),
|
|
2197
|
-
strings: deserializeBool(pos + 9),
|
|
2198
|
-
name: deserializeStr(pos + 16),
|
|
2199
|
-
value: deserializeOptionStr(pos + 32),
|
|
2200
|
-
};
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
function deserializeDot(pos) {
|
|
2204
|
-
return {
|
|
2205
|
-
type: 'Dot',
|
|
2206
|
-
start: deserializeU32(pos),
|
|
2207
|
-
end: deserializeU32(pos + 4),
|
|
2208
|
-
};
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
function deserializeCharacterClass(pos) {
|
|
2212
|
-
return {
|
|
2213
|
-
type: 'CharacterClass',
|
|
2214
|
-
start: deserializeU32(pos),
|
|
2215
|
-
end: deserializeU32(pos + 4),
|
|
2216
|
-
negative: deserializeBool(pos + 8),
|
|
2217
|
-
strings: deserializeBool(pos + 9),
|
|
2218
|
-
kind: deserializeCharacterClassContentsKind(pos + 10),
|
|
2219
|
-
body: deserializeVecCharacterClassContents(pos + 16),
|
|
2220
|
-
};
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
|
-
function deserializeCharacterClassRange(pos) {
|
|
2224
|
-
return {
|
|
2225
|
-
type: 'CharacterClassRange',
|
|
2226
|
-
start: deserializeU32(pos),
|
|
2227
|
-
end: deserializeU32(pos + 4),
|
|
2228
|
-
min: deserializeCharacter(pos + 8),
|
|
2229
|
-
max: deserializeCharacter(pos + 24),
|
|
2230
|
-
};
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
function deserializeClassStringDisjunction(pos) {
|
|
2234
|
-
return {
|
|
2235
|
-
type: 'ClassStringDisjunction',
|
|
2236
|
-
start: deserializeU32(pos),
|
|
2237
|
-
end: deserializeU32(pos + 4),
|
|
2238
|
-
strings: deserializeBool(pos + 8),
|
|
2239
|
-
body: deserializeVecClassString(pos + 16),
|
|
2240
|
-
};
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
function deserializeClassString(pos) {
|
|
2244
|
-
return {
|
|
2245
|
-
type: 'ClassString',
|
|
2246
|
-
start: deserializeU32(pos),
|
|
2247
|
-
end: deserializeU32(pos + 4),
|
|
2248
|
-
strings: deserializeBool(pos + 8),
|
|
2249
|
-
body: deserializeVecCharacter(pos + 16),
|
|
2250
|
-
};
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
function deserializeCapturingGroup(pos) {
|
|
2254
|
-
return {
|
|
2255
|
-
type: 'CapturingGroup',
|
|
2256
|
-
start: deserializeU32(pos),
|
|
2257
|
-
end: deserializeU32(pos + 4),
|
|
2258
|
-
name: deserializeOptionStr(pos + 8),
|
|
2259
|
-
body: deserializeDisjunction(pos + 24),
|
|
2260
|
-
};
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
function deserializeIgnoreGroup(pos) {
|
|
2264
|
-
return {
|
|
2265
|
-
type: 'IgnoreGroup',
|
|
2266
|
-
start: deserializeU32(pos),
|
|
2267
|
-
end: deserializeU32(pos + 4),
|
|
2268
|
-
modifiers: deserializeOptionModifiers(pos + 8),
|
|
2269
|
-
body: deserializeDisjunction(pos + 24),
|
|
2270
|
-
};
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
|
-
function deserializeModifiers(pos) {
|
|
2274
|
-
return {
|
|
2275
|
-
type: 'Modifiers',
|
|
2276
|
-
start: deserializeU32(pos),
|
|
2277
|
-
end: deserializeU32(pos + 4),
|
|
2278
|
-
enabling: deserializeOptionModifier(pos + 8),
|
|
2279
|
-
disabling: deserializeOptionModifier(pos + 11),
|
|
2280
|
-
};
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
function deserializeModifier(pos) {
|
|
2284
|
-
return {
|
|
2285
|
-
type: 'Modifier',
|
|
2286
|
-
ignoreCase: deserializeBool(pos),
|
|
2287
|
-
multiline: deserializeBool(pos + 1),
|
|
2288
|
-
sticky: deserializeBool(pos + 2),
|
|
2289
|
-
};
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
function deserializeIndexedReference(pos) {
|
|
2293
|
-
return {
|
|
2294
|
-
type: 'IndexedReference',
|
|
2295
|
-
start: deserializeU32(pos),
|
|
2296
|
-
end: deserializeU32(pos + 4),
|
|
2297
|
-
index: deserializeU32(pos + 8),
|
|
2298
|
-
};
|
|
2299
|
-
}
|
|
2300
|
-
|
|
2301
|
-
function deserializeNamedReference(pos) {
|
|
2302
|
-
return {
|
|
2303
|
-
type: 'NamedReference',
|
|
2304
|
-
start: deserializeU32(pos),
|
|
2305
|
-
end: deserializeU32(pos + 4),
|
|
2306
|
-
name: deserializeStr(pos + 8),
|
|
2307
|
-
};
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
2112
|
function deserializeRawTransferData(pos) {
|
|
2311
2113
|
return {
|
|
2312
2114
|
program: deserializeProgram(pos),
|
|
@@ -3419,19 +3221,6 @@ function deserializeModuleExportName(pos) {
|
|
|
3419
3221
|
}
|
|
3420
3222
|
}
|
|
3421
3223
|
|
|
3422
|
-
function deserializeRegExpPattern(pos) {
|
|
3423
|
-
switch (uint8[pos]) {
|
|
3424
|
-
case 0:
|
|
3425
|
-
return deserializeStr(pos + 8);
|
|
3426
|
-
case 1:
|
|
3427
|
-
return deserializeStr(pos + 8);
|
|
3428
|
-
case 2:
|
|
3429
|
-
return deserializeBoxPattern(pos + 8);
|
|
3430
|
-
default:
|
|
3431
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for RegExpPattern`);
|
|
3432
|
-
}
|
|
3433
|
-
}
|
|
3434
|
-
|
|
3435
3224
|
function deserializeJSXElementName(pos) {
|
|
3436
3225
|
switch (uint8[pos]) {
|
|
3437
3226
|
case 0:
|
|
@@ -4202,145 +3991,6 @@ function deserializeModuleKind(pos) {
|
|
|
4202
3991
|
}
|
|
4203
3992
|
}
|
|
4204
3993
|
|
|
4205
|
-
function deserializeTerm(pos) {
|
|
4206
|
-
switch (uint8[pos]) {
|
|
4207
|
-
case 0:
|
|
4208
|
-
return deserializeBoxBoundaryAssertion(pos + 8);
|
|
4209
|
-
case 1:
|
|
4210
|
-
return deserializeBoxLookAroundAssertion(pos + 8);
|
|
4211
|
-
case 2:
|
|
4212
|
-
return deserializeBoxQuantifier(pos + 8);
|
|
4213
|
-
case 3:
|
|
4214
|
-
return deserializeBoxCharacter(pos + 8);
|
|
4215
|
-
case 4:
|
|
4216
|
-
return deserializeDot(pos + 8);
|
|
4217
|
-
case 5:
|
|
4218
|
-
return deserializeBoxCharacterClassEscape(pos + 8);
|
|
4219
|
-
case 6:
|
|
4220
|
-
return deserializeBoxUnicodePropertyEscape(pos + 8);
|
|
4221
|
-
case 7:
|
|
4222
|
-
return deserializeBoxCharacterClass(pos + 8);
|
|
4223
|
-
case 8:
|
|
4224
|
-
return deserializeBoxCapturingGroup(pos + 8);
|
|
4225
|
-
case 9:
|
|
4226
|
-
return deserializeBoxIgnoreGroup(pos + 8);
|
|
4227
|
-
case 10:
|
|
4228
|
-
return deserializeBoxIndexedReference(pos + 8);
|
|
4229
|
-
case 11:
|
|
4230
|
-
return deserializeBoxNamedReference(pos + 8);
|
|
4231
|
-
default:
|
|
4232
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for Term`);
|
|
4233
|
-
}
|
|
4234
|
-
}
|
|
4235
|
-
|
|
4236
|
-
function deserializeBoundaryAssertionKind(pos) {
|
|
4237
|
-
switch (uint8[pos]) {
|
|
4238
|
-
case 0:
|
|
4239
|
-
return 'start';
|
|
4240
|
-
case 1:
|
|
4241
|
-
return 'end';
|
|
4242
|
-
case 2:
|
|
4243
|
-
return 'boundary';
|
|
4244
|
-
case 3:
|
|
4245
|
-
return 'negativeBoundary';
|
|
4246
|
-
default:
|
|
4247
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for BoundaryAssertionKind`);
|
|
4248
|
-
}
|
|
4249
|
-
}
|
|
4250
|
-
|
|
4251
|
-
function deserializeLookAroundAssertionKind(pos) {
|
|
4252
|
-
switch (uint8[pos]) {
|
|
4253
|
-
case 0:
|
|
4254
|
-
return 'lookahead';
|
|
4255
|
-
case 1:
|
|
4256
|
-
return 'negativeLookahead';
|
|
4257
|
-
case 2:
|
|
4258
|
-
return 'lookbehind';
|
|
4259
|
-
case 3:
|
|
4260
|
-
return 'negativeLookbehind';
|
|
4261
|
-
default:
|
|
4262
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for LookAroundAssertionKind`);
|
|
4263
|
-
}
|
|
4264
|
-
}
|
|
4265
|
-
|
|
4266
|
-
function deserializeCharacterKind(pos) {
|
|
4267
|
-
switch (uint8[pos]) {
|
|
4268
|
-
case 0:
|
|
4269
|
-
return 'controlLetter';
|
|
4270
|
-
case 1:
|
|
4271
|
-
return 'hexadecimalEscape';
|
|
4272
|
-
case 2:
|
|
4273
|
-
return 'identifier';
|
|
4274
|
-
case 3:
|
|
4275
|
-
return 'null';
|
|
4276
|
-
case 4:
|
|
4277
|
-
return 'octal1';
|
|
4278
|
-
case 5:
|
|
4279
|
-
return 'octal2';
|
|
4280
|
-
case 6:
|
|
4281
|
-
return 'octal3';
|
|
4282
|
-
case 7:
|
|
4283
|
-
return 'singleEscape';
|
|
4284
|
-
case 8:
|
|
4285
|
-
return 'symbol';
|
|
4286
|
-
case 9:
|
|
4287
|
-
return 'unicodeEscape';
|
|
4288
|
-
default:
|
|
4289
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterKind`);
|
|
4290
|
-
}
|
|
4291
|
-
}
|
|
4292
|
-
|
|
4293
|
-
function deserializeCharacterClassEscapeKind(pos) {
|
|
4294
|
-
switch (uint8[pos]) {
|
|
4295
|
-
case 0:
|
|
4296
|
-
return 'd';
|
|
4297
|
-
case 1:
|
|
4298
|
-
return 'negativeD';
|
|
4299
|
-
case 2:
|
|
4300
|
-
return 's';
|
|
4301
|
-
case 3:
|
|
4302
|
-
return 'negativeS';
|
|
4303
|
-
case 4:
|
|
4304
|
-
return 'w';
|
|
4305
|
-
case 5:
|
|
4306
|
-
return 'negativeW';
|
|
4307
|
-
default:
|
|
4308
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterClassEscapeKind`);
|
|
4309
|
-
}
|
|
4310
|
-
}
|
|
4311
|
-
|
|
4312
|
-
function deserializeCharacterClassContentsKind(pos) {
|
|
4313
|
-
switch (uint8[pos]) {
|
|
4314
|
-
case 0:
|
|
4315
|
-
return 'union';
|
|
4316
|
-
case 1:
|
|
4317
|
-
return 'intersection';
|
|
4318
|
-
case 2:
|
|
4319
|
-
return 'subtraction';
|
|
4320
|
-
default:
|
|
4321
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterClassContentsKind`);
|
|
4322
|
-
}
|
|
4323
|
-
}
|
|
4324
|
-
|
|
4325
|
-
function deserializeCharacterClassContents(pos) {
|
|
4326
|
-
switch (uint8[pos]) {
|
|
4327
|
-
case 0:
|
|
4328
|
-
return deserializeBoxCharacterClassRange(pos + 8);
|
|
4329
|
-
case 1:
|
|
4330
|
-
return deserializeBoxCharacterClassEscape(pos + 8);
|
|
4331
|
-
case 2:
|
|
4332
|
-
return deserializeBoxUnicodePropertyEscape(pos + 8);
|
|
4333
|
-
case 3:
|
|
4334
|
-
return deserializeBoxCharacter(pos + 8);
|
|
4335
|
-
case 4:
|
|
4336
|
-
return deserializeBoxCharacterClass(pos + 8);
|
|
4337
|
-
case 5:
|
|
4338
|
-
return deserializeBoxClassStringDisjunction(pos + 8);
|
|
4339
|
-
default:
|
|
4340
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterClassContents`);
|
|
4341
|
-
}
|
|
4342
|
-
}
|
|
4343
|
-
|
|
4344
3994
|
function deserializeErrorSeverity(pos) {
|
|
4345
3995
|
switch (uint8[pos]) {
|
|
4346
3996
|
case 0:
|
|
@@ -5208,6 +4858,11 @@ function deserializeBoxPattern(pos) {
|
|
|
5208
4858
|
return deserializePattern(uint32[pos >> 2]);
|
|
5209
4859
|
}
|
|
5210
4860
|
|
|
4861
|
+
function deserializeOptionBoxPattern(pos) {
|
|
4862
|
+
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
4863
|
+
return deserializeBoxPattern(pos);
|
|
4864
|
+
}
|
|
4865
|
+
|
|
5211
4866
|
function deserializeU8(pos) {
|
|
5212
4867
|
return uint8[pos];
|
|
5213
4868
|
}
|
|
@@ -5216,15 +4871,6 @@ function deserializeBoxJSXOpeningElement(pos) {
|
|
|
5216
4871
|
return deserializeJSXOpeningElement(uint32[pos >> 2]);
|
|
5217
4872
|
}
|
|
5218
4873
|
|
|
5219
|
-
function deserializeBoxJSXClosingElement(pos) {
|
|
5220
|
-
return deserializeJSXClosingElement(uint32[pos >> 2]);
|
|
5221
|
-
}
|
|
5222
|
-
|
|
5223
|
-
function deserializeOptionBoxJSXClosingElement(pos) {
|
|
5224
|
-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
5225
|
-
return deserializeBoxJSXClosingElement(pos);
|
|
5226
|
-
}
|
|
5227
|
-
|
|
5228
4874
|
function deserializeVecJSXChild(pos) {
|
|
5229
4875
|
const arr = [],
|
|
5230
4876
|
pos32 = pos >> 2,
|
|
@@ -5237,6 +4883,15 @@ function deserializeVecJSXChild(pos) {
|
|
|
5237
4883
|
return arr;
|
|
5238
4884
|
}
|
|
5239
4885
|
|
|
4886
|
+
function deserializeBoxJSXClosingElement(pos) {
|
|
4887
|
+
return deserializeJSXClosingElement(uint32[pos >> 2]);
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
function deserializeOptionBoxJSXClosingElement(pos) {
|
|
4891
|
+
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
4892
|
+
return deserializeBoxJSXClosingElement(pos);
|
|
4893
|
+
}
|
|
4894
|
+
|
|
5240
4895
|
function deserializeVecJSXAttributeItem(pos) {
|
|
5241
4896
|
const arr = [],
|
|
5242
4897
|
pos32 = pos >> 2,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Auto-generated code, DO NOT EDIT DIRECTLY!
|
|
2
|
-
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer.rs
|
|
2
|
+
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer.rs`.
|
|
3
3
|
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -177,8 +177,8 @@ function deserializeTaggedTemplateExpression(pos) {
|
|
|
177
177
|
start: deserializeU32(pos),
|
|
178
178
|
end: deserializeU32(pos + 4),
|
|
179
179
|
tag: deserializeExpression(pos + 8),
|
|
180
|
-
quasi: deserializeTemplateLiteral(pos +
|
|
181
|
-
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos +
|
|
180
|
+
quasi: deserializeTemplateLiteral(pos + 32),
|
|
181
|
+
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 24),
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
|
|
@@ -255,8 +255,8 @@ function deserializeNewExpression(pos) {
|
|
|
255
255
|
start: deserializeU32(pos),
|
|
256
256
|
end: deserializeU32(pos + 4),
|
|
257
257
|
callee: deserializeExpression(pos + 8),
|
|
258
|
-
arguments: deserializeVecArgument(pos +
|
|
259
|
-
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos +
|
|
258
|
+
arguments: deserializeVecArgument(pos + 32),
|
|
259
|
+
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 24),
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
|
|
@@ -997,18 +997,18 @@ function deserializePropertyDefinition(pos) {
|
|
|
997
997
|
type: deserializePropertyDefinitionType(pos + 8),
|
|
998
998
|
start: deserializeU32(pos),
|
|
999
999
|
end: deserializeU32(pos + 4),
|
|
1000
|
-
static: deserializeBool(pos +
|
|
1001
|
-
computed: deserializeBool(pos +
|
|
1000
|
+
static: deserializeBool(pos + 89),
|
|
1001
|
+
computed: deserializeBool(pos + 88),
|
|
1002
1002
|
key: deserializePropertyKey(pos + 48),
|
|
1003
|
-
value: deserializeOptionExpression(pos +
|
|
1003
|
+
value: deserializeOptionExpression(pos + 72),
|
|
1004
1004
|
decorators: deserializeVecDecorator(pos + 16),
|
|
1005
|
-
declare: deserializeBool(pos +
|
|
1006
|
-
override: deserializeBool(pos +
|
|
1007
|
-
optional: deserializeBool(pos +
|
|
1008
|
-
definite: deserializeBool(pos +
|
|
1009
|
-
readonly: deserializeBool(pos +
|
|
1010
|
-
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos +
|
|
1011
|
-
accessibility: deserializeOptionTSAccessibility(pos +
|
|
1005
|
+
declare: deserializeBool(pos + 90),
|
|
1006
|
+
override: deserializeBool(pos + 91),
|
|
1007
|
+
optional: deserializeBool(pos + 92),
|
|
1008
|
+
definite: deserializeBool(pos + 93),
|
|
1009
|
+
readonly: deserializeBool(pos + 94),
|
|
1010
|
+
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 64),
|
|
1011
|
+
accessibility: deserializeOptionTSAccessibility(pos + 95),
|
|
1012
1012
|
};
|
|
1013
1013
|
}
|
|
1014
1014
|
|
|
@@ -1036,15 +1036,15 @@ function deserializeAccessorProperty(pos) {
|
|
|
1036
1036
|
start: deserializeU32(pos),
|
|
1037
1037
|
end: deserializeU32(pos + 4),
|
|
1038
1038
|
key: deserializePropertyKey(pos + 48),
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1039
|
+
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 64),
|
|
1040
|
+
value: deserializeOptionExpression(pos + 72),
|
|
1041
|
+
computed: deserializeBool(pos + 88),
|
|
1042
|
+
static: deserializeBool(pos + 89),
|
|
1042
1043
|
decorators: deserializeVecDecorator(pos + 16),
|
|
1043
|
-
definite: deserializeBool(pos +
|
|
1044
|
-
|
|
1045
|
-
accessibility: deserializeOptionTSAccessibility(pos + 96),
|
|
1044
|
+
definite: deserializeBool(pos + 91),
|
|
1045
|
+
accessibility: deserializeOptionTSAccessibility(pos + 92),
|
|
1046
1046
|
optional: false,
|
|
1047
|
-
override: deserializeBool(pos +
|
|
1047
|
+
override: deserializeBool(pos + 90),
|
|
1048
1048
|
readonly: false,
|
|
1049
1049
|
declare: false,
|
|
1050
1050
|
};
|
|
@@ -1262,11 +1262,17 @@ function deserializeRegExpLiteral(pos) {
|
|
|
1262
1262
|
|
|
1263
1263
|
function deserializeRegExp(pos) {
|
|
1264
1264
|
return {
|
|
1265
|
-
pattern:
|
|
1265
|
+
pattern: deserializeStr(pos),
|
|
1266
1266
|
flags: deserializeRegExpFlags(pos + 24),
|
|
1267
1267
|
};
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
1270
|
+
function deserializeRegExpPattern(pos) {
|
|
1271
|
+
return {
|
|
1272
|
+
pattern: deserializeStr(pos),
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1270
1276
|
function deserializeRegExpFlags(pos) {
|
|
1271
1277
|
const flagBits = deserializeU8(pos);
|
|
1272
1278
|
let flags = '';
|
|
@@ -1283,7 +1289,7 @@ function deserializeRegExpFlags(pos) {
|
|
|
1283
1289
|
}
|
|
1284
1290
|
|
|
1285
1291
|
function deserializeJSXElement(pos) {
|
|
1286
|
-
const closingElement = deserializeOptionBoxJSXClosingElement(pos +
|
|
1292
|
+
const closingElement = deserializeOptionBoxJSXClosingElement(pos + 48);
|
|
1287
1293
|
const openingElement = deserializeBoxJSXOpeningElement(pos + 8);
|
|
1288
1294
|
if (closingElement === null) openingElement.selfClosing = true;
|
|
1289
1295
|
return {
|
|
@@ -1292,7 +1298,7 @@ function deserializeJSXElement(pos) {
|
|
|
1292
1298
|
end: deserializeU32(pos + 4),
|
|
1293
1299
|
openingElement,
|
|
1294
1300
|
closingElement,
|
|
1295
|
-
children: deserializeVecJSXChild(pos +
|
|
1301
|
+
children: deserializeVecJSXChild(pos + 16),
|
|
1296
1302
|
};
|
|
1297
1303
|
}
|
|
1298
1304
|
|
|
@@ -1301,10 +1307,10 @@ function deserializeJSXOpeningElement(pos) {
|
|
|
1301
1307
|
type: 'JSXOpeningElement',
|
|
1302
1308
|
start: deserializeU32(pos),
|
|
1303
1309
|
end: deserializeU32(pos + 4),
|
|
1304
|
-
attributes: deserializeVecJSXAttributeItem(pos +
|
|
1310
|
+
attributes: deserializeVecJSXAttributeItem(pos + 32),
|
|
1305
1311
|
name: deserializeJSXElementName(pos + 8),
|
|
1306
1312
|
selfClosing: false,
|
|
1307
|
-
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos +
|
|
1313
|
+
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 24),
|
|
1308
1314
|
};
|
|
1309
1315
|
}
|
|
1310
1316
|
|
|
@@ -1323,8 +1329,8 @@ function deserializeJSXFragment(pos) {
|
|
|
1323
1329
|
start: deserializeU32(pos),
|
|
1324
1330
|
end: deserializeU32(pos + 4),
|
|
1325
1331
|
openingFragment: deserializeJSXOpeningFragment(pos + 8),
|
|
1326
|
-
closingFragment: deserializeJSXClosingFragment(pos +
|
|
1327
|
-
children: deserializeVecJSXChild(pos +
|
|
1332
|
+
closingFragment: deserializeJSXClosingFragment(pos + 48),
|
|
1333
|
+
children: deserializeVecJSXChild(pos + 16),
|
|
1328
1334
|
};
|
|
1329
1335
|
}
|
|
1330
1336
|
|
|
@@ -1435,9 +1441,9 @@ function deserializeTSThisParameter(pos) {
|
|
|
1435
1441
|
start: deserializeU32(pos),
|
|
1436
1442
|
end: deserializeU32(pos + 4),
|
|
1437
1443
|
name: 'this',
|
|
1438
|
-
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 16),
|
|
1439
1444
|
decorators: [],
|
|
1440
1445
|
optional: false,
|
|
1446
|
+
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 16),
|
|
1441
1447
|
};
|
|
1442
1448
|
}
|
|
1443
1449
|
|
|
@@ -1573,8 +1579,8 @@ function deserializeTSNamedTupleMember(pos) {
|
|
|
1573
1579
|
type: 'TSNamedTupleMember',
|
|
1574
1580
|
start: deserializeU32(pos),
|
|
1575
1581
|
end: deserializeU32(pos + 4),
|
|
1576
|
-
|
|
1577
|
-
|
|
1582
|
+
label: deserializeIdentifierName(pos + 8),
|
|
1583
|
+
elementType: deserializeTSTupleElement(pos + 32),
|
|
1578
1584
|
optional: deserializeBool(pos + 48),
|
|
1579
1585
|
};
|
|
1580
1586
|
}
|
|
@@ -1910,9 +1916,9 @@ function deserializeTSIndexSignatureName(pos) {
|
|
|
1910
1916
|
start: deserializeU32(pos),
|
|
1911
1917
|
end: deserializeU32(pos + 4),
|
|
1912
1918
|
name: deserializeStr(pos + 8),
|
|
1913
|
-
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1914
1919
|
decorators: [],
|
|
1915
1920
|
optional: false,
|
|
1921
|
+
typeAnnotation: deserializeBoxTSTypeAnnotation(pos + 24),
|
|
1916
1922
|
};
|
|
1917
1923
|
}
|
|
1918
1924
|
|
|
@@ -2005,22 +2011,12 @@ function deserializeTSTypeQuery(pos) {
|
|
|
2005
2011
|
}
|
|
2006
2012
|
|
|
2007
2013
|
function deserializeTSImportType(pos) {
|
|
2008
|
-
let options = deserializeOptionBoxObjectExpression(pos + 24);
|
|
2009
|
-
if (options !== null && options.properties.length === 1) {
|
|
2010
|
-
const prop = options.properties[0];
|
|
2011
|
-
if (
|
|
2012
|
-
!prop.method && !prop.shorthand && !prop.computed &&
|
|
2013
|
-
prop.key.type === 'Identifier' && prop.key.name === 'assert'
|
|
2014
|
-
) {
|
|
2015
|
-
prop.key.name = 'with';
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
2014
|
return {
|
|
2019
2015
|
type: 'TSImportType',
|
|
2020
2016
|
start: deserializeU32(pos),
|
|
2021
2017
|
end: deserializeU32(pos + 4),
|
|
2022
2018
|
argument: deserializeTSType(pos + 8),
|
|
2023
|
-
options,
|
|
2019
|
+
options: deserializeOptionBoxObjectExpression(pos + 24),
|
|
2024
2020
|
qualifier: deserializeOptionTSTypeName(pos + 32),
|
|
2025
2021
|
typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
|
|
2026
2022
|
};
|
|
@@ -2053,6 +2049,8 @@ function deserializeTSConstructorType(pos) {
|
|
|
2053
2049
|
}
|
|
2054
2050
|
|
|
2055
2051
|
function deserializeTSMappedType(pos) {
|
|
2052
|
+
let optional = deserializeOptionTSMappedTypeModifierOperator(pos + 48) || false;
|
|
2053
|
+
if (optional === null) optional = false;
|
|
2056
2054
|
const typeParameter = deserializeBoxTSTypeParameter(pos + 8);
|
|
2057
2055
|
return {
|
|
2058
2056
|
type: 'TSMappedType',
|
|
@@ -2060,7 +2058,7 @@ function deserializeTSMappedType(pos) {
|
|
|
2060
2058
|
end: deserializeU32(pos + 4),
|
|
2061
2059
|
nameType: deserializeOptionTSType(pos + 16),
|
|
2062
2060
|
typeAnnotation: deserializeOptionTSType(pos + 32),
|
|
2063
|
-
optional
|
|
2061
|
+
optional,
|
|
2064
2062
|
readonly: deserializeOptionTSMappedTypeModifierOperator(pos + 49),
|
|
2065
2063
|
key: typeParameter.name,
|
|
2066
2064
|
constraint: typeParameter.constraint,
|
|
@@ -2102,8 +2100,8 @@ function deserializeTSTypeAssertion(pos) {
|
|
|
2102
2100
|
type: 'TSTypeAssertion',
|
|
2103
2101
|
start: deserializeU32(pos),
|
|
2104
2102
|
end: deserializeU32(pos + 4),
|
|
2105
|
-
|
|
2106
|
-
|
|
2103
|
+
typeAnnotation: deserializeTSType(pos + 8),
|
|
2104
|
+
expression: deserializeExpression(pos + 24),
|
|
2107
2105
|
};
|
|
2108
2106
|
}
|
|
2109
2107
|
|
|
@@ -2263,202 +2261,6 @@ function deserializeSourceType(pos) {
|
|
|
2263
2261
|
};
|
|
2264
2262
|
}
|
|
2265
2263
|
|
|
2266
|
-
function deserializePattern(pos) {
|
|
2267
|
-
return {
|
|
2268
|
-
type: 'Pattern',
|
|
2269
|
-
start: deserializeU32(pos),
|
|
2270
|
-
end: deserializeU32(pos + 4),
|
|
2271
|
-
body: deserializeDisjunction(pos + 8),
|
|
2272
|
-
};
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
function deserializeDisjunction(pos) {
|
|
2276
|
-
return {
|
|
2277
|
-
type: 'Disjunction',
|
|
2278
|
-
start: deserializeU32(pos),
|
|
2279
|
-
end: deserializeU32(pos + 4),
|
|
2280
|
-
body: deserializeVecAlternative(pos + 8),
|
|
2281
|
-
};
|
|
2282
|
-
}
|
|
2283
|
-
|
|
2284
|
-
function deserializeAlternative(pos) {
|
|
2285
|
-
return {
|
|
2286
|
-
type: 'Alternative',
|
|
2287
|
-
start: deserializeU32(pos),
|
|
2288
|
-
end: deserializeU32(pos + 4),
|
|
2289
|
-
body: deserializeVecTerm(pos + 8),
|
|
2290
|
-
};
|
|
2291
|
-
}
|
|
2292
|
-
|
|
2293
|
-
function deserializeBoundaryAssertion(pos) {
|
|
2294
|
-
return {
|
|
2295
|
-
type: 'BoundaryAssertion',
|
|
2296
|
-
start: deserializeU32(pos),
|
|
2297
|
-
end: deserializeU32(pos + 4),
|
|
2298
|
-
kind: deserializeBoundaryAssertionKind(pos + 8),
|
|
2299
|
-
};
|
|
2300
|
-
}
|
|
2301
|
-
|
|
2302
|
-
function deserializeLookAroundAssertion(pos) {
|
|
2303
|
-
return {
|
|
2304
|
-
type: 'LookAroundAssertion',
|
|
2305
|
-
start: deserializeU32(pos),
|
|
2306
|
-
end: deserializeU32(pos + 4),
|
|
2307
|
-
kind: deserializeLookAroundAssertionKind(pos + 8),
|
|
2308
|
-
body: deserializeDisjunction(pos + 16),
|
|
2309
|
-
};
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
function deserializeQuantifier(pos) {
|
|
2313
|
-
return {
|
|
2314
|
-
type: 'Quantifier',
|
|
2315
|
-
start: deserializeU32(pos),
|
|
2316
|
-
end: deserializeU32(pos + 4),
|
|
2317
|
-
min: deserializeU64(pos + 8),
|
|
2318
|
-
max: deserializeOptionU64(pos + 16),
|
|
2319
|
-
greedy: deserializeBool(pos + 32),
|
|
2320
|
-
body: deserializeTerm(pos + 40),
|
|
2321
|
-
};
|
|
2322
|
-
}
|
|
2323
|
-
|
|
2324
|
-
function deserializeCharacter(pos) {
|
|
2325
|
-
return {
|
|
2326
|
-
type: 'Character',
|
|
2327
|
-
start: deserializeU32(pos),
|
|
2328
|
-
end: deserializeU32(pos + 4),
|
|
2329
|
-
kind: deserializeCharacterKind(pos + 8),
|
|
2330
|
-
value: deserializeU32(pos + 12),
|
|
2331
|
-
};
|
|
2332
|
-
}
|
|
2333
|
-
|
|
2334
|
-
function deserializeCharacterClassEscape(pos) {
|
|
2335
|
-
return {
|
|
2336
|
-
type: 'CharacterClassEscape',
|
|
2337
|
-
start: deserializeU32(pos),
|
|
2338
|
-
end: deserializeU32(pos + 4),
|
|
2339
|
-
kind: deserializeCharacterClassEscapeKind(pos + 8),
|
|
2340
|
-
};
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2343
|
-
function deserializeUnicodePropertyEscape(pos) {
|
|
2344
|
-
return {
|
|
2345
|
-
type: 'UnicodePropertyEscape',
|
|
2346
|
-
start: deserializeU32(pos),
|
|
2347
|
-
end: deserializeU32(pos + 4),
|
|
2348
|
-
negative: deserializeBool(pos + 8),
|
|
2349
|
-
strings: deserializeBool(pos + 9),
|
|
2350
|
-
name: deserializeStr(pos + 16),
|
|
2351
|
-
value: deserializeOptionStr(pos + 32),
|
|
2352
|
-
};
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
function deserializeDot(pos) {
|
|
2356
|
-
return {
|
|
2357
|
-
type: 'Dot',
|
|
2358
|
-
start: deserializeU32(pos),
|
|
2359
|
-
end: deserializeU32(pos + 4),
|
|
2360
|
-
};
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
function deserializeCharacterClass(pos) {
|
|
2364
|
-
return {
|
|
2365
|
-
type: 'CharacterClass',
|
|
2366
|
-
start: deserializeU32(pos),
|
|
2367
|
-
end: deserializeU32(pos + 4),
|
|
2368
|
-
negative: deserializeBool(pos + 8),
|
|
2369
|
-
strings: deserializeBool(pos + 9),
|
|
2370
|
-
kind: deserializeCharacterClassContentsKind(pos + 10),
|
|
2371
|
-
body: deserializeVecCharacterClassContents(pos + 16),
|
|
2372
|
-
};
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
function deserializeCharacterClassRange(pos) {
|
|
2376
|
-
return {
|
|
2377
|
-
type: 'CharacterClassRange',
|
|
2378
|
-
start: deserializeU32(pos),
|
|
2379
|
-
end: deserializeU32(pos + 4),
|
|
2380
|
-
min: deserializeCharacter(pos + 8),
|
|
2381
|
-
max: deserializeCharacter(pos + 24),
|
|
2382
|
-
};
|
|
2383
|
-
}
|
|
2384
|
-
|
|
2385
|
-
function deserializeClassStringDisjunction(pos) {
|
|
2386
|
-
return {
|
|
2387
|
-
type: 'ClassStringDisjunction',
|
|
2388
|
-
start: deserializeU32(pos),
|
|
2389
|
-
end: deserializeU32(pos + 4),
|
|
2390
|
-
strings: deserializeBool(pos + 8),
|
|
2391
|
-
body: deserializeVecClassString(pos + 16),
|
|
2392
|
-
};
|
|
2393
|
-
}
|
|
2394
|
-
|
|
2395
|
-
function deserializeClassString(pos) {
|
|
2396
|
-
return {
|
|
2397
|
-
type: 'ClassString',
|
|
2398
|
-
start: deserializeU32(pos),
|
|
2399
|
-
end: deserializeU32(pos + 4),
|
|
2400
|
-
strings: deserializeBool(pos + 8),
|
|
2401
|
-
body: deserializeVecCharacter(pos + 16),
|
|
2402
|
-
};
|
|
2403
|
-
}
|
|
2404
|
-
|
|
2405
|
-
function deserializeCapturingGroup(pos) {
|
|
2406
|
-
return {
|
|
2407
|
-
type: 'CapturingGroup',
|
|
2408
|
-
start: deserializeU32(pos),
|
|
2409
|
-
end: deserializeU32(pos + 4),
|
|
2410
|
-
name: deserializeOptionStr(pos + 8),
|
|
2411
|
-
body: deserializeDisjunction(pos + 24),
|
|
2412
|
-
};
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2415
|
-
function deserializeIgnoreGroup(pos) {
|
|
2416
|
-
return {
|
|
2417
|
-
type: 'IgnoreGroup',
|
|
2418
|
-
start: deserializeU32(pos),
|
|
2419
|
-
end: deserializeU32(pos + 4),
|
|
2420
|
-
modifiers: deserializeOptionModifiers(pos + 8),
|
|
2421
|
-
body: deserializeDisjunction(pos + 24),
|
|
2422
|
-
};
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
|
-
function deserializeModifiers(pos) {
|
|
2426
|
-
return {
|
|
2427
|
-
type: 'Modifiers',
|
|
2428
|
-
start: deserializeU32(pos),
|
|
2429
|
-
end: deserializeU32(pos + 4),
|
|
2430
|
-
enabling: deserializeOptionModifier(pos + 8),
|
|
2431
|
-
disabling: deserializeOptionModifier(pos + 11),
|
|
2432
|
-
};
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
function deserializeModifier(pos) {
|
|
2436
|
-
return {
|
|
2437
|
-
type: 'Modifier',
|
|
2438
|
-
ignoreCase: deserializeBool(pos),
|
|
2439
|
-
multiline: deserializeBool(pos + 1),
|
|
2440
|
-
sticky: deserializeBool(pos + 2),
|
|
2441
|
-
};
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
function deserializeIndexedReference(pos) {
|
|
2445
|
-
return {
|
|
2446
|
-
type: 'IndexedReference',
|
|
2447
|
-
start: deserializeU32(pos),
|
|
2448
|
-
end: deserializeU32(pos + 4),
|
|
2449
|
-
index: deserializeU32(pos + 8),
|
|
2450
|
-
};
|
|
2451
|
-
}
|
|
2452
|
-
|
|
2453
|
-
function deserializeNamedReference(pos) {
|
|
2454
|
-
return {
|
|
2455
|
-
type: 'NamedReference',
|
|
2456
|
-
start: deserializeU32(pos),
|
|
2457
|
-
end: deserializeU32(pos + 4),
|
|
2458
|
-
name: deserializeStr(pos + 8),
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
2264
|
function deserializeRawTransferData(pos) {
|
|
2463
2265
|
return {
|
|
2464
2266
|
program: deserializeProgram(pos),
|
|
@@ -3571,19 +3373,6 @@ function deserializeModuleExportName(pos) {
|
|
|
3571
3373
|
}
|
|
3572
3374
|
}
|
|
3573
3375
|
|
|
3574
|
-
function deserializeRegExpPattern(pos) {
|
|
3575
|
-
switch (uint8[pos]) {
|
|
3576
|
-
case 0:
|
|
3577
|
-
return deserializeStr(pos + 8);
|
|
3578
|
-
case 1:
|
|
3579
|
-
return deserializeStr(pos + 8);
|
|
3580
|
-
case 2:
|
|
3581
|
-
return deserializeBoxPattern(pos + 8);
|
|
3582
|
-
default:
|
|
3583
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for RegExpPattern`);
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
|
|
3587
3376
|
function deserializeJSXElementName(pos) {
|
|
3588
3377
|
switch (uint8[pos]) {
|
|
3589
3378
|
case 0:
|
|
@@ -4354,145 +4143,6 @@ function deserializeModuleKind(pos) {
|
|
|
4354
4143
|
}
|
|
4355
4144
|
}
|
|
4356
4145
|
|
|
4357
|
-
function deserializeTerm(pos) {
|
|
4358
|
-
switch (uint8[pos]) {
|
|
4359
|
-
case 0:
|
|
4360
|
-
return deserializeBoxBoundaryAssertion(pos + 8);
|
|
4361
|
-
case 1:
|
|
4362
|
-
return deserializeBoxLookAroundAssertion(pos + 8);
|
|
4363
|
-
case 2:
|
|
4364
|
-
return deserializeBoxQuantifier(pos + 8);
|
|
4365
|
-
case 3:
|
|
4366
|
-
return deserializeBoxCharacter(pos + 8);
|
|
4367
|
-
case 4:
|
|
4368
|
-
return deserializeDot(pos + 8);
|
|
4369
|
-
case 5:
|
|
4370
|
-
return deserializeBoxCharacterClassEscape(pos + 8);
|
|
4371
|
-
case 6:
|
|
4372
|
-
return deserializeBoxUnicodePropertyEscape(pos + 8);
|
|
4373
|
-
case 7:
|
|
4374
|
-
return deserializeBoxCharacterClass(pos + 8);
|
|
4375
|
-
case 8:
|
|
4376
|
-
return deserializeBoxCapturingGroup(pos + 8);
|
|
4377
|
-
case 9:
|
|
4378
|
-
return deserializeBoxIgnoreGroup(pos + 8);
|
|
4379
|
-
case 10:
|
|
4380
|
-
return deserializeBoxIndexedReference(pos + 8);
|
|
4381
|
-
case 11:
|
|
4382
|
-
return deserializeBoxNamedReference(pos + 8);
|
|
4383
|
-
default:
|
|
4384
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for Term`);
|
|
4385
|
-
}
|
|
4386
|
-
}
|
|
4387
|
-
|
|
4388
|
-
function deserializeBoundaryAssertionKind(pos) {
|
|
4389
|
-
switch (uint8[pos]) {
|
|
4390
|
-
case 0:
|
|
4391
|
-
return 'start';
|
|
4392
|
-
case 1:
|
|
4393
|
-
return 'end';
|
|
4394
|
-
case 2:
|
|
4395
|
-
return 'boundary';
|
|
4396
|
-
case 3:
|
|
4397
|
-
return 'negativeBoundary';
|
|
4398
|
-
default:
|
|
4399
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for BoundaryAssertionKind`);
|
|
4400
|
-
}
|
|
4401
|
-
}
|
|
4402
|
-
|
|
4403
|
-
function deserializeLookAroundAssertionKind(pos) {
|
|
4404
|
-
switch (uint8[pos]) {
|
|
4405
|
-
case 0:
|
|
4406
|
-
return 'lookahead';
|
|
4407
|
-
case 1:
|
|
4408
|
-
return 'negativeLookahead';
|
|
4409
|
-
case 2:
|
|
4410
|
-
return 'lookbehind';
|
|
4411
|
-
case 3:
|
|
4412
|
-
return 'negativeLookbehind';
|
|
4413
|
-
default:
|
|
4414
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for LookAroundAssertionKind`);
|
|
4415
|
-
}
|
|
4416
|
-
}
|
|
4417
|
-
|
|
4418
|
-
function deserializeCharacterKind(pos) {
|
|
4419
|
-
switch (uint8[pos]) {
|
|
4420
|
-
case 0:
|
|
4421
|
-
return 'controlLetter';
|
|
4422
|
-
case 1:
|
|
4423
|
-
return 'hexadecimalEscape';
|
|
4424
|
-
case 2:
|
|
4425
|
-
return 'identifier';
|
|
4426
|
-
case 3:
|
|
4427
|
-
return 'null';
|
|
4428
|
-
case 4:
|
|
4429
|
-
return 'octal1';
|
|
4430
|
-
case 5:
|
|
4431
|
-
return 'octal2';
|
|
4432
|
-
case 6:
|
|
4433
|
-
return 'octal3';
|
|
4434
|
-
case 7:
|
|
4435
|
-
return 'singleEscape';
|
|
4436
|
-
case 8:
|
|
4437
|
-
return 'symbol';
|
|
4438
|
-
case 9:
|
|
4439
|
-
return 'unicodeEscape';
|
|
4440
|
-
default:
|
|
4441
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterKind`);
|
|
4442
|
-
}
|
|
4443
|
-
}
|
|
4444
|
-
|
|
4445
|
-
function deserializeCharacterClassEscapeKind(pos) {
|
|
4446
|
-
switch (uint8[pos]) {
|
|
4447
|
-
case 0:
|
|
4448
|
-
return 'd';
|
|
4449
|
-
case 1:
|
|
4450
|
-
return 'negativeD';
|
|
4451
|
-
case 2:
|
|
4452
|
-
return 's';
|
|
4453
|
-
case 3:
|
|
4454
|
-
return 'negativeS';
|
|
4455
|
-
case 4:
|
|
4456
|
-
return 'w';
|
|
4457
|
-
case 5:
|
|
4458
|
-
return 'negativeW';
|
|
4459
|
-
default:
|
|
4460
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterClassEscapeKind`);
|
|
4461
|
-
}
|
|
4462
|
-
}
|
|
4463
|
-
|
|
4464
|
-
function deserializeCharacterClassContentsKind(pos) {
|
|
4465
|
-
switch (uint8[pos]) {
|
|
4466
|
-
case 0:
|
|
4467
|
-
return 'union';
|
|
4468
|
-
case 1:
|
|
4469
|
-
return 'intersection';
|
|
4470
|
-
case 2:
|
|
4471
|
-
return 'subtraction';
|
|
4472
|
-
default:
|
|
4473
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterClassContentsKind`);
|
|
4474
|
-
}
|
|
4475
|
-
}
|
|
4476
|
-
|
|
4477
|
-
function deserializeCharacterClassContents(pos) {
|
|
4478
|
-
switch (uint8[pos]) {
|
|
4479
|
-
case 0:
|
|
4480
|
-
return deserializeBoxCharacterClassRange(pos + 8);
|
|
4481
|
-
case 1:
|
|
4482
|
-
return deserializeBoxCharacterClassEscape(pos + 8);
|
|
4483
|
-
case 2:
|
|
4484
|
-
return deserializeBoxUnicodePropertyEscape(pos + 8);
|
|
4485
|
-
case 3:
|
|
4486
|
-
return deserializeBoxCharacter(pos + 8);
|
|
4487
|
-
case 4:
|
|
4488
|
-
return deserializeBoxCharacterClass(pos + 8);
|
|
4489
|
-
case 5:
|
|
4490
|
-
return deserializeBoxClassStringDisjunction(pos + 8);
|
|
4491
|
-
default:
|
|
4492
|
-
throw new Error(`Unexpected discriminant ${uint8[pos]} for CharacterClassContents`);
|
|
4493
|
-
}
|
|
4494
|
-
}
|
|
4495
|
-
|
|
4496
4146
|
function deserializeErrorSeverity(pos) {
|
|
4497
4147
|
switch (uint8[pos]) {
|
|
4498
4148
|
case 0:
|
|
@@ -5360,6 +5010,11 @@ function deserializeBoxPattern(pos) {
|
|
|
5360
5010
|
return deserializePattern(uint32[pos >> 2]);
|
|
5361
5011
|
}
|
|
5362
5012
|
|
|
5013
|
+
function deserializeOptionBoxPattern(pos) {
|
|
5014
|
+
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
5015
|
+
return deserializeBoxPattern(pos);
|
|
5016
|
+
}
|
|
5017
|
+
|
|
5363
5018
|
function deserializeU8(pos) {
|
|
5364
5019
|
return uint8[pos];
|
|
5365
5020
|
}
|
|
@@ -5368,15 +5023,6 @@ function deserializeBoxJSXOpeningElement(pos) {
|
|
|
5368
5023
|
return deserializeJSXOpeningElement(uint32[pos >> 2]);
|
|
5369
5024
|
}
|
|
5370
5025
|
|
|
5371
|
-
function deserializeBoxJSXClosingElement(pos) {
|
|
5372
|
-
return deserializeJSXClosingElement(uint32[pos >> 2]);
|
|
5373
|
-
}
|
|
5374
|
-
|
|
5375
|
-
function deserializeOptionBoxJSXClosingElement(pos) {
|
|
5376
|
-
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
5377
|
-
return deserializeBoxJSXClosingElement(pos);
|
|
5378
|
-
}
|
|
5379
|
-
|
|
5380
5026
|
function deserializeVecJSXChild(pos) {
|
|
5381
5027
|
const arr = [],
|
|
5382
5028
|
pos32 = pos >> 2,
|
|
@@ -5389,6 +5035,15 @@ function deserializeVecJSXChild(pos) {
|
|
|
5389
5035
|
return arr;
|
|
5390
5036
|
}
|
|
5391
5037
|
|
|
5038
|
+
function deserializeBoxJSXClosingElement(pos) {
|
|
5039
|
+
return deserializeJSXClosingElement(uint32[pos >> 2]);
|
|
5040
|
+
}
|
|
5041
|
+
|
|
5042
|
+
function deserializeOptionBoxJSXClosingElement(pos) {
|
|
5043
|
+
if (uint32[pos >> 2] === 0 && uint32[(pos + 4) >> 2] === 0) return null;
|
|
5044
|
+
return deserializeBoxJSXClosingElement(pos);
|
|
5045
|
+
}
|
|
5046
|
+
|
|
5392
5047
|
function deserializeVecJSXAttributeItem(pos) {
|
|
5393
5048
|
const arr = [],
|
|
5394
5049
|
pos32 = pos >> 2,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"browser": "wasm.mjs",
|
|
6
6
|
"engines": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@oxc-project/types": "^0.
|
|
42
|
+
"@oxc-project/types": "^0.69.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@codspeed/vitest-plugin": "^4.0.0",
|
|
@@ -57,9 +57,12 @@
|
|
|
57
57
|
"aarch64-pc-windows-msvc",
|
|
58
58
|
"x86_64-unknown-linux-gnu",
|
|
59
59
|
"x86_64-unknown-linux-musl",
|
|
60
|
+
"x86_64-unknown-freebsd",
|
|
60
61
|
"aarch64-unknown-linux-gnu",
|
|
61
62
|
"aarch64-unknown-linux-musl",
|
|
62
63
|
"armv7-unknown-linux-gnueabihf",
|
|
64
|
+
"s390x-unknown-linux-gnu",
|
|
65
|
+
"riscv64gc-unknown-linux-gnu",
|
|
63
66
|
"x86_64-apple-darwin",
|
|
64
67
|
"aarch64-apple-darwin",
|
|
65
68
|
"wasm32-wasip1-threads"
|
|
@@ -72,16 +75,19 @@
|
|
|
72
75
|
"dtsHeaderFile": "header.js"
|
|
73
76
|
},
|
|
74
77
|
"optionalDependencies": {
|
|
75
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
76
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
77
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
78
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
79
|
-
"@oxc-parser/binding-
|
|
80
|
-
"@oxc-parser/binding-linux-arm64-
|
|
81
|
-
"@oxc-parser/binding-linux-
|
|
82
|
-
"@oxc-parser/binding-
|
|
83
|
-
"@oxc-parser/binding-
|
|
84
|
-
"@oxc-parser/binding-
|
|
78
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.69.0",
|
|
79
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.69.0",
|
|
80
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.69.0",
|
|
81
|
+
"@oxc-parser/binding-linux-x64-musl": "0.69.0",
|
|
82
|
+
"@oxc-parser/binding-freebsd-x64": "0.69.0",
|
|
83
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.69.0",
|
|
84
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.69.0",
|
|
85
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.69.0",
|
|
86
|
+
"@oxc-parser/binding-linux-s390x-gnu": "0.69.0",
|
|
87
|
+
"@oxc-parser/binding-linux-riscv64-gnu": "0.69.0",
|
|
88
|
+
"@oxc-parser/binding-darwin-x64": "0.69.0",
|
|
89
|
+
"@oxc-parser/binding-darwin-arm64": "0.69.0",
|
|
90
|
+
"@oxc-parser/binding-wasm32-wasi": "0.69.0"
|
|
85
91
|
},
|
|
86
92
|
"scripts": {
|
|
87
93
|
"build-dev": "napi build --no-dts-cache --platform --js bindings.js",
|
package/wrap.cjs
CHANGED
|
@@ -23,25 +23,36 @@ module.exports.wrap = function wrap(result) {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// Set `value` field of `Literal`s which are `BigInt`s or `RegExp`s.
|
|
27
|
+
//
|
|
28
|
+
// Returned JSON contains an array `fixes` with paths to these nodes
|
|
29
|
+
// e.g. for `123n; foo(/xyz/)`, `fixes` will be
|
|
30
|
+
// `[["body", 0, "expression"], ["body", 1, "expression", "arguments", 2]]`.
|
|
31
|
+
//
|
|
32
|
+
// Walk down the AST to these nodes and alter them.
|
|
33
|
+
// Compiling the list of fixes on Rust side avoids having to do a full AST traversal on JS side
|
|
34
|
+
// to locate the likely very few `Literal`s which need fixing.
|
|
35
|
+
function jsonParseAst(programJson) {
|
|
36
|
+
const { node: program, fixes } = JSON.parse(programJson);
|
|
37
|
+
for (const fixPath of fixes) {
|
|
38
|
+
applyFix(program, fixPath);
|
|
39
|
+
}
|
|
40
|
+
return program;
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
43
|
+
function applyFix(program, fixPath) {
|
|
44
|
+
let node = program;
|
|
45
|
+
for (const key of fixPath) {
|
|
46
|
+
node = node[key];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (node.bigint) {
|
|
50
|
+
node.value = BigInt(node.bigint);
|
|
51
|
+
} else {
|
|
52
|
+
try {
|
|
53
|
+
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
54
|
+
} catch (_err) {
|
|
55
|
+
// Invalid regexp, or valid regexp using syntax not supported by this version of NodeJS
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
|
-
return value;
|
|
47
58
|
}
|
package/wrap.mjs
CHANGED
|
@@ -23,26 +23,38 @@ export function wrap(result) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
// Used by napi/playground/patch.mjs
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// Used by `napi/playground/patch.mjs`.
|
|
27
|
+
//
|
|
28
|
+
// Set `value` field of `Literal`s which are `BigInt`s or `RegExp`s.
|
|
29
|
+
//
|
|
30
|
+
// Returned JSON contains an array `fixes` with paths to these nodes
|
|
31
|
+
// e.g. for `123n; foo(/xyz/)`, `fixes` will be
|
|
32
|
+
// `[["body", 0, "expression"], ["body", 1, "expression", "arguments", 2]]`.
|
|
33
|
+
//
|
|
34
|
+
// Walk down the AST to these nodes and alter them.
|
|
35
|
+
// Compiling the list of fixes on Rust side avoids having to do a full AST traversal on JS side
|
|
36
|
+
// to locate the likely very few `Literal`s which need fixing.
|
|
37
|
+
export function jsonParseAst(programJson) {
|
|
38
|
+
const { node: program, fixes } = JSON.parse(programJson);
|
|
39
|
+
for (const fixPath of fixes) {
|
|
40
|
+
applyFix(program, fixPath);
|
|
41
|
+
}
|
|
42
|
+
return program;
|
|
29
43
|
}
|
|
30
44
|
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
+
function applyFix(program, fixPath) {
|
|
46
|
+
let node = program;
|
|
47
|
+
for (const key of fixPath) {
|
|
48
|
+
node = node[key];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (node.bigint) {
|
|
52
|
+
node.value = BigInt(node.bigint);
|
|
53
|
+
} else {
|
|
54
|
+
try {
|
|
55
|
+
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
56
|
+
} catch (_err) {
|
|
57
|
+
// Invalid regexp, or valid regexp using syntax not supported by this version of NodeJS
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
|
-
return value;
|
|
48
60
|
}
|