sval 0.5.3 → 0.5.4
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/README.md +8 -8
- package/dist/sval.es6.js +316 -77
- package/dist/sval.js +383 -84
- package/dist/sval.min.js +1 -1
- package/package.json +1 -1
package/dist/sval.js
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
get ReturnStatement () { return ReturnStatement$1; },
|
|
14
14
|
get BreakStatement () { return BreakStatement$1; },
|
|
15
15
|
get ContinueStatement () { return ContinueStatement$1; },
|
|
16
|
+
get LabeledStatement () { return LabeledStatement$1; },
|
|
17
|
+
get WithStatement () { return WithStatement$1; },
|
|
16
18
|
get IfStatement () { return IfStatement$1; },
|
|
17
19
|
get SwitchStatement () { return SwitchStatement$1; },
|
|
18
20
|
get SwitchCase () { return SwitchCase$1; },
|
|
@@ -49,6 +51,8 @@
|
|
|
49
51
|
get ReturnStatement () { return ReturnStatement; },
|
|
50
52
|
get BreakStatement () { return BreakStatement; },
|
|
51
53
|
get ContinueStatement () { return ContinueStatement; },
|
|
54
|
+
get LabeledStatement () { return LabeledStatement; },
|
|
55
|
+
get WithStatement () { return WithStatement; },
|
|
52
56
|
get IfStatement () { return IfStatement; },
|
|
53
57
|
get SwitchStatement () { return SwitchStatement; },
|
|
54
58
|
get SwitchCase () { return SwitchCase; },
|
|
@@ -395,6 +399,10 @@
|
|
|
395
399
|
globalObj.crypto = crypto;
|
|
396
400
|
}
|
|
397
401
|
catch (err) { }
|
|
402
|
+
try {
|
|
403
|
+
globalObj.URL = URL;
|
|
404
|
+
}
|
|
405
|
+
catch (err) { }
|
|
398
406
|
names = getOwnNames(globalObj);
|
|
399
407
|
}
|
|
400
408
|
}
|
|
@@ -444,8 +452,8 @@
|
|
|
444
452
|
|
|
445
453
|
var AWAIT = { RES: undefined };
|
|
446
454
|
var RETURN = { RES: undefined };
|
|
447
|
-
var CONTINUE =
|
|
448
|
-
var BREAK =
|
|
455
|
+
var CONTINUE = { LABEL: undefined };
|
|
456
|
+
var BREAK = { LABEL: undefined };
|
|
449
457
|
var SUPER = createSymbol('super');
|
|
450
458
|
var SUPERCALL = createSymbol('supercall');
|
|
451
459
|
var NOCTOR = createSymbol('noctor');
|
|
@@ -500,6 +508,7 @@
|
|
|
500
508
|
if (parent === void 0) { parent = null; }
|
|
501
509
|
if (isolated === void 0) { isolated = false; }
|
|
502
510
|
this.context = create(null);
|
|
511
|
+
this.withContext = create(null);
|
|
503
512
|
this.parent = parent;
|
|
504
513
|
this.isolated = isolated;
|
|
505
514
|
}
|
|
@@ -510,18 +519,13 @@
|
|
|
510
519
|
}
|
|
511
520
|
return scope;
|
|
512
521
|
};
|
|
513
|
-
Scope.prototype.clone = function () {
|
|
514
|
-
var cloneScope = new Scope(this.parent, this.isolated);
|
|
515
|
-
for (var name_1 in this.context) {
|
|
516
|
-
var variable = this.context[name_1];
|
|
517
|
-
cloneScope[variable.kind](name_1, variable.get());
|
|
518
|
-
}
|
|
519
|
-
return cloneScope;
|
|
520
|
-
};
|
|
521
522
|
Scope.prototype.find = function (name) {
|
|
522
523
|
if (this.context[name]) {
|
|
523
524
|
return this.context[name];
|
|
524
525
|
}
|
|
526
|
+
else if (name in this.withContext) {
|
|
527
|
+
return new Prop(this.withContext, name);
|
|
528
|
+
}
|
|
525
529
|
else if (this.parent) {
|
|
526
530
|
return this.parent.find(name);
|
|
527
531
|
}
|
|
@@ -588,6 +592,11 @@
|
|
|
588
592
|
throw new SyntaxError("Identifier '" + name + "' has already been declared");
|
|
589
593
|
}
|
|
590
594
|
};
|
|
595
|
+
Scope.prototype.with = function (value) {
|
|
596
|
+
if (Object.keys(value)) {
|
|
597
|
+
this.withContext = value;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
591
600
|
return Scope;
|
|
592
601
|
}());
|
|
593
602
|
|
|
@@ -1473,7 +1482,13 @@
|
|
|
1473
1482
|
}
|
|
1474
1483
|
for (var i = 0; i < block.body.length; i++) {
|
|
1475
1484
|
var result = evaluate$1(block.body[i], subScope);
|
|
1476
|
-
if (result === BREAK
|
|
1485
|
+
if (result === BREAK) {
|
|
1486
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
return result;
|
|
1490
|
+
}
|
|
1491
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1477
1492
|
return result;
|
|
1478
1493
|
}
|
|
1479
1494
|
}
|
|
@@ -1487,21 +1502,82 @@
|
|
|
1487
1502
|
RETURN.RES = node.argument ? (evaluate$1(node.argument, scope)) : undefined;
|
|
1488
1503
|
return RETURN;
|
|
1489
1504
|
}
|
|
1490
|
-
function BreakStatement$1() {
|
|
1505
|
+
function BreakStatement$1(node) {
|
|
1506
|
+
var _a;
|
|
1507
|
+
BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
1491
1508
|
return BREAK;
|
|
1492
1509
|
}
|
|
1493
|
-
function ContinueStatement$1() {
|
|
1510
|
+
function ContinueStatement$1(node) {
|
|
1511
|
+
var _a;
|
|
1512
|
+
CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
1494
1513
|
return CONTINUE;
|
|
1495
1514
|
}
|
|
1496
|
-
function
|
|
1497
|
-
|
|
1498
|
-
|
|
1515
|
+
function LabeledStatement$1(node, scope) {
|
|
1516
|
+
var label = node.label.name;
|
|
1517
|
+
if (node.body.type === 'WhileStatement') {
|
|
1518
|
+
return WhileStatement$1(node.body, scope, { label: label });
|
|
1499
1519
|
}
|
|
1500
|
-
|
|
1501
|
-
return
|
|
1520
|
+
if (node.body.type === 'DoWhileStatement') {
|
|
1521
|
+
return DoWhileStatement$1(node.body, scope, { label: label });
|
|
1522
|
+
}
|
|
1523
|
+
if (node.body.type === 'ForStatement') {
|
|
1524
|
+
return ForStatement$1(node.body, scope, { label: label });
|
|
1525
|
+
}
|
|
1526
|
+
if (node.body.type === 'ForInStatement') {
|
|
1527
|
+
return ForInStatement$1(node.body, scope, { label: label });
|
|
1528
|
+
}
|
|
1529
|
+
if (node.body.type === 'ForOfStatement') {
|
|
1530
|
+
return ForOfStatement$1(node.body, scope, { label: label });
|
|
1531
|
+
}
|
|
1532
|
+
if (node.body.type === 'BlockStatement') {
|
|
1533
|
+
return BlockStatement$1(node.body, scope, { label: label });
|
|
1502
1534
|
}
|
|
1535
|
+
if (node.body.type === 'WithStatement') {
|
|
1536
|
+
return WithStatement$1(node.body, scope, { label: label });
|
|
1537
|
+
}
|
|
1538
|
+
if (node.body.type === 'IfStatement') {
|
|
1539
|
+
return IfStatement$1(node.body, scope, { label: label });
|
|
1540
|
+
}
|
|
1541
|
+
if (node.body.type === 'SwitchStatement') {
|
|
1542
|
+
return SwitchStatement$1(node.body, scope, { label: label });
|
|
1543
|
+
}
|
|
1544
|
+
if (node.body.type === 'TryStatement') {
|
|
1545
|
+
return TryStatement$1(node.body, scope, { label: label });
|
|
1546
|
+
}
|
|
1547
|
+
throw new SyntaxError(node.body.type + " cannot be labeled");
|
|
1503
1548
|
}
|
|
1504
|
-
function
|
|
1549
|
+
function WithStatement$1(node, scope, options) {
|
|
1550
|
+
if (options === void 0) { options = {}; }
|
|
1551
|
+
var withScope = new Scope(scope);
|
|
1552
|
+
withScope.with(evaluate$1(node.object, scope));
|
|
1553
|
+
var result = evaluate$1(node.body, withScope);
|
|
1554
|
+
if (result === BREAK) {
|
|
1555
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
return result;
|
|
1559
|
+
}
|
|
1560
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1561
|
+
return result;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function IfStatement$1(node, scope, options) {
|
|
1565
|
+
if (options === void 0) { options = {}; }
|
|
1566
|
+
var result = evaluate$1(node.test, scope)
|
|
1567
|
+
? evaluate$1(node.consequent, scope)
|
|
1568
|
+
: evaluate$1(node.alternate, scope);
|
|
1569
|
+
if (result === BREAK) {
|
|
1570
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
return result;
|
|
1574
|
+
}
|
|
1575
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1576
|
+
return result;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
function SwitchStatement$1(node, scope, options) {
|
|
1580
|
+
if (options === void 0) { options = {}; }
|
|
1505
1581
|
var discriminant = evaluate$1(node.discriminant, scope);
|
|
1506
1582
|
var matched = false;
|
|
1507
1583
|
for (var i = 0; i < node.cases.length; i++) {
|
|
@@ -1514,7 +1590,10 @@
|
|
|
1514
1590
|
if (matched) {
|
|
1515
1591
|
var result = SwitchCase$1(eachCase, scope);
|
|
1516
1592
|
if (result === BREAK) {
|
|
1517
|
-
|
|
1593
|
+
if (result.LABEL === options.label) {
|
|
1594
|
+
break;
|
|
1595
|
+
}
|
|
1596
|
+
return result;
|
|
1518
1597
|
}
|
|
1519
1598
|
if (result === CONTINUE || result === RETURN) {
|
|
1520
1599
|
return result;
|
|
@@ -1533,9 +1612,11 @@
|
|
|
1533
1612
|
function ThrowStatement$1(node, scope) {
|
|
1534
1613
|
throw evaluate$1(node.argument, scope);
|
|
1535
1614
|
}
|
|
1536
|
-
function TryStatement$1(node, scope) {
|
|
1615
|
+
function TryStatement$1(node, scope, options) {
|
|
1616
|
+
if (options === void 0) { options = {}; }
|
|
1617
|
+
var result;
|
|
1537
1618
|
try {
|
|
1538
|
-
|
|
1619
|
+
result = BlockStatement$1(node.block, scope);
|
|
1539
1620
|
}
|
|
1540
1621
|
catch (err) {
|
|
1541
1622
|
if (node.handler) {
|
|
@@ -1550,7 +1631,7 @@
|
|
|
1550
1631
|
pattern(param, scope, { feed: err });
|
|
1551
1632
|
}
|
|
1552
1633
|
}
|
|
1553
|
-
|
|
1634
|
+
result = CatchClause$1(node.handler, subScope);
|
|
1554
1635
|
}
|
|
1555
1636
|
else {
|
|
1556
1637
|
throw err;
|
|
@@ -1558,45 +1639,66 @@
|
|
|
1558
1639
|
}
|
|
1559
1640
|
finally {
|
|
1560
1641
|
if (node.finalizer) {
|
|
1561
|
-
|
|
1562
|
-
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
1563
|
-
return result;
|
|
1564
|
-
}
|
|
1642
|
+
result = BlockStatement$1(node.finalizer, scope);
|
|
1565
1643
|
}
|
|
1566
1644
|
}
|
|
1645
|
+
if (result === BREAK) {
|
|
1646
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
return result;
|
|
1650
|
+
}
|
|
1651
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1652
|
+
return result;
|
|
1653
|
+
}
|
|
1567
1654
|
}
|
|
1568
1655
|
function CatchClause$1(node, scope) {
|
|
1569
1656
|
return BlockStatement$1(node.body, scope, { invasived: true });
|
|
1570
1657
|
}
|
|
1571
|
-
function WhileStatement$1(node, scope) {
|
|
1658
|
+
function WhileStatement$1(node, scope, options) {
|
|
1659
|
+
if (options === void 0) { options = {}; }
|
|
1572
1660
|
while (evaluate$1(node.test, scope)) {
|
|
1573
1661
|
var result = evaluate$1(node.body, scope);
|
|
1574
1662
|
if (result === BREAK) {
|
|
1575
|
-
|
|
1663
|
+
if (result.LABEL === options.label) {
|
|
1664
|
+
break;
|
|
1665
|
+
}
|
|
1666
|
+
return result;
|
|
1576
1667
|
}
|
|
1577
1668
|
else if (result === CONTINUE) {
|
|
1578
|
-
|
|
1669
|
+
if (result.LABEL === options.label) {
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
return result;
|
|
1579
1673
|
}
|
|
1580
1674
|
else if (result === RETURN) {
|
|
1581
1675
|
return result;
|
|
1582
1676
|
}
|
|
1583
1677
|
}
|
|
1584
1678
|
}
|
|
1585
|
-
function DoWhileStatement$1(node, scope) {
|
|
1679
|
+
function DoWhileStatement$1(node, scope, options) {
|
|
1680
|
+
if (options === void 0) { options = {}; }
|
|
1586
1681
|
do {
|
|
1587
1682
|
var result = evaluate$1(node.body, scope);
|
|
1588
1683
|
if (result === BREAK) {
|
|
1589
|
-
|
|
1684
|
+
if (result.LABEL === options.label) {
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
return result;
|
|
1590
1688
|
}
|
|
1591
1689
|
else if (result === CONTINUE) {
|
|
1592
|
-
|
|
1690
|
+
if (result.LABEL === options.label) {
|
|
1691
|
+
continue;
|
|
1692
|
+
}
|
|
1693
|
+
return result;
|
|
1593
1694
|
}
|
|
1594
1695
|
else if (result === RETURN) {
|
|
1595
1696
|
return result;
|
|
1596
1697
|
}
|
|
1597
1698
|
} while (evaluate$1(node.test, scope));
|
|
1598
1699
|
}
|
|
1599
|
-
function ForStatement$1(node, scope) {
|
|
1700
|
+
function ForStatement$1(node, scope, options) {
|
|
1701
|
+
if (options === void 0) { options = {}; }
|
|
1600
1702
|
var forScope = new Scope(scope);
|
|
1601
1703
|
for (evaluate$1(node.init, forScope); node.test ? (evaluate$1(node.test, forScope)) : true; evaluate$1(node.update, forScope)) {
|
|
1602
1704
|
var subScope = new Scope(forScope);
|
|
@@ -1608,42 +1710,62 @@
|
|
|
1608
1710
|
result = evaluate$1(node.body, subScope);
|
|
1609
1711
|
}
|
|
1610
1712
|
if (result === BREAK) {
|
|
1611
|
-
|
|
1713
|
+
if (result.LABEL === options.label) {
|
|
1714
|
+
break;
|
|
1715
|
+
}
|
|
1716
|
+
return result;
|
|
1612
1717
|
}
|
|
1613
1718
|
else if (result === CONTINUE) {
|
|
1614
|
-
|
|
1719
|
+
if (result.LABEL === options.label) {
|
|
1720
|
+
continue;
|
|
1721
|
+
}
|
|
1722
|
+
return result;
|
|
1615
1723
|
}
|
|
1616
1724
|
else if (result === RETURN) {
|
|
1617
1725
|
return result;
|
|
1618
1726
|
}
|
|
1619
1727
|
}
|
|
1620
1728
|
}
|
|
1621
|
-
function ForInStatement$1(node, scope) {
|
|
1729
|
+
function ForInStatement$1(node, scope, options) {
|
|
1730
|
+
if (options === void 0) { options = {}; }
|
|
1622
1731
|
for (var value in evaluate$1(node.right, scope)) {
|
|
1623
1732
|
var result = ForXHandler(node, scope, { value: value });
|
|
1624
1733
|
if (result === BREAK) {
|
|
1625
|
-
|
|
1734
|
+
if (result.LABEL === options.label) {
|
|
1735
|
+
break;
|
|
1736
|
+
}
|
|
1737
|
+
return result;
|
|
1626
1738
|
}
|
|
1627
1739
|
else if (result === CONTINUE) {
|
|
1628
|
-
|
|
1740
|
+
if (result.LABEL === options.label) {
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
return result;
|
|
1629
1744
|
}
|
|
1630
1745
|
else if (result === RETURN) {
|
|
1631
1746
|
return result;
|
|
1632
1747
|
}
|
|
1633
1748
|
}
|
|
1634
1749
|
}
|
|
1635
|
-
function ForOfStatement$1(node, scope) {
|
|
1750
|
+
function ForOfStatement$1(node, scope, options) {
|
|
1636
1751
|
var e_1, _a;
|
|
1752
|
+
if (options === void 0) { options = {}; }
|
|
1637
1753
|
var right = evaluate$1(node.right, scope);
|
|
1638
1754
|
try {
|
|
1639
1755
|
for (var right_1 = __values(right), right_1_1 = right_1.next(); !right_1_1.done; right_1_1 = right_1.next()) {
|
|
1640
1756
|
var value = right_1_1.value;
|
|
1641
1757
|
var result = ForXHandler(node, scope, { value: value });
|
|
1642
1758
|
if (result === BREAK) {
|
|
1643
|
-
|
|
1759
|
+
if (result.LABEL === options.label) {
|
|
1760
|
+
break;
|
|
1761
|
+
}
|
|
1762
|
+
return result;
|
|
1644
1763
|
}
|
|
1645
1764
|
else if (result === CONTINUE) {
|
|
1646
|
-
|
|
1765
|
+
if (result.LABEL === options.label) {
|
|
1766
|
+
continue;
|
|
1767
|
+
}
|
|
1768
|
+
return result;
|
|
1647
1769
|
}
|
|
1648
1770
|
else if (result === RETURN) {
|
|
1649
1771
|
return result;
|
|
@@ -3171,7 +3293,13 @@
|
|
|
3171
3293
|
return [5, __values(evaluate(block.body[i], subScope))];
|
|
3172
3294
|
case 4:
|
|
3173
3295
|
result = _c.sent();
|
|
3174
|
-
if (result === BREAK
|
|
3296
|
+
if (result === BREAK) {
|
|
3297
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3298
|
+
return [3, 6];
|
|
3299
|
+
}
|
|
3300
|
+
return [2, result];
|
|
3301
|
+
}
|
|
3302
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3175
3303
|
return [2, result];
|
|
3176
3304
|
}
|
|
3177
3305
|
_c.label = 5;
|
|
@@ -3213,31 +3341,130 @@
|
|
|
3213
3341
|
}
|
|
3214
3342
|
});
|
|
3215
3343
|
}
|
|
3216
|
-
function BreakStatement() {
|
|
3217
|
-
|
|
3344
|
+
function BreakStatement(node) {
|
|
3345
|
+
var _a;
|
|
3346
|
+
return __generator(this, function (_b) {
|
|
3347
|
+
BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
3218
3348
|
return [2, BREAK];
|
|
3219
3349
|
});
|
|
3220
3350
|
}
|
|
3221
|
-
function ContinueStatement() {
|
|
3222
|
-
|
|
3351
|
+
function ContinueStatement(node) {
|
|
3352
|
+
var _a;
|
|
3353
|
+
return __generator(this, function (_b) {
|
|
3354
|
+
CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
3223
3355
|
return [2, CONTINUE];
|
|
3224
3356
|
});
|
|
3225
3357
|
}
|
|
3226
|
-
function
|
|
3358
|
+
function LabeledStatement(node, scope) {
|
|
3359
|
+
var label;
|
|
3227
3360
|
return __generator(this, function (_a) {
|
|
3228
3361
|
switch (_a.label) {
|
|
3229
|
-
case 0:
|
|
3362
|
+
case 0:
|
|
3363
|
+
label = node.label.name;
|
|
3364
|
+
if (!(node.body.type === 'WhileStatement')) return [3, 2];
|
|
3365
|
+
return [5, __values(WhileStatement(node.body, scope, { label: label }))];
|
|
3366
|
+
case 1: return [2, _a.sent()];
|
|
3367
|
+
case 2:
|
|
3368
|
+
if (!(node.body.type === 'DoWhileStatement')) return [3, 4];
|
|
3369
|
+
return [5, __values(DoWhileStatement(node.body, scope, { label: label }))];
|
|
3370
|
+
case 3: return [2, _a.sent()];
|
|
3371
|
+
case 4:
|
|
3372
|
+
if (!(node.body.type === 'ForStatement')) return [3, 6];
|
|
3373
|
+
return [5, __values(ForStatement(node.body, scope, { label: label }))];
|
|
3374
|
+
case 5: return [2, _a.sent()];
|
|
3375
|
+
case 6:
|
|
3376
|
+
if (!(node.body.type === 'ForInStatement')) return [3, 8];
|
|
3377
|
+
return [5, __values(ForInStatement(node.body, scope, { label: label }))];
|
|
3378
|
+
case 7: return [2, _a.sent()];
|
|
3379
|
+
case 8:
|
|
3380
|
+
if (!(node.body.type === 'ForOfStatement')) return [3, 10];
|
|
3381
|
+
return [5, __values(ForOfStatement(node.body, scope, { label: label }))];
|
|
3382
|
+
case 9: return [2, _a.sent()];
|
|
3383
|
+
case 10:
|
|
3384
|
+
if (!(node.body.type === 'BlockStatement')) return [3, 12];
|
|
3385
|
+
return [5, __values(BlockStatement(node.body, scope, { label: label }))];
|
|
3386
|
+
case 11: return [2, _a.sent()];
|
|
3387
|
+
case 12:
|
|
3388
|
+
if (!(node.body.type === 'WithStatement')) return [3, 14];
|
|
3389
|
+
return [5, __values(WithStatement(node.body, scope, { label: label }))];
|
|
3390
|
+
case 13: return [2, _a.sent()];
|
|
3391
|
+
case 14:
|
|
3392
|
+
if (!(node.body.type === 'IfStatement')) return [3, 16];
|
|
3393
|
+
return [5, __values(IfStatement(node.body, scope, { label: label }))];
|
|
3394
|
+
case 15: return [2, _a.sent()];
|
|
3395
|
+
case 16:
|
|
3396
|
+
if (!(node.body.type === 'SwitchStatement')) return [3, 18];
|
|
3397
|
+
return [5, __values(SwitchStatement(node.body, scope, { label: label }))];
|
|
3398
|
+
case 17: return [2, _a.sent()];
|
|
3399
|
+
case 18:
|
|
3400
|
+
if (!(node.body.type === 'TryStatement')) return [3, 20];
|
|
3401
|
+
return [5, __values(TryStatement(node.body, scope, { label: label }))];
|
|
3402
|
+
case 19: return [2, _a.sent()];
|
|
3403
|
+
case 20: throw new SyntaxError(node.body.type + " cannot be labeled");
|
|
3404
|
+
}
|
|
3405
|
+
});
|
|
3406
|
+
}
|
|
3407
|
+
function WithStatement(node, scope, options) {
|
|
3408
|
+
var withScope, _a, _b, result;
|
|
3409
|
+
if (options === void 0) { options = {}; }
|
|
3410
|
+
return __generator(this, function (_c) {
|
|
3411
|
+
switch (_c.label) {
|
|
3412
|
+
case 0:
|
|
3413
|
+
withScope = new Scope(scope);
|
|
3414
|
+
_b = (_a = withScope).with;
|
|
3415
|
+
return [5, __values(evaluate(node.object, scope))];
|
|
3230
3416
|
case 1:
|
|
3231
|
-
|
|
3417
|
+
_b.apply(_a, [_c.sent()]);
|
|
3418
|
+
return [5, __values(evaluate(node.body, withScope))];
|
|
3419
|
+
case 2:
|
|
3420
|
+
result = _c.sent();
|
|
3421
|
+
if (result === BREAK) {
|
|
3422
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3423
|
+
return [2];
|
|
3424
|
+
}
|
|
3425
|
+
return [2, result];
|
|
3426
|
+
}
|
|
3427
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3428
|
+
return [2, result];
|
|
3429
|
+
}
|
|
3430
|
+
return [2];
|
|
3431
|
+
}
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
function IfStatement(node, scope, options) {
|
|
3435
|
+
var result, _a;
|
|
3436
|
+
if (options === void 0) { options = {}; }
|
|
3437
|
+
return __generator(this, function (_b) {
|
|
3438
|
+
switch (_b.label) {
|
|
3439
|
+
case 0:
|
|
3440
|
+
if (!evaluate(node.test, scope)) return [3, 2];
|
|
3232
3441
|
return [5, __values(evaluate(node.consequent, scope))];
|
|
3233
|
-
case
|
|
3234
|
-
|
|
3235
|
-
|
|
3442
|
+
case 1:
|
|
3443
|
+
_a = _b.sent();
|
|
3444
|
+
return [3, 4];
|
|
3445
|
+
case 2: return [5, __values(evaluate(node.alternate, scope))];
|
|
3446
|
+
case 3:
|
|
3447
|
+
_a = _b.sent();
|
|
3448
|
+
_b.label = 4;
|
|
3449
|
+
case 4: return [5, __values(_a)];
|
|
3450
|
+
case 5:
|
|
3451
|
+
result = _b.sent();
|
|
3452
|
+
if (result === BREAK) {
|
|
3453
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3454
|
+
return [2];
|
|
3455
|
+
}
|
|
3456
|
+
return [2, result];
|
|
3457
|
+
}
|
|
3458
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3459
|
+
return [2, result];
|
|
3460
|
+
}
|
|
3461
|
+
return [2];
|
|
3236
3462
|
}
|
|
3237
3463
|
});
|
|
3238
3464
|
}
|
|
3239
|
-
function SwitchStatement(node, scope) {
|
|
3465
|
+
function SwitchStatement(node, scope, options) {
|
|
3240
3466
|
var discriminant, matched, i, eachCase, _a, _b, result;
|
|
3467
|
+
if (options === void 0) { options = {}; }
|
|
3241
3468
|
return __generator(this, function (_c) {
|
|
3242
3469
|
switch (_c.label) {
|
|
3243
3470
|
case 0: return [5, __values(evaluate(node.discriminant, scope))];
|
|
@@ -3269,7 +3496,10 @@
|
|
|
3269
3496
|
case 6:
|
|
3270
3497
|
result = _c.sent();
|
|
3271
3498
|
if (result === BREAK) {
|
|
3272
|
-
|
|
3499
|
+
if (result.LABEL === options.label) {
|
|
3500
|
+
return [3, 8];
|
|
3501
|
+
}
|
|
3502
|
+
return [2, result];
|
|
3273
3503
|
}
|
|
3274
3504
|
if (result === CONTINUE || result === RETURN) {
|
|
3275
3505
|
return [2, result];
|
|
@@ -3313,14 +3543,17 @@
|
|
|
3313
3543
|
}
|
|
3314
3544
|
});
|
|
3315
3545
|
}
|
|
3316
|
-
function TryStatement(node, scope) {
|
|
3317
|
-
var err_1, subScope, param, name_1
|
|
3546
|
+
function TryStatement(node, scope, options) {
|
|
3547
|
+
var result, err_1, subScope, param, name_1;
|
|
3548
|
+
if (options === void 0) { options = {}; }
|
|
3318
3549
|
return __generator(this, function (_a) {
|
|
3319
3550
|
switch (_a.label) {
|
|
3320
3551
|
case 0:
|
|
3321
3552
|
_a.trys.push([0, 2, 9, 12]);
|
|
3322
3553
|
return [5, __values(BlockStatement(node.block, scope))];
|
|
3323
|
-
case 1:
|
|
3554
|
+
case 1:
|
|
3555
|
+
result = _a.sent();
|
|
3556
|
+
return [3, 12];
|
|
3324
3557
|
case 2:
|
|
3325
3558
|
err_1 = _a.sent();
|
|
3326
3559
|
if (!node.handler) return [3, 7];
|
|
@@ -3336,7 +3569,9 @@
|
|
|
3336
3569
|
_a.sent();
|
|
3337
3570
|
_a.label = 5;
|
|
3338
3571
|
case 5: return [5, __values(CatchClause(node.handler, subScope))];
|
|
3339
|
-
case 6:
|
|
3572
|
+
case 6:
|
|
3573
|
+
result = _a.sent();
|
|
3574
|
+
return [3, 8];
|
|
3340
3575
|
case 7: throw err_1;
|
|
3341
3576
|
case 8: return [3, 12];
|
|
3342
3577
|
case 9:
|
|
@@ -3344,12 +3579,19 @@
|
|
|
3344
3579
|
return [5, __values(BlockStatement(node.finalizer, scope))];
|
|
3345
3580
|
case 10:
|
|
3346
3581
|
result = _a.sent();
|
|
3347
|
-
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
3348
|
-
return [2, result];
|
|
3349
|
-
}
|
|
3350
3582
|
_a.label = 11;
|
|
3351
3583
|
case 11: return [7];
|
|
3352
|
-
case 12:
|
|
3584
|
+
case 12:
|
|
3585
|
+
if (result === BREAK) {
|
|
3586
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3587
|
+
return [2];
|
|
3588
|
+
}
|
|
3589
|
+
return [2, result];
|
|
3590
|
+
}
|
|
3591
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3592
|
+
return [2, result];
|
|
3593
|
+
}
|
|
3594
|
+
return [2];
|
|
3353
3595
|
}
|
|
3354
3596
|
});
|
|
3355
3597
|
}
|
|
@@ -3361,8 +3603,9 @@
|
|
|
3361
3603
|
}
|
|
3362
3604
|
});
|
|
3363
3605
|
}
|
|
3364
|
-
function WhileStatement(node, scope) {
|
|
3606
|
+
function WhileStatement(node, scope, options) {
|
|
3365
3607
|
var result;
|
|
3608
|
+
if (options === void 0) { options = {}; }
|
|
3366
3609
|
return __generator(this, function (_a) {
|
|
3367
3610
|
switch (_a.label) {
|
|
3368
3611
|
case 0: return [5, __values(evaluate(node.test, scope))];
|
|
@@ -3372,10 +3615,16 @@
|
|
|
3372
3615
|
case 2:
|
|
3373
3616
|
result = _a.sent();
|
|
3374
3617
|
if (result === BREAK) {
|
|
3375
|
-
|
|
3618
|
+
if (result.LABEL === options.label) {
|
|
3619
|
+
return [3, 3];
|
|
3620
|
+
}
|
|
3621
|
+
return [2, result];
|
|
3376
3622
|
}
|
|
3377
3623
|
else if (result === CONTINUE) {
|
|
3378
|
-
|
|
3624
|
+
if (result.LABEL === options.label) {
|
|
3625
|
+
return [3, 0];
|
|
3626
|
+
}
|
|
3627
|
+
return [2, result];
|
|
3379
3628
|
}
|
|
3380
3629
|
else if (result === RETURN) {
|
|
3381
3630
|
return [2, result];
|
|
@@ -3385,18 +3634,25 @@
|
|
|
3385
3634
|
}
|
|
3386
3635
|
});
|
|
3387
3636
|
}
|
|
3388
|
-
function DoWhileStatement(node, scope) {
|
|
3637
|
+
function DoWhileStatement(node, scope, options) {
|
|
3389
3638
|
var result;
|
|
3639
|
+
if (options === void 0) { options = {}; }
|
|
3390
3640
|
return __generator(this, function (_a) {
|
|
3391
3641
|
switch (_a.label) {
|
|
3392
3642
|
case 0: return [5, __values(evaluate(node.body, scope))];
|
|
3393
3643
|
case 1:
|
|
3394
3644
|
result = _a.sent();
|
|
3395
3645
|
if (result === BREAK) {
|
|
3396
|
-
|
|
3646
|
+
if (result.LABEL === options.label) {
|
|
3647
|
+
return [3, 4];
|
|
3648
|
+
}
|
|
3649
|
+
return [2, result];
|
|
3397
3650
|
}
|
|
3398
3651
|
else if (result === CONTINUE) {
|
|
3399
|
-
|
|
3652
|
+
if (result.LABEL === options.label) {
|
|
3653
|
+
return [3, 2];
|
|
3654
|
+
}
|
|
3655
|
+
return [2, result];
|
|
3400
3656
|
}
|
|
3401
3657
|
else if (result === RETURN) {
|
|
3402
3658
|
return [2, result];
|
|
@@ -3410,8 +3666,9 @@
|
|
|
3410
3666
|
}
|
|
3411
3667
|
});
|
|
3412
3668
|
}
|
|
3413
|
-
function ForStatement(node, scope) {
|
|
3669
|
+
function ForStatement(node, scope, options) {
|
|
3414
3670
|
var forScope, _a, subScope, result;
|
|
3671
|
+
if (options === void 0) { options = {}; }
|
|
3415
3672
|
return __generator(this, function (_b) {
|
|
3416
3673
|
switch (_b.label) {
|
|
3417
3674
|
case 0:
|
|
@@ -3444,10 +3701,16 @@
|
|
|
3444
3701
|
_b.label = 9;
|
|
3445
3702
|
case 9:
|
|
3446
3703
|
if (result === BREAK) {
|
|
3447
|
-
|
|
3704
|
+
if (result.LABEL === options.label) {
|
|
3705
|
+
return [3, 12];
|
|
3706
|
+
}
|
|
3707
|
+
return [2, result];
|
|
3448
3708
|
}
|
|
3449
3709
|
else if (result === CONTINUE) {
|
|
3450
|
-
|
|
3710
|
+
if (result.LABEL === options.label) {
|
|
3711
|
+
return [3, 10];
|
|
3712
|
+
}
|
|
3713
|
+
return [2, result];
|
|
3451
3714
|
}
|
|
3452
3715
|
else if (result === RETURN) {
|
|
3453
3716
|
return [2, result];
|
|
@@ -3461,8 +3724,9 @@
|
|
|
3461
3724
|
}
|
|
3462
3725
|
});
|
|
3463
3726
|
}
|
|
3464
|
-
function ForInStatement(node, scope) {
|
|
3727
|
+
function ForInStatement(node, scope, options) {
|
|
3465
3728
|
var _a, _b, _i, value, result;
|
|
3729
|
+
if (options === void 0) { options = {}; }
|
|
3466
3730
|
return __generator(this, function (_c) {
|
|
3467
3731
|
switch (_c.label) {
|
|
3468
3732
|
case 0:
|
|
@@ -3480,10 +3744,16 @@
|
|
|
3480
3744
|
case 3:
|
|
3481
3745
|
result = _c.sent();
|
|
3482
3746
|
if (result === BREAK) {
|
|
3483
|
-
|
|
3747
|
+
if (result.LABEL === options.label) {
|
|
3748
|
+
return [3, 5];
|
|
3749
|
+
}
|
|
3750
|
+
return [2, result];
|
|
3484
3751
|
}
|
|
3485
3752
|
else if (result === CONTINUE) {
|
|
3486
|
-
|
|
3753
|
+
if (result.LABEL === options.label) {
|
|
3754
|
+
return [3, 4];
|
|
3755
|
+
}
|
|
3756
|
+
return [2, result];
|
|
3487
3757
|
}
|
|
3488
3758
|
else if (result === RETURN) {
|
|
3489
3759
|
return [2, result];
|
|
@@ -3496,9 +3766,10 @@
|
|
|
3496
3766
|
}
|
|
3497
3767
|
});
|
|
3498
3768
|
}
|
|
3499
|
-
function ForOfStatement(node, scope) {
|
|
3769
|
+
function ForOfStatement(node, scope, options) {
|
|
3500
3770
|
var right, iterator, ret, result, right_1, right_1_1, value, result, e_1_1;
|
|
3501
3771
|
var e_1, _a;
|
|
3772
|
+
if (options === void 0) { options = {}; }
|
|
3502
3773
|
return __generator(this, function (_b) {
|
|
3503
3774
|
switch (_b.label) {
|
|
3504
3775
|
case 0: return [5, __values(evaluate(node.right, scope))];
|
|
@@ -3518,10 +3789,16 @@
|
|
|
3518
3789
|
case 4:
|
|
3519
3790
|
result = _b.sent();
|
|
3520
3791
|
if (result === BREAK) {
|
|
3521
|
-
|
|
3792
|
+
if (result.LABEL === options.label) {
|
|
3793
|
+
return [3, 7];
|
|
3794
|
+
}
|
|
3795
|
+
return [2, result];
|
|
3522
3796
|
}
|
|
3523
3797
|
else if (result === CONTINUE) {
|
|
3524
|
-
|
|
3798
|
+
if (result.LABEL === options.label) {
|
|
3799
|
+
return [3, 5];
|
|
3800
|
+
}
|
|
3801
|
+
return [2, result];
|
|
3525
3802
|
}
|
|
3526
3803
|
else if (result === RETURN) {
|
|
3527
3804
|
return [2, result];
|
|
@@ -3545,10 +3822,16 @@
|
|
|
3545
3822
|
case 10:
|
|
3546
3823
|
result = _b.sent();
|
|
3547
3824
|
if (result === BREAK) {
|
|
3548
|
-
|
|
3825
|
+
if (result.LABEL === options.label) {
|
|
3826
|
+
return [3, 12];
|
|
3827
|
+
}
|
|
3828
|
+
return [2, result];
|
|
3549
3829
|
}
|
|
3550
3830
|
else if (result === CONTINUE) {
|
|
3551
|
-
|
|
3831
|
+
if (result.LABEL === options.label) {
|
|
3832
|
+
return [3, 11];
|
|
3833
|
+
}
|
|
3834
|
+
return [2, result];
|
|
3552
3835
|
}
|
|
3553
3836
|
else if (result === RETURN) {
|
|
3554
3837
|
return [2, result];
|
|
@@ -4261,15 +4544,16 @@
|
|
|
4261
4544
|
});
|
|
4262
4545
|
}
|
|
4263
4546
|
function createFunc$1(node, scope, options) {
|
|
4547
|
+
var _a;
|
|
4264
4548
|
if (options === void 0) { options = {}; }
|
|
4265
4549
|
if (!node.generator && !node.async) {
|
|
4266
4550
|
return createFunc(node, scope, options);
|
|
4267
4551
|
}
|
|
4268
4552
|
var superClass = options.superClass, construct = options.construct;
|
|
4269
4553
|
var params = node.params;
|
|
4270
|
-
var tmpFunc = function
|
|
4554
|
+
var tmpFunc = function _b() {
|
|
4271
4555
|
var _i, subScope, i, param, result;
|
|
4272
|
-
var _newTarget = this && this instanceof
|
|
4556
|
+
var _newTarget = this && this instanceof _b ? this.constructor : void 0;
|
|
4273
4557
|
var args = [];
|
|
4274
4558
|
for (_i = 0; _i < arguments.length; _i++) {
|
|
4275
4559
|
args[_i] = arguments[_i];
|
|
@@ -4388,6 +4672,13 @@
|
|
|
4388
4672
|
value: params.length,
|
|
4389
4673
|
configurable: true
|
|
4390
4674
|
});
|
|
4675
|
+
var source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
|
|
4676
|
+
if (source) {
|
|
4677
|
+
define(func, 'toString', {
|
|
4678
|
+
value: function () { return source.substring(node.start, node.end); },
|
|
4679
|
+
configurable: true
|
|
4680
|
+
});
|
|
4681
|
+
}
|
|
4391
4682
|
return func;
|
|
4392
4683
|
}
|
|
4393
4684
|
function createClass$1(node, scope) {
|
|
@@ -4593,14 +4884,15 @@
|
|
|
4593
4884
|
}
|
|
4594
4885
|
}
|
|
4595
4886
|
function createFunc(node, scope, options) {
|
|
4887
|
+
var _a;
|
|
4596
4888
|
if (options === void 0) { options = {}; }
|
|
4597
4889
|
if (node.generator || node.async) {
|
|
4598
4890
|
return createFunc$1(node, scope, options);
|
|
4599
4891
|
}
|
|
4600
4892
|
var superClass = options.superClass, construct = options.construct;
|
|
4601
4893
|
var params = node.params;
|
|
4602
|
-
var tmpFunc = function
|
|
4603
|
-
var _newTarget = this && this instanceof
|
|
4894
|
+
var tmpFunc = function _b() {
|
|
4895
|
+
var _newTarget = this && this instanceof _b ? this.constructor : void 0;
|
|
4604
4896
|
var args = [];
|
|
4605
4897
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
4606
4898
|
args[_i] = arguments[_i];
|
|
@@ -4664,6 +4956,13 @@
|
|
|
4664
4956
|
value: params.length,
|
|
4665
4957
|
configurable: true
|
|
4666
4958
|
});
|
|
4959
|
+
var source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
|
|
4960
|
+
if (source) {
|
|
4961
|
+
define(func, 'toString', {
|
|
4962
|
+
value: function () { return source.substring(node.start, node.end); },
|
|
4963
|
+
configurable: true
|
|
4964
|
+
});
|
|
4965
|
+
}
|
|
4667
4966
|
return func;
|
|
4668
4967
|
}
|
|
4669
4968
|
function createClass(node, scope) {
|