sval 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.1";
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 = evaluate(node.left, scope);
792
- var right = evaluate(node.right, scope);
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 = object[key].bind(thisObject);
1060
+ func = obj[key].bind(thisObject);
974
1061
  }
975
1062
  else {
976
- func = object[key];
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
- return scope.find(NEWTARGET).get();
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;
@@ -1138,6 +1230,27 @@
1138
1230
  }
1139
1231
  function ChainExpression(node, scope) {
1140
1232
  return evaluate(node.expression, scope);
1233
+ }
1234
+ function ImportExpression(node, scope) {
1235
+ var globalScope = scope.global();
1236
+ var source = evaluate(node.source, scope);
1237
+ var module = globalScope.find(IMPORT + source);
1238
+ var value;
1239
+ if (module) {
1240
+ var result = module.get();
1241
+ if (result) {
1242
+ if (typeof result === 'function') {
1243
+ value = result();
1244
+ }
1245
+ else if (typeof result === 'object') {
1246
+ value = result;
1247
+ }
1248
+ }
1249
+ }
1250
+ if (!value || typeof value !== 'object') {
1251
+ return Promise.reject(new TypeError("Failed to resolve module specifier \"" + source + "\""));
1252
+ }
1253
+ return Promise.resolve(value);
1141
1254
  }
1142
1255
 
1143
1256
  var expression = /*#__PURE__*/Object.freeze({
@@ -1164,9 +1277,180 @@
1164
1277
  ClassExpression: ClassExpression,
1165
1278
  Super: Super,
1166
1279
  SpreadElement: SpreadElement,
1167
- ChainExpression: ChainExpression
1280
+ ChainExpression: ChainExpression,
1281
+ ImportExpression: ImportExpression
1282
+ });
1283
+
1284
+ function ObjectPattern(node, scope, options) {
1285
+ if (options === void 0) { options = {}; }
1286
+ 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;
1287
+ var fedKeys = [];
1288
+ for (var i = 0; i < node.properties.length; i++) {
1289
+ var property = node.properties[i];
1290
+ if (hoist) {
1291
+ if (onlyBlock || kind === 'var') {
1292
+ if (property.type === 'Property') {
1293
+ var value = property.value;
1294
+ if (value.type === 'Identifier') {
1295
+ scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1296
+ }
1297
+ else {
1298
+ pattern$3(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1299
+ }
1300
+ }
1301
+ else {
1302
+ RestElement(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1303
+ }
1304
+ }
1305
+ }
1306
+ else if (property.type === 'Property') {
1307
+ var key = void 0;
1308
+ if (property.computed) {
1309
+ key = evaluate(property.key, scope);
1310
+ }
1311
+ else {
1312
+ key = property.key.name;
1313
+ }
1314
+ fedKeys.push(key);
1315
+ var value = property.value;
1316
+ if (value.type === 'Identifier') {
1317
+ scope[kind](value.name, feed[key]);
1318
+ }
1319
+ else {
1320
+ pattern$3(value, scope, { kind: kind, feed: feed[key] });
1321
+ }
1322
+ }
1323
+ else {
1324
+ var rest = assign({}, feed);
1325
+ for (var i_1 = 0; i_1 < fedKeys.length; i_1++)
1326
+ delete rest[fedKeys[i_1]];
1327
+ RestElement(property, scope, { kind: kind, feed: rest });
1328
+ }
1329
+ }
1330
+ }
1331
+ function ArrayPattern(node, scope, options) {
1332
+ if (options === void 0) { options = {}; }
1333
+ 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;
1334
+ var result = [];
1335
+ for (var i = 0; i < node.elements.length; i++) {
1336
+ var element = node.elements[i];
1337
+ if (!element)
1338
+ continue;
1339
+ if (hoist) {
1340
+ if (onlyBlock || kind === 'var') {
1341
+ if (element.type === 'Identifier') {
1342
+ scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1343
+ }
1344
+ else {
1345
+ pattern$3(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1346
+ }
1347
+ }
1348
+ }
1349
+ else if (element.type === 'Identifier') {
1350
+ if (kind) {
1351
+ scope[kind](element.name, feed[i]);
1352
+ }
1353
+ else {
1354
+ var variable = Identifier(element, scope, { getVar: true });
1355
+ variable.set(feed[i]);
1356
+ result.push(variable.get());
1357
+ }
1358
+ }
1359
+ else if (element.type === 'RestElement') {
1360
+ RestElement(element, scope, { kind: kind, feed: feed.slice(i) });
1361
+ }
1362
+ else {
1363
+ pattern$3(element, scope, { kind: kind, feed: feed[i] });
1364
+ }
1365
+ }
1366
+ if (result.length) {
1367
+ return result;
1368
+ }
1369
+ }
1370
+ function RestElement(node, scope, options) {
1371
+ if (options === void 0) { options = {}; }
1372
+ 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;
1373
+ var arg = node.argument;
1374
+ if (hoist) {
1375
+ if (onlyBlock || kind === 'var') {
1376
+ if (arg.type === 'Identifier') {
1377
+ scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1378
+ }
1379
+ else {
1380
+ pattern$3(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1381
+ }
1382
+ }
1383
+ }
1384
+ else if (arg.type === 'Identifier') {
1385
+ if (kind) {
1386
+ scope[kind](arg.name, feed);
1387
+ }
1388
+ else {
1389
+ var variable = Identifier(arg, scope, { getVar: true });
1390
+ variable.set(feed);
1391
+ }
1392
+ }
1393
+ else {
1394
+ pattern$3(arg, scope, { kind: kind, feed: feed });
1395
+ }
1396
+ }
1397
+ function AssignmentPattern(node, scope, options) {
1398
+ if (options === void 0) { options = {}; }
1399
+ 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;
1400
+ var left = node.left;
1401
+ if (hoist) {
1402
+ if (onlyBlock || kind === 'var') {
1403
+ if (left.type === 'Identifier') {
1404
+ scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1405
+ }
1406
+ else {
1407
+ pattern$3(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1408
+ }
1409
+ }
1410
+ }
1411
+ else if (left.type === 'Identifier') {
1412
+ scope[kind](left.name, feed);
1413
+ }
1414
+ else {
1415
+ pattern$3(left, scope, { kind: kind, feed: feed });
1416
+ }
1417
+ }
1418
+
1419
+ var pattern = /*#__PURE__*/Object.freeze({
1420
+ __proto__: null,
1421
+ ObjectPattern: ObjectPattern,
1422
+ ArrayPattern: ArrayPattern,
1423
+ RestElement: RestElement,
1424
+ AssignmentPattern: AssignmentPattern
1425
+ });
1426
+
1427
+ function Program(program, scope) {
1428
+ for (var i = 0; i < program.body.length; i++) {
1429
+ evaluate(program.body[i], scope);
1430
+ }
1431
+ }
1432
+
1433
+ var program = /*#__PURE__*/Object.freeze({
1434
+ __proto__: null,
1435
+ Program: Program
1168
1436
  });
1169
1437
 
1438
+ var evaluateOps;
1439
+ function evaluate(node, scope) {
1440
+ if (!node)
1441
+ return;
1442
+ if (!evaluateOps) {
1443
+ evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern, program);
1444
+ }
1445
+ var handler = evaluateOps[node.type];
1446
+ if (handler) {
1447
+ return handler(node, scope);
1448
+ }
1449
+ else {
1450
+ throw new Error(node.type + " isn't implemented");
1451
+ }
1452
+ }
1453
+
1170
1454
  function ExpressionStatement(node, scope) {
1171
1455
  evaluate(node.expression, scope);
1172
1456
  }
@@ -1365,230 +1649,38 @@
1365
1649
  }
1366
1650
  }
1367
1651
 
1368
- var statement = /*#__PURE__*/Object.freeze({
1369
- __proto__: null,
1370
- ExpressionStatement: ExpressionStatement,
1371
- BlockStatement: BlockStatement,
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) {
1652
+ function FunctionDeclaration(node, scope) {
1653
+ scope.func(node.id.name, createFunc$1(node, scope));
1654
+ }
1655
+ function VariableDeclaration(node, scope, options) {
1391
1656
  if (options === void 0) { options = {}; }
1392
- 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;
1393
- var fedKeys = [];
1394
- for (var i = 0; i < node.properties.length; i++) {
1395
- var property = node.properties[i];
1396
- if (hoist) {
1397
- if (onlyBlock || kind === 'var') {
1398
- if (property.type === 'Property') {
1399
- var value = property.value;
1400
- if (value.type === 'Identifier') {
1401
- scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1402
- }
1403
- else {
1404
- pattern$3(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1405
- }
1406
- }
1407
- else {
1408
- RestElement(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1409
- }
1657
+ for (var i = 0; i < node.declarations.length; i++) {
1658
+ VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
1659
+ }
1660
+ }
1661
+ function VariableDeclarator(node, scope, options) {
1662
+ if (options === void 0) { options = {}; }
1663
+ 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;
1664
+ if (hoist) {
1665
+ if (onlyBlock || kind === 'var') {
1666
+ if (node.id.type === 'Identifier') {
1667
+ scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1668
+ }
1669
+ else {
1670
+ pattern$3(node.id, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
1410
1671
  }
1411
1672
  }
1412
- else if (property.type === 'Property') {
1413
- var key = void 0;
1414
- if (property.computed) {
1415
- key = evaluate(property.key, scope);
1673
+ }
1674
+ else {
1675
+ var hasFeed = 'feed' in options;
1676
+ var value = hasFeed ? feed : evaluate(node.init, scope);
1677
+ if (node.id.type === 'Identifier') {
1678
+ var name_1 = node.id.name;
1679
+ if (kind === 'var' && !node.init && !hasFeed) {
1680
+ scope.var(name_1, NOINIT);
1416
1681
  }
1417
1682
  else {
1418
- key = property.key.name;
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);
1683
+ scope[kind](name_1, value);
1592
1684
  }
1593
1685
  if (node.init
1594
1686
  && ['ClassExpression', 'FunctionExpression', 'ArrowFunctionExpression']
@@ -1616,22 +1708,39 @@
1616
1708
  if (def.type === 'MethodDefinition') {
1617
1709
  MethodDefinition(def, scope, { klass: klass, superClass: superClass });
1618
1710
  }
1711
+ else if (def.type === 'PropertyDefinition' && def.static) {
1712
+ PropertyDefinition(def, scope, { klass: klass, superClass: superClass });
1713
+ }
1714
+ else if (def.type === 'StaticBlock') {
1715
+ StaticBlock(def, scope, { klass: klass, superClass: superClass });
1716
+ }
1619
1717
  }
1620
1718
  }
1621
1719
  function MethodDefinition(node, scope, options) {
1622
1720
  if (options === void 0) { options = {}; }
1623
1721
  var klass = options.klass, superClass = options.superClass;
1624
1722
  var key;
1723
+ var priv = false;
1625
1724
  if (node.computed) {
1626
1725
  key = evaluate(node.key, scope);
1627
1726
  }
1628
1727
  else if (node.key.type === 'Identifier') {
1629
1728
  key = node.key.name;
1630
1729
  }
1730
+ else if (node.key.type === 'PrivateIdentifier') {
1731
+ key = node.key.name;
1732
+ priv = true;
1733
+ }
1631
1734
  else {
1632
1735
  throw new SyntaxError('Unexpected token');
1633
1736
  }
1634
1737
  var obj = node.static ? klass : klass.prototype;
1738
+ if (priv) {
1739
+ if (!obj[PRIVATE]) {
1740
+ define(obj, PRIVATE, { value: {} });
1741
+ }
1742
+ obj = obj[PRIVATE];
1743
+ }
1635
1744
  var value = createFunc$1(node.value, scope, { superClass: superClass });
1636
1745
  switch (node.kind) {
1637
1746
  case 'constructor':
@@ -1664,6 +1773,193 @@
1664
1773
  default:
1665
1774
  throw new SyntaxError('Unexpected token');
1666
1775
  }
1776
+ }
1777
+ function PropertyDefinition(node, scope, options) {
1778
+ if (options === void 0) { options = {}; }
1779
+ var klass = options.klass, superClass = options.superClass;
1780
+ var key;
1781
+ var priv = false;
1782
+ if (node.computed) {
1783
+ key = evaluate(node.key, scope);
1784
+ }
1785
+ else if (node.key.type === 'Identifier') {
1786
+ key = node.key.name;
1787
+ }
1788
+ else if (node.key.type === 'PrivateIdentifier') {
1789
+ key = node.key.name;
1790
+ priv = true;
1791
+ }
1792
+ else {
1793
+ throw new SyntaxError('Unexpected token');
1794
+ }
1795
+ var subScope = new Scope(scope, true);
1796
+ subScope.const('this', klass);
1797
+ var obj = klass;
1798
+ if (priv) {
1799
+ if (!obj[PRIVATE]) {
1800
+ define(obj, PRIVATE, { value: {} });
1801
+ }
1802
+ obj = obj[PRIVATE];
1803
+ }
1804
+ if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
1805
+ obj[key] = createFunc$1(node.value, subScope, { superClass: superClass });
1806
+ }
1807
+ else {
1808
+ obj[key] = evaluate(node.value, subScope);
1809
+ }
1810
+ }
1811
+ function StaticBlock(node, scope, options) {
1812
+ if (options === void 0) { options = {}; }
1813
+ var klass = options.klass;
1814
+ var subScope = new Scope(scope, true);
1815
+ subScope.const('this', klass);
1816
+ return BlockStatement(node, subScope, { invasived: true });
1817
+ }
1818
+ function ImportDeclaration(node, scope) {
1819
+ var globalScope = scope.global();
1820
+ var module = globalScope.find(IMPORT + node.source.value);
1821
+ var value;
1822
+ if (module) {
1823
+ var result = module.get();
1824
+ if (result) {
1825
+ if (typeof result === 'function') {
1826
+ value = result();
1827
+ }
1828
+ else if (typeof result === 'object') {
1829
+ value = result;
1830
+ }
1831
+ }
1832
+ }
1833
+ if (!value || typeof value !== 'object') {
1834
+ throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
1835
+ }
1836
+ for (var i = 0; i < node.specifiers.length; i++) {
1837
+ var spec = node.specifiers[i];
1838
+ var name_2 = void 0;
1839
+ if (spec.type === 'ImportSpecifier') {
1840
+ name_2 = spec.imported.type === 'Identifier'
1841
+ ? spec.imported.name : spec.imported.value;
1842
+ }
1843
+ else if (spec.type === 'ImportDefaultSpecifier') {
1844
+ name_2 = 'default';
1845
+ }
1846
+ else if (spec.type === 'ImportNamespaceSpecifier') {
1847
+ name_2 = '*';
1848
+ }
1849
+ if (name_2 !== '*' && !hasOwn(value, name_2)) {
1850
+ throw new SyntaxError("The requested module \"" + node.source.value + "\" does not provide an export named \"" + name_2 + "\"");
1851
+ }
1852
+ scope.var(spec.local.name, name_2 === '*' ? assign({}, value) : value[name_2]);
1853
+ }
1854
+ }
1855
+ function ExportDefaultDeclaration(node, scope) {
1856
+ var globalScope = scope.global();
1857
+ var value;
1858
+ if (node.declaration.type === 'FunctionDeclaration') {
1859
+ value = createFunc$1(node.declaration, scope);
1860
+ scope.func(node.declaration.id.name, value);
1861
+ }
1862
+ else if (node.declaration.type === 'ClassDeclaration') {
1863
+ value = createClass$1(node.declaration, scope);
1864
+ scope.func(node.declaration.id.name, value);
1865
+ }
1866
+ else {
1867
+ value = evaluate(node.declaration, scope);
1868
+ }
1869
+ var variable = globalScope.find(EXPORTS);
1870
+ if (variable) {
1871
+ var exports_1 = variable.get();
1872
+ if (exports_1 && typeof exports_1 === 'object') {
1873
+ exports_1.default = value;
1874
+ }
1875
+ }
1876
+ }
1877
+ function ExportNamedDeclaration(node, scope) {
1878
+ var globalScope = scope.global();
1879
+ if (node.declaration) {
1880
+ if (node.declaration.type === 'FunctionDeclaration') {
1881
+ var value = createFunc$1(node.declaration, scope);
1882
+ scope.func(node.declaration.id.name, value);
1883
+ var variable = globalScope.find(EXPORTS);
1884
+ if (variable) {
1885
+ var exports_2 = variable.get();
1886
+ if (exports_2 && typeof exports_2 === 'object') {
1887
+ exports_2[node.declaration.id.name] = value;
1888
+ }
1889
+ }
1890
+ }
1891
+ else if (node.declaration.type === 'ClassDeclaration') {
1892
+ var value = createClass$1(node.declaration, scope);
1893
+ scope.func(node.declaration.id.name, value);
1894
+ var variable = globalScope.find(EXPORTS);
1895
+ if (variable) {
1896
+ var exports_3 = variable.get();
1897
+ if (exports_3 && typeof exports_3 === 'object') {
1898
+ exports_3[node.declaration.id.name] = value;
1899
+ }
1900
+ }
1901
+ }
1902
+ else if (node.declaration.type === 'VariableDeclaration') {
1903
+ VariableDeclaration(node.declaration, scope);
1904
+ var variable = globalScope.find(EXPORTS);
1905
+ if (variable) {
1906
+ var exports_4 = variable.get();
1907
+ if (exports_4 && typeof exports_4 === 'object') {
1908
+ for (var i = 0; i < node.declaration.declarations.length; i++) {
1909
+ var name_3 = node.declaration.declarations[i].id.name;
1910
+ var item = scope.find(name_3);
1911
+ if (item) {
1912
+ exports_4[name_3] = item.get();
1913
+ }
1914
+ }
1915
+ }
1916
+ }
1917
+ }
1918
+ }
1919
+ else if (node.specifiers) {
1920
+ var variable = globalScope.find(EXPORTS);
1921
+ if (variable) {
1922
+ var exports_5 = variable.get();
1923
+ if (exports_5 && typeof exports_5 === 'object') {
1924
+ for (var i = 0; i < node.specifiers.length; i++) {
1925
+ var spec = node.specifiers[i];
1926
+ var name_4 = spec.local.type === 'Identifier'
1927
+ ? spec.local.name : spec.local.value;
1928
+ var item = scope.find(name_4);
1929
+ if (item) {
1930
+ exports_5[spec.exported.type === 'Identifier'
1931
+ ? spec.exported.name : spec.exported.value] = item.get();
1932
+ }
1933
+ }
1934
+ }
1935
+ }
1936
+ }
1937
+ }
1938
+ function ExportAllDeclaration(node, scope) {
1939
+ var globalScope = scope.global();
1940
+ var module = globalScope.find(IMPORT + node.source.value);
1941
+ var value;
1942
+ if (module) {
1943
+ var result = module.get();
1944
+ if (result) {
1945
+ if (typeof result === 'function') {
1946
+ value = result();
1947
+ }
1948
+ else if (typeof result === 'object') {
1949
+ value = result;
1950
+ }
1951
+ }
1952
+ }
1953
+ if (!value || typeof value !== 'object') {
1954
+ throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
1955
+ }
1956
+ var variable = globalScope.find(EXPORTS);
1957
+ if (variable) {
1958
+ var exports_6 = variable.get();
1959
+ if (exports_6 && typeof exports_6 === 'object') {
1960
+ assign(exports_6, value);
1961
+ }
1962
+ }
1667
1963
  }
1668
1964
 
1669
1965
  function Identifier$1(node, scope, options) {
@@ -1928,12 +2224,22 @@
1928
2224
  var left, right;
1929
2225
  return __generator(this, function (_a) {
1930
2226
  switch (_a.label) {
1931
- case 0: return [5, __values(evaluate$1(node.left, scope))];
2227
+ case 0:
2228
+ if (!(node.left.type === 'PrivateIdentifier')) return [3, 2];
2229
+ left = node.left.name;
2230
+ return [5, __values(evaluate$1(node.right, scope))];
1932
2231
  case 1:
2232
+ right = _a.sent();
2233
+ right = right[PRIVATE];
2234
+ return [3, 5];
2235
+ case 2: return [5, __values(evaluate$1(node.left, scope))];
2236
+ case 3:
1933
2237
  left = _a.sent();
1934
2238
  return [5, __values(evaluate$1(node.right, scope))];
1935
- case 2:
2239
+ case 4:
1936
2240
  right = _a.sent();
2241
+ _a.label = 5;
2242
+ case 5:
1937
2243
  switch (node.operator) {
1938
2244
  case '==': return [2, left == right];
1939
2245
  case '!=': return [2, left != right];
@@ -2092,7 +2398,7 @@
2092
2398
  });
2093
2399
  }
2094
2400
  function MemberExpression$1(node, scope, options) {
2095
- var _a, getObj, _b, getVar, object, key, setter, thisObject, privateKey, getter, thisObject;
2401
+ var _a, getObj, _b, getVar, object, key, priv, setter, thisObject, privateKey, getter, thisObject;
2096
2402
  if (options === void 0) { options = {}; }
2097
2403
  return __generator(this, function (_c) {
2098
2404
  switch (_c.label) {
@@ -2110,15 +2416,25 @@
2110
2416
  case 4:
2111
2417
  if (getObj)
2112
2418
  return [2, object];
2419
+ priv = false;
2113
2420
  if (!node.computed) return [3, 6];
2114
2421
  return [5, __values(evaluate$1(node.property, scope))];
2115
2422
  case 5:
2116
2423
  key = _c.sent();
2117
2424
  return [3, 7];
2118
2425
  case 6:
2119
- key = node.property.name;
2120
- _c.label = 7;
2121
- case 7:
2426
+ if (node.property.type === 'PrivateIdentifier') {
2427
+ key = node.property.name;
2428
+ priv = true;
2429
+ }
2430
+ else {
2431
+ key = node.property.name;
2432
+ }
2433
+ _c.label = 7;
2434
+ case 7:
2435
+ if (priv) {
2436
+ object = object[PRIVATE];
2437
+ }
2122
2438
  if (getVar) {
2123
2439
  setter = getSetter(object, key);
2124
2440
  if (node.object.type === 'Super' && setter) {
@@ -2170,7 +2486,7 @@
2170
2486
  });
2171
2487
  }
2172
2488
  function CallExpression$1(node, scope) {
2173
- var func, object, key, thisObject, name_1, args, i, arg, _a, _b, _c, _d, superCall;
2489
+ var func, object, key, priv, obj, thisObject, name_1, args, i, arg, _a, _b, _c, _d, superCall;
2174
2490
  return __generator(this, function (_e) {
2175
2491
  switch (_e.label) {
2176
2492
  case 0:
@@ -2182,21 +2498,32 @@
2182
2498
  return [2, undefined];
2183
2499
  }
2184
2500
  key = void 0;
2501
+ priv = false;
2185
2502
  if (!node.callee.computed) return [3, 3];
2186
2503
  return [5, __values(evaluate$1(node.callee.property, scope))];
2187
2504
  case 2:
2188
2505
  key = _e.sent();
2189
2506
  return [3, 4];
2190
2507
  case 3:
2191
- key = node.callee.property.name;
2508
+ if (node.callee.property.type === 'PrivateIdentifier') {
2509
+ key = node.callee.property.name;
2510
+ priv = true;
2511
+ }
2512
+ else {
2513
+ key = node.callee.property.name;
2514
+ }
2192
2515
  _e.label = 4;
2193
2516
  case 4:
2517
+ obj = object;
2518
+ if (priv) {
2519
+ obj = obj[PRIVATE];
2520
+ }
2194
2521
  if (node.callee.object.type === 'Super') {
2195
2522
  thisObject = scope.find('this').get();
2196
- func = object[key].bind(thisObject);
2523
+ func = obj[key].bind(thisObject);
2197
2524
  }
2198
2525
  else {
2199
- func = object[key];
2526
+ func = obj[key];
2200
2527
  }
2201
2528
  if (node.optional && func == null) {
2202
2529
  return [2, undefined];
@@ -2326,7 +2653,13 @@
2326
2653
  }
2327
2654
  function MetaProperty$1(node, scope) {
2328
2655
  return __generator(this, function (_a) {
2329
- return [2, scope.find(NEWTARGET).get()];
2656
+ if (node.meta.name === 'new' && node.property.name === 'target') {
2657
+ return [2, scope.find(NEWTARGET).get()];
2658
+ }
2659
+ else if (node.meta.name === 'import' && node.property.name === 'meta') {
2660
+ return [2, { url: '' }];
2661
+ }
2662
+ return [2];
2330
2663
  });
2331
2664
  }
2332
2665
  function SequenceExpression$1(node, scope) {
@@ -2460,6 +2793,34 @@
2460
2793
  }
2461
2794
  });
2462
2795
  }
2796
+ function ImportExpression$1(node, scope) {
2797
+ var globalScope, source, module, value, result;
2798
+ return __generator(this, function (_a) {
2799
+ switch (_a.label) {
2800
+ case 0:
2801
+ globalScope = scope.global();
2802
+ return [5, __values(evaluate$1(node.source, scope))];
2803
+ case 1:
2804
+ source = _a.sent();
2805
+ module = globalScope.find(IMPORT + source);
2806
+ if (module) {
2807
+ result = module.get();
2808
+ if (result) {
2809
+ if (typeof result === 'function') {
2810
+ value = result();
2811
+ }
2812
+ else if (typeof result === 'object') {
2813
+ value = result;
2814
+ }
2815
+ }
2816
+ }
2817
+ if (!value || typeof value !== 'object') {
2818
+ return [2, Promise.reject(new TypeError("Failed to resolve module specifier \"" + source + "\""))];
2819
+ }
2820
+ return [2, Promise.resolve(value)];
2821
+ }
2822
+ });
2823
+ }
2463
2824
  function YieldExpression(node, scope) {
2464
2825
  var res, _a;
2465
2826
  return __generator(this, function (_b) {
@@ -2520,10 +2881,242 @@
2520
2881
  Super: Super$1,
2521
2882
  SpreadElement: SpreadElement$1,
2522
2883
  ChainExpression: ChainExpression$1,
2884
+ ImportExpression: ImportExpression$1,
2523
2885
  YieldExpression: YieldExpression,
2524
2886
  AwaitExpression: AwaitExpression
2525
2887
  });
2526
2888
 
2889
+ function ObjectPattern$1(node, scope, options) {
2890
+ var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, fedKeys, i, property, value, key, value, rest, i_1;
2891
+ if (options === void 0) { options = {}; }
2892
+ return __generator(this, function (_e) {
2893
+ switch (_e.label) {
2894
+ case 0:
2895
+ _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;
2896
+ fedKeys = [];
2897
+ i = 0;
2898
+ _e.label = 1;
2899
+ case 1:
2900
+ if (!(i < node.properties.length)) return [3, 18];
2901
+ property = node.properties[i];
2902
+ if (!hoist) return [3, 8];
2903
+ if (!(onlyBlock || kind === 'var')) return [3, 7];
2904
+ if (!(property.type === 'Property')) return [3, 5];
2905
+ value = property.value;
2906
+ if (!(value.type === 'Identifier')) return [3, 2];
2907
+ scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2908
+ return [3, 4];
2909
+ case 2: return [5, __values(pattern$2(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
2910
+ case 3:
2911
+ _e.sent();
2912
+ _e.label = 4;
2913
+ case 4: return [3, 7];
2914
+ case 5: return [5, __values(RestElement$1(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
2915
+ case 6:
2916
+ _e.sent();
2917
+ _e.label = 7;
2918
+ case 7: return [3, 17];
2919
+ case 8:
2920
+ if (!(property.type === 'Property')) return [3, 15];
2921
+ key = void 0;
2922
+ if (!property.computed) return [3, 10];
2923
+ return [5, __values(evaluate$1(property.key, scope))];
2924
+ case 9:
2925
+ key = _e.sent();
2926
+ return [3, 11];
2927
+ case 10:
2928
+ key = property.key.name;
2929
+ _e.label = 11;
2930
+ case 11:
2931
+ fedKeys.push(key);
2932
+ value = property.value;
2933
+ if (!(value.type === 'Identifier')) return [3, 12];
2934
+ scope[kind](value.name, feed[key]);
2935
+ return [3, 14];
2936
+ case 12: return [5, __values(pattern$2(value, scope, { kind: kind, feed: feed[key] }))];
2937
+ case 13:
2938
+ _e.sent();
2939
+ _e.label = 14;
2940
+ case 14: return [3, 17];
2941
+ case 15:
2942
+ rest = assign({}, feed);
2943
+ for (i_1 = 0; i_1 < fedKeys.length; i_1++)
2944
+ delete rest[fedKeys[i_1]];
2945
+ return [5, __values(RestElement$1(property, scope, { kind: kind, feed: rest }))];
2946
+ case 16:
2947
+ _e.sent();
2948
+ _e.label = 17;
2949
+ case 17:
2950
+ i++;
2951
+ return [3, 1];
2952
+ case 18: return [2];
2953
+ }
2954
+ });
2955
+ }
2956
+ function ArrayPattern$1(node, scope, options) {
2957
+ var kind, _a, hoist, _b, onlyBlock, _c, feed, result, i, element, variable;
2958
+ if (options === void 0) { options = {}; }
2959
+ return __generator(this, function (_d) {
2960
+ switch (_d.label) {
2961
+ case 0:
2962
+ 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;
2963
+ result = [];
2964
+ i = 0;
2965
+ _d.label = 1;
2966
+ case 1:
2967
+ if (!(i < node.elements.length)) return [3, 14];
2968
+ element = node.elements[i];
2969
+ if (!element)
2970
+ return [3, 13];
2971
+ if (!hoist) return [3, 5];
2972
+ if (!(onlyBlock || kind === 'var')) return [3, 4];
2973
+ if (!(element.type === 'Identifier')) return [3, 2];
2974
+ scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2975
+ return [3, 4];
2976
+ case 2: return [5, __values(pattern$2(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
2977
+ case 3:
2978
+ _d.sent();
2979
+ _d.label = 4;
2980
+ case 4: return [3, 13];
2981
+ case 5:
2982
+ if (!(element.type === 'Identifier')) return [3, 9];
2983
+ if (!kind) return [3, 6];
2984
+ scope[kind](element.name, feed[i]);
2985
+ return [3, 8];
2986
+ case 6: return [5, __values(Identifier$1(element, scope, { getVar: true }))];
2987
+ case 7:
2988
+ variable = _d.sent();
2989
+ variable.set(feed[i]);
2990
+ result.push(variable.get());
2991
+ _d.label = 8;
2992
+ case 8: return [3, 13];
2993
+ case 9:
2994
+ if (!(element.type === 'RestElement')) return [3, 11];
2995
+ return [5, __values(RestElement$1(element, scope, { kind: kind, feed: feed.slice(i) }))];
2996
+ case 10:
2997
+ _d.sent();
2998
+ return [3, 13];
2999
+ case 11: return [5, __values(pattern$2(element, scope, { kind: kind, feed: feed[i] }))];
3000
+ case 12:
3001
+ _d.sent();
3002
+ _d.label = 13;
3003
+ case 13:
3004
+ i++;
3005
+ return [3, 1];
3006
+ case 14:
3007
+ if (result.length) {
3008
+ return [2, result];
3009
+ }
3010
+ return [2];
3011
+ }
3012
+ });
3013
+ }
3014
+ function RestElement$1(node, scope, options) {
3015
+ var kind, _a, hoist, _b, onlyBlock, _c, feed, arg, variable;
3016
+ if (options === void 0) { options = {}; }
3017
+ return __generator(this, function (_d) {
3018
+ switch (_d.label) {
3019
+ case 0:
3020
+ 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;
3021
+ arg = node.argument;
3022
+ if (!hoist) return [3, 4];
3023
+ if (!(onlyBlock || kind === 'var')) return [3, 3];
3024
+ if (!(arg.type === 'Identifier')) return [3, 1];
3025
+ scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
3026
+ return [3, 3];
3027
+ case 1: return [5, __values(pattern$2(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
3028
+ case 2:
3029
+ _d.sent();
3030
+ _d.label = 3;
3031
+ case 3: return [3, 10];
3032
+ case 4:
3033
+ if (!(arg.type === 'Identifier')) return [3, 8];
3034
+ if (!kind) return [3, 5];
3035
+ scope[kind](arg.name, feed);
3036
+ return [3, 7];
3037
+ case 5: return [5, __values(Identifier$1(arg, scope, { getVar: true }))];
3038
+ case 6:
3039
+ variable = _d.sent();
3040
+ variable.set(feed);
3041
+ _d.label = 7;
3042
+ case 7: return [3, 10];
3043
+ case 8: return [5, __values(pattern$2(arg, scope, { kind: kind, feed: feed }))];
3044
+ case 9:
3045
+ _d.sent();
3046
+ _d.label = 10;
3047
+ case 10: return [2];
3048
+ }
3049
+ });
3050
+ }
3051
+ function AssignmentPattern$1(node, scope, options) {
3052
+ var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, _e, left;
3053
+ if (options === void 0) { options = {}; }
3054
+ return __generator(this, function (_f) {
3055
+ switch (_f.label) {
3056
+ case 0:
3057
+ _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;
3058
+ if (!(_d === void 0)) return [3, 2];
3059
+ return [5, __values(evaluate$1(node.right, scope))];
3060
+ case 1:
3061
+ _e = _f.sent();
3062
+ return [3, 3];
3063
+ case 2:
3064
+ _e = _d;
3065
+ _f.label = 3;
3066
+ case 3:
3067
+ feed = _e;
3068
+ left = node.left;
3069
+ if (!hoist) return [3, 7];
3070
+ if (!(onlyBlock || kind === 'var')) return [3, 6];
3071
+ if (!(left.type === 'Identifier')) return [3, 4];
3072
+ scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
3073
+ return [3, 6];
3074
+ case 4: return [5, __values(pattern$2(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
3075
+ case 5:
3076
+ _f.sent();
3077
+ _f.label = 6;
3078
+ case 6: return [3, 10];
3079
+ case 7:
3080
+ if (!(left.type === 'Identifier')) return [3, 8];
3081
+ scope[kind](left.name, feed);
3082
+ return [3, 10];
3083
+ case 8: return [5, __values(pattern$2(left, scope, { kind: kind, feed: feed }))];
3084
+ case 9:
3085
+ _f.sent();
3086
+ _f.label = 10;
3087
+ case 10: return [2];
3088
+ }
3089
+ });
3090
+ }
3091
+
3092
+ var pattern$1 = /*#__PURE__*/Object.freeze({
3093
+ __proto__: null,
3094
+ ObjectPattern: ObjectPattern$1,
3095
+ ArrayPattern: ArrayPattern$1,
3096
+ RestElement: RestElement$1,
3097
+ AssignmentPattern: AssignmentPattern$1
3098
+ });
3099
+
3100
+ var evaluateOps$1;
3101
+ function evaluate$1(node, scope) {
3102
+ var handler;
3103
+ return __generator(this, function (_a) {
3104
+ switch (_a.label) {
3105
+ case 0:
3106
+ if (!node)
3107
+ return [2];
3108
+ if (!evaluateOps$1) {
3109
+ evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$1);
3110
+ }
3111
+ handler = evaluateOps$1[node.type];
3112
+ if (!handler) return [3, 2];
3113
+ return [5, __values(handler(node, scope))];
3114
+ case 1: return [2, _a.sent()];
3115
+ case 2: throw new Error(node.type + " isn't implemented");
3116
+ }
3117
+ });
3118
+ }
3119
+
2527
3120
  function ExpressionStatement$1(node, scope) {
2528
3121
  return __generator(this, function (_a) {
2529
3122
  switch (_a.label) {
@@ -2879,333 +3472,80 @@
2879
3472
  case 5: return [2];
2880
3473
  }
2881
3474
  });
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);
3475
+ }
3476
+ function ForOfStatement$1(node, scope) {
3477
+ var right, iterator, ret, result, right_1, right_1_1, value, result, e_1_1;
3478
+ var e_1, _a;
3479
+ return __generator(this, function (_b) {
3480
+ switch (_b.label) {
3481
+ case 0: return [5, __values(evaluate$1(node.right, scope))];
3482
+ case 1:
3483
+ right = _b.sent();
3484
+ if (!node.await) return [3, 8];
3485
+ iterator = getAsyncIterator(right);
3486
+ ret = void 0;
3487
+ AWAIT.RES = iterator.next();
3488
+ return [4, AWAIT];
3489
+ case 2:
3490
+ ret = _b.sent();
3491
+ _b.label = 3;
3492
+ case 3:
3493
+ if (!!ret.done) return [3, 7];
3494
+ return [5, __values(ForXHandler(node, scope, { value: ret.value }))];
3495
+ case 4:
3496
+ result = _b.sent();
3497
+ if (result === BREAK) {
3498
+ return [3, 7];
3203
3499
  }
3204
- handler = evaluateOps$1[node.type];
3205
- if (!handler) return [3, 2];
3206
- return [5, __values(handler(node, scope))];
3207
- case 1: return [2, _a.sent()];
3208
- case 2: throw new Error(node.type + " isn't implemented");
3500
+ else if (result === CONTINUE) {
3501
+ return [3, 5];
3502
+ }
3503
+ else if (result === RETURN) {
3504
+ return [2, result];
3505
+ }
3506
+ _b.label = 5;
3507
+ case 5:
3508
+ AWAIT.RES = iterator.next();
3509
+ return [4, AWAIT];
3510
+ case 6:
3511
+ ret = _b.sent();
3512
+ return [3, 3];
3513
+ case 7: return [3, 15];
3514
+ case 8:
3515
+ _b.trys.push([8, 13, 14, 15]);
3516
+ right_1 = __values(right), right_1_1 = right_1.next();
3517
+ _b.label = 9;
3518
+ case 9:
3519
+ if (!!right_1_1.done) return [3, 12];
3520
+ value = right_1_1.value;
3521
+ return [5, __values(ForXHandler(node, scope, { value: value }))];
3522
+ case 10:
3523
+ result = _b.sent();
3524
+ if (result === BREAK) {
3525
+ return [3, 12];
3526
+ }
3527
+ else if (result === CONTINUE) {
3528
+ return [3, 11];
3529
+ }
3530
+ else if (result === RETURN) {
3531
+ return [2, result];
3532
+ }
3533
+ _b.label = 11;
3534
+ case 11:
3535
+ right_1_1 = right_1.next();
3536
+ return [3, 9];
3537
+ case 12: return [3, 15];
3538
+ case 13:
3539
+ e_1_1 = _b.sent();
3540
+ e_1 = { error: e_1_1 };
3541
+ return [3, 15];
3542
+ case 14:
3543
+ try {
3544
+ if (right_1_1 && !right_1_1.done && (_a = right_1.return)) _a.call(right_1);
3545
+ }
3546
+ finally { if (e_1) throw e_1.error; }
3547
+ return [7];
3548
+ case 15: return [2];
3209
3549
  }
3210
3550
  });
3211
3551
  }
@@ -3315,27 +3655,40 @@
3315
3655
  i = 0;
3316
3656
  _a.label = 1;
3317
3657
  case 1:
3318
- if (!(i < node.body.length)) return [3, 4];
3658
+ if (!(i < node.body.length)) return [3, 8];
3319
3659
  def = node.body[i];
3320
3660
  if (!(def.type === 'MethodDefinition')) return [3, 3];
3321
3661
  return [5, __values(MethodDefinition$1(def, scope, { klass: klass, superClass: superClass }))];
3322
3662
  case 2:
3323
3663
  _a.sent();
3324
- _a.label = 3;
3664
+ return [3, 7];
3325
3665
  case 3:
3666
+ if (!(def.type === 'PropertyDefinition' && def.static)) return [3, 5];
3667
+ return [5, __values(PropertyDefinition$1(def, scope, { klass: klass, superClass: superClass }))];
3668
+ case 4:
3669
+ _a.sent();
3670
+ return [3, 7];
3671
+ case 5:
3672
+ if (!(def.type === 'StaticBlock')) return [3, 7];
3673
+ return [5, __values(StaticBlock$1(def, scope, { klass: klass, superClass: superClass }))];
3674
+ case 6:
3675
+ _a.sent();
3676
+ _a.label = 7;
3677
+ case 7:
3326
3678
  i++;
3327
3679
  return [3, 1];
3328
- case 4: return [2];
3680
+ case 8: return [2];
3329
3681
  }
3330
3682
  });
3331
3683
  }
3332
3684
  function MethodDefinition$1(node, scope, options) {
3333
- var klass, superClass, key, obj, value, oriDptor, oriDptor;
3685
+ var klass, superClass, key, priv, obj, value, oriDptor, oriDptor;
3334
3686
  if (options === void 0) { options = {}; }
3335
3687
  return __generator(this, function (_a) {
3336
3688
  switch (_a.label) {
3337
3689
  case 0:
3338
3690
  klass = options.klass, superClass = options.superClass;
3691
+ priv = false;
3339
3692
  if (!node.computed) return [3, 2];
3340
3693
  return [5, __values(evaluate$1(node.key, scope))];
3341
3694
  case 1:
@@ -3345,12 +3698,22 @@
3345
3698
  if (node.key.type === 'Identifier') {
3346
3699
  key = node.key.name;
3347
3700
  }
3701
+ else if (node.key.type === 'PrivateIdentifier') {
3702
+ key = node.key.name;
3703
+ priv = true;
3704
+ }
3348
3705
  else {
3349
3706
  throw new SyntaxError('Unexpected token');
3350
3707
  }
3351
3708
  _a.label = 3;
3352
3709
  case 3:
3353
3710
  obj = node.static ? klass : klass.prototype;
3711
+ if (priv) {
3712
+ if (!obj[PRIVATE]) {
3713
+ define(obj, PRIVATE, { value: {} });
3714
+ }
3715
+ obj = obj[PRIVATE];
3716
+ }
3354
3717
  value = createFunc(node.value, scope, { superClass: superClass });
3355
3718
  switch (node.kind) {
3356
3719
  case 'constructor':
@@ -3386,6 +3749,247 @@
3386
3749
  return [2];
3387
3750
  }
3388
3751
  });
3752
+ }
3753
+ function PropertyDefinition$1(node, scope, options) {
3754
+ var klass, superClass, key, priv, subScope, obj, _a, _b;
3755
+ if (options === void 0) { options = {}; }
3756
+ return __generator(this, function (_c) {
3757
+ switch (_c.label) {
3758
+ case 0:
3759
+ klass = options.klass, superClass = options.superClass;
3760
+ priv = false;
3761
+ if (!node.computed) return [3, 2];
3762
+ return [5, __values(evaluate$1(node.key, scope))];
3763
+ case 1:
3764
+ key = _c.sent();
3765
+ return [3, 3];
3766
+ case 2:
3767
+ if (node.key.type === 'Identifier') {
3768
+ key = node.key.name;
3769
+ }
3770
+ else if (node.key.type === 'PrivateIdentifier') {
3771
+ key = node.key.name;
3772
+ priv = true;
3773
+ }
3774
+ else {
3775
+ throw new SyntaxError('Unexpected token');
3776
+ }
3777
+ _c.label = 3;
3778
+ case 3:
3779
+ subScope = new Scope(scope, true);
3780
+ subScope.const('this', klass);
3781
+ obj = klass;
3782
+ if (priv) {
3783
+ if (!obj[PRIVATE]) {
3784
+ define(obj, PRIVATE, { value: {} });
3785
+ }
3786
+ obj = obj[PRIVATE];
3787
+ }
3788
+ if (!(node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression')) return [3, 4];
3789
+ obj[key] = createFunc(node.value, subScope, { superClass: superClass });
3790
+ return [3, 6];
3791
+ case 4:
3792
+ _a = obj;
3793
+ _b = key;
3794
+ return [5, __values(evaluate$1(node.value, subScope))];
3795
+ case 5:
3796
+ _a[_b] = _c.sent();
3797
+ _c.label = 6;
3798
+ case 6: return [2];
3799
+ }
3800
+ });
3801
+ }
3802
+ function StaticBlock$1(node, scope, options) {
3803
+ var klass, subScope;
3804
+ if (options === void 0) { options = {}; }
3805
+ return __generator(this, function (_a) {
3806
+ switch (_a.label) {
3807
+ case 0:
3808
+ klass = options.klass;
3809
+ subScope = new Scope(scope, true);
3810
+ subScope.const('this', klass);
3811
+ return [5, __values(BlockStatement$1(node, subScope, { invasived: true }))];
3812
+ case 1: return [2, _a.sent()];
3813
+ }
3814
+ });
3815
+ }
3816
+ function ImportDeclaration$1(node, scope) {
3817
+ var globalScope, module, value, result, i, spec, name_2;
3818
+ return __generator(this, function (_a) {
3819
+ globalScope = scope.global();
3820
+ module = globalScope.find(IMPORT + node.source.value);
3821
+ if (module) {
3822
+ result = module.get();
3823
+ if (result) {
3824
+ if (typeof result === 'function') {
3825
+ value = result();
3826
+ }
3827
+ else if (typeof result === 'object') {
3828
+ value = result;
3829
+ }
3830
+ }
3831
+ }
3832
+ if (!value || typeof value !== 'object') {
3833
+ throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
3834
+ }
3835
+ for (i = 0; i < node.specifiers.length; i++) {
3836
+ spec = node.specifiers[i];
3837
+ name_2 = void 0;
3838
+ if (spec.type === 'ImportSpecifier') {
3839
+ name_2 = spec.imported.type === 'Identifier'
3840
+ ? spec.imported.name : spec.imported.value;
3841
+ }
3842
+ else if (spec.type === 'ImportDefaultSpecifier') {
3843
+ name_2 = 'default';
3844
+ }
3845
+ else if (spec.type === 'ImportNamespaceSpecifier') {
3846
+ name_2 = '*';
3847
+ }
3848
+ if (name_2 !== '*' && !hasOwn(value, name_2)) {
3849
+ throw new SyntaxError("The requested module \"" + node.source.value + "\" does not provide an export named \"" + name_2 + "\"");
3850
+ }
3851
+ scope.var(spec.local.name, name_2 === '*' ? assign({}, value) : value[name_2]);
3852
+ }
3853
+ return [2];
3854
+ });
3855
+ }
3856
+ function ExportDefaultDeclaration$1(node, scope) {
3857
+ var globalScope, value, variable, exports_1;
3858
+ return __generator(this, function (_a) {
3859
+ switch (_a.label) {
3860
+ case 0:
3861
+ globalScope = scope.global();
3862
+ if (!(node.declaration.type === 'FunctionDeclaration')) return [3, 1];
3863
+ value = createFunc(node.declaration, scope);
3864
+ scope.func(node.declaration.id.name, value);
3865
+ return [3, 5];
3866
+ case 1:
3867
+ if (!(node.declaration.type === 'ClassDeclaration')) return [3, 3];
3868
+ return [5, __values(createClass(node.declaration, scope))];
3869
+ case 2:
3870
+ value = _a.sent();
3871
+ scope.func(node.declaration.id.name, value);
3872
+ return [3, 5];
3873
+ case 3: return [5, __values(evaluate$1(node.declaration, scope))];
3874
+ case 4:
3875
+ value = _a.sent();
3876
+ _a.label = 5;
3877
+ case 5:
3878
+ variable = globalScope.find(EXPORTS);
3879
+ if (variable) {
3880
+ exports_1 = variable.get();
3881
+ if (exports_1 && typeof exports_1 === 'object') {
3882
+ exports_1.default = value;
3883
+ }
3884
+ }
3885
+ return [2];
3886
+ }
3887
+ });
3888
+ }
3889
+ function ExportNamedDeclaration$1(node, scope) {
3890
+ 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;
3891
+ return __generator(this, function (_a) {
3892
+ switch (_a.label) {
3893
+ case 0:
3894
+ globalScope = scope.global();
3895
+ if (!node.declaration) return [3, 6];
3896
+ if (!(node.declaration.type === 'FunctionDeclaration')) return [3, 1];
3897
+ value = createFunc(node.declaration, scope);
3898
+ scope.func(node.declaration.id.name, value);
3899
+ variable = globalScope.find(EXPORTS);
3900
+ if (variable) {
3901
+ exports_2 = variable.get();
3902
+ if (exports_2 && typeof exports_2 === 'object') {
3903
+ exports_2[node.declaration.id.name] = value;
3904
+ }
3905
+ }
3906
+ return [3, 5];
3907
+ case 1:
3908
+ if (!(node.declaration.type === 'ClassDeclaration')) return [3, 3];
3909
+ return [5, __values(createClass(node.declaration, scope))];
3910
+ case 2:
3911
+ value = _a.sent();
3912
+ scope.func(node.declaration.id.name, value);
3913
+ variable = globalScope.find(EXPORTS);
3914
+ if (variable) {
3915
+ exports_3 = variable.get();
3916
+ if (exports_3 && typeof exports_3 === 'object') {
3917
+ exports_3[node.declaration.id.name] = value;
3918
+ }
3919
+ }
3920
+ return [3, 5];
3921
+ case 3:
3922
+ if (!(node.declaration.type === 'VariableDeclaration')) return [3, 5];
3923
+ return [5, __values(VariableDeclaration$1(node.declaration, scope))];
3924
+ case 4:
3925
+ _a.sent();
3926
+ variable = globalScope.find(EXPORTS);
3927
+ if (variable) {
3928
+ exports_4 = variable.get();
3929
+ if (exports_4 && typeof exports_4 === 'object') {
3930
+ for (i = 0; i < node.declaration.declarations.length; i++) {
3931
+ name_3 = node.declaration.declarations[i].id.name;
3932
+ item = scope.find(name_3);
3933
+ if (item) {
3934
+ exports_4[name_3] = item.get();
3935
+ }
3936
+ }
3937
+ }
3938
+ }
3939
+ _a.label = 5;
3940
+ case 5: return [3, 7];
3941
+ case 6:
3942
+ if (node.specifiers) {
3943
+ variable = globalScope.find(EXPORTS);
3944
+ if (variable) {
3945
+ exports_5 = variable.get();
3946
+ if (exports_5 && typeof exports_5 === 'object') {
3947
+ for (i = 0; i < node.specifiers.length; i++) {
3948
+ spec = node.specifiers[i];
3949
+ name_4 = spec.local.type === 'Identifier'
3950
+ ? spec.local.name : spec.local.value;
3951
+ item = scope.find(name_4);
3952
+ if (item) {
3953
+ exports_5[spec.exported.type === 'Identifier'
3954
+ ? spec.exported.name : spec.exported.value] = item.get();
3955
+ }
3956
+ }
3957
+ }
3958
+ }
3959
+ }
3960
+ _a.label = 7;
3961
+ case 7: return [2];
3962
+ }
3963
+ });
3964
+ }
3965
+ function ExportAllDeclaration$1(node, scope) {
3966
+ var globalScope, module, value, result, variable, exports_6;
3967
+ return __generator(this, function (_a) {
3968
+ globalScope = scope.global();
3969
+ module = globalScope.find(IMPORT + node.source.value);
3970
+ if (module) {
3971
+ result = module.get();
3972
+ if (result) {
3973
+ if (typeof result === 'function') {
3974
+ value = result();
3975
+ }
3976
+ else if (typeof result === 'object') {
3977
+ value = result;
3978
+ }
3979
+ }
3980
+ }
3981
+ if (!value || typeof value !== 'object') {
3982
+ throw new TypeError("Failed to resolve module specifier \"" + node.source.value + "\"");
3983
+ }
3984
+ variable = globalScope.find(EXPORTS);
3985
+ if (variable) {
3986
+ exports_6 = variable.get();
3987
+ if (exports_6 && typeof exports_6 === 'object') {
3988
+ assign(exports_6, value);
3989
+ }
3990
+ }
3991
+ return [2];
3992
+ });
3389
3993
  }
3390
3994
 
3391
3995
  function runAsync(iterator, options) {
@@ -3638,7 +4242,7 @@
3638
4242
  if (!node.generator && !node.async) {
3639
4243
  return createFunc$1(node, scope, options);
3640
4244
  }
3641
- var superClass = options.superClass, isCtor = options.isCtor;
4245
+ var superClass = options.superClass, construct = options.construct;
3642
4246
  var params = node.params;
3643
4247
  var tmpFunc = function _a() {
3644
4248
  var _i, subScope, i, param, result;
@@ -3651,58 +4255,65 @@
3651
4255
  switch (_a.label) {
3652
4256
  case 0:
3653
4257
  subScope = new Scope(scope, true);
3654
- if (node.type !== 'ArrowFunctionExpression') {
3655
- subScope.const('this', this);
3656
- subScope.let('arguments', arguments);
3657
- subScope.const(NEWTARGET, _newTarget);
3658
- if (superClass) {
3659
- subScope.const(SUPER, superClass);
3660
- if (isCtor)
3661
- subScope.let(SUPERCALL, false);
3662
- }
4258
+ if (!(node.type !== 'ArrowFunctionExpression')) return [3, 3];
4259
+ subScope.const('this', this);
4260
+ subScope.let('arguments', arguments);
4261
+ subScope.const(NEWTARGET, _newTarget);
4262
+ if (!construct) return [3, 2];
4263
+ return [5, __values(construct(this))];
4264
+ case 1:
4265
+ _a.sent();
4266
+ _a.label = 2;
4267
+ case 2:
4268
+ if (superClass) {
4269
+ subScope.const(SUPER, superClass);
4270
+ if (construct)
4271
+ subScope.let(SUPERCALL, false);
3663
4272
  }
4273
+ _a.label = 3;
4274
+ case 3:
3664
4275
  i = 0;
3665
- _a.label = 1;
3666
- case 1:
3667
- if (!(i < params.length)) return [3, 7];
4276
+ _a.label = 4;
4277
+ case 4:
4278
+ if (!(i < params.length)) return [3, 10];
3668
4279
  param = params[i];
3669
- if (!(param.type === 'Identifier')) return [3, 2];
4280
+ if (!(param.type === 'Identifier')) return [3, 5];
3670
4281
  subScope.var(param.name, args[i]);
3671
- return [3, 6];
3672
- case 2:
3673
- if (!(param.type === 'RestElement')) return [3, 4];
4282
+ return [3, 9];
4283
+ case 5:
4284
+ if (!(param.type === 'RestElement')) return [3, 7];
3674
4285
  return [5, __values(RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) }))];
3675
- case 3:
4286
+ case 6:
3676
4287
  _a.sent();
3677
- return [3, 6];
3678
- case 4: return [5, __values(pattern$2(param, subScope, { kind: 'var', feed: args[i] }))];
3679
- case 5:
4288
+ return [3, 9];
4289
+ case 7: return [5, __values(pattern$2(param, subScope, { kind: 'var', feed: args[i] }))];
4290
+ case 8:
3680
4291
  _a.sent();
3681
- _a.label = 6;
3682
- case 6:
4292
+ _a.label = 9;
4293
+ case 9:
3683
4294
  i++;
3684
- return [3, 1];
3685
- case 7:
3686
- if (!(node.body.type === 'BlockStatement')) return [3, 10];
4295
+ return [3, 4];
4296
+ case 10:
4297
+ if (!(node.body.type === 'BlockStatement')) return [3, 13];
3687
4298
  return [5, __values(hoist(node.body, subScope))];
3688
- case 8:
4299
+ case 11:
3689
4300
  _a.sent();
3690
4301
  return [5, __values(BlockStatement$1(node.body, subScope, {
3691
4302
  invasived: true,
3692
4303
  hoisted: true
3693
4304
  }))];
3694
- case 9:
4305
+ case 12:
3695
4306
  result = _a.sent();
3696
- return [3, 12];
3697
- case 10: return [5, __values(evaluate$1(node.body, subScope))];
3698
- case 11:
4307
+ return [3, 15];
4308
+ case 13: return [5, __values(evaluate$1(node.body, subScope))];
4309
+ case 14:
3699
4310
  result = _a.sent();
3700
4311
  if (node.type === 'ArrowFunctionExpression') {
3701
4312
  RETURN.RES = result;
3702
4313
  result = RETURN;
3703
4314
  }
3704
- _a.label = 12;
3705
- case 12:
4315
+ _a.label = 15;
4316
+ case 15:
3706
4317
  if (result === RETURN) {
3707
4318
  return [2, result.RES];
3708
4319
  }
@@ -3757,22 +4368,52 @@
3757
4368
  return func;
3758
4369
  }
3759
4370
  function createClass(node, scope) {
3760
- var superClass, klass, methodBody, i, method;
4371
+ var superClass, methodBody, construct, klass, i, method;
3761
4372
  return __generator(this, function (_a) {
3762
4373
  switch (_a.label) {
3763
4374
  case 0: return [5, __values(evaluate$1(node.superClass, scope))];
3764
4375
  case 1:
3765
4376
  superClass = _a.sent();
4377
+ methodBody = node.body.body;
4378
+ construct = function (object) {
4379
+ var i, def;
4380
+ return __generator(this, function (_a) {
4381
+ switch (_a.label) {
4382
+ case 0:
4383
+ i = 0;
4384
+ _a.label = 1;
4385
+ case 1:
4386
+ if (!(i < methodBody.length)) return [3, 4];
4387
+ def = methodBody[i];
4388
+ if (!(def.type === 'PropertyDefinition' && !def.static)) return [3, 3];
4389
+ return [5, __values(PropertyDefinition$1(def, scope, { klass: object, superClass: superClass }))];
4390
+ case 2:
4391
+ _a.sent();
4392
+ _a.label = 3;
4393
+ case 3:
4394
+ i++;
4395
+ return [3, 1];
4396
+ case 4: return [2];
4397
+ }
4398
+ });
4399
+ };
3766
4400
  klass = function () {
3767
- if (superClass) {
3768
- superClass.apply(this);
3769
- }
4401
+ return __generator(this, function (_a) {
4402
+ switch (_a.label) {
4403
+ case 0: return [5, __values(construct(this))];
4404
+ case 1:
4405
+ _a.sent();
4406
+ if (superClass) {
4407
+ superClass.apply(this);
4408
+ }
4409
+ return [2];
4410
+ }
4411
+ });
3770
4412
  };
3771
- methodBody = node.body.body;
3772
4413
  for (i = 0; i < methodBody.length; i++) {
3773
4414
  method = methodBody[i];
3774
4415
  if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
3775
- klass = createFunc(method.value, scope, { superClass: superClass, isCtor: true });
4416
+ klass = createFunc(method.value, scope, { superClass: superClass, construct: construct });
3776
4417
  break;
3777
4418
  }
3778
4419
  }
@@ -3933,7 +4574,7 @@
3933
4574
  if (node.generator || node.async) {
3934
4575
  return createFunc(node, scope, options);
3935
4576
  }
3936
- var superClass = options.superClass, isCtor = options.isCtor;
4577
+ var superClass = options.superClass, construct = options.construct;
3937
4578
  var params = node.params;
3938
4579
  var tmpFunc = function _a() {
3939
4580
  var _newTarget = this && this instanceof _a ? this.constructor : void 0;
@@ -3946,9 +4587,12 @@
3946
4587
  subScope.const('this', this);
3947
4588
  subScope.let('arguments', arguments);
3948
4589
  subScope.const(NEWTARGET, _newTarget);
4590
+ if (construct) {
4591
+ construct(this);
4592
+ }
3949
4593
  if (superClass) {
3950
4594
  subScope.const(SUPER, superClass);
3951
- if (isCtor)
4595
+ if (construct)
3952
4596
  subScope.let(SUPERCALL, false);
3953
4597
  }
3954
4598
  }
@@ -4001,16 +4645,25 @@
4001
4645
  }
4002
4646
  function createClass$1(node, scope) {
4003
4647
  var superClass = evaluate(node.superClass, scope);
4648
+ var methodBody = node.body.body;
4649
+ var construct = function (object) {
4650
+ for (var i = 0; i < methodBody.length; i++) {
4651
+ var def = methodBody[i];
4652
+ if (def.type === 'PropertyDefinition' && !def.static) {
4653
+ PropertyDefinition(def, scope, { klass: object, superClass: superClass });
4654
+ }
4655
+ }
4656
+ };
4004
4657
  var klass = function () {
4658
+ construct(this);
4005
4659
  if (superClass) {
4006
4660
  superClass.apply(this);
4007
4661
  }
4008
4662
  };
4009
- var methodBody = node.body.body;
4010
4663
  for (var i = 0; i < methodBody.length; i++) {
4011
4664
  var method = methodBody[i];
4012
4665
  if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
4013
- klass = createFunc$1(method.value, scope, { superClass: superClass, isCtor: true });
4666
+ klass = createFunc$1(method.value, scope, { superClass: superClass, construct: construct });
4014
4667
  break;
4015
4668
  }
4016
4669
  }
@@ -4056,7 +4709,7 @@
4056
4709
  this.options = { ecmaVersion: 'latest' };
4057
4710
  this.scope = new Scope(null, true);
4058
4711
  this.exports = {};
4059
- var _a = options.ecmaVer, ecmaVer = _a === void 0 ? 'latest' : _a, _b = options.sandBox, sandBox = _b === void 0 ? true : _b;
4712
+ 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
4713
  if (typeof ecmaVer === 'number') {
4061
4714
  ecmaVer -= ecmaVer < 2015 ? 0 : 2009;
4062
4715
  }
@@ -4064,16 +4717,19 @@
4064
4717
  throw new Error("unsupported ecmaVer");
4065
4718
  }
4066
4719
  this.options.ecmaVersion = ecmaVer;
4720
+ this.options.sourceType = sourceType;
4067
4721
  if (sandBox) {
4068
4722
  var win = createSandBox();
4723
+ this.scope.let('globalThis', win);
4069
4724
  this.scope.let('window', win);
4070
4725
  this.scope.let('this', win);
4071
4726
  }
4072
4727
  else {
4728
+ this.scope.let('globalThis', globalObj);
4073
4729
  this.scope.let('window', globalObj);
4074
4730
  this.scope.let('this', globalObj);
4075
4731
  }
4076
- this.scope.const('exports', this.exports = {});
4732
+ this.scope.const(sourceType === 'module' ? EXPORTS : 'exports', this.exports = {});
4077
4733
  }
4078
4734
  Sval.prototype.import = function (nameOrModules, mod) {
4079
4735
  var _a;
@@ -4085,7 +4741,8 @@
4085
4741
  var names = getOwnNames(nameOrModules);
4086
4742
  for (var i = 0; i < names.length; i++) {
4087
4743
  var name_1 = names[i];
4088
- this.scope.var(name_1, nameOrModules[name_1]);
4744
+ var modName = this.options.sourceType === 'module' ? IMPORT + name_1 : name_1;
4745
+ this.scope.var(modName, nameOrModules[name_1]);
4089
4746
  }
4090
4747
  };
4091
4748
  Sval.prototype.parse = function (code, parser) {