sval 0.5.3 → 0.5.5

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.es6.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
  }
@@ -443,8 +451,8 @@
443
451
 
444
452
  const AWAIT = { RES: undefined };
445
453
  const RETURN = { RES: undefined };
446
- const CONTINUE = createSymbol('continue');
447
- const BREAK = createSymbol('break');
454
+ const CONTINUE = { LABEL: undefined };
455
+ const BREAK = { LABEL: undefined };
448
456
  const SUPER = createSymbol('super');
449
457
  const SUPERCALL = createSymbol('supercall');
450
458
  const NOCTOR = createSymbol('noctor');
@@ -456,7 +464,7 @@
456
464
  const IMPORT = createSymbol('import');
457
465
  const EXPORTS = createSymbol('exports');
458
466
 
459
- var version = "0.5.3";
467
+ var version = "0.5.5";
460
468
 
461
469
  class Var {
462
470
  constructor(kind, value) {
@@ -495,6 +503,7 @@
495
503
  class Scope {
496
504
  constructor(parent = null, isolated = false) {
497
505
  this.context = create(null);
506
+ this.withContext = create(null);
498
507
  this.parent = parent;
499
508
  this.isolated = isolated;
500
509
  }
@@ -505,18 +514,13 @@
505
514
  }
506
515
  return scope;
507
516
  }
508
- clone() {
509
- const cloneScope = new Scope(this.parent, this.isolated);
510
- for (const name in this.context) {
511
- const variable = this.context[name];
512
- cloneScope[variable.kind](name, variable.get());
513
- }
514
- return cloneScope;
515
- }
516
517
  find(name) {
517
518
  if (this.context[name]) {
518
519
  return this.context[name];
519
520
  }
521
+ else if (name in this.withContext) {
522
+ return new Prop(this.withContext, name);
523
+ }
520
524
  else if (this.parent) {
521
525
  return this.parent.find(name);
522
526
  }
@@ -583,6 +587,11 @@
583
587
  throw new SyntaxError(`Identifier '${name}' has already been declared`);
584
588
  }
585
589
  }
590
+ with(value) {
591
+ if (Object.keys(value)) {
592
+ this.withContext = value;
593
+ }
594
+ }
586
595
  }
587
596
 
588
597
  function Identifier$1(node, scope, options = {}) {
@@ -1382,7 +1391,13 @@
1382
1391
  }
1383
1392
  for (let i = 0; i < block.body.length; i++) {
1384
1393
  const result = evaluate$1(block.body[i], subScope);
1385
- if (result === BREAK || result === CONTINUE || result === RETURN) {
1394
+ if (result === BREAK) {
1395
+ if (result.LABEL && result.LABEL === options.label) {
1396
+ break;
1397
+ }
1398
+ return result;
1399
+ }
1400
+ if (result === CONTINUE || result === RETURN) {
1386
1401
  return result;
1387
1402
  }
1388
1403
  }
@@ -1396,21 +1411,83 @@
1396
1411
  RETURN.RES = node.argument ? (evaluate$1(node.argument, scope)) : undefined;
1397
1412
  return RETURN;
1398
1413
  }
1399
- function BreakStatement$1() {
1414
+ function BreakStatement$1(node) {
1415
+ var _a;
1416
+ BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
1400
1417
  return BREAK;
1401
1418
  }
1402
- function ContinueStatement$1() {
1419
+ function ContinueStatement$1(node) {
1420
+ var _a;
1421
+ CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
1403
1422
  return CONTINUE;
1404
1423
  }
1405
- function IfStatement$1(node, scope) {
1424
+ function LabeledStatement$1(node, scope) {
1425
+ const label = node.label.name;
1426
+ if (node.body.type === 'WhileStatement') {
1427
+ return WhileStatement$1(node.body, scope, { label });
1428
+ }
1429
+ if (node.body.type === 'DoWhileStatement') {
1430
+ return DoWhileStatement$1(node.body, scope, { label });
1431
+ }
1432
+ if (node.body.type === 'ForStatement') {
1433
+ return ForStatement$1(node.body, scope, { label });
1434
+ }
1435
+ if (node.body.type === 'ForInStatement') {
1436
+ return ForInStatement$1(node.body, scope, { label });
1437
+ }
1438
+ if (node.body.type === 'ForOfStatement') {
1439
+ return ForOfStatement$1(node.body, scope, { label });
1440
+ }
1441
+ if (node.body.type === 'BlockStatement') {
1442
+ return BlockStatement$1(node.body, scope, { label });
1443
+ }
1444
+ if (node.body.type === 'WithStatement') {
1445
+ return WithStatement$1(node.body, scope, { label });
1446
+ }
1447
+ if (node.body.type === 'IfStatement') {
1448
+ return IfStatement$1(node.body, scope, { label });
1449
+ }
1450
+ if (node.body.type === 'SwitchStatement') {
1451
+ return SwitchStatement$1(node.body, scope, { label });
1452
+ }
1453
+ if (node.body.type === 'TryStatement') {
1454
+ return TryStatement$1(node.body, scope, { label });
1455
+ }
1456
+ throw new SyntaxError(`${node.body.type} cannot be labeled`);
1457
+ }
1458
+ function WithStatement$1(node, scope, options = {}) {
1459
+ const withScope = new Scope(scope);
1460
+ withScope.with(evaluate$1(node.object, scope));
1461
+ const result = evaluate$1(node.body, withScope);
1462
+ if (result === BREAK) {
1463
+ if (result.LABEL && result.LABEL === options.label) {
1464
+ return;
1465
+ }
1466
+ return result;
1467
+ }
1468
+ if (result === CONTINUE || result === RETURN) {
1469
+ return result;
1470
+ }
1471
+ }
1472
+ function IfStatement$1(node, scope, options = {}) {
1473
+ let result;
1406
1474
  if (evaluate$1(node.test, scope)) {
1407
- return evaluate$1(node.consequent, scope);
1475
+ result = evaluate$1(node.consequent, scope);
1408
1476
  }
1409
1477
  else {
1410
- return evaluate$1(node.alternate, scope);
1478
+ result = evaluate$1(node.alternate, scope);
1479
+ }
1480
+ if (result === BREAK) {
1481
+ if (result.LABEL && result.LABEL === options.label) {
1482
+ return;
1483
+ }
1484
+ return result;
1485
+ }
1486
+ if (result === CONTINUE || result === RETURN) {
1487
+ return result;
1411
1488
  }
1412
1489
  }
1413
- function SwitchStatement$1(node, scope) {
1490
+ function SwitchStatement$1(node, scope, options = {}) {
1414
1491
  const discriminant = evaluate$1(node.discriminant, scope);
1415
1492
  let matched = false;
1416
1493
  for (let i = 0; i < node.cases.length; i++) {
@@ -1423,7 +1500,10 @@
1423
1500
  if (matched) {
1424
1501
  const result = SwitchCase$1(eachCase, scope);
1425
1502
  if (result === BREAK) {
1426
- break;
1503
+ if (result.LABEL === options.label) {
1504
+ break;
1505
+ }
1506
+ return result;
1427
1507
  }
1428
1508
  if (result === CONTINUE || result === RETURN) {
1429
1509
  return result;
@@ -1442,9 +1522,10 @@
1442
1522
  function ThrowStatement$1(node, scope) {
1443
1523
  throw evaluate$1(node.argument, scope);
1444
1524
  }
1445
- function TryStatement$1(node, scope) {
1525
+ function TryStatement$1(node, scope, options = {}) {
1526
+ let result;
1446
1527
  try {
1447
- return BlockStatement$1(node.block, scope);
1528
+ result = BlockStatement$1(node.block, scope);
1448
1529
  }
1449
1530
  catch (err) {
1450
1531
  if (node.handler) {
@@ -1459,7 +1540,7 @@
1459
1540
  pattern(param, scope, { feed: err });
1460
1541
  }
1461
1542
  }
1462
- return CatchClause$1(node.handler, subScope);
1543
+ result = CatchClause$1(node.handler, subScope);
1463
1544
  }
1464
1545
  else {
1465
1546
  throw err;
@@ -1467,45 +1548,63 @@
1467
1548
  }
1468
1549
  finally {
1469
1550
  if (node.finalizer) {
1470
- const result = BlockStatement$1(node.finalizer, scope);
1471
- if (result === BREAK || result === CONTINUE || result === RETURN) {
1472
- return result;
1473
- }
1551
+ result = BlockStatement$1(node.finalizer, scope);
1552
+ }
1553
+ }
1554
+ if (result === BREAK) {
1555
+ if (result.LABEL && result.LABEL === options.label) {
1556
+ return;
1474
1557
  }
1558
+ return result;
1559
+ }
1560
+ if (result === CONTINUE || result === RETURN) {
1561
+ return result;
1475
1562
  }
1476
1563
  }
1477
1564
  function CatchClause$1(node, scope) {
1478
1565
  return BlockStatement$1(node.body, scope, { invasived: true });
1479
1566
  }
1480
- function WhileStatement$1(node, scope) {
1567
+ function WhileStatement$1(node, scope, options = {}) {
1481
1568
  while (evaluate$1(node.test, scope)) {
1482
1569
  const result = evaluate$1(node.body, scope);
1483
1570
  if (result === BREAK) {
1484
- break;
1571
+ if (result.LABEL === options.label) {
1572
+ break;
1573
+ }
1574
+ return result;
1485
1575
  }
1486
1576
  else if (result === CONTINUE) {
1487
- continue;
1577
+ if (result.LABEL === options.label) {
1578
+ continue;
1579
+ }
1580
+ return result;
1488
1581
  }
1489
1582
  else if (result === RETURN) {
1490
1583
  return result;
1491
1584
  }
1492
1585
  }
1493
1586
  }
1494
- function DoWhileStatement$1(node, scope) {
1587
+ function DoWhileStatement$1(node, scope, options = {}) {
1495
1588
  do {
1496
1589
  const result = evaluate$1(node.body, scope);
1497
1590
  if (result === BREAK) {
1498
- break;
1591
+ if (result.LABEL === options.label) {
1592
+ break;
1593
+ }
1594
+ return result;
1499
1595
  }
1500
1596
  else if (result === CONTINUE) {
1501
- continue;
1597
+ if (result.LABEL === options.label) {
1598
+ continue;
1599
+ }
1600
+ return result;
1502
1601
  }
1503
1602
  else if (result === RETURN) {
1504
1603
  return result;
1505
1604
  }
1506
1605
  } while (evaluate$1(node.test, scope));
1507
1606
  }
1508
- function ForStatement$1(node, scope) {
1607
+ function ForStatement$1(node, scope, options = {}) {
1509
1608
  const forScope = new Scope(scope);
1510
1609
  for (evaluate$1(node.init, forScope); node.test ? (evaluate$1(node.test, forScope)) : true; evaluate$1(node.update, forScope)) {
1511
1610
  const subScope = new Scope(forScope);
@@ -1517,39 +1616,57 @@
1517
1616
  result = evaluate$1(node.body, subScope);
1518
1617
  }
1519
1618
  if (result === BREAK) {
1520
- break;
1619
+ if (result.LABEL === options.label) {
1620
+ break;
1621
+ }
1622
+ return result;
1521
1623
  }
1522
1624
  else if (result === CONTINUE) {
1523
- continue;
1625
+ if (result.LABEL === options.label) {
1626
+ continue;
1627
+ }
1628
+ return result;
1524
1629
  }
1525
1630
  else if (result === RETURN) {
1526
1631
  return result;
1527
1632
  }
1528
1633
  }
1529
1634
  }
1530
- function ForInStatement$1(node, scope) {
1635
+ function ForInStatement$1(node, scope, options = {}) {
1531
1636
  for (const value in evaluate$1(node.right, scope)) {
1532
1637
  const result = ForXHandler(node, scope, { value });
1533
1638
  if (result === BREAK) {
1534
- break;
1639
+ if (result.LABEL === options.label) {
1640
+ break;
1641
+ }
1642
+ return result;
1535
1643
  }
1536
1644
  else if (result === CONTINUE) {
1537
- continue;
1645
+ if (result.LABEL === options.label) {
1646
+ continue;
1647
+ }
1648
+ return result;
1538
1649
  }
1539
1650
  else if (result === RETURN) {
1540
1651
  return result;
1541
1652
  }
1542
1653
  }
1543
1654
  }
1544
- function ForOfStatement$1(node, scope) {
1655
+ function ForOfStatement$1(node, scope, options = {}) {
1545
1656
  const right = evaluate$1(node.right, scope);
1546
1657
  for (const value of right) {
1547
1658
  const result = ForXHandler(node, scope, { value });
1548
1659
  if (result === BREAK) {
1549
- break;
1660
+ if (result.LABEL === options.label) {
1661
+ break;
1662
+ }
1663
+ return result;
1550
1664
  }
1551
1665
  else if (result === CONTINUE) {
1552
- continue;
1666
+ if (result.LABEL === options.label) {
1667
+ continue;
1668
+ }
1669
+ return result;
1553
1670
  }
1554
1671
  else if (result === RETURN) {
1555
1672
  return result;
@@ -2660,7 +2777,13 @@
2660
2777
  }
2661
2778
  for (let i = 0; i < block.body.length; i++) {
2662
2779
  const result = yield* evaluate(block.body[i], subScope);
2663
- if (result === BREAK || result === CONTINUE || result === RETURN) {
2780
+ if (result === BREAK) {
2781
+ if (result.LABEL && result.LABEL === options.label) {
2782
+ break;
2783
+ }
2784
+ return result;
2785
+ }
2786
+ if (result === CONTINUE || result === RETURN) {
2664
2787
  return result;
2665
2788
  }
2666
2789
  }
@@ -2674,21 +2797,83 @@
2674
2797
  RETURN.RES = node.argument ? (yield* evaluate(node.argument, scope)) : undefined;
2675
2798
  return RETURN;
2676
2799
  }
2677
- function* BreakStatement() {
2800
+ function* BreakStatement(node) {
2801
+ var _a;
2802
+ BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2678
2803
  return BREAK;
2679
2804
  }
2680
- function* ContinueStatement() {
2805
+ function* ContinueStatement(node) {
2806
+ var _a;
2807
+ CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2681
2808
  return CONTINUE;
2682
2809
  }
2683
- function* IfStatement(node, scope) {
2810
+ function* LabeledStatement(node, scope) {
2811
+ const label = node.label.name;
2812
+ if (node.body.type === 'WhileStatement') {
2813
+ return yield* WhileStatement(node.body, scope, { label });
2814
+ }
2815
+ if (node.body.type === 'DoWhileStatement') {
2816
+ return yield* DoWhileStatement(node.body, scope, { label });
2817
+ }
2818
+ if (node.body.type === 'ForStatement') {
2819
+ return yield* ForStatement(node.body, scope, { label });
2820
+ }
2821
+ if (node.body.type === 'ForInStatement') {
2822
+ return yield* ForInStatement(node.body, scope, { label });
2823
+ }
2824
+ if (node.body.type === 'ForOfStatement') {
2825
+ return yield* ForOfStatement(node.body, scope, { label });
2826
+ }
2827
+ if (node.body.type === 'BlockStatement') {
2828
+ return yield* BlockStatement(node.body, scope, { label });
2829
+ }
2830
+ if (node.body.type === 'WithStatement') {
2831
+ return yield* WithStatement(node.body, scope, { label });
2832
+ }
2833
+ if (node.body.type === 'IfStatement') {
2834
+ return yield* IfStatement(node.body, scope, { label });
2835
+ }
2836
+ if (node.body.type === 'SwitchStatement') {
2837
+ return yield* SwitchStatement(node.body, scope, { label });
2838
+ }
2839
+ if (node.body.type === 'TryStatement') {
2840
+ return yield* TryStatement(node.body, scope, { label });
2841
+ }
2842
+ throw new SyntaxError(`${node.body.type} cannot be labeled`);
2843
+ }
2844
+ function* WithStatement(node, scope, options = {}) {
2845
+ const withScope = new Scope(scope);
2846
+ withScope.with(yield* evaluate(node.object, scope));
2847
+ const result = yield* evaluate(node.body, withScope);
2848
+ if (result === BREAK) {
2849
+ if (result.LABEL && result.LABEL === options.label) {
2850
+ return;
2851
+ }
2852
+ return result;
2853
+ }
2854
+ if (result === CONTINUE || result === RETURN) {
2855
+ return result;
2856
+ }
2857
+ }
2858
+ function* IfStatement(node, scope, options = {}) {
2859
+ let result;
2684
2860
  if (yield* evaluate(node.test, scope)) {
2685
- return yield* evaluate(node.consequent, scope);
2861
+ result = yield* evaluate(node.consequent, scope);
2686
2862
  }
2687
2863
  else {
2688
- return yield* evaluate(node.alternate, scope);
2864
+ result = yield* evaluate(node.alternate, scope);
2865
+ }
2866
+ if (result === BREAK) {
2867
+ if (result.LABEL && result.LABEL === options.label) {
2868
+ return;
2869
+ }
2870
+ return result;
2871
+ }
2872
+ if (result === CONTINUE || result === RETURN) {
2873
+ return result;
2689
2874
  }
2690
2875
  }
2691
- function* SwitchStatement(node, scope) {
2876
+ function* SwitchStatement(node, scope, options = {}) {
2692
2877
  const discriminant = yield* evaluate(node.discriminant, scope);
2693
2878
  let matched = false;
2694
2879
  for (let i = 0; i < node.cases.length; i++) {
@@ -2701,7 +2886,10 @@
2701
2886
  if (matched) {
2702
2887
  const result = yield* SwitchCase(eachCase, scope);
2703
2888
  if (result === BREAK) {
2704
- break;
2889
+ if (result.LABEL === options.label) {
2890
+ break;
2891
+ }
2892
+ return result;
2705
2893
  }
2706
2894
  if (result === CONTINUE || result === RETURN) {
2707
2895
  return result;
@@ -2720,9 +2908,10 @@
2720
2908
  function* ThrowStatement(node, scope) {
2721
2909
  throw yield* evaluate(node.argument, scope);
2722
2910
  }
2723
- function* TryStatement(node, scope) {
2911
+ function* TryStatement(node, scope, options = {}) {
2912
+ let result;
2724
2913
  try {
2725
- return yield* BlockStatement(node.block, scope);
2914
+ result = yield* BlockStatement(node.block, scope);
2726
2915
  }
2727
2916
  catch (err) {
2728
2917
  if (node.handler) {
@@ -2737,7 +2926,7 @@
2737
2926
  yield* pattern$1(param, scope, { feed: err });
2738
2927
  }
2739
2928
  }
2740
- return yield* CatchClause(node.handler, subScope);
2929
+ result = yield* CatchClause(node.handler, subScope);
2741
2930
  }
2742
2931
  else {
2743
2932
  throw err;
@@ -2745,45 +2934,63 @@
2745
2934
  }
2746
2935
  finally {
2747
2936
  if (node.finalizer) {
2748
- const result = yield* BlockStatement(node.finalizer, scope);
2749
- if (result === BREAK || result === CONTINUE || result === RETURN) {
2750
- return result;
2751
- }
2937
+ result = yield* BlockStatement(node.finalizer, scope);
2752
2938
  }
2753
2939
  }
2940
+ if (result === BREAK) {
2941
+ if (result.LABEL && result.LABEL === options.label) {
2942
+ return;
2943
+ }
2944
+ return result;
2945
+ }
2946
+ if (result === CONTINUE || result === RETURN) {
2947
+ return result;
2948
+ }
2754
2949
  }
2755
2950
  function* CatchClause(node, scope) {
2756
2951
  return yield* BlockStatement(node.body, scope, { invasived: true });
2757
2952
  }
2758
- function* WhileStatement(node, scope) {
2953
+ function* WhileStatement(node, scope, options = {}) {
2759
2954
  while (yield* evaluate(node.test, scope)) {
2760
2955
  const result = yield* evaluate(node.body, scope);
2761
2956
  if (result === BREAK) {
2762
- break;
2957
+ if (result.LABEL === options.label) {
2958
+ break;
2959
+ }
2960
+ return result;
2763
2961
  }
2764
2962
  else if (result === CONTINUE) {
2765
- continue;
2963
+ if (result.LABEL === options.label) {
2964
+ continue;
2965
+ }
2966
+ return result;
2766
2967
  }
2767
2968
  else if (result === RETURN) {
2768
2969
  return result;
2769
2970
  }
2770
2971
  }
2771
2972
  }
2772
- function* DoWhileStatement(node, scope) {
2973
+ function* DoWhileStatement(node, scope, options = {}) {
2773
2974
  do {
2774
2975
  const result = yield* evaluate(node.body, scope);
2775
2976
  if (result === BREAK) {
2776
- break;
2977
+ if (result.LABEL === options.label) {
2978
+ break;
2979
+ }
2980
+ return result;
2777
2981
  }
2778
2982
  else if (result === CONTINUE) {
2779
- continue;
2983
+ if (result.LABEL === options.label) {
2984
+ continue;
2985
+ }
2986
+ return result;
2780
2987
  }
2781
2988
  else if (result === RETURN) {
2782
2989
  return result;
2783
2990
  }
2784
2991
  } while (yield* evaluate(node.test, scope));
2785
2992
  }
2786
- function* ForStatement(node, scope) {
2993
+ function* ForStatement(node, scope, options = {}) {
2787
2994
  const forScope = new Scope(scope);
2788
2995
  for (yield* evaluate(node.init, forScope); node.test ? (yield* evaluate(node.test, forScope)) : true; yield* evaluate(node.update, forScope)) {
2789
2996
  const subScope = new Scope(forScope);
@@ -2795,31 +3002,43 @@
2795
3002
  result = yield* evaluate(node.body, subScope);
2796
3003
  }
2797
3004
  if (result === BREAK) {
2798
- break;
3005
+ if (result.LABEL === options.label) {
3006
+ break;
3007
+ }
3008
+ return result;
2799
3009
  }
2800
3010
  else if (result === CONTINUE) {
2801
- continue;
3011
+ if (result.LABEL === options.label) {
3012
+ continue;
3013
+ }
3014
+ return result;
2802
3015
  }
2803
3016
  else if (result === RETURN) {
2804
3017
  return result;
2805
3018
  }
2806
3019
  }
2807
3020
  }
2808
- function* ForInStatement(node, scope) {
3021
+ function* ForInStatement(node, scope, options = {}) {
2809
3022
  for (const value in yield* evaluate(node.right, scope)) {
2810
3023
  const result = yield* ForXHandler$1(node, scope, { value });
2811
3024
  if (result === BREAK) {
2812
- break;
3025
+ if (result.LABEL === options.label) {
3026
+ break;
3027
+ }
3028
+ return result;
2813
3029
  }
2814
3030
  else if (result === CONTINUE) {
2815
- continue;
3031
+ if (result.LABEL === options.label) {
3032
+ continue;
3033
+ }
3034
+ return result;
2816
3035
  }
2817
3036
  else if (result === RETURN) {
2818
3037
  return result;
2819
3038
  }
2820
3039
  }
2821
3040
  }
2822
- function* ForOfStatement(node, scope) {
3041
+ function* ForOfStatement(node, scope, options = {}) {
2823
3042
  const right = yield* evaluate(node.right, scope);
2824
3043
  if (node.await) {
2825
3044
  const iterator = getAsyncIterator(right);
@@ -2827,10 +3046,16 @@
2827
3046
  for (AWAIT.RES = iterator.next(), ret = yield AWAIT; !ret.done; AWAIT.RES = iterator.next(), ret = yield AWAIT) {
2828
3047
  const result = yield* ForXHandler$1(node, scope, { value: ret.value });
2829
3048
  if (result === BREAK) {
2830
- break;
3049
+ if (result.LABEL === options.label) {
3050
+ break;
3051
+ }
3052
+ return result;
2831
3053
  }
2832
3054
  else if (result === CONTINUE) {
2833
- continue;
3055
+ if (result.LABEL === options.label) {
3056
+ continue;
3057
+ }
3058
+ return result;
2834
3059
  }
2835
3060
  else if (result === RETURN) {
2836
3061
  return result;
@@ -2841,10 +3066,16 @@
2841
3066
  for (const value of right) {
2842
3067
  const result = yield* ForXHandler$1(node, scope, { value });
2843
3068
  if (result === BREAK) {
2844
- break;
3069
+ if (result.LABEL === options.label) {
3070
+ break;
3071
+ }
3072
+ return result;
2845
3073
  }
2846
3074
  else if (result === CONTINUE) {
2847
- continue;
3075
+ if (result.LABEL === options.label) {
3076
+ continue;
3077
+ }
3078
+ return result;
2848
3079
  }
2849
3080
  else if (result === RETURN) {
2850
3081
  return result;
@@ -3303,6 +3534,7 @@
3303
3534
  }
3304
3535
  }
3305
3536
  function createFunc$1(node, scope, options = {}) {
3537
+ var _a;
3306
3538
  if (!node.generator && !node.async) {
3307
3539
  return createFunc(node, scope, options);
3308
3540
  }
@@ -3396,6 +3628,13 @@
3396
3628
  value: params.length,
3397
3629
  configurable: true
3398
3630
  });
3631
+ const source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
3632
+ if (source) {
3633
+ define(func, 'toString', {
3634
+ value: () => source.substring(node.start, node.end),
3635
+ configurable: true
3636
+ });
3637
+ }
3399
3638
  return func;
3400
3639
  }
3401
3640
  function* createClass$1(node, scope) {
@@ -3554,6 +3793,7 @@
3554
3793
  }
3555
3794
  }
3556
3795
  function createFunc(node, scope, options = {}) {
3796
+ var _a;
3557
3797
  if (node.generator || node.async) {
3558
3798
  return createFunc$1(node, scope, options);
3559
3799
  }
@@ -3619,6 +3859,13 @@
3619
3859
  value: params.length,
3620
3860
  configurable: true
3621
3861
  });
3862
+ const source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
3863
+ if (source) {
3864
+ define(func, 'toString', {
3865
+ value: () => source.substring(node.start, node.end),
3866
+ configurable: true
3867
+ });
3868
+ }
3622
3869
  return func;
3623
3870
  }
3624
3871
  function createClass(node, scope) {