sval 0.5.0 → 0.5.2
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/.github/workflows/coverage.yml +3 -3
- package/README.md +80 -28
- package/dist/sval.es6.js +979 -422
- package/dist/sval.js +1355 -694
- package/dist/sval.min.js +1 -1
- package/package.json +1 -2
- package/types/index.d.ts +6 -10
package/dist/sval.js
CHANGED
|
@@ -4,6 +4,27 @@
|
|
|
4
4
|
(global = global || self, global.Sval = factory(global.acorn));
|
|
5
5
|
}(this, (function (acorn) { 'use strict';
|
|
6
6
|
|
|
7
|
+
var statement = /*#__PURE__*/Object.freeze({
|
|
8
|
+
__proto__: null,
|
|
9
|
+
get ExpressionStatement () { return ExpressionStatement; },
|
|
10
|
+
get BlockStatement () { return BlockStatement; },
|
|
11
|
+
get EmptyStatement () { return EmptyStatement; },
|
|
12
|
+
get DebuggerStatement () { return DebuggerStatement; },
|
|
13
|
+
get ReturnStatement () { return ReturnStatement; },
|
|
14
|
+
get BreakStatement () { return BreakStatement; },
|
|
15
|
+
get ContinueStatement () { return ContinueStatement; },
|
|
16
|
+
get IfStatement () { return IfStatement; },
|
|
17
|
+
get SwitchStatement () { return SwitchStatement; },
|
|
18
|
+
get SwitchCase () { return SwitchCase; },
|
|
19
|
+
get ThrowStatement () { return ThrowStatement; },
|
|
20
|
+
get TryStatement () { return TryStatement; },
|
|
21
|
+
get CatchClause () { return CatchClause; },
|
|
22
|
+
get WhileStatement () { return WhileStatement; },
|
|
23
|
+
get DoWhileStatement () { return DoWhileStatement; },
|
|
24
|
+
get ForStatement () { return ForStatement; },
|
|
25
|
+
get ForInStatement () { return ForInStatement; },
|
|
26
|
+
get ForOfStatement () { return ForOfStatement; }
|
|
27
|
+
});
|
|
7
28
|
var declaration = /*#__PURE__*/Object.freeze({
|
|
8
29
|
__proto__: null,
|
|
9
30
|
get FunctionDeclaration () { return FunctionDeclaration; },
|
|
@@ -11,7 +32,34 @@
|
|
|
11
32
|
get VariableDeclarator () { return VariableDeclarator; },
|
|
12
33
|
get ClassDeclaration () { return ClassDeclaration; },
|
|
13
34
|
get ClassBody () { return ClassBody; },
|
|
14
|
-
get MethodDefinition () { return MethodDefinition; }
|
|
35
|
+
get MethodDefinition () { return MethodDefinition; },
|
|
36
|
+
get PropertyDefinition () { return PropertyDefinition; },
|
|
37
|
+
get StaticBlock () { return StaticBlock; },
|
|
38
|
+
get ImportDeclaration () { return ImportDeclaration; },
|
|
39
|
+
get ExportDefaultDeclaration () { return ExportDefaultDeclaration; },
|
|
40
|
+
get ExportNamedDeclaration () { return ExportNamedDeclaration; },
|
|
41
|
+
get ExportAllDeclaration () { return ExportAllDeclaration; }
|
|
42
|
+
});
|
|
43
|
+
var statement$1 = /*#__PURE__*/Object.freeze({
|
|
44
|
+
__proto__: null,
|
|
45
|
+
get ExpressionStatement () { return ExpressionStatement$1; },
|
|
46
|
+
get BlockStatement () { return BlockStatement$1; },
|
|
47
|
+
get EmptyStatement () { return EmptyStatement$1; },
|
|
48
|
+
get DebuggerStatement () { return DebuggerStatement$1; },
|
|
49
|
+
get ReturnStatement () { return ReturnStatement$1; },
|
|
50
|
+
get BreakStatement () { return BreakStatement$1; },
|
|
51
|
+
get ContinueStatement () { return ContinueStatement$1; },
|
|
52
|
+
get IfStatement () { return IfStatement$1; },
|
|
53
|
+
get SwitchStatement () { return SwitchStatement$1; },
|
|
54
|
+
get SwitchCase () { return SwitchCase$1; },
|
|
55
|
+
get ThrowStatement () { return ThrowStatement$1; },
|
|
56
|
+
get TryStatement () { return TryStatement$1; },
|
|
57
|
+
get CatchClause () { return CatchClause$1; },
|
|
58
|
+
get WhileStatement () { return WhileStatement$1; },
|
|
59
|
+
get DoWhileStatement () { return DoWhileStatement$1; },
|
|
60
|
+
get ForStatement () { return ForStatement$1; },
|
|
61
|
+
get ForInStatement () { return ForInStatement$1; },
|
|
62
|
+
get ForOfStatement () { return ForOfStatement$1; }
|
|
15
63
|
});
|
|
16
64
|
var declaration$1 = /*#__PURE__*/Object.freeze({
|
|
17
65
|
__proto__: null,
|
|
@@ -20,7 +68,13 @@
|
|
|
20
68
|
get VariableDeclarator () { return VariableDeclarator$1; },
|
|
21
69
|
get ClassDeclaration () { return ClassDeclaration$1; },
|
|
22
70
|
get ClassBody () { return ClassBody$1; },
|
|
23
|
-
get MethodDefinition () { return MethodDefinition$1; }
|
|
71
|
+
get MethodDefinition () { return MethodDefinition$1; },
|
|
72
|
+
get PropertyDefinition () { return PropertyDefinition$1; },
|
|
73
|
+
get StaticBlock () { return StaticBlock$1; },
|
|
74
|
+
get ImportDeclaration () { return ImportDeclaration$1; },
|
|
75
|
+
get ExportDefaultDeclaration () { return ExportDefaultDeclaration$1; },
|
|
76
|
+
get ExportNamedDeclaration () { return ExportNamedDeclaration$1; },
|
|
77
|
+
get ExportAllDeclaration () { return ExportAllDeclaration$1; }
|
|
24
78
|
});
|
|
25
79
|
|
|
26
80
|
var freeze = Object.freeze;
|
|
@@ -269,6 +323,10 @@
|
|
|
269
323
|
globalObj.Reflect = Reflect;
|
|
270
324
|
}
|
|
271
325
|
catch (err) { }
|
|
326
|
+
try {
|
|
327
|
+
globalObj.BigInt = BigInt;
|
|
328
|
+
}
|
|
329
|
+
catch (err) { }
|
|
272
330
|
try {
|
|
273
331
|
globalObj.decodeURI = decodeURI;
|
|
274
332
|
}
|
|
@@ -384,8 +442,6 @@
|
|
|
384
442
|
}
|
|
385
443
|
}
|
|
386
444
|
|
|
387
|
-
var version = "0.5.0";
|
|
388
|
-
|
|
389
445
|
var AWAIT = { RES: undefined };
|
|
390
446
|
var RETURN = { RES: undefined };
|
|
391
447
|
var CONTINUE = createSymbol('continue');
|
|
@@ -395,8 +451,13 @@
|
|
|
395
451
|
var NOCTOR = createSymbol('noctor');
|
|
396
452
|
var CLSCTOR = createSymbol('clsctor');
|
|
397
453
|
var NEWTARGET = createSymbol('newtarget');
|
|
454
|
+
var PRIVATE = createSymbol('private');
|
|
398
455
|
var NOINIT = createSymbol('noinit');
|
|
399
|
-
var DEADZONE = createSymbol('deadzone');
|
|
456
|
+
var DEADZONE = createSymbol('deadzone');
|
|
457
|
+
var IMPORT = createSymbol('import');
|
|
458
|
+
var EXPORTS = createSymbol('exports');
|
|
459
|
+
|
|
460
|
+
var version = "0.5.2";
|
|
400
461
|
|
|
401
462
|
var Var = (function () {
|
|
402
463
|
function Var(kind, value) {
|
|
@@ -788,8 +849,17 @@
|
|
|
788
849
|
}
|
|
789
850
|
}
|
|
790
851
|
function BinaryExpression(node, scope) {
|
|
791
|
-
var left
|
|
792
|
-
var right
|
|
852
|
+
var left;
|
|
853
|
+
var right;
|
|
854
|
+
if (node.left.type === 'PrivateIdentifier') {
|
|
855
|
+
left = node.left.name;
|
|
856
|
+
right = evaluate(node.right, scope);
|
|
857
|
+
right = right[PRIVATE];
|
|
858
|
+
}
|
|
859
|
+
else {
|
|
860
|
+
left = evaluate(node.left, scope);
|
|
861
|
+
right = evaluate(node.right, scope);
|
|
862
|
+
}
|
|
793
863
|
switch (node.operator) {
|
|
794
864
|
case '==': return left == right;
|
|
795
865
|
case '!=': return left != right;
|
|
@@ -913,12 +983,20 @@
|
|
|
913
983
|
if (getObj)
|
|
914
984
|
return object;
|
|
915
985
|
var key;
|
|
986
|
+
var priv = false;
|
|
916
987
|
if (node.computed) {
|
|
917
988
|
key = evaluate(node.property, scope);
|
|
918
989
|
}
|
|
990
|
+
else if (node.property.type === 'PrivateIdentifier') {
|
|
991
|
+
key = node.property.name;
|
|
992
|
+
priv = true;
|
|
993
|
+
}
|
|
919
994
|
else {
|
|
920
995
|
key = node.property.name;
|
|
921
996
|
}
|
|
997
|
+
if (priv) {
|
|
998
|
+
object = object[PRIVATE];
|
|
999
|
+
}
|
|
922
1000
|
if (getVar) {
|
|
923
1001
|
var setter = getSetter(object, key);
|
|
924
1002
|
if (node.object.type === 'Super' && setter) {
|
|
@@ -962,18 +1040,27 @@
|
|
|
962
1040
|
return undefined;
|
|
963
1041
|
}
|
|
964
1042
|
var key = void 0;
|
|
1043
|
+
var priv = false;
|
|
965
1044
|
if (node.callee.computed) {
|
|
966
1045
|
key = evaluate(node.callee.property, scope);
|
|
967
1046
|
}
|
|
1047
|
+
else if (node.callee.property.type === 'PrivateIdentifier') {
|
|
1048
|
+
key = node.callee.property.name;
|
|
1049
|
+
priv = true;
|
|
1050
|
+
}
|
|
968
1051
|
else {
|
|
969
1052
|
key = node.callee.property.name;
|
|
970
1053
|
}
|
|
1054
|
+
var obj = object;
|
|
1055
|
+
if (priv) {
|
|
1056
|
+
obj = obj[PRIVATE];
|
|
1057
|
+
}
|
|
971
1058
|
if (node.callee.object.type === 'Super') {
|
|
972
1059
|
var thisObject = scope.find('this').get();
|
|
973
|
-
func =
|
|
1060
|
+
func = obj[key].bind(thisObject);
|
|
974
1061
|
}
|
|
975
1062
|
else {
|
|
976
|
-
func =
|
|
1063
|
+
func = obj[key];
|
|
977
1064
|
}
|
|
978
1065
|
if (node.optional && func == null) {
|
|
979
1066
|
return undefined;
|
|
@@ -1069,7 +1156,12 @@
|
|
|
1069
1156
|
return new (constructor.bind.apply(constructor, __spread([void 0], args)))();
|
|
1070
1157
|
}
|
|
1071
1158
|
function MetaProperty(node, scope) {
|
|
1072
|
-
|
|
1159
|
+
if (node.meta.name === 'new' && node.property.name === 'target') {
|
|
1160
|
+
return scope.find(NEWTARGET).get();
|
|
1161
|
+
}
|
|
1162
|
+
else if (node.meta.name === 'import' && node.property.name === 'meta') {
|
|
1163
|
+
return { url: '' };
|
|
1164
|
+
}
|
|
1073
1165
|
}
|
|
1074
1166
|
function SequenceExpression(node, scope) {
|
|
1075
1167
|
var result;
|
|
@@ -1134,10 +1226,32 @@
|
|
|
1134
1226
|
return getProto ? superClass.prototype : superClass;
|
|
1135
1227
|
}
|
|
1136
1228
|
function SpreadElement(node, scope) {
|
|
1137
|
-
|
|
1229
|
+
var result = evaluate(node.argument, scope);
|
|
1230
|
+
return typeof result === 'string' ? __spread(result) : result;
|
|
1138
1231
|
}
|
|
1139
1232
|
function ChainExpression(node, scope) {
|
|
1140
1233
|
return evaluate(node.expression, scope);
|
|
1234
|
+
}
|
|
1235
|
+
function ImportExpression(node, scope) {
|
|
1236
|
+
var globalScope = scope.global();
|
|
1237
|
+
var source = evaluate(node.source, scope);
|
|
1238
|
+
var module = globalScope.find(IMPORT + source);
|
|
1239
|
+
var value;
|
|
1240
|
+
if (module) {
|
|
1241
|
+
var result = module.get();
|
|
1242
|
+
if (result) {
|
|
1243
|
+
if (typeof result === 'function') {
|
|
1244
|
+
value = result();
|
|
1245
|
+
}
|
|
1246
|
+
else if (typeof result === 'object') {
|
|
1247
|
+
value = result;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
if (!value || typeof value !== 'object') {
|
|
1252
|
+
return Promise.reject(new TypeError("Failed to resolve module specifier \"" + source + "\""));
|
|
1253
|
+
}
|
|
1254
|
+
return Promise.resolve(value);
|
|
1141
1255
|
}
|
|
1142
1256
|
|
|
1143
1257
|
var expression = /*#__PURE__*/Object.freeze({
|
|
@@ -1164,9 +1278,180 @@
|
|
|
1164
1278
|
ClassExpression: ClassExpression,
|
|
1165
1279
|
Super: Super,
|
|
1166
1280
|
SpreadElement: SpreadElement,
|
|
1167
|
-
ChainExpression: ChainExpression
|
|
1281
|
+
ChainExpression: ChainExpression,
|
|
1282
|
+
ImportExpression: ImportExpression
|
|
1283
|
+
});
|
|
1284
|
+
|
|
1285
|
+
function ObjectPattern(node, scope, options) {
|
|
1286
|
+
if (options === void 0) { options = {}; }
|
|
1287
|
+
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? {} : _d;
|
|
1288
|
+
var fedKeys = [];
|
|
1289
|
+
for (var i = 0; i < node.properties.length; i++) {
|
|
1290
|
+
var property = node.properties[i];
|
|
1291
|
+
if (hoist) {
|
|
1292
|
+
if (onlyBlock || kind === 'var') {
|
|
1293
|
+
if (property.type === 'Property') {
|
|
1294
|
+
var value = property.value;
|
|
1295
|
+
if (value.type === 'Identifier') {
|
|
1296
|
+
scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
pattern$3(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
else {
|
|
1303
|
+
RestElement(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
else if (property.type === 'Property') {
|
|
1308
|
+
var key = void 0;
|
|
1309
|
+
if (property.computed) {
|
|
1310
|
+
key = evaluate(property.key, scope);
|
|
1311
|
+
}
|
|
1312
|
+
else {
|
|
1313
|
+
key = property.key.name;
|
|
1314
|
+
}
|
|
1315
|
+
fedKeys.push(key);
|
|
1316
|
+
var value = property.value;
|
|
1317
|
+
if (value.type === 'Identifier') {
|
|
1318
|
+
scope[kind](value.name, feed[key]);
|
|
1319
|
+
}
|
|
1320
|
+
else {
|
|
1321
|
+
pattern$3(value, scope, { kind: kind, feed: feed[key] });
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
else {
|
|
1325
|
+
var rest = assign({}, feed);
|
|
1326
|
+
for (var i_1 = 0; i_1 < fedKeys.length; i_1++)
|
|
1327
|
+
delete rest[fedKeys[i_1]];
|
|
1328
|
+
RestElement(property, scope, { kind: kind, feed: rest });
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
function ArrayPattern(node, scope, options) {
|
|
1333
|
+
if (options === void 0) { options = {}; }
|
|
1334
|
+
var kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
1335
|
+
var result = [];
|
|
1336
|
+
for (var i = 0; i < node.elements.length; i++) {
|
|
1337
|
+
var element = node.elements[i];
|
|
1338
|
+
if (!element)
|
|
1339
|
+
continue;
|
|
1340
|
+
if (hoist) {
|
|
1341
|
+
if (onlyBlock || kind === 'var') {
|
|
1342
|
+
if (element.type === 'Identifier') {
|
|
1343
|
+
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1344
|
+
}
|
|
1345
|
+
else {
|
|
1346
|
+
pattern$3(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
else if (element.type === 'Identifier') {
|
|
1351
|
+
if (kind) {
|
|
1352
|
+
scope[kind](element.name, feed[i]);
|
|
1353
|
+
}
|
|
1354
|
+
else {
|
|
1355
|
+
var variable = Identifier(element, scope, { getVar: true });
|
|
1356
|
+
variable.set(feed[i]);
|
|
1357
|
+
result.push(variable.get());
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
else if (element.type === 'RestElement') {
|
|
1361
|
+
RestElement(element, scope, { kind: kind, feed: feed.slice(i) });
|
|
1362
|
+
}
|
|
1363
|
+
else {
|
|
1364
|
+
pattern$3(element, scope, { kind: kind, feed: feed[i] });
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
if (result.length) {
|
|
1368
|
+
return result;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
function RestElement(node, scope, options) {
|
|
1372
|
+
if (options === void 0) { options = {}; }
|
|
1373
|
+
var kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
1374
|
+
var arg = node.argument;
|
|
1375
|
+
if (hoist) {
|
|
1376
|
+
if (onlyBlock || kind === 'var') {
|
|
1377
|
+
if (arg.type === 'Identifier') {
|
|
1378
|
+
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1379
|
+
}
|
|
1380
|
+
else {
|
|
1381
|
+
pattern$3(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
else if (arg.type === 'Identifier') {
|
|
1386
|
+
if (kind) {
|
|
1387
|
+
scope[kind](arg.name, feed);
|
|
1388
|
+
}
|
|
1389
|
+
else {
|
|
1390
|
+
var variable = Identifier(arg, scope, { getVar: true });
|
|
1391
|
+
variable.set(feed);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
else {
|
|
1395
|
+
pattern$3(arg, scope, { kind: kind, feed: feed });
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
function AssignmentPattern(node, scope, options) {
|
|
1399
|
+
if (options === void 0) { options = {}; }
|
|
1400
|
+
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? evaluate(node.right, scope) : _d;
|
|
1401
|
+
var left = node.left;
|
|
1402
|
+
if (hoist) {
|
|
1403
|
+
if (onlyBlock || kind === 'var') {
|
|
1404
|
+
if (left.type === 'Identifier') {
|
|
1405
|
+
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1406
|
+
}
|
|
1407
|
+
else {
|
|
1408
|
+
pattern$3(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
else if (left.type === 'Identifier') {
|
|
1413
|
+
scope[kind](left.name, feed);
|
|
1414
|
+
}
|
|
1415
|
+
else {
|
|
1416
|
+
pattern$3(left, scope, { kind: kind, feed: feed });
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
var pattern = /*#__PURE__*/Object.freeze({
|
|
1421
|
+
__proto__: null,
|
|
1422
|
+
ObjectPattern: ObjectPattern,
|
|
1423
|
+
ArrayPattern: ArrayPattern,
|
|
1424
|
+
RestElement: RestElement,
|
|
1425
|
+
AssignmentPattern: AssignmentPattern
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
function Program(program, scope) {
|
|
1429
|
+
for (var i = 0; i < program.body.length; i++) {
|
|
1430
|
+
evaluate(program.body[i], scope);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
var program = /*#__PURE__*/Object.freeze({
|
|
1435
|
+
__proto__: null,
|
|
1436
|
+
Program: Program
|
|
1168
1437
|
});
|
|
1169
1438
|
|
|
1439
|
+
var evaluateOps;
|
|
1440
|
+
function evaluate(node, scope) {
|
|
1441
|
+
if (!node)
|
|
1442
|
+
return;
|
|
1443
|
+
if (!evaluateOps) {
|
|
1444
|
+
evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern, program);
|
|
1445
|
+
}
|
|
1446
|
+
var handler = evaluateOps[node.type];
|
|
1447
|
+
if (handler) {
|
|
1448
|
+
return handler(node, scope);
|
|
1449
|
+
}
|
|
1450
|
+
else {
|
|
1451
|
+
throw new Error(node.type + " isn't implemented");
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1170
1455
|
function ExpressionStatement(node, scope) {
|
|
1171
1456
|
evaluate(node.expression, scope);
|
|
1172
1457
|
}
|
|
@@ -1365,230 +1650,38 @@
|
|
|
1365
1650
|
}
|
|
1366
1651
|
}
|
|
1367
1652
|
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
EmptyStatement: EmptyStatement,
|
|
1373
|
-
DebuggerStatement: DebuggerStatement,
|
|
1374
|
-
ReturnStatement: ReturnStatement,
|
|
1375
|
-
BreakStatement: BreakStatement,
|
|
1376
|
-
ContinueStatement: ContinueStatement,
|
|
1377
|
-
IfStatement: IfStatement,
|
|
1378
|
-
SwitchStatement: SwitchStatement,
|
|
1379
|
-
SwitchCase: SwitchCase,
|
|
1380
|
-
ThrowStatement: ThrowStatement,
|
|
1381
|
-
TryStatement: TryStatement,
|
|
1382
|
-
CatchClause: CatchClause,
|
|
1383
|
-
WhileStatement: WhileStatement,
|
|
1384
|
-
DoWhileStatement: DoWhileStatement,
|
|
1385
|
-
ForStatement: ForStatement,
|
|
1386
|
-
ForInStatement: ForInStatement,
|
|
1387
|
-
ForOfStatement: ForOfStatement
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
function ObjectPattern(node, scope, options) {
|
|
1653
|
+
function FunctionDeclaration(node, scope) {
|
|
1654
|
+
scope.func(node.id.name, createFunc$1(node, scope));
|
|
1655
|
+
}
|
|
1656
|
+
function VariableDeclaration(node, scope, options) {
|
|
1391
1657
|
if (options === void 0) { options = {}; }
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
}
|
|
1407
|
-
else {
|
|
1408
|
-
RestElement(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1409
|
-
}
|
|
1658
|
+
for (var i = 0; i < node.declarations.length; i++) {
|
|
1659
|
+
VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
function VariableDeclarator(node, scope, options) {
|
|
1663
|
+
if (options === void 0) { options = {}; }
|
|
1664
|
+
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, feed = options.feed;
|
|
1665
|
+
if (hoist) {
|
|
1666
|
+
if (onlyBlock || kind === 'var') {
|
|
1667
|
+
if (node.id.type === 'Identifier') {
|
|
1668
|
+
scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1669
|
+
}
|
|
1670
|
+
else {
|
|
1671
|
+
pattern$3(node.id, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1410
1672
|
}
|
|
1411
1673
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1674
|
+
}
|
|
1675
|
+
else {
|
|
1676
|
+
var hasFeed = 'feed' in options;
|
|
1677
|
+
var value = hasFeed ? feed : evaluate(node.init, scope);
|
|
1678
|
+
if (node.id.type === 'Identifier') {
|
|
1679
|
+
var name_1 = node.id.name;
|
|
1680
|
+
if (kind === 'var' && !node.init && !hasFeed) {
|
|
1681
|
+
scope.var(name_1, NOINIT);
|
|
1416
1682
|
}
|
|
1417
1683
|
else {
|
|
1418
|
-
|
|
1419
|
-
}
|
|
1420
|
-
fedKeys.push(key);
|
|
1421
|
-
var value = property.value;
|
|
1422
|
-
if (value.type === 'Identifier') {
|
|
1423
|
-
scope[kind](value.name, feed[key]);
|
|
1424
|
-
}
|
|
1425
|
-
else {
|
|
1426
|
-
pattern$3(value, scope, { kind: kind, feed: feed[key] });
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
else {
|
|
1430
|
-
var rest = assign({}, feed);
|
|
1431
|
-
for (var i_1 = 0; i_1 < fedKeys.length; i_1++)
|
|
1432
|
-
delete rest[fedKeys[i_1]];
|
|
1433
|
-
RestElement(property, scope, { kind: kind, feed: rest });
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
function ArrayPattern(node, scope, options) {
|
|
1438
|
-
if (options === void 0) { options = {}; }
|
|
1439
|
-
var kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
1440
|
-
var result = [];
|
|
1441
|
-
for (var i = 0; i < node.elements.length; i++) {
|
|
1442
|
-
var element = node.elements[i];
|
|
1443
|
-
if (!element)
|
|
1444
|
-
continue;
|
|
1445
|
-
if (hoist) {
|
|
1446
|
-
if (onlyBlock || kind === 'var') {
|
|
1447
|
-
if (element.type === 'Identifier') {
|
|
1448
|
-
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1449
|
-
}
|
|
1450
|
-
else {
|
|
1451
|
-
pattern$3(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
else if (element.type === 'Identifier') {
|
|
1456
|
-
if (kind) {
|
|
1457
|
-
scope[kind](element.name, feed[i]);
|
|
1458
|
-
}
|
|
1459
|
-
else {
|
|
1460
|
-
var variable = Identifier(element, scope, { getVar: true });
|
|
1461
|
-
variable.set(feed[i]);
|
|
1462
|
-
result.push(variable.get());
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
else if (element.type === 'RestElement') {
|
|
1466
|
-
RestElement(element, scope, { kind: kind, feed: feed.slice(i) });
|
|
1467
|
-
}
|
|
1468
|
-
else {
|
|
1469
|
-
pattern$3(element, scope, { kind: kind, feed: feed[i] });
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
if (result.length) {
|
|
1473
|
-
return result;
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
function RestElement(node, scope, options) {
|
|
1477
|
-
if (options === void 0) { options = {}; }
|
|
1478
|
-
var kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
1479
|
-
var arg = node.argument;
|
|
1480
|
-
if (hoist) {
|
|
1481
|
-
if (onlyBlock || kind === 'var') {
|
|
1482
|
-
if (arg.type === 'Identifier') {
|
|
1483
|
-
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1484
|
-
}
|
|
1485
|
-
else {
|
|
1486
|
-
pattern$3(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
else if (arg.type === 'Identifier') {
|
|
1491
|
-
if (kind) {
|
|
1492
|
-
scope[kind](arg.name, feed);
|
|
1493
|
-
}
|
|
1494
|
-
else {
|
|
1495
|
-
var variable = Identifier(arg, scope, { getVar: true });
|
|
1496
|
-
variable.set(feed);
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
else {
|
|
1500
|
-
pattern$3(arg, scope, { kind: kind, feed: feed });
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
function AssignmentPattern(node, scope, options) {
|
|
1504
|
-
if (options === void 0) { options = {}; }
|
|
1505
|
-
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? evaluate(node.right, scope) : _d;
|
|
1506
|
-
var left = node.left;
|
|
1507
|
-
if (hoist) {
|
|
1508
|
-
if (onlyBlock || kind === 'var') {
|
|
1509
|
-
if (left.type === 'Identifier') {
|
|
1510
|
-
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1511
|
-
}
|
|
1512
|
-
else {
|
|
1513
|
-
pattern$3(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
else if (left.type === 'Identifier') {
|
|
1518
|
-
scope[kind](left.name, feed);
|
|
1519
|
-
}
|
|
1520
|
-
else {
|
|
1521
|
-
pattern$3(left, scope, { kind: kind, feed: feed });
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
var pattern = /*#__PURE__*/Object.freeze({
|
|
1526
|
-
__proto__: null,
|
|
1527
|
-
ObjectPattern: ObjectPattern,
|
|
1528
|
-
ArrayPattern: ArrayPattern,
|
|
1529
|
-
RestElement: RestElement,
|
|
1530
|
-
AssignmentPattern: AssignmentPattern
|
|
1531
|
-
});
|
|
1532
|
-
|
|
1533
|
-
function Program(program, scope) {
|
|
1534
|
-
for (var i = 0; i < program.body.length; i++) {
|
|
1535
|
-
evaluate(program.body[i], scope);
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
var program = /*#__PURE__*/Object.freeze({
|
|
1540
|
-
__proto__: null,
|
|
1541
|
-
Program: Program
|
|
1542
|
-
});
|
|
1543
|
-
|
|
1544
|
-
var evaluateOps;
|
|
1545
|
-
function evaluate(node, scope) {
|
|
1546
|
-
if (!node)
|
|
1547
|
-
return;
|
|
1548
|
-
if (!evaluateOps) {
|
|
1549
|
-
evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern, program);
|
|
1550
|
-
}
|
|
1551
|
-
var handler = evaluateOps[node.type];
|
|
1552
|
-
if (handler) {
|
|
1553
|
-
return handler(node, scope);
|
|
1554
|
-
}
|
|
1555
|
-
else {
|
|
1556
|
-
throw new Error(node.type + " isn't implemented");
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
function FunctionDeclaration(node, scope) {
|
|
1561
|
-
scope.func(node.id.name, createFunc$1(node, scope));
|
|
1562
|
-
}
|
|
1563
|
-
function VariableDeclaration(node, scope, options) {
|
|
1564
|
-
if (options === void 0) { options = {}; }
|
|
1565
|
-
for (var i = 0; i < node.declarations.length; i++) {
|
|
1566
|
-
VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
function VariableDeclarator(node, scope, options) {
|
|
1570
|
-
if (options === void 0) { options = {}; }
|
|
1571
|
-
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, feed = options.feed;
|
|
1572
|
-
if (hoist) {
|
|
1573
|
-
if (onlyBlock || kind === 'var') {
|
|
1574
|
-
if (node.id.type === 'Identifier') {
|
|
1575
|
-
scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1576
|
-
}
|
|
1577
|
-
else {
|
|
1578
|
-
pattern$3(node.id, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
else {
|
|
1583
|
-
var hasFeed = 'feed' in options;
|
|
1584
|
-
var value = hasFeed ? feed : evaluate(node.init, scope);
|
|
1585
|
-
if (node.id.type === 'Identifier') {
|
|
1586
|
-
var name_1 = node.id.name;
|
|
1587
|
-
if (kind === 'var' && !node.init && !hasFeed) {
|
|
1588
|
-
scope.var(name_1, NOINIT);
|
|
1589
|
-
}
|
|
1590
|
-
else {
|
|
1591
|
-
scope[kind](name_1, value);
|
|
1684
|
+
scope[kind](name_1, value);
|
|
1592
1685
|
}
|
|
1593
1686
|
if (node.init
|
|
1594
1687
|
&& ['ClassExpression', 'FunctionExpression', 'ArrowFunctionExpression']
|
|
@@ -1616,22 +1709,39 @@
|
|
|
1616
1709
|
if (def.type === 'MethodDefinition') {
|
|
1617
1710
|
MethodDefinition(def, scope, { klass: klass, superClass: superClass });
|
|
1618
1711
|
}
|
|
1712
|
+
else if (def.type === 'PropertyDefinition' && def.static) {
|
|
1713
|
+
PropertyDefinition(def, scope, { klass: klass, superClass: superClass });
|
|
1714
|
+
}
|
|
1715
|
+
else if (def.type === 'StaticBlock') {
|
|
1716
|
+
StaticBlock(def, scope, { klass: klass, superClass: superClass });
|
|
1717
|
+
}
|
|
1619
1718
|
}
|
|
1620
1719
|
}
|
|
1621
1720
|
function MethodDefinition(node, scope, options) {
|
|
1622
1721
|
if (options === void 0) { options = {}; }
|
|
1623
1722
|
var klass = options.klass, superClass = options.superClass;
|
|
1624
1723
|
var key;
|
|
1724
|
+
var priv = false;
|
|
1625
1725
|
if (node.computed) {
|
|
1626
1726
|
key = evaluate(node.key, scope);
|
|
1627
1727
|
}
|
|
1628
1728
|
else if (node.key.type === 'Identifier') {
|
|
1629
1729
|
key = node.key.name;
|
|
1630
1730
|
}
|
|
1731
|
+
else if (node.key.type === 'PrivateIdentifier') {
|
|
1732
|
+
key = node.key.name;
|
|
1733
|
+
priv = true;
|
|
1734
|
+
}
|
|
1631
1735
|
else {
|
|
1632
1736
|
throw new SyntaxError('Unexpected token');
|
|
1633
1737
|
}
|
|
1634
1738
|
var obj = node.static ? klass : klass.prototype;
|
|
1739
|
+
if (priv) {
|
|
1740
|
+
if (!obj[PRIVATE]) {
|
|
1741
|
+
define(obj, PRIVATE, { value: {} });
|
|
1742
|
+
}
|
|
1743
|
+
obj = obj[PRIVATE];
|
|
1744
|
+
}
|
|
1635
1745
|
var value = createFunc$1(node.value, scope, { superClass: superClass });
|
|
1636
1746
|
switch (node.kind) {
|
|
1637
1747
|
case 'constructor':
|
|
@@ -1664,6 +1774,193 @@
|
|
|
1664
1774
|
default:
|
|
1665
1775
|
throw new SyntaxError('Unexpected token');
|
|
1666
1776
|
}
|
|
1777
|
+
}
|
|
1778
|
+
function PropertyDefinition(node, scope, options) {
|
|
1779
|
+
if (options === void 0) { options = {}; }
|
|
1780
|
+
var klass = options.klass, superClass = options.superClass;
|
|
1781
|
+
var key;
|
|
1782
|
+
var priv = false;
|
|
1783
|
+
if (node.computed) {
|
|
1784
|
+
key = evaluate(node.key, scope);
|
|
1785
|
+
}
|
|
1786
|
+
else if (node.key.type === 'Identifier') {
|
|
1787
|
+
key = node.key.name;
|
|
1788
|
+
}
|
|
1789
|
+
else if (node.key.type === 'PrivateIdentifier') {
|
|
1790
|
+
key = node.key.name;
|
|
1791
|
+
priv = true;
|
|
1792
|
+
}
|
|
1793
|
+
else {
|
|
1794
|
+
throw new SyntaxError('Unexpected token');
|
|
1795
|
+
}
|
|
1796
|
+
var subScope = new Scope(scope, true);
|
|
1797
|
+
subScope.const('this', klass);
|
|
1798
|
+
var obj = klass;
|
|
1799
|
+
if (priv) {
|
|
1800
|
+
if (!obj[PRIVATE]) {
|
|
1801
|
+
define(obj, PRIVATE, { value: {} });
|
|
1802
|
+
}
|
|
1803
|
+
obj = obj[PRIVATE];
|
|
1804
|
+
}
|
|
1805
|
+
if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
|
|
1806
|
+
obj[key] = createFunc$1(node.value, subScope, { superClass: superClass });
|
|
1807
|
+
}
|
|
1808
|
+
else {
|
|
1809
|
+
obj[key] = evaluate(node.value, subScope);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
function StaticBlock(node, scope, options) {
|
|
1813
|
+
if (options === void 0) { options = {}; }
|
|
1814
|
+
var klass = options.klass;
|
|
1815
|
+
var subScope = new Scope(scope, true);
|
|
1816
|
+
subScope.const('this', klass);
|
|
1817
|
+
return BlockStatement(node, subScope, { invasived: true });
|
|
1818
|
+
}
|
|
1819
|
+
function ImportDeclaration(node, scope) {
|
|
1820
|
+
var globalScope = scope.global();
|
|
1821
|
+
var module = globalScope.find(IMPORT + node.source.value);
|
|
1822
|
+
var value;
|
|
1823
|
+
if (module) {
|
|
1824
|
+
var result = module.get();
|
|
1825
|
+
if (result) {
|
|
1826
|
+
if (typeof result === 'function') {
|
|
1827
|
+
value = result();
|
|
1828
|
+
}
|
|
1829
|
+
else if (typeof result === 'object') {
|
|
1830
|
+
value = result;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
if (!value || typeof value !== 'object') {
|
|
1835
|
+
throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
|
|
1836
|
+
}
|
|
1837
|
+
for (var i = 0; i < node.specifiers.length; i++) {
|
|
1838
|
+
var spec = node.specifiers[i];
|
|
1839
|
+
var name_2 = void 0;
|
|
1840
|
+
if (spec.type === 'ImportSpecifier') {
|
|
1841
|
+
name_2 = spec.imported.type === 'Identifier'
|
|
1842
|
+
? spec.imported.name : spec.imported.value;
|
|
1843
|
+
}
|
|
1844
|
+
else if (spec.type === 'ImportDefaultSpecifier') {
|
|
1845
|
+
name_2 = 'default';
|
|
1846
|
+
}
|
|
1847
|
+
else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
1848
|
+
name_2 = '*';
|
|
1849
|
+
}
|
|
1850
|
+
if (name_2 !== '*' && !hasOwn(value, name_2)) {
|
|
1851
|
+
throw new SyntaxError("The requested module \"" + node.source.value + "\" does not provide an export named \"" + name_2 + "\"");
|
|
1852
|
+
}
|
|
1853
|
+
scope.var(spec.local.name, name_2 === '*' ? assign({}, value) : value[name_2]);
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
function ExportDefaultDeclaration(node, scope) {
|
|
1857
|
+
var globalScope = scope.global();
|
|
1858
|
+
var value;
|
|
1859
|
+
if (node.declaration.type === 'FunctionDeclaration') {
|
|
1860
|
+
value = createFunc$1(node.declaration, scope);
|
|
1861
|
+
scope.func(node.declaration.id.name, value);
|
|
1862
|
+
}
|
|
1863
|
+
else if (node.declaration.type === 'ClassDeclaration') {
|
|
1864
|
+
value = createClass$1(node.declaration, scope);
|
|
1865
|
+
scope.func(node.declaration.id.name, value);
|
|
1866
|
+
}
|
|
1867
|
+
else {
|
|
1868
|
+
value = evaluate(node.declaration, scope);
|
|
1869
|
+
}
|
|
1870
|
+
var variable = globalScope.find(EXPORTS);
|
|
1871
|
+
if (variable) {
|
|
1872
|
+
var exports_1 = variable.get();
|
|
1873
|
+
if (exports_1 && typeof exports_1 === 'object') {
|
|
1874
|
+
exports_1.default = value;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
function ExportNamedDeclaration(node, scope) {
|
|
1879
|
+
var globalScope = scope.global();
|
|
1880
|
+
if (node.declaration) {
|
|
1881
|
+
if (node.declaration.type === 'FunctionDeclaration') {
|
|
1882
|
+
var value = createFunc$1(node.declaration, scope);
|
|
1883
|
+
scope.func(node.declaration.id.name, value);
|
|
1884
|
+
var variable = globalScope.find(EXPORTS);
|
|
1885
|
+
if (variable) {
|
|
1886
|
+
var exports_2 = variable.get();
|
|
1887
|
+
if (exports_2 && typeof exports_2 === 'object') {
|
|
1888
|
+
exports_2[node.declaration.id.name] = value;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
else if (node.declaration.type === 'ClassDeclaration') {
|
|
1893
|
+
var value = createClass$1(node.declaration, scope);
|
|
1894
|
+
scope.func(node.declaration.id.name, value);
|
|
1895
|
+
var variable = globalScope.find(EXPORTS);
|
|
1896
|
+
if (variable) {
|
|
1897
|
+
var exports_3 = variable.get();
|
|
1898
|
+
if (exports_3 && typeof exports_3 === 'object') {
|
|
1899
|
+
exports_3[node.declaration.id.name] = value;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
else if (node.declaration.type === 'VariableDeclaration') {
|
|
1904
|
+
VariableDeclaration(node.declaration, scope);
|
|
1905
|
+
var variable = globalScope.find(EXPORTS);
|
|
1906
|
+
if (variable) {
|
|
1907
|
+
var exports_4 = variable.get();
|
|
1908
|
+
if (exports_4 && typeof exports_4 === 'object') {
|
|
1909
|
+
for (var i = 0; i < node.declaration.declarations.length; i++) {
|
|
1910
|
+
var name_3 = node.declaration.declarations[i].id.name;
|
|
1911
|
+
var item = scope.find(name_3);
|
|
1912
|
+
if (item) {
|
|
1913
|
+
exports_4[name_3] = item.get();
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
else if (node.specifiers) {
|
|
1921
|
+
var variable = globalScope.find(EXPORTS);
|
|
1922
|
+
if (variable) {
|
|
1923
|
+
var exports_5 = variable.get();
|
|
1924
|
+
if (exports_5 && typeof exports_5 === 'object') {
|
|
1925
|
+
for (var i = 0; i < node.specifiers.length; i++) {
|
|
1926
|
+
var spec = node.specifiers[i];
|
|
1927
|
+
var name_4 = spec.local.type === 'Identifier'
|
|
1928
|
+
? spec.local.name : spec.local.value;
|
|
1929
|
+
var item = scope.find(name_4);
|
|
1930
|
+
if (item) {
|
|
1931
|
+
exports_5[spec.exported.type === 'Identifier'
|
|
1932
|
+
? spec.exported.name : spec.exported.value] = item.get();
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
function ExportAllDeclaration(node, scope) {
|
|
1940
|
+
var globalScope = scope.global();
|
|
1941
|
+
var module = globalScope.find(IMPORT + node.source.value);
|
|
1942
|
+
var value;
|
|
1943
|
+
if (module) {
|
|
1944
|
+
var result = module.get();
|
|
1945
|
+
if (result) {
|
|
1946
|
+
if (typeof result === 'function') {
|
|
1947
|
+
value = result();
|
|
1948
|
+
}
|
|
1949
|
+
else if (typeof result === 'object') {
|
|
1950
|
+
value = result;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
if (!value || typeof value !== 'object') {
|
|
1955
|
+
throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
|
|
1956
|
+
}
|
|
1957
|
+
var variable = globalScope.find(EXPORTS);
|
|
1958
|
+
if (variable) {
|
|
1959
|
+
var exports_6 = variable.get();
|
|
1960
|
+
if (exports_6 && typeof exports_6 === 'object') {
|
|
1961
|
+
assign(exports_6, value);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1667
1964
|
}
|
|
1668
1965
|
|
|
1669
1966
|
function Identifier$1(node, scope, options) {
|
|
@@ -1928,12 +2225,22 @@
|
|
|
1928
2225
|
var left, right;
|
|
1929
2226
|
return __generator(this, function (_a) {
|
|
1930
2227
|
switch (_a.label) {
|
|
1931
|
-
case 0:
|
|
2228
|
+
case 0:
|
|
2229
|
+
if (!(node.left.type === 'PrivateIdentifier')) return [3, 2];
|
|
2230
|
+
left = node.left.name;
|
|
2231
|
+
return [5, __values(evaluate$1(node.right, scope))];
|
|
1932
2232
|
case 1:
|
|
2233
|
+
right = _a.sent();
|
|
2234
|
+
right = right[PRIVATE];
|
|
2235
|
+
return [3, 5];
|
|
2236
|
+
case 2: return [5, __values(evaluate$1(node.left, scope))];
|
|
2237
|
+
case 3:
|
|
1933
2238
|
left = _a.sent();
|
|
1934
2239
|
return [5, __values(evaluate$1(node.right, scope))];
|
|
1935
|
-
case
|
|
2240
|
+
case 4:
|
|
1936
2241
|
right = _a.sent();
|
|
2242
|
+
_a.label = 5;
|
|
2243
|
+
case 5:
|
|
1937
2244
|
switch (node.operator) {
|
|
1938
2245
|
case '==': return [2, left == right];
|
|
1939
2246
|
case '!=': return [2, left != right];
|
|
@@ -2092,7 +2399,7 @@
|
|
|
2092
2399
|
});
|
|
2093
2400
|
}
|
|
2094
2401
|
function MemberExpression$1(node, scope, options) {
|
|
2095
|
-
var _a, getObj, _b, getVar, object, key, setter, thisObject, privateKey, getter, thisObject;
|
|
2402
|
+
var _a, getObj, _b, getVar, object, key, priv, setter, thisObject, privateKey, getter, thisObject;
|
|
2096
2403
|
if (options === void 0) { options = {}; }
|
|
2097
2404
|
return __generator(this, function (_c) {
|
|
2098
2405
|
switch (_c.label) {
|
|
@@ -2110,15 +2417,25 @@
|
|
|
2110
2417
|
case 4:
|
|
2111
2418
|
if (getObj)
|
|
2112
2419
|
return [2, object];
|
|
2420
|
+
priv = false;
|
|
2113
2421
|
if (!node.computed) return [3, 6];
|
|
2114
2422
|
return [5, __values(evaluate$1(node.property, scope))];
|
|
2115
2423
|
case 5:
|
|
2116
2424
|
key = _c.sent();
|
|
2117
2425
|
return [3, 7];
|
|
2118
2426
|
case 6:
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2427
|
+
if (node.property.type === 'PrivateIdentifier') {
|
|
2428
|
+
key = node.property.name;
|
|
2429
|
+
priv = true;
|
|
2430
|
+
}
|
|
2431
|
+
else {
|
|
2432
|
+
key = node.property.name;
|
|
2433
|
+
}
|
|
2434
|
+
_c.label = 7;
|
|
2435
|
+
case 7:
|
|
2436
|
+
if (priv) {
|
|
2437
|
+
object = object[PRIVATE];
|
|
2438
|
+
}
|
|
2122
2439
|
if (getVar) {
|
|
2123
2440
|
setter = getSetter(object, key);
|
|
2124
2441
|
if (node.object.type === 'Super' && setter) {
|
|
@@ -2170,7 +2487,7 @@
|
|
|
2170
2487
|
});
|
|
2171
2488
|
}
|
|
2172
2489
|
function CallExpression$1(node, scope) {
|
|
2173
|
-
var func, object, key, thisObject, name_1, args, i, arg, _a, _b, _c, _d, superCall;
|
|
2490
|
+
var func, object, key, priv, obj, thisObject, name_1, args, i, arg, _a, _b, _c, _d, superCall;
|
|
2174
2491
|
return __generator(this, function (_e) {
|
|
2175
2492
|
switch (_e.label) {
|
|
2176
2493
|
case 0:
|
|
@@ -2182,21 +2499,32 @@
|
|
|
2182
2499
|
return [2, undefined];
|
|
2183
2500
|
}
|
|
2184
2501
|
key = void 0;
|
|
2502
|
+
priv = false;
|
|
2185
2503
|
if (!node.callee.computed) return [3, 3];
|
|
2186
2504
|
return [5, __values(evaluate$1(node.callee.property, scope))];
|
|
2187
2505
|
case 2:
|
|
2188
2506
|
key = _e.sent();
|
|
2189
2507
|
return [3, 4];
|
|
2190
2508
|
case 3:
|
|
2191
|
-
|
|
2509
|
+
if (node.callee.property.type === 'PrivateIdentifier') {
|
|
2510
|
+
key = node.callee.property.name;
|
|
2511
|
+
priv = true;
|
|
2512
|
+
}
|
|
2513
|
+
else {
|
|
2514
|
+
key = node.callee.property.name;
|
|
2515
|
+
}
|
|
2192
2516
|
_e.label = 4;
|
|
2193
2517
|
case 4:
|
|
2518
|
+
obj = object;
|
|
2519
|
+
if (priv) {
|
|
2520
|
+
obj = obj[PRIVATE];
|
|
2521
|
+
}
|
|
2194
2522
|
if (node.callee.object.type === 'Super') {
|
|
2195
2523
|
thisObject = scope.find('this').get();
|
|
2196
|
-
func =
|
|
2524
|
+
func = obj[key].bind(thisObject);
|
|
2197
2525
|
}
|
|
2198
2526
|
else {
|
|
2199
|
-
func =
|
|
2527
|
+
func = obj[key];
|
|
2200
2528
|
}
|
|
2201
2529
|
if (node.optional && func == null) {
|
|
2202
2530
|
return [2, undefined];
|
|
@@ -2326,7 +2654,13 @@
|
|
|
2326
2654
|
}
|
|
2327
2655
|
function MetaProperty$1(node, scope) {
|
|
2328
2656
|
return __generator(this, function (_a) {
|
|
2329
|
-
|
|
2657
|
+
if (node.meta.name === 'new' && node.property.name === 'target') {
|
|
2658
|
+
return [2, scope.find(NEWTARGET).get()];
|
|
2659
|
+
}
|
|
2660
|
+
else if (node.meta.name === 'import' && node.property.name === 'meta') {
|
|
2661
|
+
return [2, { url: '' }];
|
|
2662
|
+
}
|
|
2663
|
+
return [2];
|
|
2330
2664
|
});
|
|
2331
2665
|
}
|
|
2332
2666
|
function SequenceExpression$1(node, scope) {
|
|
@@ -2445,10 +2779,13 @@
|
|
|
2445
2779
|
});
|
|
2446
2780
|
}
|
|
2447
2781
|
function SpreadElement$1(node, scope) {
|
|
2782
|
+
var result;
|
|
2448
2783
|
return __generator(this, function (_a) {
|
|
2449
2784
|
switch (_a.label) {
|
|
2450
2785
|
case 0: return [5, __values(evaluate$1(node.argument, scope))];
|
|
2451
|
-
case 1:
|
|
2786
|
+
case 1:
|
|
2787
|
+
result = _a.sent();
|
|
2788
|
+
return [2, typeof result === 'string' ? __spread(result) : result];
|
|
2452
2789
|
}
|
|
2453
2790
|
});
|
|
2454
2791
|
}
|
|
@@ -2460,6 +2797,34 @@
|
|
|
2460
2797
|
}
|
|
2461
2798
|
});
|
|
2462
2799
|
}
|
|
2800
|
+
function ImportExpression$1(node, scope) {
|
|
2801
|
+
var globalScope, source, module, value, result;
|
|
2802
|
+
return __generator(this, function (_a) {
|
|
2803
|
+
switch (_a.label) {
|
|
2804
|
+
case 0:
|
|
2805
|
+
globalScope = scope.global();
|
|
2806
|
+
return [5, __values(evaluate$1(node.source, scope))];
|
|
2807
|
+
case 1:
|
|
2808
|
+
source = _a.sent();
|
|
2809
|
+
module = globalScope.find(IMPORT + source);
|
|
2810
|
+
if (module) {
|
|
2811
|
+
result = module.get();
|
|
2812
|
+
if (result) {
|
|
2813
|
+
if (typeof result === 'function') {
|
|
2814
|
+
value = result();
|
|
2815
|
+
}
|
|
2816
|
+
else if (typeof result === 'object') {
|
|
2817
|
+
value = result;
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
if (!value || typeof value !== 'object') {
|
|
2822
|
+
return [2, Promise.reject(new TypeError("Failed to resolve module specifier \"" + source + "\""))];
|
|
2823
|
+
}
|
|
2824
|
+
return [2, Promise.resolve(value)];
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2463
2828
|
function YieldExpression(node, scope) {
|
|
2464
2829
|
var res, _a;
|
|
2465
2830
|
return __generator(this, function (_b) {
|
|
@@ -2520,105 +2885,337 @@
|
|
|
2520
2885
|
Super: Super$1,
|
|
2521
2886
|
SpreadElement: SpreadElement$1,
|
|
2522
2887
|
ChainExpression: ChainExpression$1,
|
|
2888
|
+
ImportExpression: ImportExpression$1,
|
|
2523
2889
|
YieldExpression: YieldExpression,
|
|
2524
2890
|
AwaitExpression: AwaitExpression
|
|
2525
2891
|
});
|
|
2526
2892
|
|
|
2527
|
-
function
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2893
|
+
function ObjectPattern$1(node, scope, options) {
|
|
2894
|
+
var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, fedKeys, i, property, value, key, value, rest, i_1;
|
|
2895
|
+
if (options === void 0) { options = {}; }
|
|
2896
|
+
return __generator(this, function (_e) {
|
|
2897
|
+
switch (_e.label) {
|
|
2898
|
+
case 0:
|
|
2899
|
+
_a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? {} : _d;
|
|
2900
|
+
fedKeys = [];
|
|
2901
|
+
i = 0;
|
|
2902
|
+
_e.label = 1;
|
|
2531
2903
|
case 1:
|
|
2532
|
-
|
|
2533
|
-
|
|
2904
|
+
if (!(i < node.properties.length)) return [3, 18];
|
|
2905
|
+
property = node.properties[i];
|
|
2906
|
+
if (!hoist) return [3, 8];
|
|
2907
|
+
if (!(onlyBlock || kind === 'var')) return [3, 7];
|
|
2908
|
+
if (!(property.type === 'Property')) return [3, 5];
|
|
2909
|
+
value = property.value;
|
|
2910
|
+
if (!(value.type === 'Identifier')) return [3, 2];
|
|
2911
|
+
scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2912
|
+
return [3, 4];
|
|
2913
|
+
case 2: return [5, __values(pattern$2(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
2914
|
+
case 3:
|
|
2915
|
+
_e.sent();
|
|
2916
|
+
_e.label = 4;
|
|
2917
|
+
case 4: return [3, 7];
|
|
2918
|
+
case 5: return [5, __values(RestElement$1(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
2919
|
+
case 6:
|
|
2920
|
+
_e.sent();
|
|
2921
|
+
_e.label = 7;
|
|
2922
|
+
case 7: return [3, 17];
|
|
2923
|
+
case 8:
|
|
2924
|
+
if (!(property.type === 'Property')) return [3, 15];
|
|
2925
|
+
key = void 0;
|
|
2926
|
+
if (!property.computed) return [3, 10];
|
|
2927
|
+
return [5, __values(evaluate$1(property.key, scope))];
|
|
2928
|
+
case 9:
|
|
2929
|
+
key = _e.sent();
|
|
2930
|
+
return [3, 11];
|
|
2931
|
+
case 10:
|
|
2932
|
+
key = property.key.name;
|
|
2933
|
+
_e.label = 11;
|
|
2934
|
+
case 11:
|
|
2935
|
+
fedKeys.push(key);
|
|
2936
|
+
value = property.value;
|
|
2937
|
+
if (!(value.type === 'Identifier')) return [3, 12];
|
|
2938
|
+
scope[kind](value.name, feed[key]);
|
|
2939
|
+
return [3, 14];
|
|
2940
|
+
case 12: return [5, __values(pattern$2(value, scope, { kind: kind, feed: feed[key] }))];
|
|
2941
|
+
case 13:
|
|
2942
|
+
_e.sent();
|
|
2943
|
+
_e.label = 14;
|
|
2944
|
+
case 14: return [3, 17];
|
|
2945
|
+
case 15:
|
|
2946
|
+
rest = assign({}, feed);
|
|
2947
|
+
for (i_1 = 0; i_1 < fedKeys.length; i_1++)
|
|
2948
|
+
delete rest[fedKeys[i_1]];
|
|
2949
|
+
return [5, __values(RestElement$1(property, scope, { kind: kind, feed: rest }))];
|
|
2950
|
+
case 16:
|
|
2951
|
+
_e.sent();
|
|
2952
|
+
_e.label = 17;
|
|
2953
|
+
case 17:
|
|
2954
|
+
i++;
|
|
2955
|
+
return [3, 1];
|
|
2956
|
+
case 18: return [2];
|
|
2534
2957
|
}
|
|
2535
2958
|
});
|
|
2536
2959
|
}
|
|
2537
|
-
function
|
|
2538
|
-
var _a,
|
|
2960
|
+
function ArrayPattern$1(node, scope, options) {
|
|
2961
|
+
var kind, _a, hoist, _b, onlyBlock, _c, feed, result, i, element, variable;
|
|
2539
2962
|
if (options === void 0) { options = {}; }
|
|
2540
|
-
return __generator(this, function (
|
|
2541
|
-
switch (
|
|
2963
|
+
return __generator(this, function (_d) {
|
|
2964
|
+
switch (_d.label) {
|
|
2542
2965
|
case 0:
|
|
2543
|
-
_a = options.
|
|
2544
|
-
|
|
2545
|
-
if (!!hoisted) return [3, 2];
|
|
2546
|
-
return [5, __values(hoist(block, subScope, { onlyBlock: true }))];
|
|
2547
|
-
case 1:
|
|
2548
|
-
_c.sent();
|
|
2549
|
-
_c.label = 2;
|
|
2550
|
-
case 2:
|
|
2966
|
+
kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
2967
|
+
result = [];
|
|
2551
2968
|
i = 0;
|
|
2552
|
-
|
|
2969
|
+
_d.label = 1;
|
|
2970
|
+
case 1:
|
|
2971
|
+
if (!(i < node.elements.length)) return [3, 14];
|
|
2972
|
+
element = node.elements[i];
|
|
2973
|
+
if (!element)
|
|
2974
|
+
return [3, 13];
|
|
2975
|
+
if (!hoist) return [3, 5];
|
|
2976
|
+
if (!(onlyBlock || kind === 'var')) return [3, 4];
|
|
2977
|
+
if (!(element.type === 'Identifier')) return [3, 2];
|
|
2978
|
+
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2979
|
+
return [3, 4];
|
|
2980
|
+
case 2: return [5, __values(pattern$2(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
2553
2981
|
case 3:
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
case 4:
|
|
2557
|
-
result = _c.sent();
|
|
2558
|
-
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
2559
|
-
return [2, result];
|
|
2560
|
-
}
|
|
2561
|
-
_c.label = 5;
|
|
2982
|
+
_d.sent();
|
|
2983
|
+
_d.label = 4;
|
|
2984
|
+
case 4: return [3, 13];
|
|
2562
2985
|
case 5:
|
|
2986
|
+
if (!(element.type === 'Identifier')) return [3, 9];
|
|
2987
|
+
if (!kind) return [3, 6];
|
|
2988
|
+
scope[kind](element.name, feed[i]);
|
|
2989
|
+
return [3, 8];
|
|
2990
|
+
case 6: return [5, __values(Identifier$1(element, scope, { getVar: true }))];
|
|
2991
|
+
case 7:
|
|
2992
|
+
variable = _d.sent();
|
|
2993
|
+
variable.set(feed[i]);
|
|
2994
|
+
result.push(variable.get());
|
|
2995
|
+
_d.label = 8;
|
|
2996
|
+
case 8: return [3, 13];
|
|
2997
|
+
case 9:
|
|
2998
|
+
if (!(element.type === 'RestElement')) return [3, 11];
|
|
2999
|
+
return [5, __values(RestElement$1(element, scope, { kind: kind, feed: feed.slice(i) }))];
|
|
3000
|
+
case 10:
|
|
3001
|
+
_d.sent();
|
|
3002
|
+
return [3, 13];
|
|
3003
|
+
case 11: return [5, __values(pattern$2(element, scope, { kind: kind, feed: feed[i] }))];
|
|
3004
|
+
case 12:
|
|
3005
|
+
_d.sent();
|
|
3006
|
+
_d.label = 13;
|
|
3007
|
+
case 13:
|
|
2563
3008
|
i++;
|
|
2564
|
-
return [3,
|
|
2565
|
-
case
|
|
3009
|
+
return [3, 1];
|
|
3010
|
+
case 14:
|
|
3011
|
+
if (result.length) {
|
|
3012
|
+
return [2, result];
|
|
3013
|
+
}
|
|
3014
|
+
return [2];
|
|
2566
3015
|
}
|
|
2567
3016
|
});
|
|
2568
3017
|
}
|
|
2569
|
-
function
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
function DebuggerStatement$1() {
|
|
2575
|
-
return __generator(this, function (_a) {
|
|
2576
|
-
debugger;
|
|
2577
|
-
return [2];
|
|
2578
|
-
});
|
|
2579
|
-
}
|
|
2580
|
-
function ReturnStatement$1(node, scope) {
|
|
2581
|
-
var _a, _b;
|
|
2582
|
-
return __generator(this, function (_c) {
|
|
2583
|
-
switch (_c.label) {
|
|
3018
|
+
function RestElement$1(node, scope, options) {
|
|
3019
|
+
var kind, _a, hoist, _b, onlyBlock, _c, feed, arg, variable;
|
|
3020
|
+
if (options === void 0) { options = {}; }
|
|
3021
|
+
return __generator(this, function (_d) {
|
|
3022
|
+
switch (_d.label) {
|
|
2584
3023
|
case 0:
|
|
2585
|
-
_a =
|
|
2586
|
-
|
|
2587
|
-
return [
|
|
2588
|
-
|
|
2589
|
-
|
|
3024
|
+
kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
3025
|
+
arg = node.argument;
|
|
3026
|
+
if (!hoist) return [3, 4];
|
|
3027
|
+
if (!(onlyBlock || kind === 'var')) return [3, 3];
|
|
3028
|
+
if (!(arg.type === 'Identifier')) return [3, 1];
|
|
3029
|
+
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2590
3030
|
return [3, 3];
|
|
3031
|
+
case 1: return [5, __values(pattern$2(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
2591
3032
|
case 2:
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
case 3:
|
|
2595
|
-
|
|
2596
|
-
return [
|
|
3033
|
+
_d.sent();
|
|
3034
|
+
_d.label = 3;
|
|
3035
|
+
case 3: return [3, 10];
|
|
3036
|
+
case 4:
|
|
3037
|
+
if (!(arg.type === 'Identifier')) return [3, 8];
|
|
3038
|
+
if (!kind) return [3, 5];
|
|
3039
|
+
scope[kind](arg.name, feed);
|
|
3040
|
+
return [3, 7];
|
|
3041
|
+
case 5: return [5, __values(Identifier$1(arg, scope, { getVar: true }))];
|
|
3042
|
+
case 6:
|
|
3043
|
+
variable = _d.sent();
|
|
3044
|
+
variable.set(feed);
|
|
3045
|
+
_d.label = 7;
|
|
3046
|
+
case 7: return [3, 10];
|
|
3047
|
+
case 8: return [5, __values(pattern$2(arg, scope, { kind: kind, feed: feed }))];
|
|
3048
|
+
case 9:
|
|
3049
|
+
_d.sent();
|
|
3050
|
+
_d.label = 10;
|
|
3051
|
+
case 10: return [2];
|
|
2597
3052
|
}
|
|
2598
3053
|
});
|
|
2599
3054
|
}
|
|
2600
|
-
function
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
}
|
|
2610
|
-
function IfStatement$1(node, scope) {
|
|
2611
|
-
return __generator(this, function (_a) {
|
|
2612
|
-
switch (_a.label) {
|
|
2613
|
-
case 0: return [5, __values(evaluate$1(node.test, scope))];
|
|
3055
|
+
function AssignmentPattern$1(node, scope, options) {
|
|
3056
|
+
var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, _e, left;
|
|
3057
|
+
if (options === void 0) { options = {}; }
|
|
3058
|
+
return __generator(this, function (_f) {
|
|
3059
|
+
switch (_f.label) {
|
|
3060
|
+
case 0:
|
|
3061
|
+
_a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed;
|
|
3062
|
+
if (!(_d === void 0)) return [3, 2];
|
|
3063
|
+
return [5, __values(evaluate$1(node.right, scope))];
|
|
2614
3064
|
case 1:
|
|
2615
|
-
|
|
2616
|
-
return [
|
|
2617
|
-
case 2:
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
3065
|
+
_e = _f.sent();
|
|
3066
|
+
return [3, 3];
|
|
3067
|
+
case 2:
|
|
3068
|
+
_e = _d;
|
|
3069
|
+
_f.label = 3;
|
|
3070
|
+
case 3:
|
|
3071
|
+
feed = _e;
|
|
3072
|
+
left = node.left;
|
|
3073
|
+
if (!hoist) return [3, 7];
|
|
3074
|
+
if (!(onlyBlock || kind === 'var')) return [3, 6];
|
|
3075
|
+
if (!(left.type === 'Identifier')) return [3, 4];
|
|
3076
|
+
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3077
|
+
return [3, 6];
|
|
3078
|
+
case 4: return [5, __values(pattern$2(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3079
|
+
case 5:
|
|
3080
|
+
_f.sent();
|
|
3081
|
+
_f.label = 6;
|
|
3082
|
+
case 6: return [3, 10];
|
|
3083
|
+
case 7:
|
|
3084
|
+
if (!(left.type === 'Identifier')) return [3, 8];
|
|
3085
|
+
scope[kind](left.name, feed);
|
|
3086
|
+
return [3, 10];
|
|
3087
|
+
case 8: return [5, __values(pattern$2(left, scope, { kind: kind, feed: feed }))];
|
|
3088
|
+
case 9:
|
|
3089
|
+
_f.sent();
|
|
3090
|
+
_f.label = 10;
|
|
3091
|
+
case 10: return [2];
|
|
3092
|
+
}
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
|
|
3096
|
+
var pattern$1 = /*#__PURE__*/Object.freeze({
|
|
3097
|
+
__proto__: null,
|
|
3098
|
+
ObjectPattern: ObjectPattern$1,
|
|
3099
|
+
ArrayPattern: ArrayPattern$1,
|
|
3100
|
+
RestElement: RestElement$1,
|
|
3101
|
+
AssignmentPattern: AssignmentPattern$1
|
|
3102
|
+
});
|
|
3103
|
+
|
|
3104
|
+
var evaluateOps$1;
|
|
3105
|
+
function evaluate$1(node, scope) {
|
|
3106
|
+
var handler;
|
|
3107
|
+
return __generator(this, function (_a) {
|
|
3108
|
+
switch (_a.label) {
|
|
3109
|
+
case 0:
|
|
3110
|
+
if (!node)
|
|
3111
|
+
return [2];
|
|
3112
|
+
if (!evaluateOps$1) {
|
|
3113
|
+
evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$1);
|
|
3114
|
+
}
|
|
3115
|
+
handler = evaluateOps$1[node.type];
|
|
3116
|
+
if (!handler) return [3, 2];
|
|
3117
|
+
return [5, __values(handler(node, scope))];
|
|
3118
|
+
case 1: return [2, _a.sent()];
|
|
3119
|
+
case 2: throw new Error(node.type + " isn't implemented");
|
|
3120
|
+
}
|
|
3121
|
+
});
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
function ExpressionStatement$1(node, scope) {
|
|
3125
|
+
return __generator(this, function (_a) {
|
|
3126
|
+
switch (_a.label) {
|
|
3127
|
+
case 0: return [5, __values(evaluate$1(node.expression, scope))];
|
|
3128
|
+
case 1:
|
|
3129
|
+
_a.sent();
|
|
3130
|
+
return [2];
|
|
3131
|
+
}
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
function BlockStatement$1(block, scope, options) {
|
|
3135
|
+
var _a, invasived, _b, hoisted, subScope, i, result;
|
|
3136
|
+
if (options === void 0) { options = {}; }
|
|
3137
|
+
return __generator(this, function (_c) {
|
|
3138
|
+
switch (_c.label) {
|
|
3139
|
+
case 0:
|
|
3140
|
+
_a = options.invasived, invasived = _a === void 0 ? false : _a, _b = options.hoisted, hoisted = _b === void 0 ? false : _b;
|
|
3141
|
+
subScope = invasived ? scope : new Scope(scope);
|
|
3142
|
+
if (!!hoisted) return [3, 2];
|
|
3143
|
+
return [5, __values(hoist(block, subScope, { onlyBlock: true }))];
|
|
3144
|
+
case 1:
|
|
3145
|
+
_c.sent();
|
|
3146
|
+
_c.label = 2;
|
|
3147
|
+
case 2:
|
|
3148
|
+
i = 0;
|
|
3149
|
+
_c.label = 3;
|
|
3150
|
+
case 3:
|
|
3151
|
+
if (!(i < block.body.length)) return [3, 6];
|
|
3152
|
+
return [5, __values(evaluate$1(block.body[i], subScope))];
|
|
3153
|
+
case 4:
|
|
3154
|
+
result = _c.sent();
|
|
3155
|
+
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
3156
|
+
return [2, result];
|
|
3157
|
+
}
|
|
3158
|
+
_c.label = 5;
|
|
3159
|
+
case 5:
|
|
3160
|
+
i++;
|
|
3161
|
+
return [3, 3];
|
|
3162
|
+
case 6: return [2];
|
|
3163
|
+
}
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
function EmptyStatement$1() {
|
|
3167
|
+
return __generator(this, function (_a) {
|
|
3168
|
+
return [2];
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
function DebuggerStatement$1() {
|
|
3172
|
+
return __generator(this, function (_a) {
|
|
3173
|
+
debugger;
|
|
3174
|
+
return [2];
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
function ReturnStatement$1(node, scope) {
|
|
3178
|
+
var _a, _b;
|
|
3179
|
+
return __generator(this, function (_c) {
|
|
3180
|
+
switch (_c.label) {
|
|
3181
|
+
case 0:
|
|
3182
|
+
_a = RETURN;
|
|
3183
|
+
if (!node.argument) return [3, 2];
|
|
3184
|
+
return [5, __values(evaluate$1(node.argument, scope))];
|
|
3185
|
+
case 1:
|
|
3186
|
+
_b = (_c.sent());
|
|
3187
|
+
return [3, 3];
|
|
3188
|
+
case 2:
|
|
3189
|
+
_b = undefined;
|
|
3190
|
+
_c.label = 3;
|
|
3191
|
+
case 3:
|
|
3192
|
+
_a.RES = _b;
|
|
3193
|
+
return [2, RETURN];
|
|
3194
|
+
}
|
|
3195
|
+
});
|
|
3196
|
+
}
|
|
3197
|
+
function BreakStatement$1() {
|
|
3198
|
+
return __generator(this, function (_a) {
|
|
3199
|
+
return [2, BREAK];
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
function ContinueStatement$1() {
|
|
3203
|
+
return __generator(this, function (_a) {
|
|
3204
|
+
return [2, CONTINUE];
|
|
3205
|
+
});
|
|
3206
|
+
}
|
|
3207
|
+
function IfStatement$1(node, scope) {
|
|
3208
|
+
return __generator(this, function (_a) {
|
|
3209
|
+
switch (_a.label) {
|
|
3210
|
+
case 0: return [5, __values(evaluate$1(node.test, scope))];
|
|
3211
|
+
case 1:
|
|
3212
|
+
if (!_a.sent()) return [3, 3];
|
|
3213
|
+
return [5, __values(evaluate$1(node.consequent, scope))];
|
|
3214
|
+
case 2: return [2, _a.sent()];
|
|
3215
|
+
case 3: return [5, __values(evaluate$1(node.alternate, scope))];
|
|
3216
|
+
case 4: return [2, _a.sent()];
|
|
3217
|
+
}
|
|
3218
|
+
});
|
|
2622
3219
|
}
|
|
2623
3220
|
function SwitchStatement$1(node, scope) {
|
|
2624
3221
|
var discriminant, matched, i, eachCase, _a, _b, result;
|
|
@@ -2879,333 +3476,80 @@
|
|
|
2879
3476
|
case 5: return [2];
|
|
2880
3477
|
}
|
|
2881
3478
|
});
|
|
2882
|
-
}
|
|
2883
|
-
function ForOfStatement$1(node, scope) {
|
|
2884
|
-
var right, iterator, ret, result, right_1, right_1_1, value, result, e_1_1;
|
|
2885
|
-
var e_1, _a;
|
|
2886
|
-
return __generator(this, function (_b) {
|
|
2887
|
-
switch (_b.label) {
|
|
2888
|
-
case 0: return [5, __values(evaluate$1(node.right, scope))];
|
|
2889
|
-
case 1:
|
|
2890
|
-
right = _b.sent();
|
|
2891
|
-
if (!node.await) return [3, 8];
|
|
2892
|
-
iterator = getAsyncIterator(right);
|
|
2893
|
-
ret = void 0;
|
|
2894
|
-
AWAIT.RES = iterator.next();
|
|
2895
|
-
return [4, AWAIT];
|
|
2896
|
-
case 2:
|
|
2897
|
-
ret = _b.sent();
|
|
2898
|
-
_b.label = 3;
|
|
2899
|
-
case 3:
|
|
2900
|
-
if (!!ret.done) return [3, 7];
|
|
2901
|
-
return [5, __values(ForXHandler(node, scope, { value: ret.value }))];
|
|
2902
|
-
case 4:
|
|
2903
|
-
result = _b.sent();
|
|
2904
|
-
if (result === BREAK) {
|
|
2905
|
-
return [3, 7];
|
|
2906
|
-
}
|
|
2907
|
-
else if (result === CONTINUE) {
|
|
2908
|
-
return [3, 5];
|
|
2909
|
-
}
|
|
2910
|
-
else if (result === RETURN) {
|
|
2911
|
-
return [2, result];
|
|
2912
|
-
}
|
|
2913
|
-
_b.label = 5;
|
|
2914
|
-
case 5:
|
|
2915
|
-
AWAIT.RES = iterator.next();
|
|
2916
|
-
return [4, AWAIT];
|
|
2917
|
-
case 6:
|
|
2918
|
-
ret = _b.sent();
|
|
2919
|
-
return [3, 3];
|
|
2920
|
-
case 7: return [3, 15];
|
|
2921
|
-
case 8:
|
|
2922
|
-
_b.trys.push([8, 13, 14, 15]);
|
|
2923
|
-
right_1 = __values(right), right_1_1 = right_1.next();
|
|
2924
|
-
_b.label = 9;
|
|
2925
|
-
case 9:
|
|
2926
|
-
if (!!right_1_1.done) return [3, 12];
|
|
2927
|
-
value = right_1_1.value;
|
|
2928
|
-
return [5, __values(ForXHandler(node, scope, { value: value }))];
|
|
2929
|
-
case 10:
|
|
2930
|
-
result = _b.sent();
|
|
2931
|
-
if (result === BREAK) {
|
|
2932
|
-
return [3, 12];
|
|
2933
|
-
}
|
|
2934
|
-
else if (result === CONTINUE) {
|
|
2935
|
-
return [3, 11];
|
|
2936
|
-
}
|
|
2937
|
-
else if (result === RETURN) {
|
|
2938
|
-
return [2, result];
|
|
2939
|
-
}
|
|
2940
|
-
_b.label = 11;
|
|
2941
|
-
case 11:
|
|
2942
|
-
right_1_1 = right_1.next();
|
|
2943
|
-
return [3, 9];
|
|
2944
|
-
case 12: return [3, 15];
|
|
2945
|
-
case 13:
|
|
2946
|
-
e_1_1 = _b.sent();
|
|
2947
|
-
e_1 = { error: e_1_1 };
|
|
2948
|
-
return [3, 15];
|
|
2949
|
-
case 14:
|
|
2950
|
-
try {
|
|
2951
|
-
if (right_1_1 && !right_1_1.done && (_a = right_1.return)) _a.call(right_1);
|
|
2952
|
-
}
|
|
2953
|
-
finally { if (e_1) throw e_1.error; }
|
|
2954
|
-
return [7];
|
|
2955
|
-
case 15: return [2];
|
|
2956
|
-
}
|
|
2957
|
-
});
|
|
2958
|
-
}
|
|
2959
|
-
|
|
2960
|
-
var statement$1 = /*#__PURE__*/Object.freeze({
|
|
2961
|
-
__proto__: null,
|
|
2962
|
-
ExpressionStatement: ExpressionStatement$1,
|
|
2963
|
-
BlockStatement: BlockStatement$1,
|
|
2964
|
-
EmptyStatement: EmptyStatement$1,
|
|
2965
|
-
DebuggerStatement: DebuggerStatement$1,
|
|
2966
|
-
ReturnStatement: ReturnStatement$1,
|
|
2967
|
-
BreakStatement: BreakStatement$1,
|
|
2968
|
-
ContinueStatement: ContinueStatement$1,
|
|
2969
|
-
IfStatement: IfStatement$1,
|
|
2970
|
-
SwitchStatement: SwitchStatement$1,
|
|
2971
|
-
SwitchCase: SwitchCase$1,
|
|
2972
|
-
ThrowStatement: ThrowStatement$1,
|
|
2973
|
-
TryStatement: TryStatement$1,
|
|
2974
|
-
CatchClause: CatchClause$1,
|
|
2975
|
-
WhileStatement: WhileStatement$1,
|
|
2976
|
-
DoWhileStatement: DoWhileStatement$1,
|
|
2977
|
-
ForStatement: ForStatement$1,
|
|
2978
|
-
ForInStatement: ForInStatement$1,
|
|
2979
|
-
ForOfStatement: ForOfStatement$1
|
|
2980
|
-
});
|
|
2981
|
-
|
|
2982
|
-
function ObjectPattern$1(node, scope, options) {
|
|
2983
|
-
var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, fedKeys, i, property, value, key, value, rest, i_1;
|
|
2984
|
-
if (options === void 0) { options = {}; }
|
|
2985
|
-
return __generator(this, function (_e) {
|
|
2986
|
-
switch (_e.label) {
|
|
2987
|
-
case 0:
|
|
2988
|
-
_a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? {} : _d;
|
|
2989
|
-
fedKeys = [];
|
|
2990
|
-
i = 0;
|
|
2991
|
-
_e.label = 1;
|
|
2992
|
-
case 1:
|
|
2993
|
-
if (!(i < node.properties.length)) return [3, 18];
|
|
2994
|
-
property = node.properties[i];
|
|
2995
|
-
if (!hoist) return [3, 8];
|
|
2996
|
-
if (!(onlyBlock || kind === 'var')) return [3, 7];
|
|
2997
|
-
if (!(property.type === 'Property')) return [3, 5];
|
|
2998
|
-
value = property.value;
|
|
2999
|
-
if (!(value.type === 'Identifier')) return [3, 2];
|
|
3000
|
-
scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3001
|
-
return [3, 4];
|
|
3002
|
-
case 2: return [5, __values(pattern$2(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3003
|
-
case 3:
|
|
3004
|
-
_e.sent();
|
|
3005
|
-
_e.label = 4;
|
|
3006
|
-
case 4: return [3, 7];
|
|
3007
|
-
case 5: return [5, __values(RestElement$1(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3008
|
-
case 6:
|
|
3009
|
-
_e.sent();
|
|
3010
|
-
_e.label = 7;
|
|
3011
|
-
case 7: return [3, 17];
|
|
3012
|
-
case 8:
|
|
3013
|
-
if (!(property.type === 'Property')) return [3, 15];
|
|
3014
|
-
key = void 0;
|
|
3015
|
-
if (!property.computed) return [3, 10];
|
|
3016
|
-
return [5, __values(evaluate$1(property.key, scope))];
|
|
3017
|
-
case 9:
|
|
3018
|
-
key = _e.sent();
|
|
3019
|
-
return [3, 11];
|
|
3020
|
-
case 10:
|
|
3021
|
-
key = property.key.name;
|
|
3022
|
-
_e.label = 11;
|
|
3023
|
-
case 11:
|
|
3024
|
-
fedKeys.push(key);
|
|
3025
|
-
value = property.value;
|
|
3026
|
-
if (!(value.type === 'Identifier')) return [3, 12];
|
|
3027
|
-
scope[kind](value.name, feed[key]);
|
|
3028
|
-
return [3, 14];
|
|
3029
|
-
case 12: return [5, __values(pattern$2(value, scope, { kind: kind, feed: feed[key] }))];
|
|
3030
|
-
case 13:
|
|
3031
|
-
_e.sent();
|
|
3032
|
-
_e.label = 14;
|
|
3033
|
-
case 14: return [3, 17];
|
|
3034
|
-
case 15:
|
|
3035
|
-
rest = assign({}, feed);
|
|
3036
|
-
for (i_1 = 0; i_1 < fedKeys.length; i_1++)
|
|
3037
|
-
delete rest[fedKeys[i_1]];
|
|
3038
|
-
return [5, __values(RestElement$1(property, scope, { kind: kind, feed: rest }))];
|
|
3039
|
-
case 16:
|
|
3040
|
-
_e.sent();
|
|
3041
|
-
_e.label = 17;
|
|
3042
|
-
case 17:
|
|
3043
|
-
i++;
|
|
3044
|
-
return [3, 1];
|
|
3045
|
-
case 18: return [2];
|
|
3046
|
-
}
|
|
3047
|
-
});
|
|
3048
|
-
}
|
|
3049
|
-
function ArrayPattern$1(node, scope, options) {
|
|
3050
|
-
var kind, _a, hoist, _b, onlyBlock, _c, feed, result, i, element, variable;
|
|
3051
|
-
if (options === void 0) { options = {}; }
|
|
3052
|
-
return __generator(this, function (_d) {
|
|
3053
|
-
switch (_d.label) {
|
|
3054
|
-
case 0:
|
|
3055
|
-
kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
3056
|
-
result = [];
|
|
3057
|
-
i = 0;
|
|
3058
|
-
_d.label = 1;
|
|
3059
|
-
case 1:
|
|
3060
|
-
if (!(i < node.elements.length)) return [3, 14];
|
|
3061
|
-
element = node.elements[i];
|
|
3062
|
-
if (!element)
|
|
3063
|
-
return [3, 13];
|
|
3064
|
-
if (!hoist) return [3, 5];
|
|
3065
|
-
if (!(onlyBlock || kind === 'var')) return [3, 4];
|
|
3066
|
-
if (!(element.type === 'Identifier')) return [3, 2];
|
|
3067
|
-
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3068
|
-
return [3, 4];
|
|
3069
|
-
case 2: return [5, __values(pattern$2(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3070
|
-
case 3:
|
|
3071
|
-
_d.sent();
|
|
3072
|
-
_d.label = 4;
|
|
3073
|
-
case 4: return [3, 13];
|
|
3074
|
-
case 5:
|
|
3075
|
-
if (!(element.type === 'Identifier')) return [3, 9];
|
|
3076
|
-
if (!kind) return [3, 6];
|
|
3077
|
-
scope[kind](element.name, feed[i]);
|
|
3078
|
-
return [3, 8];
|
|
3079
|
-
case 6: return [5, __values(Identifier$1(element, scope, { getVar: true }))];
|
|
3080
|
-
case 7:
|
|
3081
|
-
variable = _d.sent();
|
|
3082
|
-
variable.set(feed[i]);
|
|
3083
|
-
result.push(variable.get());
|
|
3084
|
-
_d.label = 8;
|
|
3085
|
-
case 8: return [3, 13];
|
|
3086
|
-
case 9:
|
|
3087
|
-
if (!(element.type === 'RestElement')) return [3, 11];
|
|
3088
|
-
return [5, __values(RestElement$1(element, scope, { kind: kind, feed: feed.slice(i) }))];
|
|
3089
|
-
case 10:
|
|
3090
|
-
_d.sent();
|
|
3091
|
-
return [3, 13];
|
|
3092
|
-
case 11: return [5, __values(pattern$2(element, scope, { kind: kind, feed: feed[i] }))];
|
|
3093
|
-
case 12:
|
|
3094
|
-
_d.sent();
|
|
3095
|
-
_d.label = 13;
|
|
3096
|
-
case 13:
|
|
3097
|
-
i++;
|
|
3098
|
-
return [3, 1];
|
|
3099
|
-
case 14:
|
|
3100
|
-
if (result.length) {
|
|
3101
|
-
return [2, result];
|
|
3102
|
-
}
|
|
3103
|
-
return [2];
|
|
3104
|
-
}
|
|
3105
|
-
});
|
|
3106
|
-
}
|
|
3107
|
-
function RestElement$1(node, scope, options) {
|
|
3108
|
-
var kind, _a, hoist, _b, onlyBlock, _c, feed, arg, variable;
|
|
3109
|
-
if (options === void 0) { options = {}; }
|
|
3110
|
-
return __generator(this, function (_d) {
|
|
3111
|
-
switch (_d.label) {
|
|
3112
|
-
case 0:
|
|
3113
|
-
kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
3114
|
-
arg = node.argument;
|
|
3115
|
-
if (!hoist) return [3, 4];
|
|
3116
|
-
if (!(onlyBlock || kind === 'var')) return [3, 3];
|
|
3117
|
-
if (!(arg.type === 'Identifier')) return [3, 1];
|
|
3118
|
-
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3119
|
-
return [3, 3];
|
|
3120
|
-
case 1: return [5, __values(pattern$2(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3121
|
-
case 2:
|
|
3122
|
-
_d.sent();
|
|
3123
|
-
_d.label = 3;
|
|
3124
|
-
case 3: return [3, 10];
|
|
3125
|
-
case 4:
|
|
3126
|
-
if (!(arg.type === 'Identifier')) return [3, 8];
|
|
3127
|
-
if (!kind) return [3, 5];
|
|
3128
|
-
scope[kind](arg.name, feed);
|
|
3129
|
-
return [3, 7];
|
|
3130
|
-
case 5: return [5, __values(Identifier$1(arg, scope, { getVar: true }))];
|
|
3131
|
-
case 6:
|
|
3132
|
-
variable = _d.sent();
|
|
3133
|
-
variable.set(feed);
|
|
3134
|
-
_d.label = 7;
|
|
3135
|
-
case 7: return [3, 10];
|
|
3136
|
-
case 8: return [5, __values(pattern$2(arg, scope, { kind: kind, feed: feed }))];
|
|
3137
|
-
case 9:
|
|
3138
|
-
_d.sent();
|
|
3139
|
-
_d.label = 10;
|
|
3140
|
-
case 10: return [2];
|
|
3141
|
-
}
|
|
3142
|
-
});
|
|
3143
|
-
}
|
|
3144
|
-
function AssignmentPattern$1(node, scope, options) {
|
|
3145
|
-
var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, _e, left;
|
|
3146
|
-
if (options === void 0) { options = {}; }
|
|
3147
|
-
return __generator(this, function (_f) {
|
|
3148
|
-
switch (_f.label) {
|
|
3149
|
-
case 0:
|
|
3150
|
-
_a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed;
|
|
3151
|
-
if (!(_d === void 0)) return [3, 2];
|
|
3152
|
-
return [5, __values(evaluate$1(node.right, scope))];
|
|
3153
|
-
case 1:
|
|
3154
|
-
_e = _f.sent();
|
|
3155
|
-
return [3, 3];
|
|
3156
|
-
case 2:
|
|
3157
|
-
_e = _d;
|
|
3158
|
-
_f.label = 3;
|
|
3159
|
-
case 3:
|
|
3160
|
-
feed = _e;
|
|
3161
|
-
left = node.left;
|
|
3162
|
-
if (!hoist) return [3, 7];
|
|
3163
|
-
if (!(onlyBlock || kind === 'var')) return [3, 6];
|
|
3164
|
-
if (!(left.type === 'Identifier')) return [3, 4];
|
|
3165
|
-
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3166
|
-
return [3, 6];
|
|
3167
|
-
case 4: return [5, __values(pattern$2(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3168
|
-
case 5:
|
|
3169
|
-
_f.sent();
|
|
3170
|
-
_f.label = 6;
|
|
3171
|
-
case 6: return [3, 10];
|
|
3172
|
-
case 7:
|
|
3173
|
-
if (!(left.type === 'Identifier')) return [3, 8];
|
|
3174
|
-
scope[kind](left.name, feed);
|
|
3175
|
-
return [3, 10];
|
|
3176
|
-
case 8: return [5, __values(pattern$2(left, scope, { kind: kind, feed: feed }))];
|
|
3177
|
-
case 9:
|
|
3178
|
-
_f.sent();
|
|
3179
|
-
_f.label = 10;
|
|
3180
|
-
case 10: return [2];
|
|
3181
|
-
}
|
|
3182
|
-
});
|
|
3183
|
-
}
|
|
3184
|
-
|
|
3185
|
-
var pattern$1 = /*#__PURE__*/Object.freeze({
|
|
3186
|
-
__proto__: null,
|
|
3187
|
-
ObjectPattern: ObjectPattern$1,
|
|
3188
|
-
ArrayPattern: ArrayPattern$1,
|
|
3189
|
-
RestElement: RestElement$1,
|
|
3190
|
-
AssignmentPattern: AssignmentPattern$1
|
|
3191
|
-
});
|
|
3192
|
-
|
|
3193
|
-
var evaluateOps$1;
|
|
3194
|
-
function evaluate$1(node, scope) {
|
|
3195
|
-
var handler;
|
|
3196
|
-
return __generator(this, function (_a) {
|
|
3197
|
-
switch (_a.label) {
|
|
3198
|
-
case 0:
|
|
3199
|
-
if (!node)
|
|
3200
|
-
return [2];
|
|
3201
|
-
if (!evaluateOps$1) {
|
|
3202
|
-
evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$1);
|
|
3479
|
+
}
|
|
3480
|
+
function ForOfStatement$1(node, scope) {
|
|
3481
|
+
var right, iterator, ret, result, right_1, right_1_1, value, result, e_1_1;
|
|
3482
|
+
var e_1, _a;
|
|
3483
|
+
return __generator(this, function (_b) {
|
|
3484
|
+
switch (_b.label) {
|
|
3485
|
+
case 0: return [5, __values(evaluate$1(node.right, scope))];
|
|
3486
|
+
case 1:
|
|
3487
|
+
right = _b.sent();
|
|
3488
|
+
if (!node.await) return [3, 8];
|
|
3489
|
+
iterator = getAsyncIterator(right);
|
|
3490
|
+
ret = void 0;
|
|
3491
|
+
AWAIT.RES = iterator.next();
|
|
3492
|
+
return [4, AWAIT];
|
|
3493
|
+
case 2:
|
|
3494
|
+
ret = _b.sent();
|
|
3495
|
+
_b.label = 3;
|
|
3496
|
+
case 3:
|
|
3497
|
+
if (!!ret.done) return [3, 7];
|
|
3498
|
+
return [5, __values(ForXHandler(node, scope, { value: ret.value }))];
|
|
3499
|
+
case 4:
|
|
3500
|
+
result = _b.sent();
|
|
3501
|
+
if (result === BREAK) {
|
|
3502
|
+
return [3, 7];
|
|
3203
3503
|
}
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3504
|
+
else if (result === CONTINUE) {
|
|
3505
|
+
return [3, 5];
|
|
3506
|
+
}
|
|
3507
|
+
else if (result === RETURN) {
|
|
3508
|
+
return [2, result];
|
|
3509
|
+
}
|
|
3510
|
+
_b.label = 5;
|
|
3511
|
+
case 5:
|
|
3512
|
+
AWAIT.RES = iterator.next();
|
|
3513
|
+
return [4, AWAIT];
|
|
3514
|
+
case 6:
|
|
3515
|
+
ret = _b.sent();
|
|
3516
|
+
return [3, 3];
|
|
3517
|
+
case 7: return [3, 15];
|
|
3518
|
+
case 8:
|
|
3519
|
+
_b.trys.push([8, 13, 14, 15]);
|
|
3520
|
+
right_1 = __values(right), right_1_1 = right_1.next();
|
|
3521
|
+
_b.label = 9;
|
|
3522
|
+
case 9:
|
|
3523
|
+
if (!!right_1_1.done) return [3, 12];
|
|
3524
|
+
value = right_1_1.value;
|
|
3525
|
+
return [5, __values(ForXHandler(node, scope, { value: value }))];
|
|
3526
|
+
case 10:
|
|
3527
|
+
result = _b.sent();
|
|
3528
|
+
if (result === BREAK) {
|
|
3529
|
+
return [3, 12];
|
|
3530
|
+
}
|
|
3531
|
+
else if (result === CONTINUE) {
|
|
3532
|
+
return [3, 11];
|
|
3533
|
+
}
|
|
3534
|
+
else if (result === RETURN) {
|
|
3535
|
+
return [2, result];
|
|
3536
|
+
}
|
|
3537
|
+
_b.label = 11;
|
|
3538
|
+
case 11:
|
|
3539
|
+
right_1_1 = right_1.next();
|
|
3540
|
+
return [3, 9];
|
|
3541
|
+
case 12: return [3, 15];
|
|
3542
|
+
case 13:
|
|
3543
|
+
e_1_1 = _b.sent();
|
|
3544
|
+
e_1 = { error: e_1_1 };
|
|
3545
|
+
return [3, 15];
|
|
3546
|
+
case 14:
|
|
3547
|
+
try {
|
|
3548
|
+
if (right_1_1 && !right_1_1.done && (_a = right_1.return)) _a.call(right_1);
|
|
3549
|
+
}
|
|
3550
|
+
finally { if (e_1) throw e_1.error; }
|
|
3551
|
+
return [7];
|
|
3552
|
+
case 15: return [2];
|
|
3209
3553
|
}
|
|
3210
3554
|
});
|
|
3211
3555
|
}
|
|
@@ -3315,27 +3659,40 @@
|
|
|
3315
3659
|
i = 0;
|
|
3316
3660
|
_a.label = 1;
|
|
3317
3661
|
case 1:
|
|
3318
|
-
if (!(i < node.body.length)) return [3,
|
|
3662
|
+
if (!(i < node.body.length)) return [3, 8];
|
|
3319
3663
|
def = node.body[i];
|
|
3320
3664
|
if (!(def.type === 'MethodDefinition')) return [3, 3];
|
|
3321
3665
|
return [5, __values(MethodDefinition$1(def, scope, { klass: klass, superClass: superClass }))];
|
|
3322
3666
|
case 2:
|
|
3323
3667
|
_a.sent();
|
|
3324
|
-
|
|
3668
|
+
return [3, 7];
|
|
3325
3669
|
case 3:
|
|
3670
|
+
if (!(def.type === 'PropertyDefinition' && def.static)) return [3, 5];
|
|
3671
|
+
return [5, __values(PropertyDefinition$1(def, scope, { klass: klass, superClass: superClass }))];
|
|
3672
|
+
case 4:
|
|
3673
|
+
_a.sent();
|
|
3674
|
+
return [3, 7];
|
|
3675
|
+
case 5:
|
|
3676
|
+
if (!(def.type === 'StaticBlock')) return [3, 7];
|
|
3677
|
+
return [5, __values(StaticBlock$1(def, scope, { klass: klass, superClass: superClass }))];
|
|
3678
|
+
case 6:
|
|
3679
|
+
_a.sent();
|
|
3680
|
+
_a.label = 7;
|
|
3681
|
+
case 7:
|
|
3326
3682
|
i++;
|
|
3327
3683
|
return [3, 1];
|
|
3328
|
-
case
|
|
3684
|
+
case 8: return [2];
|
|
3329
3685
|
}
|
|
3330
3686
|
});
|
|
3331
3687
|
}
|
|
3332
3688
|
function MethodDefinition$1(node, scope, options) {
|
|
3333
|
-
var klass, superClass, key, obj, value, oriDptor, oriDptor;
|
|
3689
|
+
var klass, superClass, key, priv, obj, value, oriDptor, oriDptor;
|
|
3334
3690
|
if (options === void 0) { options = {}; }
|
|
3335
3691
|
return __generator(this, function (_a) {
|
|
3336
3692
|
switch (_a.label) {
|
|
3337
3693
|
case 0:
|
|
3338
3694
|
klass = options.klass, superClass = options.superClass;
|
|
3695
|
+
priv = false;
|
|
3339
3696
|
if (!node.computed) return [3, 2];
|
|
3340
3697
|
return [5, __values(evaluate$1(node.key, scope))];
|
|
3341
3698
|
case 1:
|
|
@@ -3345,12 +3702,22 @@
|
|
|
3345
3702
|
if (node.key.type === 'Identifier') {
|
|
3346
3703
|
key = node.key.name;
|
|
3347
3704
|
}
|
|
3705
|
+
else if (node.key.type === 'PrivateIdentifier') {
|
|
3706
|
+
key = node.key.name;
|
|
3707
|
+
priv = true;
|
|
3708
|
+
}
|
|
3348
3709
|
else {
|
|
3349
3710
|
throw new SyntaxError('Unexpected token');
|
|
3350
3711
|
}
|
|
3351
3712
|
_a.label = 3;
|
|
3352
3713
|
case 3:
|
|
3353
3714
|
obj = node.static ? klass : klass.prototype;
|
|
3715
|
+
if (priv) {
|
|
3716
|
+
if (!obj[PRIVATE]) {
|
|
3717
|
+
define(obj, PRIVATE, { value: {} });
|
|
3718
|
+
}
|
|
3719
|
+
obj = obj[PRIVATE];
|
|
3720
|
+
}
|
|
3354
3721
|
value = createFunc(node.value, scope, { superClass: superClass });
|
|
3355
3722
|
switch (node.kind) {
|
|
3356
3723
|
case 'constructor':
|
|
@@ -3386,6 +3753,247 @@
|
|
|
3386
3753
|
return [2];
|
|
3387
3754
|
}
|
|
3388
3755
|
});
|
|
3756
|
+
}
|
|
3757
|
+
function PropertyDefinition$1(node, scope, options) {
|
|
3758
|
+
var klass, superClass, key, priv, subScope, obj, _a, _b;
|
|
3759
|
+
if (options === void 0) { options = {}; }
|
|
3760
|
+
return __generator(this, function (_c) {
|
|
3761
|
+
switch (_c.label) {
|
|
3762
|
+
case 0:
|
|
3763
|
+
klass = options.klass, superClass = options.superClass;
|
|
3764
|
+
priv = false;
|
|
3765
|
+
if (!node.computed) return [3, 2];
|
|
3766
|
+
return [5, __values(evaluate$1(node.key, scope))];
|
|
3767
|
+
case 1:
|
|
3768
|
+
key = _c.sent();
|
|
3769
|
+
return [3, 3];
|
|
3770
|
+
case 2:
|
|
3771
|
+
if (node.key.type === 'Identifier') {
|
|
3772
|
+
key = node.key.name;
|
|
3773
|
+
}
|
|
3774
|
+
else if (node.key.type === 'PrivateIdentifier') {
|
|
3775
|
+
key = node.key.name;
|
|
3776
|
+
priv = true;
|
|
3777
|
+
}
|
|
3778
|
+
else {
|
|
3779
|
+
throw new SyntaxError('Unexpected token');
|
|
3780
|
+
}
|
|
3781
|
+
_c.label = 3;
|
|
3782
|
+
case 3:
|
|
3783
|
+
subScope = new Scope(scope, true);
|
|
3784
|
+
subScope.const('this', klass);
|
|
3785
|
+
obj = klass;
|
|
3786
|
+
if (priv) {
|
|
3787
|
+
if (!obj[PRIVATE]) {
|
|
3788
|
+
define(obj, PRIVATE, { value: {} });
|
|
3789
|
+
}
|
|
3790
|
+
obj = obj[PRIVATE];
|
|
3791
|
+
}
|
|
3792
|
+
if (!(node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression')) return [3, 4];
|
|
3793
|
+
obj[key] = createFunc(node.value, subScope, { superClass: superClass });
|
|
3794
|
+
return [3, 6];
|
|
3795
|
+
case 4:
|
|
3796
|
+
_a = obj;
|
|
3797
|
+
_b = key;
|
|
3798
|
+
return [5, __values(evaluate$1(node.value, subScope))];
|
|
3799
|
+
case 5:
|
|
3800
|
+
_a[_b] = _c.sent();
|
|
3801
|
+
_c.label = 6;
|
|
3802
|
+
case 6: return [2];
|
|
3803
|
+
}
|
|
3804
|
+
});
|
|
3805
|
+
}
|
|
3806
|
+
function StaticBlock$1(node, scope, options) {
|
|
3807
|
+
var klass, subScope;
|
|
3808
|
+
if (options === void 0) { options = {}; }
|
|
3809
|
+
return __generator(this, function (_a) {
|
|
3810
|
+
switch (_a.label) {
|
|
3811
|
+
case 0:
|
|
3812
|
+
klass = options.klass;
|
|
3813
|
+
subScope = new Scope(scope, true);
|
|
3814
|
+
subScope.const('this', klass);
|
|
3815
|
+
return [5, __values(BlockStatement$1(node, subScope, { invasived: true }))];
|
|
3816
|
+
case 1: return [2, _a.sent()];
|
|
3817
|
+
}
|
|
3818
|
+
});
|
|
3819
|
+
}
|
|
3820
|
+
function ImportDeclaration$1(node, scope) {
|
|
3821
|
+
var globalScope, module, value, result, i, spec, name_2;
|
|
3822
|
+
return __generator(this, function (_a) {
|
|
3823
|
+
globalScope = scope.global();
|
|
3824
|
+
module = globalScope.find(IMPORT + node.source.value);
|
|
3825
|
+
if (module) {
|
|
3826
|
+
result = module.get();
|
|
3827
|
+
if (result) {
|
|
3828
|
+
if (typeof result === 'function') {
|
|
3829
|
+
value = result();
|
|
3830
|
+
}
|
|
3831
|
+
else if (typeof result === 'object') {
|
|
3832
|
+
value = result;
|
|
3833
|
+
}
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
if (!value || typeof value !== 'object') {
|
|
3837
|
+
throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
|
|
3838
|
+
}
|
|
3839
|
+
for (i = 0; i < node.specifiers.length; i++) {
|
|
3840
|
+
spec = node.specifiers[i];
|
|
3841
|
+
name_2 = void 0;
|
|
3842
|
+
if (spec.type === 'ImportSpecifier') {
|
|
3843
|
+
name_2 = spec.imported.type === 'Identifier'
|
|
3844
|
+
? spec.imported.name : spec.imported.value;
|
|
3845
|
+
}
|
|
3846
|
+
else if (spec.type === 'ImportDefaultSpecifier') {
|
|
3847
|
+
name_2 = 'default';
|
|
3848
|
+
}
|
|
3849
|
+
else if (spec.type === 'ImportNamespaceSpecifier') {
|
|
3850
|
+
name_2 = '*';
|
|
3851
|
+
}
|
|
3852
|
+
if (name_2 !== '*' && !hasOwn(value, name_2)) {
|
|
3853
|
+
throw new SyntaxError("The requested module \"" + node.source.value + "\" does not provide an export named \"" + name_2 + "\"");
|
|
3854
|
+
}
|
|
3855
|
+
scope.var(spec.local.name, name_2 === '*' ? assign({}, value) : value[name_2]);
|
|
3856
|
+
}
|
|
3857
|
+
return [2];
|
|
3858
|
+
});
|
|
3859
|
+
}
|
|
3860
|
+
function ExportDefaultDeclaration$1(node, scope) {
|
|
3861
|
+
var globalScope, value, variable, exports_1;
|
|
3862
|
+
return __generator(this, function (_a) {
|
|
3863
|
+
switch (_a.label) {
|
|
3864
|
+
case 0:
|
|
3865
|
+
globalScope = scope.global();
|
|
3866
|
+
if (!(node.declaration.type === 'FunctionDeclaration')) return [3, 1];
|
|
3867
|
+
value = createFunc(node.declaration, scope);
|
|
3868
|
+
scope.func(node.declaration.id.name, value);
|
|
3869
|
+
return [3, 5];
|
|
3870
|
+
case 1:
|
|
3871
|
+
if (!(node.declaration.type === 'ClassDeclaration')) return [3, 3];
|
|
3872
|
+
return [5, __values(createClass(node.declaration, scope))];
|
|
3873
|
+
case 2:
|
|
3874
|
+
value = _a.sent();
|
|
3875
|
+
scope.func(node.declaration.id.name, value);
|
|
3876
|
+
return [3, 5];
|
|
3877
|
+
case 3: return [5, __values(evaluate$1(node.declaration, scope))];
|
|
3878
|
+
case 4:
|
|
3879
|
+
value = _a.sent();
|
|
3880
|
+
_a.label = 5;
|
|
3881
|
+
case 5:
|
|
3882
|
+
variable = globalScope.find(EXPORTS);
|
|
3883
|
+
if (variable) {
|
|
3884
|
+
exports_1 = variable.get();
|
|
3885
|
+
if (exports_1 && typeof exports_1 === 'object') {
|
|
3886
|
+
exports_1.default = value;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
return [2];
|
|
3890
|
+
}
|
|
3891
|
+
});
|
|
3892
|
+
}
|
|
3893
|
+
function ExportNamedDeclaration$1(node, scope) {
|
|
3894
|
+
var globalScope, value, variable, exports_2, value, variable, exports_3, variable, exports_4, i, name_3, item, variable, exports_5, i, spec, name_4, item;
|
|
3895
|
+
return __generator(this, function (_a) {
|
|
3896
|
+
switch (_a.label) {
|
|
3897
|
+
case 0:
|
|
3898
|
+
globalScope = scope.global();
|
|
3899
|
+
if (!node.declaration) return [3, 6];
|
|
3900
|
+
if (!(node.declaration.type === 'FunctionDeclaration')) return [3, 1];
|
|
3901
|
+
value = createFunc(node.declaration, scope);
|
|
3902
|
+
scope.func(node.declaration.id.name, value);
|
|
3903
|
+
variable = globalScope.find(EXPORTS);
|
|
3904
|
+
if (variable) {
|
|
3905
|
+
exports_2 = variable.get();
|
|
3906
|
+
if (exports_2 && typeof exports_2 === 'object') {
|
|
3907
|
+
exports_2[node.declaration.id.name] = value;
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
return [3, 5];
|
|
3911
|
+
case 1:
|
|
3912
|
+
if (!(node.declaration.type === 'ClassDeclaration')) return [3, 3];
|
|
3913
|
+
return [5, __values(createClass(node.declaration, scope))];
|
|
3914
|
+
case 2:
|
|
3915
|
+
value = _a.sent();
|
|
3916
|
+
scope.func(node.declaration.id.name, value);
|
|
3917
|
+
variable = globalScope.find(EXPORTS);
|
|
3918
|
+
if (variable) {
|
|
3919
|
+
exports_3 = variable.get();
|
|
3920
|
+
if (exports_3 && typeof exports_3 === 'object') {
|
|
3921
|
+
exports_3[node.declaration.id.name] = value;
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
return [3, 5];
|
|
3925
|
+
case 3:
|
|
3926
|
+
if (!(node.declaration.type === 'VariableDeclaration')) return [3, 5];
|
|
3927
|
+
return [5, __values(VariableDeclaration$1(node.declaration, scope))];
|
|
3928
|
+
case 4:
|
|
3929
|
+
_a.sent();
|
|
3930
|
+
variable = globalScope.find(EXPORTS);
|
|
3931
|
+
if (variable) {
|
|
3932
|
+
exports_4 = variable.get();
|
|
3933
|
+
if (exports_4 && typeof exports_4 === 'object') {
|
|
3934
|
+
for (i = 0; i < node.declaration.declarations.length; i++) {
|
|
3935
|
+
name_3 = node.declaration.declarations[i].id.name;
|
|
3936
|
+
item = scope.find(name_3);
|
|
3937
|
+
if (item) {
|
|
3938
|
+
exports_4[name_3] = item.get();
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
_a.label = 5;
|
|
3944
|
+
case 5: return [3, 7];
|
|
3945
|
+
case 6:
|
|
3946
|
+
if (node.specifiers) {
|
|
3947
|
+
variable = globalScope.find(EXPORTS);
|
|
3948
|
+
if (variable) {
|
|
3949
|
+
exports_5 = variable.get();
|
|
3950
|
+
if (exports_5 && typeof exports_5 === 'object') {
|
|
3951
|
+
for (i = 0; i < node.specifiers.length; i++) {
|
|
3952
|
+
spec = node.specifiers[i];
|
|
3953
|
+
name_4 = spec.local.type === 'Identifier'
|
|
3954
|
+
? spec.local.name : spec.local.value;
|
|
3955
|
+
item = scope.find(name_4);
|
|
3956
|
+
if (item) {
|
|
3957
|
+
exports_5[spec.exported.type === 'Identifier'
|
|
3958
|
+
? spec.exported.name : spec.exported.value] = item.get();
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
_a.label = 7;
|
|
3965
|
+
case 7: return [2];
|
|
3966
|
+
}
|
|
3967
|
+
});
|
|
3968
|
+
}
|
|
3969
|
+
function ExportAllDeclaration$1(node, scope) {
|
|
3970
|
+
var globalScope, module, value, result, variable, exports_6;
|
|
3971
|
+
return __generator(this, function (_a) {
|
|
3972
|
+
globalScope = scope.global();
|
|
3973
|
+
module = globalScope.find(IMPORT + node.source.value);
|
|
3974
|
+
if (module) {
|
|
3975
|
+
result = module.get();
|
|
3976
|
+
if (result) {
|
|
3977
|
+
if (typeof result === 'function') {
|
|
3978
|
+
value = result();
|
|
3979
|
+
}
|
|
3980
|
+
else if (typeof result === 'object') {
|
|
3981
|
+
value = result;
|
|
3982
|
+
}
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
if (!value || typeof value !== 'object') {
|
|
3986
|
+
throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
|
|
3987
|
+
}
|
|
3988
|
+
variable = globalScope.find(EXPORTS);
|
|
3989
|
+
if (variable) {
|
|
3990
|
+
exports_6 = variable.get();
|
|
3991
|
+
if (exports_6 && typeof exports_6 === 'object') {
|
|
3992
|
+
assign(exports_6, value);
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
return [2];
|
|
3996
|
+
});
|
|
3389
3997
|
}
|
|
3390
3998
|
|
|
3391
3999
|
function runAsync(iterator, options) {
|
|
@@ -3638,7 +4246,7 @@
|
|
|
3638
4246
|
if (!node.generator && !node.async) {
|
|
3639
4247
|
return createFunc$1(node, scope, options);
|
|
3640
4248
|
}
|
|
3641
|
-
var superClass = options.superClass,
|
|
4249
|
+
var superClass = options.superClass, construct = options.construct;
|
|
3642
4250
|
var params = node.params;
|
|
3643
4251
|
var tmpFunc = function _a() {
|
|
3644
4252
|
var _i, subScope, i, param, result;
|
|
@@ -3651,58 +4259,65 @@
|
|
|
3651
4259
|
switch (_a.label) {
|
|
3652
4260
|
case 0:
|
|
3653
4261
|
subScope = new Scope(scope, true);
|
|
3654
|
-
if (node.type !== 'ArrowFunctionExpression')
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
4262
|
+
if (!(node.type !== 'ArrowFunctionExpression')) return [3, 3];
|
|
4263
|
+
subScope.const('this', this);
|
|
4264
|
+
subScope.let('arguments', arguments);
|
|
4265
|
+
subScope.const(NEWTARGET, _newTarget);
|
|
4266
|
+
if (!construct) return [3, 2];
|
|
4267
|
+
return [5, __values(construct(this))];
|
|
4268
|
+
case 1:
|
|
4269
|
+
_a.sent();
|
|
4270
|
+
_a.label = 2;
|
|
4271
|
+
case 2:
|
|
4272
|
+
if (superClass) {
|
|
4273
|
+
subScope.const(SUPER, superClass);
|
|
4274
|
+
if (construct)
|
|
4275
|
+
subScope.let(SUPERCALL, false);
|
|
3663
4276
|
}
|
|
4277
|
+
_a.label = 3;
|
|
4278
|
+
case 3:
|
|
3664
4279
|
i = 0;
|
|
3665
|
-
_a.label =
|
|
3666
|
-
case
|
|
3667
|
-
if (!(i < params.length)) return [3,
|
|
4280
|
+
_a.label = 4;
|
|
4281
|
+
case 4:
|
|
4282
|
+
if (!(i < params.length)) return [3, 10];
|
|
3668
4283
|
param = params[i];
|
|
3669
|
-
if (!(param.type === 'Identifier')) return [3,
|
|
4284
|
+
if (!(param.type === 'Identifier')) return [3, 5];
|
|
3670
4285
|
subScope.var(param.name, args[i]);
|
|
3671
|
-
return [3,
|
|
3672
|
-
case
|
|
3673
|
-
if (!(param.type === 'RestElement')) return [3,
|
|
4286
|
+
return [3, 9];
|
|
4287
|
+
case 5:
|
|
4288
|
+
if (!(param.type === 'RestElement')) return [3, 7];
|
|
3674
4289
|
return [5, __values(RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) }))];
|
|
3675
|
-
case
|
|
4290
|
+
case 6:
|
|
3676
4291
|
_a.sent();
|
|
3677
|
-
return [3,
|
|
3678
|
-
case
|
|
3679
|
-
case
|
|
4292
|
+
return [3, 9];
|
|
4293
|
+
case 7: return [5, __values(pattern$2(param, subScope, { kind: 'var', feed: args[i] }))];
|
|
4294
|
+
case 8:
|
|
3680
4295
|
_a.sent();
|
|
3681
|
-
_a.label =
|
|
3682
|
-
case
|
|
4296
|
+
_a.label = 9;
|
|
4297
|
+
case 9:
|
|
3683
4298
|
i++;
|
|
3684
|
-
return [3,
|
|
3685
|
-
case
|
|
3686
|
-
if (!(node.body.type === 'BlockStatement')) return [3,
|
|
4299
|
+
return [3, 4];
|
|
4300
|
+
case 10:
|
|
4301
|
+
if (!(node.body.type === 'BlockStatement')) return [3, 13];
|
|
3687
4302
|
return [5, __values(hoist(node.body, subScope))];
|
|
3688
|
-
case
|
|
4303
|
+
case 11:
|
|
3689
4304
|
_a.sent();
|
|
3690
4305
|
return [5, __values(BlockStatement$1(node.body, subScope, {
|
|
3691
4306
|
invasived: true,
|
|
3692
4307
|
hoisted: true
|
|
3693
4308
|
}))];
|
|
3694
|
-
case
|
|
4309
|
+
case 12:
|
|
3695
4310
|
result = _a.sent();
|
|
3696
|
-
return [3,
|
|
3697
|
-
case
|
|
3698
|
-
case
|
|
4311
|
+
return [3, 15];
|
|
4312
|
+
case 13: return [5, __values(evaluate$1(node.body, subScope))];
|
|
4313
|
+
case 14:
|
|
3699
4314
|
result = _a.sent();
|
|
3700
4315
|
if (node.type === 'ArrowFunctionExpression') {
|
|
3701
4316
|
RETURN.RES = result;
|
|
3702
4317
|
result = RETURN;
|
|
3703
4318
|
}
|
|
3704
|
-
_a.label =
|
|
3705
|
-
case
|
|
4319
|
+
_a.label = 15;
|
|
4320
|
+
case 15:
|
|
3706
4321
|
if (result === RETURN) {
|
|
3707
4322
|
return [2, result.RES];
|
|
3708
4323
|
}
|
|
@@ -3757,22 +4372,52 @@
|
|
|
3757
4372
|
return func;
|
|
3758
4373
|
}
|
|
3759
4374
|
function createClass(node, scope) {
|
|
3760
|
-
var superClass,
|
|
4375
|
+
var superClass, methodBody, construct, klass, i, method;
|
|
3761
4376
|
return __generator(this, function (_a) {
|
|
3762
4377
|
switch (_a.label) {
|
|
3763
4378
|
case 0: return [5, __values(evaluate$1(node.superClass, scope))];
|
|
3764
4379
|
case 1:
|
|
3765
4380
|
superClass = _a.sent();
|
|
4381
|
+
methodBody = node.body.body;
|
|
4382
|
+
construct = function (object) {
|
|
4383
|
+
var i, def;
|
|
4384
|
+
return __generator(this, function (_a) {
|
|
4385
|
+
switch (_a.label) {
|
|
4386
|
+
case 0:
|
|
4387
|
+
i = 0;
|
|
4388
|
+
_a.label = 1;
|
|
4389
|
+
case 1:
|
|
4390
|
+
if (!(i < methodBody.length)) return [3, 4];
|
|
4391
|
+
def = methodBody[i];
|
|
4392
|
+
if (!(def.type === 'PropertyDefinition' && !def.static)) return [3, 3];
|
|
4393
|
+
return [5, __values(PropertyDefinition$1(def, scope, { klass: object, superClass: superClass }))];
|
|
4394
|
+
case 2:
|
|
4395
|
+
_a.sent();
|
|
4396
|
+
_a.label = 3;
|
|
4397
|
+
case 3:
|
|
4398
|
+
i++;
|
|
4399
|
+
return [3, 1];
|
|
4400
|
+
case 4: return [2];
|
|
4401
|
+
}
|
|
4402
|
+
});
|
|
4403
|
+
};
|
|
3766
4404
|
klass = function () {
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
4405
|
+
return __generator(this, function (_a) {
|
|
4406
|
+
switch (_a.label) {
|
|
4407
|
+
case 0: return [5, __values(construct(this))];
|
|
4408
|
+
case 1:
|
|
4409
|
+
_a.sent();
|
|
4410
|
+
if (superClass) {
|
|
4411
|
+
superClass.apply(this);
|
|
4412
|
+
}
|
|
4413
|
+
return [2];
|
|
4414
|
+
}
|
|
4415
|
+
});
|
|
3770
4416
|
};
|
|
3771
|
-
methodBody = node.body.body;
|
|
3772
4417
|
for (i = 0; i < methodBody.length; i++) {
|
|
3773
4418
|
method = methodBody[i];
|
|
3774
4419
|
if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
|
|
3775
|
-
klass = createFunc(method.value, scope, { superClass: superClass,
|
|
4420
|
+
klass = createFunc(method.value, scope, { superClass: superClass, construct: construct });
|
|
3776
4421
|
break;
|
|
3777
4422
|
}
|
|
3778
4423
|
}
|
|
@@ -3933,7 +4578,7 @@
|
|
|
3933
4578
|
if (node.generator || node.async) {
|
|
3934
4579
|
return createFunc(node, scope, options);
|
|
3935
4580
|
}
|
|
3936
|
-
var superClass = options.superClass,
|
|
4581
|
+
var superClass = options.superClass, construct = options.construct;
|
|
3937
4582
|
var params = node.params;
|
|
3938
4583
|
var tmpFunc = function _a() {
|
|
3939
4584
|
var _newTarget = this && this instanceof _a ? this.constructor : void 0;
|
|
@@ -3946,9 +4591,12 @@
|
|
|
3946
4591
|
subScope.const('this', this);
|
|
3947
4592
|
subScope.let('arguments', arguments);
|
|
3948
4593
|
subScope.const(NEWTARGET, _newTarget);
|
|
4594
|
+
if (construct) {
|
|
4595
|
+
construct(this);
|
|
4596
|
+
}
|
|
3949
4597
|
if (superClass) {
|
|
3950
4598
|
subScope.const(SUPER, superClass);
|
|
3951
|
-
if (
|
|
4599
|
+
if (construct)
|
|
3952
4600
|
subScope.let(SUPERCALL, false);
|
|
3953
4601
|
}
|
|
3954
4602
|
}
|
|
@@ -4001,16 +4649,25 @@
|
|
|
4001
4649
|
}
|
|
4002
4650
|
function createClass$1(node, scope) {
|
|
4003
4651
|
var superClass = evaluate(node.superClass, scope);
|
|
4652
|
+
var methodBody = node.body.body;
|
|
4653
|
+
var construct = function (object) {
|
|
4654
|
+
for (var i = 0; i < methodBody.length; i++) {
|
|
4655
|
+
var def = methodBody[i];
|
|
4656
|
+
if (def.type === 'PropertyDefinition' && !def.static) {
|
|
4657
|
+
PropertyDefinition(def, scope, { klass: object, superClass: superClass });
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
};
|
|
4004
4661
|
var klass = function () {
|
|
4662
|
+
construct(this);
|
|
4005
4663
|
if (superClass) {
|
|
4006
4664
|
superClass.apply(this);
|
|
4007
4665
|
}
|
|
4008
4666
|
};
|
|
4009
|
-
var methodBody = node.body.body;
|
|
4010
4667
|
for (var i = 0; i < methodBody.length; i++) {
|
|
4011
4668
|
var method = methodBody[i];
|
|
4012
4669
|
if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
|
|
4013
|
-
klass = createFunc$1(method.value, scope, { superClass: superClass,
|
|
4670
|
+
klass = createFunc$1(method.value, scope, { superClass: superClass, construct: construct });
|
|
4014
4671
|
break;
|
|
4015
4672
|
}
|
|
4016
4673
|
}
|
|
@@ -4056,7 +4713,7 @@
|
|
|
4056
4713
|
this.options = { ecmaVersion: 'latest' };
|
|
4057
4714
|
this.scope = new Scope(null, true);
|
|
4058
4715
|
this.exports = {};
|
|
4059
|
-
var _a = options.ecmaVer, ecmaVer = _a === void 0 ? 'latest' : _a, _b = options.sandBox, sandBox = _b === void 0 ? true : _b;
|
|
4716
|
+
var _a = options.ecmaVer, ecmaVer = _a === void 0 ? 'latest' : _a, _b = options.sandBox, sandBox = _b === void 0 ? true : _b, _c = options.sourceType, sourceType = _c === void 0 ? 'script' : _c;
|
|
4060
4717
|
if (typeof ecmaVer === 'number') {
|
|
4061
4718
|
ecmaVer -= ecmaVer < 2015 ? 0 : 2009;
|
|
4062
4719
|
}
|
|
@@ -4064,16 +4721,19 @@
|
|
|
4064
4721
|
throw new Error("unsupported ecmaVer");
|
|
4065
4722
|
}
|
|
4066
4723
|
this.options.ecmaVersion = ecmaVer;
|
|
4724
|
+
this.options.sourceType = sourceType;
|
|
4067
4725
|
if (sandBox) {
|
|
4068
4726
|
var win = createSandBox();
|
|
4727
|
+
this.scope.let('globalThis', win);
|
|
4069
4728
|
this.scope.let('window', win);
|
|
4070
4729
|
this.scope.let('this', win);
|
|
4071
4730
|
}
|
|
4072
4731
|
else {
|
|
4732
|
+
this.scope.let('globalThis', globalObj);
|
|
4073
4733
|
this.scope.let('window', globalObj);
|
|
4074
4734
|
this.scope.let('this', globalObj);
|
|
4075
4735
|
}
|
|
4076
|
-
this.scope.const('exports', this.exports = {});
|
|
4736
|
+
this.scope.const(sourceType === 'module' ? EXPORTS : 'exports', this.exports = {});
|
|
4077
4737
|
}
|
|
4078
4738
|
Sval.prototype.import = function (nameOrModules, mod) {
|
|
4079
4739
|
var _a;
|
|
@@ -4085,7 +4745,8 @@
|
|
|
4085
4745
|
var names = getOwnNames(nameOrModules);
|
|
4086
4746
|
for (var i = 0; i < names.length; i++) {
|
|
4087
4747
|
var name_1 = names[i];
|
|
4088
|
-
this.
|
|
4748
|
+
var modName = this.options.sourceType === 'module' ? IMPORT + name_1 : name_1;
|
|
4749
|
+
this.scope.var(modName, nameOrModules[name_1]);
|
|
4089
4750
|
}
|
|
4090
4751
|
};
|
|
4091
4752
|
Sval.prototype.parse = function (code, parser) {
|