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