@rollup/wasm-node 4.9.4 → 4.9.6
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/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +33 -11
- package/dist/es/shared/parseAst.js +318 -361
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +318 -361
- package/dist/shared/rollup.js +33 -11
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/dist/wasm-node/bindings_wasm.js +22 -22
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +13 -12
package/dist/shared/parseAst.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.9.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.9.6
|
|
4
|
+
Sun, 21 Jan 2024 05:51:51 GMT - commit ecb6b0a430098052781aa6ee04ec92ee70960321
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -1020,21 +1020,21 @@ const FIXED_STRINGS = [
|
|
|
1020
1020
|
'noSideEffects'
|
|
1021
1021
|
];
|
|
1022
1022
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
throw new Error(`Unknown node type: ${nodeType}`);
|
|
1031
|
-
}
|
|
1032
|
-
return converter(position + 1, buffer, readString);
|
|
1033
|
-
};
|
|
1023
|
+
// This file is generated by scripts/generate-ast-converters.js.
|
|
1024
|
+
// Do not edit this file directly.
|
|
1025
|
+
const ANNOTATION_KEY = '_rollupAnnotations';
|
|
1026
|
+
const INVALID_ANNOTATION_KEY = '_rollupRemoved';
|
|
1027
|
+
function convertProgram(buffer, readString) {
|
|
1028
|
+
return convertNode(0, new Uint32Array(buffer), readString);
|
|
1029
|
+
}
|
|
1034
1030
|
/* eslint-disable sort-keys */
|
|
1035
1031
|
const nodeConverters = [
|
|
1036
|
-
|
|
1037
|
-
|
|
1032
|
+
function parseError(position, buffer, readString) {
|
|
1033
|
+
const pos = buffer[position++];
|
|
1034
|
+
const message = convertString(position, buffer, readString);
|
|
1035
|
+
error(logParseError(message, pos));
|
|
1036
|
+
},
|
|
1037
|
+
function arrayExpression(position, buffer, readString) {
|
|
1038
1038
|
const start = buffer[position++];
|
|
1039
1039
|
const end = buffer[position++];
|
|
1040
1040
|
const elements = convertNodeList(position, buffer, readString);
|
|
@@ -1045,8 +1045,7 @@ const nodeConverters = [
|
|
|
1045
1045
|
elements
|
|
1046
1046
|
};
|
|
1047
1047
|
},
|
|
1048
|
-
|
|
1049
|
-
(position, buffer, readString) => {
|
|
1048
|
+
function arrayPattern(position, buffer, readString) {
|
|
1050
1049
|
const start = buffer[position++];
|
|
1051
1050
|
const end = buffer[position++];
|
|
1052
1051
|
const elements = convertNodeList(position, buffer, readString);
|
|
@@ -1057,30 +1056,30 @@ const nodeConverters = [
|
|
|
1057
1056
|
elements
|
|
1058
1057
|
};
|
|
1059
1058
|
},
|
|
1060
|
-
|
|
1061
|
-
(position, buffer, readString) => {
|
|
1059
|
+
function arrowFunctionExpression(position, buffer, readString) {
|
|
1062
1060
|
const start = buffer[position++];
|
|
1063
1061
|
const end = buffer[position++];
|
|
1064
|
-
const
|
|
1065
|
-
const
|
|
1066
|
-
const expression =
|
|
1062
|
+
const flags = buffer[position++];
|
|
1063
|
+
const async = (flags & 1) === 1;
|
|
1064
|
+
const expression = (flags & 2) === 2;
|
|
1065
|
+
const generator = (flags & 4) === 4;
|
|
1067
1066
|
const parameters = convertNodeList(buffer[position++], buffer, readString);
|
|
1068
1067
|
const body = convertNode(buffer[position++], buffer, readString);
|
|
1069
|
-
const annotations =
|
|
1070
|
-
return
|
|
1068
|
+
const annotations = convertAnnotations(position, buffer);
|
|
1069
|
+
return {
|
|
1071
1070
|
type: 'ArrowFunctionExpression',
|
|
1072
1071
|
start,
|
|
1073
1072
|
end,
|
|
1074
1073
|
async,
|
|
1075
|
-
body,
|
|
1076
1074
|
expression,
|
|
1077
1075
|
generator,
|
|
1078
|
-
|
|
1079
|
-
params: parameters
|
|
1080
|
-
|
|
1076
|
+
...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
|
|
1077
|
+
params: parameters,
|
|
1078
|
+
body,
|
|
1079
|
+
id: null
|
|
1080
|
+
};
|
|
1081
1081
|
},
|
|
1082
|
-
|
|
1083
|
-
(position, buffer, readString) => {
|
|
1082
|
+
function assignmentExpression(position, buffer, readString) {
|
|
1084
1083
|
const start = buffer[position++];
|
|
1085
1084
|
const end = buffer[position++];
|
|
1086
1085
|
const operator = FIXED_STRINGS[buffer[position++]];
|
|
@@ -1090,13 +1089,12 @@ const nodeConverters = [
|
|
|
1090
1089
|
type: 'AssignmentExpression',
|
|
1091
1090
|
start,
|
|
1092
1091
|
end,
|
|
1093
|
-
left,
|
|
1094
1092
|
operator,
|
|
1093
|
+
left,
|
|
1095
1094
|
right
|
|
1096
1095
|
};
|
|
1097
1096
|
},
|
|
1098
|
-
|
|
1099
|
-
(position, buffer, readString) => {
|
|
1097
|
+
function assignmentPattern(position, buffer, readString) {
|
|
1100
1098
|
const start = buffer[position++];
|
|
1101
1099
|
const end = buffer[position++];
|
|
1102
1100
|
const right = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1109,20 +1107,18 @@ const nodeConverters = [
|
|
|
1109
1107
|
right
|
|
1110
1108
|
};
|
|
1111
1109
|
},
|
|
1112
|
-
|
|
1113
|
-
(position, buffer, readString) => {
|
|
1110
|
+
function awaitExpression(position, buffer, readString) {
|
|
1114
1111
|
const start = buffer[position++];
|
|
1115
1112
|
const end = buffer[position++];
|
|
1116
1113
|
const argument = convertNode(position, buffer, readString);
|
|
1117
1114
|
return {
|
|
1118
1115
|
type: 'AwaitExpression',
|
|
1119
1116
|
start,
|
|
1120
|
-
|
|
1121
|
-
|
|
1117
|
+
end,
|
|
1118
|
+
argument
|
|
1122
1119
|
};
|
|
1123
1120
|
},
|
|
1124
|
-
|
|
1125
|
-
(position, buffer, readString) => {
|
|
1121
|
+
function binaryExpression(position, buffer, readString) {
|
|
1126
1122
|
const start = buffer[position++];
|
|
1127
1123
|
const end = buffer[position++];
|
|
1128
1124
|
const operator = FIXED_STRINGS[buffer[position++]];
|
|
@@ -1132,68 +1128,67 @@ const nodeConverters = [
|
|
|
1132
1128
|
type: 'BinaryExpression',
|
|
1133
1129
|
start,
|
|
1134
1130
|
end,
|
|
1135
|
-
left,
|
|
1136
1131
|
operator,
|
|
1132
|
+
left,
|
|
1137
1133
|
right
|
|
1138
1134
|
};
|
|
1139
1135
|
},
|
|
1140
|
-
|
|
1141
|
-
(position, buffer, readString) => {
|
|
1136
|
+
function blockStatement(position, buffer, readString) {
|
|
1142
1137
|
const start = buffer[position++];
|
|
1143
1138
|
const end = buffer[position++];
|
|
1144
1139
|
const body = convertNodeList(position, buffer, readString);
|
|
1145
1140
|
return {
|
|
1146
1141
|
type: 'BlockStatement',
|
|
1147
1142
|
start,
|
|
1148
|
-
|
|
1149
|
-
|
|
1143
|
+
end,
|
|
1144
|
+
body
|
|
1150
1145
|
};
|
|
1151
1146
|
},
|
|
1152
|
-
|
|
1153
|
-
(position, buffer, readString) => {
|
|
1147
|
+
function breakStatement(position, buffer, readString) {
|
|
1154
1148
|
const start = buffer[position++];
|
|
1155
1149
|
const end = buffer[position++];
|
|
1156
|
-
const labelPosition = buffer[position
|
|
1150
|
+
const labelPosition = buffer[position];
|
|
1151
|
+
const label = labelPosition === 0 ? null : convertNode(labelPosition, buffer, readString);
|
|
1157
1152
|
return {
|
|
1158
1153
|
type: 'BreakStatement',
|
|
1159
1154
|
start,
|
|
1160
1155
|
end,
|
|
1161
|
-
label
|
|
1156
|
+
label
|
|
1162
1157
|
};
|
|
1163
1158
|
},
|
|
1164
|
-
|
|
1165
|
-
(position, buffer, readString) => {
|
|
1159
|
+
function callExpression(position, buffer, readString) {
|
|
1166
1160
|
const start = buffer[position++];
|
|
1167
1161
|
const end = buffer[position++];
|
|
1168
|
-
const
|
|
1162
|
+
const flags = buffer[position++];
|
|
1163
|
+
const optional = (flags & 1) === 1;
|
|
1169
1164
|
const callee = convertNode(buffer[position++], buffer, readString);
|
|
1170
|
-
const
|
|
1171
|
-
const annotations =
|
|
1172
|
-
return
|
|
1165
|
+
const callArguments = convertNodeList(buffer[position++], buffer, readString);
|
|
1166
|
+
const annotations = convertAnnotations(position, buffer);
|
|
1167
|
+
return {
|
|
1173
1168
|
type: 'CallExpression',
|
|
1174
1169
|
start,
|
|
1175
1170
|
end,
|
|
1176
|
-
|
|
1171
|
+
optional,
|
|
1172
|
+
...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
|
|
1177
1173
|
callee,
|
|
1178
|
-
|
|
1179
|
-
}
|
|
1174
|
+
arguments: callArguments
|
|
1175
|
+
};
|
|
1180
1176
|
},
|
|
1181
|
-
|
|
1182
|
-
(position, buffer, readString) => {
|
|
1177
|
+
function catchClause(position, buffer, readString) {
|
|
1183
1178
|
const start = buffer[position++];
|
|
1184
1179
|
const end = buffer[position++];
|
|
1185
1180
|
const parameterPosition = buffer[position++];
|
|
1181
|
+
const parameter = parameterPosition === 0 ? null : convertNode(parameterPosition, buffer, readString);
|
|
1186
1182
|
const body = convertNode(buffer[position], buffer, readString);
|
|
1187
1183
|
return {
|
|
1188
1184
|
type: 'CatchClause',
|
|
1189
1185
|
start,
|
|
1190
1186
|
end,
|
|
1191
|
-
|
|
1192
|
-
|
|
1187
|
+
param: parameter,
|
|
1188
|
+
body
|
|
1193
1189
|
};
|
|
1194
1190
|
},
|
|
1195
|
-
|
|
1196
|
-
(position, buffer, readString) => {
|
|
1191
|
+
function chainExpression(position, buffer, readString) {
|
|
1197
1192
|
const start = buffer[position++];
|
|
1198
1193
|
const end = buffer[position++];
|
|
1199
1194
|
const expression = convertNode(position, buffer, readString);
|
|
@@ -1204,8 +1199,7 @@ const nodeConverters = [
|
|
|
1204
1199
|
expression
|
|
1205
1200
|
};
|
|
1206
1201
|
},
|
|
1207
|
-
|
|
1208
|
-
(position, buffer, readString) => {
|
|
1202
|
+
function classBody(position, buffer, readString) {
|
|
1209
1203
|
const start = buffer[position++];
|
|
1210
1204
|
const end = buffer[position++];
|
|
1211
1205
|
const body = convertNodeList(position, buffer, readString);
|
|
@@ -1216,40 +1210,41 @@ const nodeConverters = [
|
|
|
1216
1210
|
body
|
|
1217
1211
|
};
|
|
1218
1212
|
},
|
|
1219
|
-
|
|
1220
|
-
(position, buffer, readString) => {
|
|
1213
|
+
function classDeclaration(position, buffer, readString) {
|
|
1221
1214
|
const start = buffer[position++];
|
|
1222
1215
|
const end = buffer[position++];
|
|
1223
1216
|
const idPosition = buffer[position++];
|
|
1217
|
+
const id = idPosition === 0 ? null : convertNode(idPosition, buffer, readString);
|
|
1224
1218
|
const superClassPosition = buffer[position++];
|
|
1219
|
+
const superClass = superClassPosition === 0 ? null : convertNode(superClassPosition, buffer, readString);
|
|
1225
1220
|
const body = convertNode(buffer[position], buffer, readString);
|
|
1226
1221
|
return {
|
|
1227
1222
|
type: 'ClassDeclaration',
|
|
1228
1223
|
start,
|
|
1229
1224
|
end,
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1225
|
+
id,
|
|
1226
|
+
superClass,
|
|
1227
|
+
body
|
|
1233
1228
|
};
|
|
1234
1229
|
},
|
|
1235
|
-
|
|
1236
|
-
(position, buffer, readString) => {
|
|
1230
|
+
function classExpression(position, buffer, readString) {
|
|
1237
1231
|
const start = buffer[position++];
|
|
1238
1232
|
const end = buffer[position++];
|
|
1239
1233
|
const idPosition = buffer[position++];
|
|
1234
|
+
const id = idPosition === 0 ? null : convertNode(idPosition, buffer, readString);
|
|
1240
1235
|
const superClassPosition = buffer[position++];
|
|
1236
|
+
const superClass = superClassPosition === 0 ? null : convertNode(superClassPosition, buffer, readString);
|
|
1241
1237
|
const body = convertNode(buffer[position], buffer, readString);
|
|
1242
1238
|
return {
|
|
1243
1239
|
type: 'ClassExpression',
|
|
1244
1240
|
start,
|
|
1245
1241
|
end,
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1242
|
+
id,
|
|
1243
|
+
superClass,
|
|
1244
|
+
body
|
|
1249
1245
|
};
|
|
1250
1246
|
},
|
|
1251
|
-
|
|
1252
|
-
(position, buffer, readString) => {
|
|
1247
|
+
function conditionalExpression(position, buffer, readString) {
|
|
1253
1248
|
const start = buffer[position++];
|
|
1254
1249
|
const end = buffer[position++];
|
|
1255
1250
|
const consequent = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1259,25 +1254,24 @@ const nodeConverters = [
|
|
|
1259
1254
|
type: 'ConditionalExpression',
|
|
1260
1255
|
start,
|
|
1261
1256
|
end,
|
|
1262
|
-
|
|
1257
|
+
test,
|
|
1263
1258
|
consequent,
|
|
1264
|
-
|
|
1259
|
+
alternate
|
|
1265
1260
|
};
|
|
1266
1261
|
},
|
|
1267
|
-
|
|
1268
|
-
(position, buffer, readString) => {
|
|
1262
|
+
function continueStatement(position, buffer, readString) {
|
|
1269
1263
|
const start = buffer[position++];
|
|
1270
1264
|
const end = buffer[position++];
|
|
1271
1265
|
const labelPosition = buffer[position];
|
|
1266
|
+
const label = labelPosition === 0 ? null : convertNode(labelPosition, buffer, readString);
|
|
1272
1267
|
return {
|
|
1273
1268
|
type: 'ContinueStatement',
|
|
1274
1269
|
start,
|
|
1275
1270
|
end,
|
|
1276
|
-
label
|
|
1271
|
+
label
|
|
1277
1272
|
};
|
|
1278
1273
|
},
|
|
1279
|
-
|
|
1280
|
-
(position, buffer) => {
|
|
1274
|
+
function debuggerStatement(position, buffer) {
|
|
1281
1275
|
const start = buffer[position++];
|
|
1282
1276
|
const end = buffer[position++];
|
|
1283
1277
|
return {
|
|
@@ -1286,8 +1280,20 @@ const nodeConverters = [
|
|
|
1286
1280
|
end
|
|
1287
1281
|
};
|
|
1288
1282
|
},
|
|
1289
|
-
|
|
1290
|
-
|
|
1283
|
+
function directive(position, buffer, readString) {
|
|
1284
|
+
const start = buffer[position++];
|
|
1285
|
+
const end = buffer[position++];
|
|
1286
|
+
const expression = convertNode(buffer[position++], buffer, readString);
|
|
1287
|
+
const directive = convertString(position, buffer, readString);
|
|
1288
|
+
return {
|
|
1289
|
+
type: 'ExpressionStatement',
|
|
1290
|
+
start,
|
|
1291
|
+
end,
|
|
1292
|
+
directive,
|
|
1293
|
+
expression
|
|
1294
|
+
};
|
|
1295
|
+
},
|
|
1296
|
+
function doWhileStatement(position, buffer, readString) {
|
|
1291
1297
|
const start = buffer[position++];
|
|
1292
1298
|
const end = buffer[position++];
|
|
1293
1299
|
const test = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1300,8 +1306,7 @@ const nodeConverters = [
|
|
|
1300
1306
|
test
|
|
1301
1307
|
};
|
|
1302
1308
|
},
|
|
1303
|
-
|
|
1304
|
-
(position, buffer) => {
|
|
1309
|
+
function emptyStatement(position, buffer) {
|
|
1305
1310
|
const start = buffer[position++];
|
|
1306
1311
|
const end = buffer[position++];
|
|
1307
1312
|
return {
|
|
@@ -1310,24 +1315,23 @@ const nodeConverters = [
|
|
|
1310
1315
|
end
|
|
1311
1316
|
};
|
|
1312
1317
|
},
|
|
1313
|
-
|
|
1314
|
-
(position, buffer, readString) => {
|
|
1318
|
+
function exportAllDeclaration(position, buffer, readString) {
|
|
1315
1319
|
const start = buffer[position++];
|
|
1316
1320
|
const end = buffer[position++];
|
|
1317
1321
|
const exportedPosition = buffer[position++];
|
|
1322
|
+
const exported = exportedPosition === 0 ? null : convertNode(exportedPosition, buffer, readString);
|
|
1318
1323
|
const source = convertNode(buffer[position++], buffer, readString);
|
|
1319
1324
|
const attributes = convertNodeList(buffer[position], buffer, readString);
|
|
1320
1325
|
return {
|
|
1321
1326
|
type: 'ExportAllDeclaration',
|
|
1322
1327
|
start,
|
|
1323
1328
|
end,
|
|
1324
|
-
exported
|
|
1329
|
+
exported,
|
|
1325
1330
|
source,
|
|
1326
1331
|
attributes
|
|
1327
1332
|
};
|
|
1328
1333
|
},
|
|
1329
|
-
|
|
1330
|
-
(position, buffer, readString) => {
|
|
1334
|
+
function exportDefaultDeclaration(position, buffer, readString) {
|
|
1331
1335
|
const start = buffer[position++];
|
|
1332
1336
|
const end = buffer[position++];
|
|
1333
1337
|
const declaration = convertNode(position, buffer, readString);
|
|
@@ -1338,59 +1342,50 @@ const nodeConverters = [
|
|
|
1338
1342
|
declaration
|
|
1339
1343
|
};
|
|
1340
1344
|
},
|
|
1341
|
-
|
|
1342
|
-
(position, buffer, readString) => {
|
|
1345
|
+
function exportNamedDeclaration(position, buffer, readString) {
|
|
1343
1346
|
const start = buffer[position++];
|
|
1344
1347
|
const end = buffer[position++];
|
|
1345
|
-
const declarationPosition = buffer[position++];
|
|
1346
1348
|
const sourcePosition = buffer[position++];
|
|
1349
|
+
const source = sourcePosition === 0 ? null : convertNode(sourcePosition, buffer, readString);
|
|
1347
1350
|
const attributes = convertNodeList(buffer[position++], buffer, readString);
|
|
1351
|
+
const declarationPosition = buffer[position++];
|
|
1352
|
+
const declaration = declarationPosition === 0 ? null : convertNode(declarationPosition, buffer, readString);
|
|
1348
1353
|
const specifiers = convertNodeList(position, buffer, readString);
|
|
1349
1354
|
return {
|
|
1350
1355
|
type: 'ExportNamedDeclaration',
|
|
1351
1356
|
start,
|
|
1352
1357
|
end,
|
|
1353
|
-
declaration: declarationPosition
|
|
1354
|
-
? convertNode(declarationPosition, buffer, readString)
|
|
1355
|
-
: null,
|
|
1356
|
-
source: sourcePosition ? convertNode(sourcePosition, buffer, readString) : null,
|
|
1357
1358
|
specifiers,
|
|
1358
|
-
|
|
1359
|
+
source,
|
|
1360
|
+
attributes,
|
|
1361
|
+
declaration
|
|
1359
1362
|
};
|
|
1360
1363
|
},
|
|
1361
|
-
|
|
1362
|
-
(position, buffer, readString) => {
|
|
1364
|
+
function exportSpecifier(position, buffer, readString) {
|
|
1363
1365
|
const start = buffer[position++];
|
|
1364
1366
|
const end = buffer[position++];
|
|
1365
1367
|
const exportedPosition = buffer[position++];
|
|
1366
1368
|
const local = convertNode(position, buffer, readString);
|
|
1367
|
-
const exported = exportedPosition ? convertNode(exportedPosition, buffer, readString) : local;
|
|
1368
1369
|
return {
|
|
1369
1370
|
type: 'ExportSpecifier',
|
|
1370
1371
|
start,
|
|
1371
1372
|
end,
|
|
1372
|
-
|
|
1373
|
-
local
|
|
1373
|
+
local,
|
|
1374
|
+
exported: exportedPosition === 0 ? { ...local } : convertNode(exportedPosition, buffer, readString)
|
|
1374
1375
|
};
|
|
1375
1376
|
},
|
|
1376
|
-
|
|
1377
|
-
(position, buffer, readString) => {
|
|
1377
|
+
function expressionStatement(position, buffer, readString) {
|
|
1378
1378
|
const start = buffer[position++];
|
|
1379
1379
|
const end = buffer[position++];
|
|
1380
|
-
const directivePosition = buffer[position++];
|
|
1381
1380
|
const expression = convertNode(position, buffer, readString);
|
|
1382
1381
|
return {
|
|
1383
1382
|
type: 'ExpressionStatement',
|
|
1384
1383
|
start,
|
|
1385
1384
|
end,
|
|
1386
|
-
expression
|
|
1387
|
-
...(directivePosition
|
|
1388
|
-
? { directive: convertString(directivePosition, buffer, readString) }
|
|
1389
|
-
: {})
|
|
1385
|
+
expression
|
|
1390
1386
|
};
|
|
1391
1387
|
},
|
|
1392
|
-
|
|
1393
|
-
(position, buffer, readString) => {
|
|
1388
|
+
function forInStatement(position, buffer, readString) {
|
|
1394
1389
|
const start = buffer[position++];
|
|
1395
1390
|
const end = buffer[position++];
|
|
1396
1391
|
const right = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1400,16 +1395,16 @@ const nodeConverters = [
|
|
|
1400
1395
|
type: 'ForInStatement',
|
|
1401
1396
|
start,
|
|
1402
1397
|
end,
|
|
1403
|
-
body,
|
|
1404
1398
|
left,
|
|
1405
|
-
right
|
|
1399
|
+
right,
|
|
1400
|
+
body
|
|
1406
1401
|
};
|
|
1407
1402
|
},
|
|
1408
|
-
|
|
1409
|
-
(position, buffer, readString) => {
|
|
1403
|
+
function forOfStatement(position, buffer, readString) {
|
|
1410
1404
|
const start = buffer[position++];
|
|
1411
1405
|
const end = buffer[position++];
|
|
1412
|
-
const
|
|
1406
|
+
const flags = buffer[position++];
|
|
1407
|
+
const awaited = (flags & 1) === 1;
|
|
1413
1408
|
const right = convertNode(buffer[position++], buffer, readString);
|
|
1414
1409
|
const body = convertNode(buffer[position++], buffer, readString);
|
|
1415
1410
|
const left = convertNode(position, buffer, readString);
|
|
@@ -1418,75 +1413,80 @@ const nodeConverters = [
|
|
|
1418
1413
|
start,
|
|
1419
1414
|
end,
|
|
1420
1415
|
await: awaited,
|
|
1421
|
-
body,
|
|
1422
1416
|
left,
|
|
1423
|
-
right
|
|
1417
|
+
right,
|
|
1418
|
+
body
|
|
1424
1419
|
};
|
|
1425
1420
|
},
|
|
1426
|
-
|
|
1427
|
-
(position, buffer, readString) => {
|
|
1421
|
+
function forStatement(position, buffer, readString) {
|
|
1428
1422
|
const start = buffer[position++];
|
|
1429
1423
|
const end = buffer[position++];
|
|
1430
1424
|
const initPosition = buffer[position++];
|
|
1425
|
+
const init = initPosition === 0 ? null : convertNode(initPosition, buffer, readString);
|
|
1431
1426
|
const testPosition = buffer[position++];
|
|
1427
|
+
const test = testPosition === 0 ? null : convertNode(testPosition, buffer, readString);
|
|
1432
1428
|
const updatePosition = buffer[position++];
|
|
1429
|
+
const update = updatePosition === 0 ? null : convertNode(updatePosition, buffer, readString);
|
|
1433
1430
|
const body = convertNode(buffer[position], buffer, readString);
|
|
1434
1431
|
return {
|
|
1435
1432
|
type: 'ForStatement',
|
|
1436
1433
|
start,
|
|
1437
1434
|
end,
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1435
|
+
init,
|
|
1436
|
+
test,
|
|
1437
|
+
update,
|
|
1438
|
+
body
|
|
1442
1439
|
};
|
|
1443
1440
|
},
|
|
1444
|
-
|
|
1445
|
-
(position, buffer, readString) => {
|
|
1441
|
+
function functionDeclaration(position, buffer, readString) {
|
|
1446
1442
|
const start = buffer[position++];
|
|
1447
1443
|
const end = buffer[position++];
|
|
1448
|
-
const
|
|
1449
|
-
const
|
|
1444
|
+
const flags = buffer[position++];
|
|
1445
|
+
const async = (flags & 1) === 1;
|
|
1446
|
+
const generator = (flags & 2) === 2;
|
|
1450
1447
|
const idPosition = buffer[position++];
|
|
1448
|
+
const id = idPosition === 0 ? null : convertNode(idPosition, buffer, readString);
|
|
1451
1449
|
const parameters = convertNodeList(buffer[position++], buffer, readString);
|
|
1452
1450
|
const body = convertNode(buffer[position++], buffer, readString);
|
|
1453
|
-
const annotations =
|
|
1454
|
-
return
|
|
1451
|
+
const annotations = convertAnnotations(position, buffer);
|
|
1452
|
+
return {
|
|
1455
1453
|
type: 'FunctionDeclaration',
|
|
1456
1454
|
start,
|
|
1457
1455
|
end,
|
|
1458
1456
|
async,
|
|
1459
|
-
body,
|
|
1460
|
-
expression: false,
|
|
1461
1457
|
generator,
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1458
|
+
...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
|
|
1459
|
+
id,
|
|
1460
|
+
params: parameters,
|
|
1461
|
+
body,
|
|
1462
|
+
expression: false
|
|
1463
|
+
};
|
|
1465
1464
|
},
|
|
1466
|
-
|
|
1467
|
-
(position, buffer, readString) => {
|
|
1465
|
+
function functionExpression(position, buffer, readString) {
|
|
1468
1466
|
const start = buffer[position++];
|
|
1469
1467
|
const end = buffer[position++];
|
|
1470
|
-
const
|
|
1471
|
-
const
|
|
1468
|
+
const flags = buffer[position++];
|
|
1469
|
+
const async = (flags & 1) === 1;
|
|
1470
|
+
const generator = (flags & 2) === 2;
|
|
1472
1471
|
const idPosition = buffer[position++];
|
|
1472
|
+
const id = idPosition === 0 ? null : convertNode(idPosition, buffer, readString);
|
|
1473
1473
|
const parameters = convertNodeList(buffer[position++], buffer, readString);
|
|
1474
1474
|
const body = convertNode(buffer[position++], buffer, readString);
|
|
1475
|
-
const annotations =
|
|
1476
|
-
return
|
|
1475
|
+
const annotations = convertAnnotations(position, buffer);
|
|
1476
|
+
return {
|
|
1477
1477
|
type: 'FunctionExpression',
|
|
1478
1478
|
start,
|
|
1479
1479
|
end,
|
|
1480
1480
|
async,
|
|
1481
|
-
body,
|
|
1482
|
-
expression: false,
|
|
1483
1481
|
generator,
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1482
|
+
...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
|
|
1483
|
+
id,
|
|
1484
|
+
params: parameters,
|
|
1485
|
+
body,
|
|
1486
|
+
expression: false
|
|
1487
|
+
};
|
|
1487
1488
|
},
|
|
1488
|
-
|
|
1489
|
-
(position, buffer, readString) => {
|
|
1489
|
+
function identifier(position, buffer, readString) {
|
|
1490
1490
|
const start = buffer[position++];
|
|
1491
1491
|
const end = buffer[position++];
|
|
1492
1492
|
const name = convertString(position, buffer, readString);
|
|
@@ -1497,24 +1497,23 @@ const nodeConverters = [
|
|
|
1497
1497
|
name
|
|
1498
1498
|
};
|
|
1499
1499
|
},
|
|
1500
|
-
|
|
1501
|
-
(position, buffer, readString) => {
|
|
1500
|
+
function ifStatement(position, buffer, readString) {
|
|
1502
1501
|
const start = buffer[position++];
|
|
1503
1502
|
const end = buffer[position++];
|
|
1504
1503
|
const consequent = convertNode(buffer[position++], buffer, readString);
|
|
1505
1504
|
const alternatePosition = buffer[position++];
|
|
1505
|
+
const alternate = alternatePosition === 0 ? null : convertNode(alternatePosition, buffer, readString);
|
|
1506
1506
|
const test = convertNode(position, buffer, readString);
|
|
1507
1507
|
return {
|
|
1508
1508
|
type: 'IfStatement',
|
|
1509
1509
|
start,
|
|
1510
1510
|
end,
|
|
1511
|
-
|
|
1511
|
+
test,
|
|
1512
1512
|
consequent,
|
|
1513
|
-
|
|
1513
|
+
alternate
|
|
1514
1514
|
};
|
|
1515
1515
|
},
|
|
1516
|
-
|
|
1517
|
-
(position, buffer, readString) => {
|
|
1516
|
+
function importAttribute(position, buffer, readString) {
|
|
1518
1517
|
const start = buffer[position++];
|
|
1519
1518
|
const end = buffer[position++];
|
|
1520
1519
|
const value = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1527,8 +1526,7 @@ const nodeConverters = [
|
|
|
1527
1526
|
value
|
|
1528
1527
|
};
|
|
1529
1528
|
},
|
|
1530
|
-
|
|
1531
|
-
(position, buffer, readString) => {
|
|
1529
|
+
function importDeclaration(position, buffer, readString) {
|
|
1532
1530
|
const start = buffer[position++];
|
|
1533
1531
|
const end = buffer[position++];
|
|
1534
1532
|
const source = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1538,13 +1536,12 @@ const nodeConverters = [
|
|
|
1538
1536
|
type: 'ImportDeclaration',
|
|
1539
1537
|
start,
|
|
1540
1538
|
end,
|
|
1541
|
-
source,
|
|
1542
1539
|
specifiers,
|
|
1540
|
+
source,
|
|
1543
1541
|
attributes
|
|
1544
1542
|
};
|
|
1545
1543
|
},
|
|
1546
|
-
|
|
1547
|
-
(position, buffer, readString) => {
|
|
1544
|
+
function importDefaultSpecifier(position, buffer, readString) {
|
|
1548
1545
|
const start = buffer[position++];
|
|
1549
1546
|
const end = buffer[position++];
|
|
1550
1547
|
const local = convertNode(position, buffer, readString);
|
|
@@ -1555,22 +1552,21 @@ const nodeConverters = [
|
|
|
1555
1552
|
local
|
|
1556
1553
|
};
|
|
1557
1554
|
},
|
|
1558
|
-
|
|
1559
|
-
(position, buffer, readString) => {
|
|
1555
|
+
function importExpression(position, buffer, readString) {
|
|
1560
1556
|
const start = buffer[position++];
|
|
1561
1557
|
const end = buffer[position++];
|
|
1562
1558
|
const optionsPosition = buffer[position++];
|
|
1559
|
+
const options = optionsPosition === 0 ? null : convertNode(optionsPosition, buffer, readString);
|
|
1563
1560
|
const source = convertNode(position, buffer, readString);
|
|
1564
1561
|
return {
|
|
1565
1562
|
type: 'ImportExpression',
|
|
1566
1563
|
start,
|
|
1567
1564
|
end,
|
|
1568
1565
|
source,
|
|
1569
|
-
options
|
|
1566
|
+
options
|
|
1570
1567
|
};
|
|
1571
1568
|
},
|
|
1572
|
-
|
|
1573
|
-
(position, buffer, readString) => {
|
|
1569
|
+
function importNamespaceSpecifier(position, buffer, readString) {
|
|
1574
1570
|
const start = buffer[position++];
|
|
1575
1571
|
const end = buffer[position++];
|
|
1576
1572
|
const local = convertNode(position, buffer, readString);
|
|
@@ -1581,23 +1577,20 @@ const nodeConverters = [
|
|
|
1581
1577
|
local
|
|
1582
1578
|
};
|
|
1583
1579
|
},
|
|
1584
|
-
|
|
1585
|
-
(position, buffer, readString) => {
|
|
1580
|
+
function importSpecifier(position, buffer, readString) {
|
|
1586
1581
|
const start = buffer[position++];
|
|
1587
1582
|
const end = buffer[position++];
|
|
1588
1583
|
const importedPosition = buffer[position++];
|
|
1589
1584
|
const local = convertNode(buffer[position], buffer, readString);
|
|
1590
|
-
const imported = importedPosition ? convertNode(importedPosition, buffer, readString) : local;
|
|
1591
1585
|
return {
|
|
1592
1586
|
type: 'ImportSpecifier',
|
|
1593
1587
|
start,
|
|
1594
1588
|
end,
|
|
1595
|
-
imported,
|
|
1589
|
+
imported: importedPosition === 0 ? { ...local } : convertNode(importedPosition, buffer, readString),
|
|
1596
1590
|
local
|
|
1597
1591
|
};
|
|
1598
1592
|
},
|
|
1599
|
-
|
|
1600
|
-
(position, buffer, readString) => {
|
|
1593
|
+
function labeledStatement(position, buffer, readString) {
|
|
1601
1594
|
const start = buffer[position++];
|
|
1602
1595
|
const end = buffer[position++];
|
|
1603
1596
|
const body = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1606,67 +1599,63 @@ const nodeConverters = [
|
|
|
1606
1599
|
type: 'LabeledStatement',
|
|
1607
1600
|
start,
|
|
1608
1601
|
end,
|
|
1609
|
-
|
|
1610
|
-
|
|
1602
|
+
label,
|
|
1603
|
+
body
|
|
1611
1604
|
};
|
|
1612
1605
|
},
|
|
1613
|
-
|
|
1614
|
-
(position, buffer, readString) => {
|
|
1606
|
+
function literalBigInt(position, buffer, readString) {
|
|
1615
1607
|
const start = buffer[position++];
|
|
1616
1608
|
const end = buffer[position++];
|
|
1617
|
-
const
|
|
1618
|
-
const
|
|
1619
|
-
const value = convertString(position, buffer, readString);
|
|
1609
|
+
const raw = convertString(buffer[position++], buffer, readString);
|
|
1610
|
+
const bigint = convertString(position, buffer, readString);
|
|
1620
1611
|
return {
|
|
1621
1612
|
type: 'Literal',
|
|
1622
1613
|
start,
|
|
1623
1614
|
end,
|
|
1615
|
+
bigint,
|
|
1624
1616
|
raw,
|
|
1625
|
-
value
|
|
1617
|
+
value: BigInt(bigint)
|
|
1626
1618
|
};
|
|
1627
1619
|
},
|
|
1628
|
-
|
|
1629
|
-
(position, buffer) => {
|
|
1620
|
+
function literalBoolean(position, buffer) {
|
|
1630
1621
|
const start = buffer[position++];
|
|
1631
1622
|
const end = buffer[position++];
|
|
1632
|
-
const
|
|
1623
|
+
const flags = buffer[position++];
|
|
1624
|
+
const value = (flags & 1) === 1;
|
|
1633
1625
|
return {
|
|
1634
1626
|
type: 'Literal',
|
|
1635
1627
|
start,
|
|
1636
1628
|
end,
|
|
1637
|
-
|
|
1638
|
-
value
|
|
1629
|
+
value,
|
|
1630
|
+
raw: value ? 'true' : 'false'
|
|
1639
1631
|
};
|
|
1640
1632
|
},
|
|
1641
|
-
|
|
1642
|
-
(position, buffer, readString) => {
|
|
1633
|
+
function literalNull(position, buffer) {
|
|
1643
1634
|
const start = buffer[position++];
|
|
1644
1635
|
const end = buffer[position++];
|
|
1645
|
-
const rawPosition = buffer[position++];
|
|
1646
|
-
const raw = rawPosition ? convertString(rawPosition, buffer, readString) : undefined;
|
|
1647
|
-
const value = new DataView(buffer.buffer).getFloat64(position << 2, true);
|
|
1648
1636
|
return {
|
|
1649
1637
|
type: 'Literal',
|
|
1650
1638
|
start,
|
|
1651
1639
|
end,
|
|
1652
|
-
raw,
|
|
1653
|
-
value
|
|
1640
|
+
raw: 'null',
|
|
1641
|
+
value: null
|
|
1654
1642
|
};
|
|
1655
1643
|
},
|
|
1656
|
-
|
|
1657
|
-
(position, buffer) => {
|
|
1644
|
+
function literalNumber(position, buffer, readString) {
|
|
1658
1645
|
const start = buffer[position++];
|
|
1659
1646
|
const end = buffer[position++];
|
|
1647
|
+
const rawPosition = buffer[position++];
|
|
1648
|
+
const raw = rawPosition === 0 ? undefined : convertString(rawPosition, buffer, readString);
|
|
1649
|
+
const value = new DataView(buffer.buffer).getFloat64(position << 2, true);
|
|
1660
1650
|
return {
|
|
1661
1651
|
type: 'Literal',
|
|
1662
1652
|
start,
|
|
1663
1653
|
end,
|
|
1664
|
-
raw
|
|
1665
|
-
value
|
|
1654
|
+
raw,
|
|
1655
|
+
value
|
|
1666
1656
|
};
|
|
1667
1657
|
},
|
|
1668
|
-
|
|
1669
|
-
(position, buffer, readString) => {
|
|
1658
|
+
function literalRegExp(position, buffer, readString) {
|
|
1670
1659
|
const start = buffer[position++];
|
|
1671
1660
|
const end = buffer[position++];
|
|
1672
1661
|
const pattern = convertString(buffer[position++], buffer, readString);
|
|
@@ -1676,30 +1665,25 @@ const nodeConverters = [
|
|
|
1676
1665
|
start,
|
|
1677
1666
|
end,
|
|
1678
1667
|
raw: `/${pattern}/${flags}`,
|
|
1679
|
-
regex: {
|
|
1680
|
-
flags,
|
|
1681
|
-
pattern
|
|
1682
|
-
},
|
|
1668
|
+
regex: { flags, pattern },
|
|
1683
1669
|
value: new RegExp(pattern, flags)
|
|
1684
1670
|
};
|
|
1685
1671
|
},
|
|
1686
|
-
|
|
1687
|
-
(position, buffer, readString) => {
|
|
1672
|
+
function literalString(position, buffer, readString) {
|
|
1688
1673
|
const start = buffer[position++];
|
|
1689
1674
|
const end = buffer[position++];
|
|
1690
|
-
const
|
|
1691
|
-
const raw = convertString(
|
|
1675
|
+
const rawPosition = buffer[position++];
|
|
1676
|
+
const raw = rawPosition === 0 ? undefined : convertString(rawPosition, buffer, readString);
|
|
1677
|
+
const value = convertString(position, buffer, readString);
|
|
1692
1678
|
return {
|
|
1693
1679
|
type: 'Literal',
|
|
1694
1680
|
start,
|
|
1695
1681
|
end,
|
|
1696
|
-
|
|
1697
|
-
raw
|
|
1698
|
-
value: BigInt(bigint)
|
|
1682
|
+
value,
|
|
1683
|
+
raw
|
|
1699
1684
|
};
|
|
1700
1685
|
},
|
|
1701
|
-
|
|
1702
|
-
(position, buffer, readString) => {
|
|
1686
|
+
function logicalExpression(position, buffer, readString) {
|
|
1703
1687
|
const start = buffer[position++];
|
|
1704
1688
|
const end = buffer[position++];
|
|
1705
1689
|
const operator = FIXED_STRINGS[buffer[position++]];
|
|
@@ -1709,17 +1693,17 @@ const nodeConverters = [
|
|
|
1709
1693
|
type: 'LogicalExpression',
|
|
1710
1694
|
start,
|
|
1711
1695
|
end,
|
|
1712
|
-
left,
|
|
1713
1696
|
operator,
|
|
1697
|
+
left,
|
|
1714
1698
|
right
|
|
1715
1699
|
};
|
|
1716
1700
|
},
|
|
1717
|
-
|
|
1718
|
-
(position, buffer, readString) => {
|
|
1701
|
+
function memberExpression(position, buffer, readString) {
|
|
1719
1702
|
const start = buffer[position++];
|
|
1720
1703
|
const end = buffer[position++];
|
|
1721
|
-
const
|
|
1722
|
-
const computed =
|
|
1704
|
+
const flags = buffer[position++];
|
|
1705
|
+
const computed = (flags & 1) === 1;
|
|
1706
|
+
const optional = (flags & 2) === 2;
|
|
1723
1707
|
const property = convertNode(buffer[position++], buffer, readString);
|
|
1724
1708
|
const object = convertNode(position, buffer, readString);
|
|
1725
1709
|
return {
|
|
@@ -1727,13 +1711,12 @@ const nodeConverters = [
|
|
|
1727
1711
|
start,
|
|
1728
1712
|
end,
|
|
1729
1713
|
computed,
|
|
1730
|
-
object,
|
|
1731
1714
|
optional,
|
|
1715
|
+
object,
|
|
1732
1716
|
property
|
|
1733
1717
|
};
|
|
1734
1718
|
},
|
|
1735
|
-
|
|
1736
|
-
(position, buffer, readString) => {
|
|
1719
|
+
function metaProperty(position, buffer, readString) {
|
|
1737
1720
|
const start = buffer[position++];
|
|
1738
1721
|
const end = buffer[position++];
|
|
1739
1722
|
const property = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1746,43 +1729,42 @@ const nodeConverters = [
|
|
|
1746
1729
|
property
|
|
1747
1730
|
};
|
|
1748
1731
|
},
|
|
1749
|
-
|
|
1750
|
-
(position, buffer, readString) => {
|
|
1732
|
+
function methodDefinition(position, buffer, readString) {
|
|
1751
1733
|
const start = buffer[position++];
|
|
1752
1734
|
const end = buffer[position++];
|
|
1753
|
-
const
|
|
1754
|
-
const computed =
|
|
1755
|
-
const isStatic =
|
|
1735
|
+
const flags = buffer[position++];
|
|
1736
|
+
const computed = (flags & 1) === 1;
|
|
1737
|
+
const isStatic = (flags & 2) === 2;
|
|
1756
1738
|
const value = convertNode(buffer[position++], buffer, readString);
|
|
1739
|
+
const kind = FIXED_STRINGS[buffer[position++]];
|
|
1757
1740
|
const key = convertNode(position, buffer, readString);
|
|
1758
1741
|
return {
|
|
1759
1742
|
type: 'MethodDefinition',
|
|
1760
1743
|
start,
|
|
1761
1744
|
end,
|
|
1762
1745
|
computed,
|
|
1763
|
-
key,
|
|
1764
|
-
kind,
|
|
1765
1746
|
static: isStatic,
|
|
1766
|
-
|
|
1747
|
+
key,
|
|
1748
|
+
value,
|
|
1749
|
+
kind
|
|
1767
1750
|
};
|
|
1768
1751
|
},
|
|
1769
|
-
|
|
1770
|
-
(position, buffer, readString) => {
|
|
1752
|
+
function newExpression(position, buffer, readString) {
|
|
1771
1753
|
const start = buffer[position++];
|
|
1772
1754
|
const end = buffer[position++];
|
|
1773
1755
|
const callee = convertNode(buffer[position++], buffer, readString);
|
|
1774
|
-
const
|
|
1775
|
-
const annotations =
|
|
1776
|
-
return
|
|
1756
|
+
const callArguments = convertNodeList(buffer[position++], buffer, readString);
|
|
1757
|
+
const annotations = convertAnnotations(position, buffer);
|
|
1758
|
+
return {
|
|
1777
1759
|
type: 'NewExpression',
|
|
1778
1760
|
start,
|
|
1779
1761
|
end,
|
|
1780
|
-
|
|
1781
|
-
callee
|
|
1782
|
-
|
|
1762
|
+
...(annotations.length > 0 ? { [ANNOTATION_KEY]: annotations } : {}),
|
|
1763
|
+
callee,
|
|
1764
|
+
arguments: callArguments
|
|
1765
|
+
};
|
|
1783
1766
|
},
|
|
1784
|
-
|
|
1785
|
-
(position, buffer, readString) => {
|
|
1767
|
+
function objectExpression(position, buffer, readString) {
|
|
1786
1768
|
const start = buffer[position++];
|
|
1787
1769
|
const end = buffer[position++];
|
|
1788
1770
|
const properties = convertNodeList(position, buffer, readString);
|
|
@@ -1793,8 +1775,7 @@ const nodeConverters = [
|
|
|
1793
1775
|
properties
|
|
1794
1776
|
};
|
|
1795
1777
|
},
|
|
1796
|
-
|
|
1797
|
-
(position, buffer, readString) => {
|
|
1778
|
+
function objectPattern(position, buffer, readString) {
|
|
1798
1779
|
const start = buffer[position++];
|
|
1799
1780
|
const end = buffer[position++];
|
|
1800
1781
|
const properties = convertNodeList(position, buffer, readString);
|
|
@@ -1805,8 +1786,7 @@ const nodeConverters = [
|
|
|
1805
1786
|
properties
|
|
1806
1787
|
};
|
|
1807
1788
|
},
|
|
1808
|
-
|
|
1809
|
-
(position, buffer, readString) => {
|
|
1789
|
+
function privateIdentifier(position, buffer, readString) {
|
|
1810
1790
|
const start = buffer[position++];
|
|
1811
1791
|
const end = buffer[position++];
|
|
1812
1792
|
const name = convertString(position, buffer, readString);
|
|
@@ -1817,62 +1797,62 @@ const nodeConverters = [
|
|
|
1817
1797
|
name
|
|
1818
1798
|
};
|
|
1819
1799
|
},
|
|
1820
|
-
|
|
1821
|
-
(position, buffer, readString) => {
|
|
1800
|
+
function program(position, buffer, readString) {
|
|
1822
1801
|
const start = buffer[position++];
|
|
1823
1802
|
const end = buffer[position++];
|
|
1824
|
-
const annotations =
|
|
1803
|
+
const annotations = convertAnnotations(buffer[position++], buffer);
|
|
1825
1804
|
const body = convertNodeList(position, buffer, readString);
|
|
1826
|
-
return
|
|
1805
|
+
return {
|
|
1827
1806
|
type: 'Program',
|
|
1828
1807
|
start,
|
|
1829
1808
|
end,
|
|
1830
1809
|
body,
|
|
1810
|
+
...(annotations.length > 0 ? { [INVALID_ANNOTATION_KEY]: annotations } : {}),
|
|
1831
1811
|
sourceType: 'module'
|
|
1832
|
-
}
|
|
1812
|
+
};
|
|
1833
1813
|
},
|
|
1834
|
-
|
|
1835
|
-
(position, buffer, readString) => {
|
|
1814
|
+
function property(position, buffer, readString) {
|
|
1836
1815
|
const start = buffer[position++];
|
|
1837
1816
|
const end = buffer[position++];
|
|
1838
|
-
const
|
|
1839
|
-
const method =
|
|
1840
|
-
const
|
|
1841
|
-
const
|
|
1842
|
-
const
|
|
1843
|
-
const
|
|
1817
|
+
const flags = buffer[position++];
|
|
1818
|
+
const method = (flags & 1) === 1;
|
|
1819
|
+
const shorthand = (flags & 2) === 2;
|
|
1820
|
+
const computed = (flags & 4) === 4;
|
|
1821
|
+
const keyPosition = buffer[position++];
|
|
1822
|
+
const value = convertNode(buffer[position++], buffer, readString);
|
|
1823
|
+
const kind = FIXED_STRINGS[buffer[position]];
|
|
1844
1824
|
return {
|
|
1845
1825
|
type: 'Property',
|
|
1846
1826
|
start,
|
|
1847
1827
|
end,
|
|
1848
|
-
computed,
|
|
1849
|
-
key,
|
|
1850
|
-
kind,
|
|
1851
1828
|
method,
|
|
1852
1829
|
shorthand,
|
|
1853
|
-
|
|
1830
|
+
computed,
|
|
1831
|
+
key: keyPosition === 0 ? { ...value } : convertNode(keyPosition, buffer, readString),
|
|
1832
|
+
value,
|
|
1833
|
+
kind
|
|
1854
1834
|
};
|
|
1855
1835
|
},
|
|
1856
|
-
|
|
1857
|
-
(position, buffer, readString) => {
|
|
1836
|
+
function propertyDefinition(position, buffer, readString) {
|
|
1858
1837
|
const start = buffer[position++];
|
|
1859
1838
|
const end = buffer[position++];
|
|
1860
|
-
const
|
|
1861
|
-
const
|
|
1839
|
+
const flags = buffer[position++];
|
|
1840
|
+
const computed = (flags & 1) === 1;
|
|
1841
|
+
const isStatic = (flags & 2) === 2;
|
|
1862
1842
|
const valuePosition = buffer[position++];
|
|
1843
|
+
const value = valuePosition === 0 ? null : convertNode(valuePosition, buffer, readString);
|
|
1863
1844
|
const key = convertNode(position, buffer, readString);
|
|
1864
1845
|
return {
|
|
1865
1846
|
type: 'PropertyDefinition',
|
|
1866
1847
|
start,
|
|
1867
1848
|
end,
|
|
1868
1849
|
computed,
|
|
1869
|
-
key,
|
|
1870
1850
|
static: isStatic,
|
|
1871
|
-
|
|
1851
|
+
key,
|
|
1852
|
+
value
|
|
1872
1853
|
};
|
|
1873
1854
|
},
|
|
1874
|
-
|
|
1875
|
-
(position, buffer, readString) => {
|
|
1855
|
+
function restElement(position, buffer, readString) {
|
|
1876
1856
|
const start = buffer[position++];
|
|
1877
1857
|
const end = buffer[position++];
|
|
1878
1858
|
const argument = convertNode(position, buffer, readString);
|
|
@@ -1883,20 +1863,19 @@ const nodeConverters = [
|
|
|
1883
1863
|
argument
|
|
1884
1864
|
};
|
|
1885
1865
|
},
|
|
1886
|
-
|
|
1887
|
-
(position, buffer, readString) => {
|
|
1866
|
+
function returnStatement(position, buffer, readString) {
|
|
1888
1867
|
const start = buffer[position++];
|
|
1889
1868
|
const end = buffer[position++];
|
|
1890
1869
|
const argumentPosition = buffer[position];
|
|
1870
|
+
const argument = argumentPosition === 0 ? null : convertNode(argumentPosition, buffer, readString);
|
|
1891
1871
|
return {
|
|
1892
1872
|
type: 'ReturnStatement',
|
|
1893
1873
|
start,
|
|
1894
1874
|
end,
|
|
1895
|
-
argument
|
|
1875
|
+
argument
|
|
1896
1876
|
};
|
|
1897
1877
|
},
|
|
1898
|
-
|
|
1899
|
-
(position, buffer, readString) => {
|
|
1878
|
+
function sequenceExpression(position, buffer, readString) {
|
|
1900
1879
|
const start = buffer[position++];
|
|
1901
1880
|
const end = buffer[position++];
|
|
1902
1881
|
const expressions = convertNodeList(position, buffer, readString);
|
|
@@ -1907,8 +1886,7 @@ const nodeConverters = [
|
|
|
1907
1886
|
expressions
|
|
1908
1887
|
};
|
|
1909
1888
|
},
|
|
1910
|
-
|
|
1911
|
-
(position, buffer, readString) => {
|
|
1889
|
+
function spreadElement(position, buffer, readString) {
|
|
1912
1890
|
const start = buffer[position++];
|
|
1913
1891
|
const end = buffer[position++];
|
|
1914
1892
|
const argument = convertNode(position, buffer, readString);
|
|
@@ -1919,8 +1897,7 @@ const nodeConverters = [
|
|
|
1919
1897
|
argument
|
|
1920
1898
|
};
|
|
1921
1899
|
},
|
|
1922
|
-
|
|
1923
|
-
(position, buffer, readString) => {
|
|
1900
|
+
function staticBlock(position, buffer, readString) {
|
|
1924
1901
|
const start = buffer[position++];
|
|
1925
1902
|
const end = buffer[position++];
|
|
1926
1903
|
const body = convertNodeList(position, buffer, readString);
|
|
@@ -1931,8 +1908,7 @@ const nodeConverters = [
|
|
|
1931
1908
|
body
|
|
1932
1909
|
};
|
|
1933
1910
|
},
|
|
1934
|
-
|
|
1935
|
-
(position, buffer) => {
|
|
1911
|
+
function superElement(position, buffer) {
|
|
1936
1912
|
const start = buffer[position++];
|
|
1937
1913
|
const end = buffer[position++];
|
|
1938
1914
|
return {
|
|
@@ -1941,22 +1917,21 @@ const nodeConverters = [
|
|
|
1941
1917
|
end
|
|
1942
1918
|
};
|
|
1943
1919
|
},
|
|
1944
|
-
|
|
1945
|
-
(position, buffer, readString) => {
|
|
1920
|
+
function switchCase(position, buffer, readString) {
|
|
1946
1921
|
const start = buffer[position++];
|
|
1947
1922
|
const end = buffer[position++];
|
|
1948
1923
|
const testPosition = buffer[position++];
|
|
1924
|
+
const test = testPosition === 0 ? null : convertNode(testPosition, buffer, readString);
|
|
1949
1925
|
const consequent = convertNodeList(buffer[position], buffer, readString);
|
|
1950
1926
|
return {
|
|
1951
1927
|
type: 'SwitchCase',
|
|
1952
1928
|
start,
|
|
1953
1929
|
end,
|
|
1954
|
-
|
|
1955
|
-
|
|
1930
|
+
test,
|
|
1931
|
+
consequent
|
|
1956
1932
|
};
|
|
1957
1933
|
},
|
|
1958
|
-
|
|
1959
|
-
(position, buffer, readString) => {
|
|
1934
|
+
function switchStatement(position, buffer, readString) {
|
|
1960
1935
|
const start = buffer[position++];
|
|
1961
1936
|
const end = buffer[position++];
|
|
1962
1937
|
const cases = convertNodeList(buffer[position++], buffer, readString);
|
|
@@ -1965,12 +1940,11 @@ const nodeConverters = [
|
|
|
1965
1940
|
type: 'SwitchStatement',
|
|
1966
1941
|
start,
|
|
1967
1942
|
end,
|
|
1968
|
-
|
|
1969
|
-
|
|
1943
|
+
discriminant,
|
|
1944
|
+
cases
|
|
1970
1945
|
};
|
|
1971
1946
|
},
|
|
1972
|
-
|
|
1973
|
-
(position, buffer, readString) => {
|
|
1947
|
+
function taggedTemplateExpression(position, buffer, readString) {
|
|
1974
1948
|
const start = buffer[position++];
|
|
1975
1949
|
const end = buffer[position++];
|
|
1976
1950
|
const quasi = convertNode(buffer[position++], buffer, readString);
|
|
@@ -1979,30 +1953,27 @@ const nodeConverters = [
|
|
|
1979
1953
|
type: 'TaggedTemplateExpression',
|
|
1980
1954
|
start,
|
|
1981
1955
|
end,
|
|
1982
|
-
|
|
1983
|
-
|
|
1956
|
+
tag,
|
|
1957
|
+
quasi
|
|
1984
1958
|
};
|
|
1985
1959
|
},
|
|
1986
|
-
|
|
1987
|
-
(position, buffer, readString) => {
|
|
1960
|
+
function templateElement(position, buffer, readString) {
|
|
1988
1961
|
const start = buffer[position++];
|
|
1989
1962
|
const end = buffer[position++];
|
|
1990
|
-
const
|
|
1963
|
+
const flags = buffer[position++];
|
|
1964
|
+
const tail = (flags & 1) === 1;
|
|
1991
1965
|
const cookedPosition = buffer[position++];
|
|
1966
|
+
const cooked = cookedPosition === 0 ? undefined : convertString(cookedPosition, buffer, readString);
|
|
1992
1967
|
const raw = convertString(position, buffer, readString);
|
|
1993
1968
|
return {
|
|
1994
1969
|
type: 'TemplateElement',
|
|
1995
1970
|
start,
|
|
1996
1971
|
end,
|
|
1997
1972
|
tail,
|
|
1998
|
-
value: {
|
|
1999
|
-
cooked: cookedPosition ? convertString(cookedPosition, buffer, readString) : null,
|
|
2000
|
-
raw
|
|
2001
|
-
}
|
|
1973
|
+
value: { cooked, raw }
|
|
2002
1974
|
};
|
|
2003
1975
|
},
|
|
2004
|
-
|
|
2005
|
-
(position, buffer, readString) => {
|
|
1976
|
+
function templateLiteral(position, buffer, readString) {
|
|
2006
1977
|
const start = buffer[position++];
|
|
2007
1978
|
const end = buffer[position++];
|
|
2008
1979
|
const expressions = convertNodeList(buffer[position++], buffer, readString);
|
|
@@ -2011,12 +1982,11 @@ const nodeConverters = [
|
|
|
2011
1982
|
type: 'TemplateLiteral',
|
|
2012
1983
|
start,
|
|
2013
1984
|
end,
|
|
2014
|
-
|
|
2015
|
-
|
|
1985
|
+
quasis,
|
|
1986
|
+
expressions
|
|
2016
1987
|
};
|
|
2017
1988
|
},
|
|
2018
|
-
|
|
2019
|
-
(position, buffer) => {
|
|
1989
|
+
function thisExpression(position, buffer) {
|
|
2020
1990
|
const start = buffer[position++];
|
|
2021
1991
|
const end = buffer[position++];
|
|
2022
1992
|
return {
|
|
@@ -2025,8 +1995,7 @@ const nodeConverters = [
|
|
|
2025
1995
|
end
|
|
2026
1996
|
};
|
|
2027
1997
|
},
|
|
2028
|
-
|
|
2029
|
-
(position, buffer, readString) => {
|
|
1998
|
+
function throwStatement(position, buffer, readString) {
|
|
2030
1999
|
const start = buffer[position++];
|
|
2031
2000
|
const end = buffer[position++];
|
|
2032
2001
|
const argument = convertNode(position, buffer, readString);
|
|
@@ -2037,24 +2006,24 @@ const nodeConverters = [
|
|
|
2037
2006
|
argument
|
|
2038
2007
|
};
|
|
2039
2008
|
},
|
|
2040
|
-
|
|
2041
|
-
(position, buffer, readString) => {
|
|
2009
|
+
function tryStatement(position, buffer, readString) {
|
|
2042
2010
|
const start = buffer[position++];
|
|
2043
2011
|
const end = buffer[position++];
|
|
2044
2012
|
const handlerPosition = buffer[position++];
|
|
2013
|
+
const handler = handlerPosition === 0 ? null : convertNode(handlerPosition, buffer, readString);
|
|
2045
2014
|
const finalizerPosition = buffer[position++];
|
|
2015
|
+
const finalizer = finalizerPosition === 0 ? null : convertNode(finalizerPosition, buffer, readString);
|
|
2046
2016
|
const block = convertNode(position, buffer, readString);
|
|
2047
2017
|
return {
|
|
2048
2018
|
type: 'TryStatement',
|
|
2049
2019
|
start,
|
|
2050
2020
|
end,
|
|
2051
2021
|
block,
|
|
2052
|
-
|
|
2053
|
-
|
|
2022
|
+
handler,
|
|
2023
|
+
finalizer
|
|
2054
2024
|
};
|
|
2055
2025
|
},
|
|
2056
|
-
|
|
2057
|
-
(position, buffer, readString) => {
|
|
2026
|
+
function unaryExpression(position, buffer, readString) {
|
|
2058
2027
|
const start = buffer[position++];
|
|
2059
2028
|
const end = buffer[position++];
|
|
2060
2029
|
const operator = FIXED_STRINGS[buffer[position++]];
|
|
@@ -2063,29 +2032,28 @@ const nodeConverters = [
|
|
|
2063
2032
|
type: 'UnaryExpression',
|
|
2064
2033
|
start,
|
|
2065
2034
|
end,
|
|
2066
|
-
argument,
|
|
2067
2035
|
operator,
|
|
2036
|
+
argument,
|
|
2068
2037
|
prefix: true
|
|
2069
2038
|
};
|
|
2070
2039
|
},
|
|
2071
|
-
|
|
2072
|
-
(position, buffer, readString) => {
|
|
2040
|
+
function updateExpression(position, buffer, readString) {
|
|
2073
2041
|
const start = buffer[position++];
|
|
2074
2042
|
const end = buffer[position++];
|
|
2075
|
-
const
|
|
2043
|
+
const flags = buffer[position++];
|
|
2044
|
+
const prefix = (flags & 1) === 1;
|
|
2076
2045
|
const operator = FIXED_STRINGS[buffer[position++]];
|
|
2077
2046
|
const argument = convertNode(position, buffer, readString);
|
|
2078
2047
|
return {
|
|
2079
2048
|
type: 'UpdateExpression',
|
|
2080
2049
|
start,
|
|
2081
2050
|
end,
|
|
2082
|
-
|
|
2051
|
+
prefix,
|
|
2083
2052
|
operator,
|
|
2084
|
-
|
|
2053
|
+
argument
|
|
2085
2054
|
};
|
|
2086
2055
|
},
|
|
2087
|
-
|
|
2088
|
-
(position, buffer, readString) => {
|
|
2056
|
+
function variableDeclaration(position, buffer, readString) {
|
|
2089
2057
|
const start = buffer[position++];
|
|
2090
2058
|
const end = buffer[position++];
|
|
2091
2059
|
const kind = FIXED_STRINGS[buffer[position++]];
|
|
@@ -2094,26 +2062,25 @@ const nodeConverters = [
|
|
|
2094
2062
|
type: 'VariableDeclaration',
|
|
2095
2063
|
start,
|
|
2096
2064
|
end,
|
|
2097
|
-
|
|
2098
|
-
|
|
2065
|
+
kind,
|
|
2066
|
+
declarations
|
|
2099
2067
|
};
|
|
2100
2068
|
},
|
|
2101
|
-
|
|
2102
|
-
(position, buffer, readString) => {
|
|
2069
|
+
function variableDeclarator(position, buffer, readString) {
|
|
2103
2070
|
const start = buffer[position++];
|
|
2104
2071
|
const end = buffer[position++];
|
|
2105
|
-
const
|
|
2072
|
+
const initPosition = buffer[position++];
|
|
2073
|
+
const init = initPosition === 0 ? null : convertNode(initPosition, buffer, readString);
|
|
2106
2074
|
const id = convertNode(position, buffer, readString);
|
|
2107
2075
|
return {
|
|
2108
2076
|
type: 'VariableDeclarator',
|
|
2109
2077
|
start,
|
|
2110
2078
|
end,
|
|
2111
2079
|
id,
|
|
2112
|
-
init
|
|
2080
|
+
init
|
|
2113
2081
|
};
|
|
2114
2082
|
},
|
|
2115
|
-
|
|
2116
|
-
(position, buffer, readString) => {
|
|
2083
|
+
function whileStatement(position, buffer, readString) {
|
|
2117
2084
|
const start = buffer[position++];
|
|
2118
2085
|
const end = buffer[position++];
|
|
2119
2086
|
const body = convertNode(buffer[position++], buffer, readString);
|
|
@@ -2122,32 +2089,37 @@ const nodeConverters = [
|
|
|
2122
2089
|
type: 'WhileStatement',
|
|
2123
2090
|
start,
|
|
2124
2091
|
end,
|
|
2125
|
-
|
|
2126
|
-
|
|
2092
|
+
test,
|
|
2093
|
+
body
|
|
2127
2094
|
};
|
|
2128
2095
|
},
|
|
2129
|
-
|
|
2130
|
-
(position, buffer, readString) => {
|
|
2096
|
+
function yieldExpression(position, buffer, readString) {
|
|
2131
2097
|
const start = buffer[position++];
|
|
2132
2098
|
const end = buffer[position++];
|
|
2133
|
-
const
|
|
2099
|
+
const flags = buffer[position++];
|
|
2100
|
+
const delegate = (flags & 1) === 1;
|
|
2134
2101
|
const argumentPosition = buffer[position];
|
|
2102
|
+
const argument = argumentPosition === 0 ? null : convertNode(argumentPosition, buffer, readString);
|
|
2135
2103
|
return {
|
|
2136
2104
|
type: 'YieldExpression',
|
|
2137
2105
|
start,
|
|
2138
2106
|
end,
|
|
2139
|
-
|
|
2140
|
-
|
|
2107
|
+
delegate,
|
|
2108
|
+
argument
|
|
2141
2109
|
};
|
|
2142
|
-
},
|
|
2143
|
-
// index:76; Syntax Error
|
|
2144
|
-
(position, buffer, readString) => {
|
|
2145
|
-
const pos = buffer[position++];
|
|
2146
|
-
const message = convertString(position, buffer, readString);
|
|
2147
|
-
error(logParseError(message, pos));
|
|
2148
2110
|
}
|
|
2149
2111
|
];
|
|
2150
|
-
|
|
2112
|
+
function convertNode(position, buffer, readString) {
|
|
2113
|
+
const nodeType = buffer[position];
|
|
2114
|
+
const converter = nodeConverters[nodeType];
|
|
2115
|
+
/* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
|
|
2116
|
+
if (!converter) {
|
|
2117
|
+
console.trace();
|
|
2118
|
+
throw new Error(`Unknown node type: ${nodeType}`);
|
|
2119
|
+
}
|
|
2120
|
+
return converter(position + 1, buffer, readString);
|
|
2121
|
+
}
|
|
2122
|
+
function convertNodeList(position, buffer, readString) {
|
|
2151
2123
|
const length = buffer[position++];
|
|
2152
2124
|
const list = [];
|
|
2153
2125
|
for (let index = 0; index < length; index++) {
|
|
@@ -2155,8 +2127,8 @@ const convertNodeList = (position, buffer, readString) => {
|
|
|
2155
2127
|
list.push(nodePosition ? convertNode(nodePosition, buffer, readString) : null);
|
|
2156
2128
|
}
|
|
2157
2129
|
return list;
|
|
2158
|
-
}
|
|
2159
|
-
const
|
|
2130
|
+
}
|
|
2131
|
+
const convertAnnotations = (position, buffer) => {
|
|
2160
2132
|
const length = buffer[position++];
|
|
2161
2133
|
const list = [];
|
|
2162
2134
|
for (let index = 0; index < length; index++) {
|
|
@@ -2170,22 +2142,11 @@ const convertAnnotation = (position, buffer) => {
|
|
|
2170
2142
|
const type = FIXED_STRINGS[buffer[position]];
|
|
2171
2143
|
return { end, start, type };
|
|
2172
2144
|
};
|
|
2173
|
-
const addAnnotationProperty = (node, annotations, key) => {
|
|
2174
|
-
if (annotations.length > 0) {
|
|
2175
|
-
return {
|
|
2176
|
-
...node,
|
|
2177
|
-
[key]: annotations
|
|
2178
|
-
};
|
|
2179
|
-
}
|
|
2180
|
-
return node;
|
|
2181
|
-
};
|
|
2182
2145
|
const convertString = (position, buffer, readString) => {
|
|
2183
2146
|
const length = buffer[position++];
|
|
2184
2147
|
const bytePosition = position << 2;
|
|
2185
2148
|
return readString(bytePosition, length);
|
|
2186
2149
|
};
|
|
2187
|
-
const ANNOTATION_KEY = '_rollupAnnotations';
|
|
2188
|
-
const INVALID_ANNOTATION_KEY = '_rollupRemoved';
|
|
2189
2150
|
|
|
2190
2151
|
function getReadStringFunction(astBuffer) {
|
|
2191
2152
|
if (typeof Buffer !== 'undefined' && astBuffer instanceof Buffer) {
|
|
@@ -2203,15 +2164,11 @@ function getReadStringFunction(astBuffer) {
|
|
|
2203
2164
|
|
|
2204
2165
|
const parseAst = (input, { allowReturnOutsideFunction = false } = {}) => {
|
|
2205
2166
|
const astBuffer = native_js.parse(input, allowReturnOutsideFunction);
|
|
2206
|
-
|
|
2207
|
-
const result = convertProgram(astBuffer.buffer, readString);
|
|
2208
|
-
return result;
|
|
2167
|
+
return convertProgram(astBuffer.buffer, getReadStringFunction(astBuffer));
|
|
2209
2168
|
};
|
|
2210
2169
|
const parseAstAsync = async (input, { allowReturnOutsideFunction = false, signal } = {}) => {
|
|
2211
2170
|
const astBuffer = await native_js.parseAsync(input, allowReturnOutsideFunction, signal);
|
|
2212
|
-
|
|
2213
|
-
const result = convertProgram(astBuffer.buffer, readString);
|
|
2214
|
-
return result;
|
|
2171
|
+
return convertProgram(astBuffer.buffer, getReadStringFunction(astBuffer));
|
|
2215
2172
|
};
|
|
2216
2173
|
|
|
2217
2174
|
exports.ANNOTATION_KEY = ANNOTATION_KEY;
|