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/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.4";
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,79 @@
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) {
1406
- if (evaluate$1(node.test, scope)) {
1407
- return evaluate$1(node.consequent, 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 });
1408
1428
  }
1409
- else {
1410
- return evaluate$1(node.alternate, scope);
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;
1411
1470
  }
1412
1471
  }
1413
- function SwitchStatement$1(node, scope) {
1472
+ function IfStatement$1(node, scope, options = {}) {
1473
+ const result = evaluate$1(node.test, scope)
1474
+ ? evaluate$1(node.consequent, scope)
1475
+ : evaluate$1(node.alternate, scope);
1476
+ if (result === BREAK) {
1477
+ if (result.LABEL && result.LABEL === options.label) {
1478
+ return;
1479
+ }
1480
+ return result;
1481
+ }
1482
+ if (result === CONTINUE || result === RETURN) {
1483
+ return result;
1484
+ }
1485
+ }
1486
+ function SwitchStatement$1(node, scope, options = {}) {
1414
1487
  const discriminant = evaluate$1(node.discriminant, scope);
1415
1488
  let matched = false;
1416
1489
  for (let i = 0; i < node.cases.length; i++) {
@@ -1423,7 +1496,10 @@
1423
1496
  if (matched) {
1424
1497
  const result = SwitchCase$1(eachCase, scope);
1425
1498
  if (result === BREAK) {
1426
- break;
1499
+ if (result.LABEL === options.label) {
1500
+ break;
1501
+ }
1502
+ return result;
1427
1503
  }
1428
1504
  if (result === CONTINUE || result === RETURN) {
1429
1505
  return result;
@@ -1442,9 +1518,10 @@
1442
1518
  function ThrowStatement$1(node, scope) {
1443
1519
  throw evaluate$1(node.argument, scope);
1444
1520
  }
1445
- function TryStatement$1(node, scope) {
1521
+ function TryStatement$1(node, scope, options = {}) {
1522
+ let result;
1446
1523
  try {
1447
- return BlockStatement$1(node.block, scope);
1524
+ result = BlockStatement$1(node.block, scope);
1448
1525
  }
1449
1526
  catch (err) {
1450
1527
  if (node.handler) {
@@ -1459,7 +1536,7 @@
1459
1536
  pattern(param, scope, { feed: err });
1460
1537
  }
1461
1538
  }
1462
- return CatchClause$1(node.handler, subScope);
1539
+ result = CatchClause$1(node.handler, subScope);
1463
1540
  }
1464
1541
  else {
1465
1542
  throw err;
@@ -1467,45 +1544,63 @@
1467
1544
  }
1468
1545
  finally {
1469
1546
  if (node.finalizer) {
1470
- const result = BlockStatement$1(node.finalizer, scope);
1471
- if (result === BREAK || result === CONTINUE || result === RETURN) {
1472
- return result;
1473
- }
1547
+ result = BlockStatement$1(node.finalizer, scope);
1474
1548
  }
1475
1549
  }
1550
+ if (result === BREAK) {
1551
+ if (result.LABEL && result.LABEL === options.label) {
1552
+ return;
1553
+ }
1554
+ return result;
1555
+ }
1556
+ if (result === CONTINUE || result === RETURN) {
1557
+ return result;
1558
+ }
1476
1559
  }
1477
1560
  function CatchClause$1(node, scope) {
1478
1561
  return BlockStatement$1(node.body, scope, { invasived: true });
1479
1562
  }
1480
- function WhileStatement$1(node, scope) {
1563
+ function WhileStatement$1(node, scope, options = {}) {
1481
1564
  while (evaluate$1(node.test, scope)) {
1482
1565
  const result = evaluate$1(node.body, scope);
1483
1566
  if (result === BREAK) {
1484
- break;
1567
+ if (result.LABEL === options.label) {
1568
+ break;
1569
+ }
1570
+ return result;
1485
1571
  }
1486
1572
  else if (result === CONTINUE) {
1487
- continue;
1573
+ if (result.LABEL === options.label) {
1574
+ continue;
1575
+ }
1576
+ return result;
1488
1577
  }
1489
1578
  else if (result === RETURN) {
1490
1579
  return result;
1491
1580
  }
1492
1581
  }
1493
1582
  }
1494
- function DoWhileStatement$1(node, scope) {
1583
+ function DoWhileStatement$1(node, scope, options = {}) {
1495
1584
  do {
1496
1585
  const result = evaluate$1(node.body, scope);
1497
1586
  if (result === BREAK) {
1498
- break;
1587
+ if (result.LABEL === options.label) {
1588
+ break;
1589
+ }
1590
+ return result;
1499
1591
  }
1500
1592
  else if (result === CONTINUE) {
1501
- continue;
1593
+ if (result.LABEL === options.label) {
1594
+ continue;
1595
+ }
1596
+ return result;
1502
1597
  }
1503
1598
  else if (result === RETURN) {
1504
1599
  return result;
1505
1600
  }
1506
1601
  } while (evaluate$1(node.test, scope));
1507
1602
  }
1508
- function ForStatement$1(node, scope) {
1603
+ function ForStatement$1(node, scope, options = {}) {
1509
1604
  const forScope = new Scope(scope);
1510
1605
  for (evaluate$1(node.init, forScope); node.test ? (evaluate$1(node.test, forScope)) : true; evaluate$1(node.update, forScope)) {
1511
1606
  const subScope = new Scope(forScope);
@@ -1517,39 +1612,57 @@
1517
1612
  result = evaluate$1(node.body, subScope);
1518
1613
  }
1519
1614
  if (result === BREAK) {
1520
- break;
1615
+ if (result.LABEL === options.label) {
1616
+ break;
1617
+ }
1618
+ return result;
1521
1619
  }
1522
1620
  else if (result === CONTINUE) {
1523
- continue;
1621
+ if (result.LABEL === options.label) {
1622
+ continue;
1623
+ }
1624
+ return result;
1524
1625
  }
1525
1626
  else if (result === RETURN) {
1526
1627
  return result;
1527
1628
  }
1528
1629
  }
1529
1630
  }
1530
- function ForInStatement$1(node, scope) {
1631
+ function ForInStatement$1(node, scope, options = {}) {
1531
1632
  for (const value in evaluate$1(node.right, scope)) {
1532
1633
  const result = ForXHandler(node, scope, { value });
1533
1634
  if (result === BREAK) {
1534
- break;
1635
+ if (result.LABEL === options.label) {
1636
+ break;
1637
+ }
1638
+ return result;
1535
1639
  }
1536
1640
  else if (result === CONTINUE) {
1537
- continue;
1641
+ if (result.LABEL === options.label) {
1642
+ continue;
1643
+ }
1644
+ return result;
1538
1645
  }
1539
1646
  else if (result === RETURN) {
1540
1647
  return result;
1541
1648
  }
1542
1649
  }
1543
1650
  }
1544
- function ForOfStatement$1(node, scope) {
1651
+ function ForOfStatement$1(node, scope, options = {}) {
1545
1652
  const right = evaluate$1(node.right, scope);
1546
1653
  for (const value of right) {
1547
1654
  const result = ForXHandler(node, scope, { value });
1548
1655
  if (result === BREAK) {
1549
- break;
1656
+ if (result.LABEL === options.label) {
1657
+ break;
1658
+ }
1659
+ return result;
1550
1660
  }
1551
1661
  else if (result === CONTINUE) {
1552
- continue;
1662
+ if (result.LABEL === options.label) {
1663
+ continue;
1664
+ }
1665
+ return result;
1553
1666
  }
1554
1667
  else if (result === RETURN) {
1555
1668
  return result;
@@ -2660,7 +2773,13 @@
2660
2773
  }
2661
2774
  for (let i = 0; i < block.body.length; i++) {
2662
2775
  const result = yield* evaluate(block.body[i], subScope);
2663
- if (result === BREAK || result === CONTINUE || result === RETURN) {
2776
+ if (result === BREAK) {
2777
+ if (result.LABEL && result.LABEL === options.label) {
2778
+ break;
2779
+ }
2780
+ return result;
2781
+ }
2782
+ if (result === CONTINUE || result === RETURN) {
2664
2783
  return result;
2665
2784
  }
2666
2785
  }
@@ -2674,21 +2793,79 @@
2674
2793
  RETURN.RES = node.argument ? (yield* evaluate(node.argument, scope)) : undefined;
2675
2794
  return RETURN;
2676
2795
  }
2677
- function* BreakStatement() {
2796
+ function* BreakStatement(node) {
2797
+ var _a;
2798
+ BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2678
2799
  return BREAK;
2679
2800
  }
2680
- function* ContinueStatement() {
2801
+ function* ContinueStatement(node) {
2802
+ var _a;
2803
+ CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2681
2804
  return CONTINUE;
2682
2805
  }
2683
- function* IfStatement(node, scope) {
2684
- if (yield* evaluate(node.test, scope)) {
2685
- return yield* evaluate(node.consequent, scope);
2806
+ function* LabeledStatement(node, scope) {
2807
+ const label = node.label.name;
2808
+ if (node.body.type === 'WhileStatement') {
2809
+ return yield* WhileStatement(node.body, scope, { label });
2686
2810
  }
2687
- else {
2688
- return yield* evaluate(node.alternate, scope);
2811
+ if (node.body.type === 'DoWhileStatement') {
2812
+ return yield* DoWhileStatement(node.body, scope, { label });
2813
+ }
2814
+ if (node.body.type === 'ForStatement') {
2815
+ return yield* ForStatement(node.body, scope, { label });
2816
+ }
2817
+ if (node.body.type === 'ForInStatement') {
2818
+ return yield* ForInStatement(node.body, scope, { label });
2819
+ }
2820
+ if (node.body.type === 'ForOfStatement') {
2821
+ return yield* ForOfStatement(node.body, scope, { label });
2822
+ }
2823
+ if (node.body.type === 'BlockStatement') {
2824
+ return yield* BlockStatement(node.body, scope, { label });
2825
+ }
2826
+ if (node.body.type === 'WithStatement') {
2827
+ return yield* WithStatement(node.body, scope, { label });
2828
+ }
2829
+ if (node.body.type === 'IfStatement') {
2830
+ return yield* IfStatement(node.body, scope, { label });
2831
+ }
2832
+ if (node.body.type === 'SwitchStatement') {
2833
+ return yield* SwitchStatement(node.body, scope, { label });
2834
+ }
2835
+ if (node.body.type === 'TryStatement') {
2836
+ return yield* TryStatement(node.body, scope, { label });
2837
+ }
2838
+ throw new SyntaxError(`${node.body.type} cannot be labeled`);
2839
+ }
2840
+ function* WithStatement(node, scope, options = {}) {
2841
+ const withScope = new Scope(scope);
2842
+ withScope.with(yield* evaluate(node.object, scope));
2843
+ const result = yield* evaluate(node.body, withScope);
2844
+ if (result === BREAK) {
2845
+ if (result.LABEL && result.LABEL === options.label) {
2846
+ return;
2847
+ }
2848
+ return result;
2849
+ }
2850
+ if (result === CONTINUE || result === RETURN) {
2851
+ return result;
2852
+ }
2853
+ }
2854
+ function* IfStatement(node, scope, options = {}) {
2855
+ const result = yield* evaluate(node.test, scope)
2856
+ ? yield* evaluate(node.consequent, scope)
2857
+ : yield* evaluate(node.alternate, scope);
2858
+ if (result === BREAK) {
2859
+ if (result.LABEL && result.LABEL === options.label) {
2860
+ return;
2861
+ }
2862
+ return result;
2863
+ }
2864
+ if (result === CONTINUE || result === RETURN) {
2865
+ return result;
2689
2866
  }
2690
2867
  }
2691
- function* SwitchStatement(node, scope) {
2868
+ function* SwitchStatement(node, scope, options = {}) {
2692
2869
  const discriminant = yield* evaluate(node.discriminant, scope);
2693
2870
  let matched = false;
2694
2871
  for (let i = 0; i < node.cases.length; i++) {
@@ -2701,7 +2878,10 @@
2701
2878
  if (matched) {
2702
2879
  const result = yield* SwitchCase(eachCase, scope);
2703
2880
  if (result === BREAK) {
2704
- break;
2881
+ if (result.LABEL === options.label) {
2882
+ break;
2883
+ }
2884
+ return result;
2705
2885
  }
2706
2886
  if (result === CONTINUE || result === RETURN) {
2707
2887
  return result;
@@ -2720,9 +2900,10 @@
2720
2900
  function* ThrowStatement(node, scope) {
2721
2901
  throw yield* evaluate(node.argument, scope);
2722
2902
  }
2723
- function* TryStatement(node, scope) {
2903
+ function* TryStatement(node, scope, options = {}) {
2904
+ let result;
2724
2905
  try {
2725
- return yield* BlockStatement(node.block, scope);
2906
+ result = yield* BlockStatement(node.block, scope);
2726
2907
  }
2727
2908
  catch (err) {
2728
2909
  if (node.handler) {
@@ -2737,7 +2918,7 @@
2737
2918
  yield* pattern$1(param, scope, { feed: err });
2738
2919
  }
2739
2920
  }
2740
- return yield* CatchClause(node.handler, subScope);
2921
+ result = yield* CatchClause(node.handler, subScope);
2741
2922
  }
2742
2923
  else {
2743
2924
  throw err;
@@ -2745,45 +2926,63 @@
2745
2926
  }
2746
2927
  finally {
2747
2928
  if (node.finalizer) {
2748
- const result = yield* BlockStatement(node.finalizer, scope);
2749
- if (result === BREAK || result === CONTINUE || result === RETURN) {
2750
- return result;
2751
- }
2929
+ result = yield* BlockStatement(node.finalizer, scope);
2752
2930
  }
2753
2931
  }
2932
+ if (result === BREAK) {
2933
+ if (result.LABEL && result.LABEL === options.label) {
2934
+ return;
2935
+ }
2936
+ return result;
2937
+ }
2938
+ if (result === CONTINUE || result === RETURN) {
2939
+ return result;
2940
+ }
2754
2941
  }
2755
2942
  function* CatchClause(node, scope) {
2756
2943
  return yield* BlockStatement(node.body, scope, { invasived: true });
2757
2944
  }
2758
- function* WhileStatement(node, scope) {
2945
+ function* WhileStatement(node, scope, options = {}) {
2759
2946
  while (yield* evaluate(node.test, scope)) {
2760
2947
  const result = yield* evaluate(node.body, scope);
2761
2948
  if (result === BREAK) {
2762
- break;
2949
+ if (result.LABEL === options.label) {
2950
+ break;
2951
+ }
2952
+ return result;
2763
2953
  }
2764
2954
  else if (result === CONTINUE) {
2765
- continue;
2955
+ if (result.LABEL === options.label) {
2956
+ continue;
2957
+ }
2958
+ return result;
2766
2959
  }
2767
2960
  else if (result === RETURN) {
2768
2961
  return result;
2769
2962
  }
2770
2963
  }
2771
2964
  }
2772
- function* DoWhileStatement(node, scope) {
2965
+ function* DoWhileStatement(node, scope, options = {}) {
2773
2966
  do {
2774
2967
  const result = yield* evaluate(node.body, scope);
2775
2968
  if (result === BREAK) {
2776
- break;
2969
+ if (result.LABEL === options.label) {
2970
+ break;
2971
+ }
2972
+ return result;
2777
2973
  }
2778
2974
  else if (result === CONTINUE) {
2779
- continue;
2975
+ if (result.LABEL === options.label) {
2976
+ continue;
2977
+ }
2978
+ return result;
2780
2979
  }
2781
2980
  else if (result === RETURN) {
2782
2981
  return result;
2783
2982
  }
2784
2983
  } while (yield* evaluate(node.test, scope));
2785
2984
  }
2786
- function* ForStatement(node, scope) {
2985
+ function* ForStatement(node, scope, options = {}) {
2787
2986
  const forScope = new Scope(scope);
2788
2987
  for (yield* evaluate(node.init, forScope); node.test ? (yield* evaluate(node.test, forScope)) : true; yield* evaluate(node.update, forScope)) {
2789
2988
  const subScope = new Scope(forScope);
@@ -2795,31 +2994,43 @@
2795
2994
  result = yield* evaluate(node.body, subScope);
2796
2995
  }
2797
2996
  if (result === BREAK) {
2798
- break;
2997
+ if (result.LABEL === options.label) {
2998
+ break;
2999
+ }
3000
+ return result;
2799
3001
  }
2800
3002
  else if (result === CONTINUE) {
2801
- continue;
3003
+ if (result.LABEL === options.label) {
3004
+ continue;
3005
+ }
3006
+ return result;
2802
3007
  }
2803
3008
  else if (result === RETURN) {
2804
3009
  return result;
2805
3010
  }
2806
3011
  }
2807
3012
  }
2808
- function* ForInStatement(node, scope) {
3013
+ function* ForInStatement(node, scope, options = {}) {
2809
3014
  for (const value in yield* evaluate(node.right, scope)) {
2810
3015
  const result = yield* ForXHandler$1(node, scope, { value });
2811
3016
  if (result === BREAK) {
2812
- break;
3017
+ if (result.LABEL === options.label) {
3018
+ break;
3019
+ }
3020
+ return result;
2813
3021
  }
2814
3022
  else if (result === CONTINUE) {
2815
- continue;
3023
+ if (result.LABEL === options.label) {
3024
+ continue;
3025
+ }
3026
+ return result;
2816
3027
  }
2817
3028
  else if (result === RETURN) {
2818
3029
  return result;
2819
3030
  }
2820
3031
  }
2821
3032
  }
2822
- function* ForOfStatement(node, scope) {
3033
+ function* ForOfStatement(node, scope, options = {}) {
2823
3034
  const right = yield* evaluate(node.right, scope);
2824
3035
  if (node.await) {
2825
3036
  const iterator = getAsyncIterator(right);
@@ -2827,10 +3038,16 @@
2827
3038
  for (AWAIT.RES = iterator.next(), ret = yield AWAIT; !ret.done; AWAIT.RES = iterator.next(), ret = yield AWAIT) {
2828
3039
  const result = yield* ForXHandler$1(node, scope, { value: ret.value });
2829
3040
  if (result === BREAK) {
2830
- break;
3041
+ if (result.LABEL === options.label) {
3042
+ break;
3043
+ }
3044
+ return result;
2831
3045
  }
2832
3046
  else if (result === CONTINUE) {
2833
- continue;
3047
+ if (result.LABEL === options.label) {
3048
+ continue;
3049
+ }
3050
+ return result;
2834
3051
  }
2835
3052
  else if (result === RETURN) {
2836
3053
  return result;
@@ -2841,10 +3058,16 @@
2841
3058
  for (const value of right) {
2842
3059
  const result = yield* ForXHandler$1(node, scope, { value });
2843
3060
  if (result === BREAK) {
2844
- break;
3061
+ if (result.LABEL === options.label) {
3062
+ break;
3063
+ }
3064
+ return result;
2845
3065
  }
2846
3066
  else if (result === CONTINUE) {
2847
- continue;
3067
+ if (result.LABEL === options.label) {
3068
+ continue;
3069
+ }
3070
+ return result;
2848
3071
  }
2849
3072
  else if (result === RETURN) {
2850
3073
  return result;
@@ -3303,6 +3526,7 @@
3303
3526
  }
3304
3527
  }
3305
3528
  function createFunc$1(node, scope, options = {}) {
3529
+ var _a;
3306
3530
  if (!node.generator && !node.async) {
3307
3531
  return createFunc(node, scope, options);
3308
3532
  }
@@ -3396,6 +3620,13 @@
3396
3620
  value: params.length,
3397
3621
  configurable: true
3398
3622
  });
3623
+ const source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
3624
+ if (source) {
3625
+ define(func, 'toString', {
3626
+ value: () => source.substring(node.start, node.end),
3627
+ configurable: true
3628
+ });
3629
+ }
3399
3630
  return func;
3400
3631
  }
3401
3632
  function* createClass$1(node, scope) {
@@ -3554,6 +3785,7 @@
3554
3785
  }
3555
3786
  }
3556
3787
  function createFunc(node, scope, options = {}) {
3788
+ var _a;
3557
3789
  if (node.generator || node.async) {
3558
3790
  return createFunc$1(node, scope, options);
3559
3791
  }
@@ -3619,6 +3851,13 @@
3619
3851
  value: params.length,
3620
3852
  configurable: true
3621
3853
  });
3854
+ const source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
3855
+ if (source) {
3856
+ define(func, 'toString', {
3857
+ value: () => source.substring(node.start, node.end),
3858
+ configurable: true
3859
+ });
3860
+ }
3622
3861
  return func;
3623
3862
  }
3624
3863
  function createClass(node, scope) {