sval 0.5.2 → 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
@@ -1,45 +1,9 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('acorn')) :
3
3
  typeof define === 'function' && define.amd ? define(['acorn'], factory) :
4
- (global = global || self, global.Sval = factory(global.acorn));
5
- }(this, (function (acorn) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Sval = factory(global.acorn));
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
- });
28
- var declaration = /*#__PURE__*/Object.freeze({
29
- __proto__: null,
30
- get FunctionDeclaration () { return FunctionDeclaration; },
31
- get VariableDeclaration () { return VariableDeclaration; },
32
- get VariableDeclarator () { return VariableDeclarator; },
33
- get ClassDeclaration () { return ClassDeclaration; },
34
- get ClassBody () { return ClassBody; },
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
7
  var statement$1 = /*#__PURE__*/Object.freeze({
44
8
  __proto__: null,
45
9
  get ExpressionStatement () { return ExpressionStatement$1; },
@@ -49,6 +13,8 @@
49
13
  get ReturnStatement () { return ReturnStatement$1; },
50
14
  get BreakStatement () { return BreakStatement$1; },
51
15
  get ContinueStatement () { return ContinueStatement$1; },
16
+ get LabeledStatement () { return LabeledStatement$1; },
17
+ get WithStatement () { return WithStatement$1; },
52
18
  get IfStatement () { return IfStatement$1; },
53
19
  get SwitchStatement () { return SwitchStatement$1; },
54
20
  get SwitchCase () { return SwitchCase$1; },
@@ -76,6 +42,44 @@
76
42
  get ExportNamedDeclaration () { return ExportNamedDeclaration$1; },
77
43
  get ExportAllDeclaration () { return ExportAllDeclaration$1; }
78
44
  });
45
+ var statement = /*#__PURE__*/Object.freeze({
46
+ __proto__: null,
47
+ get ExpressionStatement () { return ExpressionStatement; },
48
+ get BlockStatement () { return BlockStatement; },
49
+ get EmptyStatement () { return EmptyStatement; },
50
+ get DebuggerStatement () { return DebuggerStatement; },
51
+ get ReturnStatement () { return ReturnStatement; },
52
+ get BreakStatement () { return BreakStatement; },
53
+ get ContinueStatement () { return ContinueStatement; },
54
+ get LabeledStatement () { return LabeledStatement; },
55
+ get WithStatement () { return WithStatement; },
56
+ get IfStatement () { return IfStatement; },
57
+ get SwitchStatement () { return SwitchStatement; },
58
+ get SwitchCase () { return SwitchCase; },
59
+ get ThrowStatement () { return ThrowStatement; },
60
+ get TryStatement () { return TryStatement; },
61
+ get CatchClause () { return CatchClause; },
62
+ get WhileStatement () { return WhileStatement; },
63
+ get DoWhileStatement () { return DoWhileStatement; },
64
+ get ForStatement () { return ForStatement; },
65
+ get ForInStatement () { return ForInStatement; },
66
+ get ForOfStatement () { return ForOfStatement; }
67
+ });
68
+ var declaration = /*#__PURE__*/Object.freeze({
69
+ __proto__: null,
70
+ get FunctionDeclaration () { return FunctionDeclaration; },
71
+ get VariableDeclaration () { return VariableDeclaration; },
72
+ get VariableDeclarator () { return VariableDeclarator; },
73
+ get ClassDeclaration () { return ClassDeclaration; },
74
+ get ClassBody () { return ClassBody; },
75
+ get MethodDefinition () { return MethodDefinition; },
76
+ get PropertyDefinition () { return PropertyDefinition; },
77
+ get StaticBlock () { return StaticBlock; },
78
+ get ImportDeclaration () { return ImportDeclaration; },
79
+ get ExportDefaultDeclaration () { return ExportDefaultDeclaration; },
80
+ get ExportNamedDeclaration () { return ExportNamedDeclaration; },
81
+ get ExportAllDeclaration () { return ExportAllDeclaration; }
82
+ });
79
83
 
80
84
  const freeze = Object.freeze;
81
85
  const define = Object.defineProperty;
@@ -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.2";
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,9 +587,14 @@
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
- function Identifier(node, scope, options = {}) {
597
+ function Identifier$1(node, scope, options = {}) {
589
598
  const { getVar = false, throwErr = true } = options;
590
599
  if (node.name === 'undefined') {
591
600
  return undefined;
@@ -613,21 +622,21 @@
613
622
  }
614
623
  }
615
624
 
616
- var identifier = /*#__PURE__*/Object.freeze({
625
+ var identifier$1 = /*#__PURE__*/Object.freeze({
617
626
  __proto__: null,
618
- Identifier: Identifier
627
+ Identifier: Identifier$1
619
628
  });
620
629
 
621
- function Literal(node, scope) {
630
+ function Literal$1(node, scope) {
622
631
  return node.value;
623
632
  }
624
633
 
625
- var literal = /*#__PURE__*/Object.freeze({
634
+ var literal$1 = /*#__PURE__*/Object.freeze({
626
635
  __proto__: null,
627
- Literal: Literal
636
+ Literal: Literal$1
628
637
  });
629
638
 
630
- function ThisExpression(node, scope) {
639
+ function ThisExpression$1(node, scope) {
631
640
  const superCall = scope.find(SUPERCALL);
632
641
  if (superCall && !superCall.get()) {
633
642
  throw new ReferenceError('Must call super constructor in derived class '
@@ -637,41 +646,41 @@
637
646
  return scope.find('this').get();
638
647
  }
639
648
  }
640
- function ArrayExpression(node, scope) {
649
+ function ArrayExpression$1(node, scope) {
641
650
  let results = [];
642
651
  for (let i = 0; i < node.elements.length; i++) {
643
652
  const item = node.elements[i];
644
653
  if (item.type === 'SpreadElement') {
645
- results = results.concat(SpreadElement(item, scope));
654
+ results = results.concat(SpreadElement$1(item, scope));
646
655
  }
647
656
  else {
648
- results.push(evaluate(item, scope));
657
+ results.push(evaluate$1(item, scope));
649
658
  }
650
659
  }
651
660
  return results;
652
661
  }
653
- function ObjectExpression(node, scope) {
662
+ function ObjectExpression$1(node, scope) {
654
663
  const object = {};
655
664
  for (let i = 0; i < node.properties.length; i++) {
656
665
  const property = node.properties[i];
657
666
  if (property.type === 'SpreadElement') {
658
- assign(object, SpreadElement(property, scope));
667
+ assign(object, SpreadElement$1(property, scope));
659
668
  }
660
669
  else {
661
670
  let key;
662
671
  const propKey = property.key;
663
672
  if (property.computed) {
664
- key = evaluate(propKey, scope);
673
+ key = evaluate$1(propKey, scope);
665
674
  }
666
675
  else {
667
676
  if (propKey.type === 'Identifier') {
668
677
  key = propKey.name;
669
678
  }
670
679
  else {
671
- key = '' + (Literal(propKey));
680
+ key = '' + (Literal$1(propKey));
672
681
  }
673
682
  }
674
- const value = evaluate(property.value, scope);
683
+ const value = evaluate$1(property.value, scope);
675
684
  const propKind = property.kind;
676
685
  if (propKind === 'init') {
677
686
  object[key] = value;
@@ -698,55 +707,55 @@
698
707
  }
699
708
  return object;
700
709
  }
701
- function FunctionExpression(node, scope) {
710
+ function FunctionExpression$1(node, scope) {
702
711
  if (node.id && node.id.name) {
703
712
  const tmpScope = new Scope(scope);
704
- const func = createFunc$1(node, tmpScope);
713
+ const func = createFunc(node, tmpScope);
705
714
  tmpScope.const(node.id.name, func);
706
715
  return func;
707
716
  }
708
717
  else {
709
- return createFunc$1(node, scope);
718
+ return createFunc(node, scope);
710
719
  }
711
720
  }
712
- function UnaryExpression(node, scope) {
721
+ function UnaryExpression$1(node, scope) {
713
722
  const arg = node.argument;
714
723
  switch (node.operator) {
715
- case '+': return +(evaluate(arg, scope));
716
- case '-': return -(evaluate(arg, scope));
717
- case '!': return !(evaluate(arg, scope));
718
- case '~': return ~(evaluate(arg, scope));
719
- case 'void': return void (evaluate(arg, scope));
724
+ case '+': return +(evaluate$1(arg, scope));
725
+ case '-': return -(evaluate$1(arg, scope));
726
+ case '!': return !(evaluate$1(arg, scope));
727
+ case '~': return ~(evaluate$1(arg, scope));
728
+ case 'void': return void (evaluate$1(arg, scope));
720
729
  case 'typeof':
721
730
  if (arg.type === 'Identifier') {
722
- return typeof (Identifier(arg, scope, { throwErr: false }));
731
+ return typeof (Identifier$1(arg, scope, { throwErr: false }));
723
732
  }
724
733
  else {
725
- return typeof (evaluate(arg, scope));
734
+ return typeof (evaluate$1(arg, scope));
726
735
  }
727
736
  case 'delete':
728
737
  if (arg.type === 'MemberExpression') {
729
- const variable = MemberExpression(arg, scope, { getVar: true });
738
+ const variable = MemberExpression$1(arg, scope, { getVar: true });
730
739
  return variable.del();
731
740
  }
732
741
  else if (arg.type === 'Identifier') {
733
742
  throw new SyntaxError('Delete of an unqualified identifier in strict mode');
734
743
  }
735
744
  else {
736
- evaluate(arg, scope);
745
+ evaluate$1(arg, scope);
737
746
  return true;
738
747
  }
739
748
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
740
749
  }
741
750
  }
742
- function UpdateExpression(node, scope) {
751
+ function UpdateExpression$1(node, scope) {
743
752
  const arg = node.argument;
744
753
  let variable;
745
754
  if (arg.type === 'Identifier') {
746
- variable = Identifier(arg, scope, { getVar: true });
755
+ variable = Identifier$1(arg, scope, { getVar: true });
747
756
  }
748
757
  else if (arg.type === 'MemberExpression') {
749
- variable = MemberExpression(arg, scope, { getVar: true });
758
+ variable = MemberExpression$1(arg, scope, { getVar: true });
750
759
  }
751
760
  else {
752
761
  throw new SyntaxError('Unexpected token');
@@ -764,17 +773,17 @@
764
773
  throw new SyntaxError(`Unexpected token ${node.operator}`);
765
774
  }
766
775
  }
767
- function BinaryExpression(node, scope) {
776
+ function BinaryExpression$1(node, scope) {
768
777
  let left;
769
778
  let right;
770
779
  if (node.left.type === 'PrivateIdentifier') {
771
780
  left = node.left.name;
772
- right = evaluate(node.right, scope);
781
+ right = evaluate$1(node.right, scope);
773
782
  right = right[PRIVATE];
774
783
  }
775
784
  else {
776
- left = evaluate(node.left, scope);
777
- right = evaluate(node.right, scope);
785
+ left = evaluate$1(node.left, scope);
786
+ right = evaluate$1(node.right, scope);
778
787
  }
779
788
  switch (node.operator) {
780
789
  case '==': return left == right;
@@ -802,25 +811,25 @@
802
811
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
803
812
  }
804
813
  }
805
- function AssignmentExpression(node, scope) {
814
+ function AssignmentExpression$1(node, scope) {
806
815
  var _a;
807
816
  const left = node.left;
808
817
  let variable;
809
818
  if (left.type === 'Identifier') {
810
- variable = Identifier(left, scope, { getVar: true, throwErr: false });
819
+ variable = Identifier$1(left, scope, { getVar: true, throwErr: false });
811
820
  if (!variable) {
812
821
  const win = scope.global().find('window').get();
813
822
  variable = new Prop(win, left.name);
814
823
  }
815
824
  }
816
825
  else if (left.type === 'MemberExpression') {
817
- variable = MemberExpression(left, scope, { getVar: true });
826
+ variable = MemberExpression$1(left, scope, { getVar: true });
818
827
  }
819
828
  else {
820
- const value = evaluate(node.right, scope);
821
- return pattern$3(left, scope, { feed: value });
829
+ const value = evaluate$1(node.right, scope);
830
+ return pattern(left, scope, { feed: value });
822
831
  }
823
- const value = evaluate(node.right, scope);
832
+ const value = evaluate$1(node.right, scope);
824
833
  switch (node.operator) {
825
834
  case '=':
826
835
  variable.set(value);
@@ -873,34 +882,34 @@
873
882
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
874
883
  }
875
884
  }
876
- function LogicalExpression(node, scope) {
885
+ function LogicalExpression$1(node, scope) {
877
886
  var _a;
878
887
  switch (node.operator) {
879
888
  case '||':
880
- return (evaluate(node.left, scope)) || (evaluate(node.right, scope));
889
+ return (evaluate$1(node.left, scope)) || (evaluate$1(node.right, scope));
881
890
  case '&&':
882
- return (evaluate(node.left, scope)) && (evaluate(node.right, scope));
891
+ return (evaluate$1(node.left, scope)) && (evaluate$1(node.right, scope));
883
892
  case '??':
884
- return (_a = (evaluate(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate(node.right, scope));
893
+ return (_a = (evaluate$1(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate$1(node.right, scope));
885
894
  default:
886
895
  throw new SyntaxError(`Unexpected token ${node.operator}`);
887
896
  }
888
897
  }
889
- function MemberExpression(node, scope, options = {}) {
898
+ function MemberExpression$1(node, scope, options = {}) {
890
899
  const { getObj = false, getVar = false } = options;
891
900
  let object;
892
901
  if (node.object.type === 'Super') {
893
- object = Super(node.object, scope, { getProto: true });
902
+ object = Super$1(node.object, scope, { getProto: true });
894
903
  }
895
904
  else {
896
- object = evaluate(node.object, scope);
905
+ object = evaluate$1(node.object, scope);
897
906
  }
898
907
  if (getObj)
899
908
  return object;
900
909
  let key;
901
910
  let priv = false;
902
911
  if (node.computed) {
903
- key = evaluate(node.property, scope);
912
+ key = evaluate$1(node.property, scope);
904
913
  }
905
914
  else if (node.property.type === 'PrivateIdentifier') {
906
915
  key = node.property.name;
@@ -941,23 +950,23 @@
941
950
  }
942
951
  }
943
952
  }
944
- function ConditionalExpression(node, scope) {
945
- return (evaluate(node.test, scope))
946
- ? (evaluate(node.consequent, scope))
947
- : (evaluate(node.alternate, scope));
953
+ function ConditionalExpression$1(node, scope) {
954
+ return (evaluate$1(node.test, scope))
955
+ ? (evaluate$1(node.consequent, scope))
956
+ : (evaluate$1(node.alternate, scope));
948
957
  }
949
- function CallExpression(node, scope) {
958
+ function CallExpression$1(node, scope) {
950
959
  let func;
951
960
  let object;
952
961
  if (node.callee.type === 'MemberExpression') {
953
- object = MemberExpression(node.callee, scope, { getObj: true });
962
+ object = MemberExpression$1(node.callee, scope, { getObj: true });
954
963
  if (node.callee.optional && object == null) {
955
964
  return undefined;
956
965
  }
957
966
  let key;
958
967
  let priv = false;
959
968
  if (node.callee.computed) {
960
- key = evaluate(node.callee.property, scope);
969
+ key = evaluate$1(node.callee.property, scope);
961
970
  }
962
971
  else if (node.callee.property.type === 'PrivateIdentifier') {
963
972
  key = node.callee.property.name;
@@ -989,7 +998,7 @@
989
998
  }
990
999
  else {
991
1000
  object = scope.find('this').get();
992
- func = evaluate(node.callee, scope);
1001
+ func = evaluate$1(node.callee, scope);
993
1002
  if (node.optional && func == null) {
994
1003
  return undefined;
995
1004
  }
@@ -1018,10 +1027,10 @@
1018
1027
  for (let i = 0; i < node.arguments.length; i++) {
1019
1028
  const arg = node.arguments[i];
1020
1029
  if (arg.type === 'SpreadElement') {
1021
- args = args.concat(SpreadElement(arg, scope));
1030
+ args = args.concat(SpreadElement$1(arg, scope));
1022
1031
  }
1023
1032
  else {
1024
- args.push(evaluate(arg, scope));
1033
+ args.push(evaluate$1(arg, scope));
1025
1034
  }
1026
1035
  }
1027
1036
  if (node.callee.type === 'Super') {
@@ -1033,13 +1042,22 @@
1033
1042
  scope.find(SUPERCALL).set(true);
1034
1043
  }
1035
1044
  }
1036
- if (object && object[WINDOW] && func.toString().indexOf('[native code]') !== -1) {
1037
- return func.apply(object[WINDOW], args);
1045
+ try {
1046
+ return func.apply(object, args);
1047
+ }
1048
+ catch (err) {
1049
+ if (err instanceof TypeError && err.message === 'Illegal invocation'
1050
+ && func.toString().indexOf('[native code]') !== -1) {
1051
+ const win = scope.global().find('window').get();
1052
+ if (win && win[WINDOW]) {
1053
+ return func.apply(win[WINDOW], args);
1054
+ }
1055
+ }
1056
+ throw err;
1038
1057
  }
1039
- return func.apply(object, args);
1040
1058
  }
1041
- function NewExpression(node, scope) {
1042
- const constructor = evaluate(node.callee, scope);
1059
+ function NewExpression$1(node, scope) {
1060
+ const constructor = evaluate$1(node.callee, scope);
1043
1061
  if (typeof constructor !== 'function') {
1044
1062
  let name;
1045
1063
  if (node.callee.type === 'Identifier') {
@@ -1062,15 +1080,15 @@
1062
1080
  for (let i = 0; i < node.arguments.length; i++) {
1063
1081
  const arg = node.arguments[i];
1064
1082
  if (arg.type === 'SpreadElement') {
1065
- args = args.concat(SpreadElement(arg, scope));
1083
+ args = args.concat(SpreadElement$1(arg, scope));
1066
1084
  }
1067
1085
  else {
1068
- args.push(evaluate(arg, scope));
1086
+ args.push(evaluate$1(arg, scope));
1069
1087
  }
1070
1088
  }
1071
1089
  return new constructor(...args);
1072
1090
  }
1073
- function MetaProperty(node, scope) {
1091
+ function MetaProperty$1(node, scope) {
1074
1092
  if (node.meta.name === 'new' && node.property.name === 'target') {
1075
1093
  return scope.find(NEWTARGET).get();
1076
1094
  }
@@ -1078,33 +1096,33 @@
1078
1096
  return { url: '' };
1079
1097
  }
1080
1098
  }
1081
- function SequenceExpression(node, scope) {
1099
+ function SequenceExpression$1(node, scope) {
1082
1100
  let result;
1083
1101
  for (let i = 0; i < node.expressions.length; i++) {
1084
- result = evaluate(node.expressions[i], scope);
1102
+ result = evaluate$1(node.expressions[i], scope);
1085
1103
  }
1086
1104
  return result;
1087
1105
  }
1088
- function ArrowFunctionExpression(node, scope) {
1089
- return createFunc$1(node, scope);
1106
+ function ArrowFunctionExpression$1(node, scope) {
1107
+ return createFunc(node, scope);
1090
1108
  }
1091
- function TemplateLiteral(node, scope) {
1109
+ function TemplateLiteral$1(node, scope) {
1092
1110
  const quasis = node.quasis.slice();
1093
1111
  const expressions = node.expressions.slice();
1094
1112
  let result = '';
1095
1113
  let temEl;
1096
1114
  let expr;
1097
1115
  while (temEl = quasis.shift()) {
1098
- result += TemplateElement(temEl);
1116
+ result += TemplateElement$1(temEl);
1099
1117
  expr = expressions.shift();
1100
1118
  if (expr) {
1101
- result += evaluate(expr, scope);
1119
+ result += evaluate$1(expr, scope);
1102
1120
  }
1103
1121
  }
1104
1122
  return result;
1105
1123
  }
1106
- function TaggedTemplateExpression(node, scope) {
1107
- const tagFunc = evaluate(node.tag, scope);
1124
+ function TaggedTemplateExpression$1(node, scope) {
1125
+ const tagFunc = evaluate$1(node.tag, scope);
1108
1126
  const quasis = node.quasi.quasis;
1109
1127
  const str = quasis.map(v => v.value.cooked);
1110
1128
  const raw = quasis.map(v => v.value.raw);
@@ -1115,40 +1133,40 @@
1115
1133
  const args = [];
1116
1134
  if (expressions) {
1117
1135
  for (let i = 0; i < expressions.length; i++) {
1118
- args.push(evaluate(expressions[i], scope));
1136
+ args.push(evaluate$1(expressions[i], scope));
1119
1137
  }
1120
1138
  }
1121
1139
  return tagFunc(freeze(str), ...args);
1122
1140
  }
1123
- function TemplateElement(node, scope) {
1141
+ function TemplateElement$1(node, scope) {
1124
1142
  return node.value.raw;
1125
1143
  }
1126
- function ClassExpression(node, scope) {
1144
+ function ClassExpression$1(node, scope) {
1127
1145
  if (node.id && node.id.name) {
1128
1146
  const tmpScope = new Scope(scope);
1129
- const klass = createClass$1(node, tmpScope);
1147
+ const klass = createClass(node, tmpScope);
1130
1148
  tmpScope.const(node.id.name, klass);
1131
1149
  return klass;
1132
1150
  }
1133
1151
  else {
1134
- return createClass$1(node, scope);
1152
+ return createClass(node, scope);
1135
1153
  }
1136
1154
  }
1137
- function Super(node, scope, options = {}) {
1155
+ function Super$1(node, scope, options = {}) {
1138
1156
  const { getProto = false } = options;
1139
1157
  const superClass = scope.find(SUPER).get();
1140
1158
  return getProto ? superClass.prototype : superClass;
1141
1159
  }
1142
- function SpreadElement(node, scope) {
1143
- const result = evaluate(node.argument, scope);
1160
+ function SpreadElement$1(node, scope) {
1161
+ const result = evaluate$1(node.argument, scope);
1144
1162
  return typeof result === 'string' ? [...result] : result;
1145
1163
  }
1146
- function ChainExpression(node, scope) {
1147
- return evaluate(node.expression, scope);
1164
+ function ChainExpression$1(node, scope) {
1165
+ return evaluate$1(node.expression, scope);
1148
1166
  }
1149
- function ImportExpression(node, scope) {
1167
+ function ImportExpression$1(node, scope) {
1150
1168
  const globalScope = scope.global();
1151
- const source = evaluate(node.source, scope);
1169
+ const source = evaluate$1(node.source, scope);
1152
1170
  const module = globalScope.find(IMPORT + source);
1153
1171
  let value;
1154
1172
  if (module) {
@@ -1168,35 +1186,35 @@
1168
1186
  return Promise.resolve(value);
1169
1187
  }
1170
1188
 
1171
- var expression = /*#__PURE__*/Object.freeze({
1189
+ var expression$1 = /*#__PURE__*/Object.freeze({
1172
1190
  __proto__: null,
1173
- ThisExpression: ThisExpression,
1174
- ArrayExpression: ArrayExpression,
1175
- ObjectExpression: ObjectExpression,
1176
- FunctionExpression: FunctionExpression,
1177
- UnaryExpression: UnaryExpression,
1178
- UpdateExpression: UpdateExpression,
1179
- BinaryExpression: BinaryExpression,
1180
- AssignmentExpression: AssignmentExpression,
1181
- LogicalExpression: LogicalExpression,
1182
- MemberExpression: MemberExpression,
1183
- ConditionalExpression: ConditionalExpression,
1184
- CallExpression: CallExpression,
1185
- NewExpression: NewExpression,
1186
- MetaProperty: MetaProperty,
1187
- SequenceExpression: SequenceExpression,
1188
- ArrowFunctionExpression: ArrowFunctionExpression,
1189
- TemplateLiteral: TemplateLiteral,
1190
- TaggedTemplateExpression: TaggedTemplateExpression,
1191
- TemplateElement: TemplateElement,
1192
- ClassExpression: ClassExpression,
1193
- Super: Super,
1194
- SpreadElement: SpreadElement,
1195
- ChainExpression: ChainExpression,
1196
- ImportExpression: ImportExpression
1191
+ ThisExpression: ThisExpression$1,
1192
+ ArrayExpression: ArrayExpression$1,
1193
+ ObjectExpression: ObjectExpression$1,
1194
+ FunctionExpression: FunctionExpression$1,
1195
+ UnaryExpression: UnaryExpression$1,
1196
+ UpdateExpression: UpdateExpression$1,
1197
+ BinaryExpression: BinaryExpression$1,
1198
+ AssignmentExpression: AssignmentExpression$1,
1199
+ LogicalExpression: LogicalExpression$1,
1200
+ MemberExpression: MemberExpression$1,
1201
+ ConditionalExpression: ConditionalExpression$1,
1202
+ CallExpression: CallExpression$1,
1203
+ NewExpression: NewExpression$1,
1204
+ MetaProperty: MetaProperty$1,
1205
+ SequenceExpression: SequenceExpression$1,
1206
+ ArrowFunctionExpression: ArrowFunctionExpression$1,
1207
+ TemplateLiteral: TemplateLiteral$1,
1208
+ TaggedTemplateExpression: TaggedTemplateExpression$1,
1209
+ TemplateElement: TemplateElement$1,
1210
+ ClassExpression: ClassExpression$1,
1211
+ Super: Super$1,
1212
+ SpreadElement: SpreadElement$1,
1213
+ ChainExpression: ChainExpression$1,
1214
+ ImportExpression: ImportExpression$1
1197
1215
  });
1198
1216
 
1199
- function ObjectPattern(node, scope, options = {}) {
1217
+ function ObjectPattern$1(node, scope, options = {}) {
1200
1218
  const { kind = 'var', hoist = false, onlyBlock = false, feed = {} } = options;
1201
1219
  const fedKeys = [];
1202
1220
  for (let i = 0; i < node.properties.length; i++) {
@@ -1209,18 +1227,18 @@
1209
1227
  scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1210
1228
  }
1211
1229
  else {
1212
- pattern$3(value, scope, { kind, hoist, onlyBlock });
1230
+ pattern(value, scope, { kind, hoist, onlyBlock });
1213
1231
  }
1214
1232
  }
1215
1233
  else {
1216
- RestElement(property, scope, { kind, hoist, onlyBlock });
1234
+ RestElement$1(property, scope, { kind, hoist, onlyBlock });
1217
1235
  }
1218
1236
  }
1219
1237
  }
1220
1238
  else if (property.type === 'Property') {
1221
1239
  let key;
1222
1240
  if (property.computed) {
1223
- key = evaluate(property.key, scope);
1241
+ key = evaluate$1(property.key, scope);
1224
1242
  }
1225
1243
  else {
1226
1244
  key = property.key.name;
@@ -1231,18 +1249,18 @@
1231
1249
  scope[kind](value.name, feed[key]);
1232
1250
  }
1233
1251
  else {
1234
- pattern$3(value, scope, { kind, feed: feed[key] });
1252
+ pattern(value, scope, { kind, feed: feed[key] });
1235
1253
  }
1236
1254
  }
1237
1255
  else {
1238
1256
  const rest = assign({}, feed);
1239
1257
  for (let i = 0; i < fedKeys.length; i++)
1240
1258
  delete rest[fedKeys[i]];
1241
- RestElement(property, scope, { kind, feed: rest });
1259
+ RestElement$1(property, scope, { kind, feed: rest });
1242
1260
  }
1243
1261
  }
1244
1262
  }
1245
- function ArrayPattern(node, scope, options = {}) {
1263
+ function ArrayPattern$1(node, scope, options = {}) {
1246
1264
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
1247
1265
  const result = [];
1248
1266
  for (let i = 0; i < node.elements.length; i++) {
@@ -1255,7 +1273,7 @@
1255
1273
  scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1256
1274
  }
1257
1275
  else {
1258
- pattern$3(element, scope, { kind, hoist, onlyBlock });
1276
+ pattern(element, scope, { kind, hoist, onlyBlock });
1259
1277
  }
1260
1278
  }
1261
1279
  }
@@ -1264,23 +1282,23 @@
1264
1282
  scope[kind](element.name, feed[i]);
1265
1283
  }
1266
1284
  else {
1267
- const variable = Identifier(element, scope, { getVar: true });
1285
+ const variable = Identifier$1(element, scope, { getVar: true });
1268
1286
  variable.set(feed[i]);
1269
1287
  result.push(variable.get());
1270
1288
  }
1271
1289
  }
1272
1290
  else if (element.type === 'RestElement') {
1273
- RestElement(element, scope, { kind, feed: feed.slice(i) });
1291
+ RestElement$1(element, scope, { kind, feed: feed.slice(i) });
1274
1292
  }
1275
1293
  else {
1276
- pattern$3(element, scope, { kind, feed: feed[i] });
1294
+ pattern(element, scope, { kind, feed: feed[i] });
1277
1295
  }
1278
1296
  }
1279
1297
  if (result.length) {
1280
1298
  return result;
1281
1299
  }
1282
1300
  }
1283
- function RestElement(node, scope, options = {}) {
1301
+ function RestElement$1(node, scope, options = {}) {
1284
1302
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
1285
1303
  const arg = node.argument;
1286
1304
  if (hoist) {
@@ -1289,7 +1307,7 @@
1289
1307
  scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1290
1308
  }
1291
1309
  else {
1292
- pattern$3(arg, scope, { kind, hoist, onlyBlock });
1310
+ pattern(arg, scope, { kind, hoist, onlyBlock });
1293
1311
  }
1294
1312
  }
1295
1313
  }
@@ -1298,16 +1316,16 @@
1298
1316
  scope[kind](arg.name, feed);
1299
1317
  }
1300
1318
  else {
1301
- const variable = Identifier(arg, scope, { getVar: true });
1319
+ const variable = Identifier$1(arg, scope, { getVar: true });
1302
1320
  variable.set(feed);
1303
1321
  }
1304
1322
  }
1305
1323
  else {
1306
- pattern$3(arg, scope, { kind, feed });
1324
+ pattern(arg, scope, { kind, feed });
1307
1325
  }
1308
1326
  }
1309
- function AssignmentPattern(node, scope, options = {}) {
1310
- const { kind = 'var', hoist = false, onlyBlock = false, feed = evaluate(node.right, scope) } = options;
1327
+ function AssignmentPattern$1(node, scope, options = {}) {
1328
+ const { kind = 'var', hoist = false, onlyBlock = false, feed = evaluate$1(node.right, scope) } = options;
1311
1329
  const left = node.left;
1312
1330
  if (hoist) {
1313
1331
  if (onlyBlock || kind === 'var') {
@@ -1315,7 +1333,7 @@
1315
1333
  scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1316
1334
  }
1317
1335
  else {
1318
- pattern$3(left, scope, { kind, hoist, onlyBlock });
1336
+ pattern(left, scope, { kind, hoist, onlyBlock });
1319
1337
  }
1320
1338
  }
1321
1339
  }
@@ -1323,21 +1341,21 @@
1323
1341
  scope[kind](left.name, feed);
1324
1342
  }
1325
1343
  else {
1326
- pattern$3(left, scope, { kind, feed });
1344
+ pattern(left, scope, { kind, feed });
1327
1345
  }
1328
1346
  }
1329
1347
 
1330
- var pattern = /*#__PURE__*/Object.freeze({
1348
+ var pattern$3 = /*#__PURE__*/Object.freeze({
1331
1349
  __proto__: null,
1332
- ObjectPattern: ObjectPattern,
1333
- ArrayPattern: ArrayPattern,
1334
- RestElement: RestElement,
1335
- AssignmentPattern: AssignmentPattern
1350
+ ObjectPattern: ObjectPattern$1,
1351
+ ArrayPattern: ArrayPattern$1,
1352
+ RestElement: RestElement$1,
1353
+ AssignmentPattern: AssignmentPattern$1
1336
1354
  });
1337
1355
 
1338
1356
  function Program(program, scope) {
1339
1357
  for (let i = 0; i < program.body.length; i++) {
1340
- evaluate(program.body[i], scope);
1358
+ evaluate$1(program.body[i], scope);
1341
1359
  }
1342
1360
  }
1343
1361
 
@@ -1346,14 +1364,14 @@
1346
1364
  Program: Program
1347
1365
  });
1348
1366
 
1349
- let evaluateOps;
1350
- function evaluate(node, scope) {
1367
+ let evaluateOps$1;
1368
+ function evaluate$1(node, scope) {
1351
1369
  if (!node)
1352
1370
  return;
1353
- if (!evaluateOps) {
1354
- evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern, program);
1371
+ if (!evaluateOps$1) {
1372
+ evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$3, program);
1355
1373
  }
1356
- const handler = evaluateOps[node.type];
1374
+ const handler = evaluateOps$1[node.type];
1357
1375
  if (handler) {
1358
1376
  return handler(node, scope);
1359
1377
  }
@@ -1362,59 +1380,126 @@
1362
1380
  }
1363
1381
  }
1364
1382
 
1365
- function ExpressionStatement(node, scope) {
1366
- evaluate(node.expression, scope);
1383
+ function ExpressionStatement$1(node, scope) {
1384
+ evaluate$1(node.expression, scope);
1367
1385
  }
1368
- function BlockStatement(block, scope, options = {}) {
1386
+ function BlockStatement$1(block, scope, options = {}) {
1369
1387
  const { invasived = false, hoisted = false, } = options;
1370
1388
  const subScope = invasived ? scope : new Scope(scope);
1371
1389
  if (!hoisted) {
1372
- hoist$1(block, subScope, { onlyBlock: true });
1390
+ hoist(block, subScope, { onlyBlock: true });
1373
1391
  }
1374
1392
  for (let i = 0; i < block.body.length; i++) {
1375
- const result = evaluate(block.body[i], subScope);
1376
- if (result === BREAK || result === CONTINUE || result === RETURN) {
1393
+ const result = evaluate$1(block.body[i], subScope);
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) {
1377
1401
  return result;
1378
1402
  }
1379
1403
  }
1380
1404
  }
1381
- function EmptyStatement() {
1405
+ function EmptyStatement$1() {
1382
1406
  }
1383
- function DebuggerStatement() {
1407
+ function DebuggerStatement$1() {
1384
1408
  debugger;
1385
1409
  }
1386
- function ReturnStatement(node, scope) {
1387
- RETURN.RES = node.argument ? (evaluate(node.argument, scope)) : undefined;
1410
+ function ReturnStatement$1(node, scope) {
1411
+ RETURN.RES = node.argument ? (evaluate$1(node.argument, scope)) : undefined;
1388
1412
  return RETURN;
1389
1413
  }
1390
- function BreakStatement() {
1414
+ function BreakStatement$1(node) {
1415
+ var _a;
1416
+ BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
1391
1417
  return BREAK;
1392
1418
  }
1393
- function ContinueStatement() {
1419
+ function ContinueStatement$1(node) {
1420
+ var _a;
1421
+ CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
1394
1422
  return CONTINUE;
1395
1423
  }
1396
- function IfStatement(node, scope) {
1397
- if (evaluate(node.test, scope)) {
1398
- return evaluate(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 });
1399
1428
  }
1400
- else {
1401
- return evaluate(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;
1470
+ }
1471
+ }
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;
1402
1484
  }
1403
1485
  }
1404
- function SwitchStatement(node, scope) {
1405
- const discriminant = evaluate(node.discriminant, scope);
1486
+ function SwitchStatement$1(node, scope, options = {}) {
1487
+ const discriminant = evaluate$1(node.discriminant, scope);
1406
1488
  let matched = false;
1407
1489
  for (let i = 0; i < node.cases.length; i++) {
1408
1490
  const eachCase = node.cases[i];
1409
1491
  if (!matched
1410
1492
  && (!eachCase.test
1411
- || (evaluate(eachCase.test, scope)) === discriminant)) {
1493
+ || (evaluate$1(eachCase.test, scope)) === discriminant)) {
1412
1494
  matched = true;
1413
1495
  }
1414
1496
  if (matched) {
1415
- const result = SwitchCase(eachCase, scope);
1497
+ const result = SwitchCase$1(eachCase, scope);
1416
1498
  if (result === BREAK) {
1417
- break;
1499
+ if (result.LABEL === options.label) {
1500
+ break;
1501
+ }
1502
+ return result;
1418
1503
  }
1419
1504
  if (result === CONTINUE || result === RETURN) {
1420
1505
  return result;
@@ -1422,20 +1507,21 @@
1422
1507
  }
1423
1508
  }
1424
1509
  }
1425
- function SwitchCase(node, scope) {
1510
+ function SwitchCase$1(node, scope) {
1426
1511
  for (let i = 0; i < node.consequent.length; i++) {
1427
- const result = evaluate(node.consequent[i], scope);
1512
+ const result = evaluate$1(node.consequent[i], scope);
1428
1513
  if (result === BREAK || result === CONTINUE || result === RETURN) {
1429
1514
  return result;
1430
1515
  }
1431
1516
  }
1432
1517
  }
1433
- function ThrowStatement(node, scope) {
1434
- throw evaluate(node.argument, scope);
1518
+ function ThrowStatement$1(node, scope) {
1519
+ throw evaluate$1(node.argument, scope);
1435
1520
  }
1436
- function TryStatement(node, scope) {
1521
+ function TryStatement$1(node, scope, options = {}) {
1522
+ let result;
1437
1523
  try {
1438
- return BlockStatement(node.block, scope);
1524
+ result = BlockStatement$1(node.block, scope);
1439
1525
  }
1440
1526
  catch (err) {
1441
1527
  if (node.handler) {
@@ -1447,10 +1533,10 @@
1447
1533
  subScope.var(name, err);
1448
1534
  }
1449
1535
  else {
1450
- pattern$3(param, scope, { feed: err });
1536
+ pattern(param, scope, { feed: err });
1451
1537
  }
1452
1538
  }
1453
- return CatchClause(node.handler, subScope);
1539
+ result = CatchClause$1(node.handler, subScope);
1454
1540
  }
1455
1541
  else {
1456
1542
  throw err;
@@ -1458,89 +1544,125 @@
1458
1544
  }
1459
1545
  finally {
1460
1546
  if (node.finalizer) {
1461
- const result = BlockStatement(node.finalizer, scope);
1462
- if (result === BREAK || result === CONTINUE || result === RETURN) {
1463
- return result;
1464
- }
1547
+ result = BlockStatement$1(node.finalizer, scope);
1465
1548
  }
1466
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
+ }
1467
1559
  }
1468
- function CatchClause(node, scope) {
1469
- return BlockStatement(node.body, scope, { invasived: true });
1560
+ function CatchClause$1(node, scope) {
1561
+ return BlockStatement$1(node.body, scope, { invasived: true });
1470
1562
  }
1471
- function WhileStatement(node, scope) {
1472
- while (evaluate(node.test, scope)) {
1473
- const result = evaluate(node.body, scope);
1563
+ function WhileStatement$1(node, scope, options = {}) {
1564
+ while (evaluate$1(node.test, scope)) {
1565
+ const result = evaluate$1(node.body, scope);
1474
1566
  if (result === BREAK) {
1475
- break;
1567
+ if (result.LABEL === options.label) {
1568
+ break;
1569
+ }
1570
+ return result;
1476
1571
  }
1477
1572
  else if (result === CONTINUE) {
1478
- continue;
1573
+ if (result.LABEL === options.label) {
1574
+ continue;
1575
+ }
1576
+ return result;
1479
1577
  }
1480
1578
  else if (result === RETURN) {
1481
1579
  return result;
1482
1580
  }
1483
1581
  }
1484
1582
  }
1485
- function DoWhileStatement(node, scope) {
1583
+ function DoWhileStatement$1(node, scope, options = {}) {
1486
1584
  do {
1487
- const result = evaluate(node.body, scope);
1585
+ const result = evaluate$1(node.body, scope);
1488
1586
  if (result === BREAK) {
1489
- break;
1587
+ if (result.LABEL === options.label) {
1588
+ break;
1589
+ }
1590
+ return result;
1490
1591
  }
1491
1592
  else if (result === CONTINUE) {
1492
- continue;
1593
+ if (result.LABEL === options.label) {
1594
+ continue;
1595
+ }
1596
+ return result;
1493
1597
  }
1494
1598
  else if (result === RETURN) {
1495
1599
  return result;
1496
1600
  }
1497
- } while (evaluate(node.test, scope));
1601
+ } while (evaluate$1(node.test, scope));
1498
1602
  }
1499
- function ForStatement(node, scope) {
1603
+ function ForStatement$1(node, scope, options = {}) {
1500
1604
  const forScope = new Scope(scope);
1501
- for (evaluate(node.init, forScope); node.test ? (evaluate(node.test, forScope)) : true; evaluate(node.update, forScope)) {
1605
+ for (evaluate$1(node.init, forScope); node.test ? (evaluate$1(node.test, forScope)) : true; evaluate$1(node.update, forScope)) {
1502
1606
  const subScope = new Scope(forScope);
1503
1607
  let result;
1504
1608
  if (node.body.type === 'BlockStatement') {
1505
- result = BlockStatement(node.body, subScope, { invasived: true });
1609
+ result = BlockStatement$1(node.body, subScope, { invasived: true });
1506
1610
  }
1507
1611
  else {
1508
- result = evaluate(node.body, subScope);
1612
+ result = evaluate$1(node.body, subScope);
1509
1613
  }
1510
1614
  if (result === BREAK) {
1511
- break;
1615
+ if (result.LABEL === options.label) {
1616
+ break;
1617
+ }
1618
+ return result;
1512
1619
  }
1513
1620
  else if (result === CONTINUE) {
1514
- continue;
1621
+ if (result.LABEL === options.label) {
1622
+ continue;
1623
+ }
1624
+ return result;
1515
1625
  }
1516
1626
  else if (result === RETURN) {
1517
1627
  return result;
1518
1628
  }
1519
1629
  }
1520
1630
  }
1521
- function ForInStatement(node, scope) {
1522
- for (const value in evaluate(node.right, scope)) {
1523
- const result = ForXHandler$1(node, scope, { value });
1631
+ function ForInStatement$1(node, scope, options = {}) {
1632
+ for (const value in evaluate$1(node.right, scope)) {
1633
+ const result = ForXHandler(node, scope, { value });
1524
1634
  if (result === BREAK) {
1525
- break;
1635
+ if (result.LABEL === options.label) {
1636
+ break;
1637
+ }
1638
+ return result;
1526
1639
  }
1527
1640
  else if (result === CONTINUE) {
1528
- continue;
1641
+ if (result.LABEL === options.label) {
1642
+ continue;
1643
+ }
1644
+ return result;
1529
1645
  }
1530
1646
  else if (result === RETURN) {
1531
1647
  return result;
1532
1648
  }
1533
1649
  }
1534
1650
  }
1535
- function ForOfStatement(node, scope) {
1536
- const right = evaluate(node.right, scope);
1651
+ function ForOfStatement$1(node, scope, options = {}) {
1652
+ const right = evaluate$1(node.right, scope);
1537
1653
  for (const value of right) {
1538
- const result = ForXHandler$1(node, scope, { value });
1654
+ const result = ForXHandler(node, scope, { value });
1539
1655
  if (result === BREAK) {
1540
- break;
1656
+ if (result.LABEL === options.label) {
1657
+ break;
1658
+ }
1659
+ return result;
1541
1660
  }
1542
1661
  else if (result === CONTINUE) {
1543
- continue;
1662
+ if (result.LABEL === options.label) {
1663
+ continue;
1664
+ }
1665
+ return result;
1544
1666
  }
1545
1667
  else if (result === RETURN) {
1546
1668
  return result;
@@ -1548,15 +1670,15 @@
1548
1670
  }
1549
1671
  }
1550
1672
 
1551
- function FunctionDeclaration(node, scope) {
1552
- scope.func(node.id.name, createFunc$1(node, scope));
1673
+ function FunctionDeclaration$1(node, scope) {
1674
+ scope.func(node.id.name, createFunc(node, scope));
1553
1675
  }
1554
- function VariableDeclaration(node, scope, options = {}) {
1676
+ function VariableDeclaration$1(node, scope, options = {}) {
1555
1677
  for (let i = 0; i < node.declarations.length; i++) {
1556
- VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
1678
+ VariableDeclarator$1(node.declarations[i], scope, assign({ kind: node.kind }, options));
1557
1679
  }
1558
1680
  }
1559
- function VariableDeclarator(node, scope, options = {}) {
1681
+ function VariableDeclarator$1(node, scope, options = {}) {
1560
1682
  const { kind = 'var', hoist = false, onlyBlock = false, feed } = options;
1561
1683
  if (hoist) {
1562
1684
  if (onlyBlock || kind === 'var') {
@@ -1564,13 +1686,13 @@
1564
1686
  scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1565
1687
  }
1566
1688
  else {
1567
- pattern$3(node.id, scope, { kind, hoist, onlyBlock });
1689
+ pattern(node.id, scope, { kind, hoist, onlyBlock });
1568
1690
  }
1569
1691
  }
1570
1692
  }
1571
1693
  else {
1572
1694
  const hasFeed = 'feed' in options;
1573
- const value = hasFeed ? feed : evaluate(node.init, scope);
1695
+ const value = hasFeed ? feed : evaluate$1(node.init, scope);
1574
1696
  if (node.id.type === 'Identifier') {
1575
1697
  const name = node.id.name;
1576
1698
  if (kind === 'var' && !node.init && !hasFeed) {
@@ -1590,34 +1712,34 @@
1590
1712
  }
1591
1713
  }
1592
1714
  else {
1593
- pattern$3(node.id, scope, { kind, feed: value });
1715
+ pattern(node.id, scope, { kind, feed: value });
1594
1716
  }
1595
1717
  }
1596
1718
  }
1597
- function ClassDeclaration(node, scope) {
1598
- scope.func(node.id.name, createClass$1(node, scope));
1719
+ function ClassDeclaration$1(node, scope) {
1720
+ scope.func(node.id.name, createClass(node, scope));
1599
1721
  }
1600
- function ClassBody(node, scope, options = {}) {
1722
+ function ClassBody$1(node, scope, options = {}) {
1601
1723
  const { klass, superClass } = options;
1602
1724
  for (let i = 0; i < node.body.length; i++) {
1603
1725
  const def = node.body[i];
1604
1726
  if (def.type === 'MethodDefinition') {
1605
- MethodDefinition(def, scope, { klass, superClass });
1727
+ MethodDefinition$1(def, scope, { klass, superClass });
1606
1728
  }
1607
1729
  else if (def.type === 'PropertyDefinition' && def.static) {
1608
- PropertyDefinition(def, scope, { klass, superClass });
1730
+ PropertyDefinition$1(def, scope, { klass, superClass });
1609
1731
  }
1610
1732
  else if (def.type === 'StaticBlock') {
1611
- StaticBlock(def, scope, { klass, superClass });
1733
+ StaticBlock$1(def, scope, { klass, superClass });
1612
1734
  }
1613
1735
  }
1614
1736
  }
1615
- function MethodDefinition(node, scope, options = {}) {
1737
+ function MethodDefinition$1(node, scope, options = {}) {
1616
1738
  const { klass, superClass } = options;
1617
1739
  let key;
1618
1740
  let priv = false;
1619
1741
  if (node.computed) {
1620
- key = evaluate(node.key, scope);
1742
+ key = evaluate$1(node.key, scope);
1621
1743
  }
1622
1744
  else if (node.key.type === 'Identifier') {
1623
1745
  key = node.key.name;
@@ -1636,7 +1758,7 @@
1636
1758
  }
1637
1759
  obj = obj[PRIVATE];
1638
1760
  }
1639
- const value = createFunc$1(node.value, scope, { superClass });
1761
+ const value = createFunc(node.value, scope, { superClass });
1640
1762
  switch (node.kind) {
1641
1763
  case 'constructor':
1642
1764
  break;
@@ -1669,12 +1791,12 @@
1669
1791
  throw new SyntaxError('Unexpected token');
1670
1792
  }
1671
1793
  }
1672
- function PropertyDefinition(node, scope, options = {}) {
1794
+ function PropertyDefinition$1(node, scope, options = {}) {
1673
1795
  const { klass, superClass } = options;
1674
1796
  let key;
1675
1797
  let priv = false;
1676
1798
  if (node.computed) {
1677
- key = evaluate(node.key, scope);
1799
+ key = evaluate$1(node.key, scope);
1678
1800
  }
1679
1801
  else if (node.key.type === 'Identifier') {
1680
1802
  key = node.key.name;
@@ -1696,19 +1818,19 @@
1696
1818
  obj = obj[PRIVATE];
1697
1819
  }
1698
1820
  if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
1699
- obj[key] = createFunc$1(node.value, subScope, { superClass });
1821
+ obj[key] = createFunc(node.value, subScope, { superClass });
1700
1822
  }
1701
1823
  else {
1702
- obj[key] = evaluate(node.value, subScope);
1824
+ obj[key] = evaluate$1(node.value, subScope);
1703
1825
  }
1704
1826
  }
1705
- function StaticBlock(node, scope, options = {}) {
1827
+ function StaticBlock$1(node, scope, options = {}) {
1706
1828
  const { klass } = options;
1707
1829
  const subScope = new Scope(scope, true);
1708
1830
  subScope.const('this', klass);
1709
- return BlockStatement(node, subScope, { invasived: true });
1831
+ return BlockStatement$1(node, subScope, { invasived: true });
1710
1832
  }
1711
- function ImportDeclaration(node, scope) {
1833
+ function ImportDeclaration$1(node, scope) {
1712
1834
  const globalScope = scope.global();
1713
1835
  const module = globalScope.find(IMPORT + node.source.value);
1714
1836
  let value;
@@ -1745,19 +1867,19 @@
1745
1867
  scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
1746
1868
  }
1747
1869
  }
1748
- function ExportDefaultDeclaration(node, scope) {
1870
+ function ExportDefaultDeclaration$1(node, scope) {
1749
1871
  const globalScope = scope.global();
1750
1872
  let value;
1751
1873
  if (node.declaration.type === 'FunctionDeclaration') {
1752
- value = createFunc$1(node.declaration, scope);
1874
+ value = createFunc(node.declaration, scope);
1753
1875
  scope.func(node.declaration.id.name, value);
1754
1876
  }
1755
1877
  else if (node.declaration.type === 'ClassDeclaration') {
1756
- value = createClass$1(node.declaration, scope);
1878
+ value = createClass(node.declaration, scope);
1757
1879
  scope.func(node.declaration.id.name, value);
1758
1880
  }
1759
1881
  else {
1760
- value = evaluate(node.declaration, scope);
1882
+ value = evaluate$1(node.declaration, scope);
1761
1883
  }
1762
1884
  const variable = globalScope.find(EXPORTS);
1763
1885
  if (variable) {
@@ -1767,11 +1889,11 @@
1767
1889
  }
1768
1890
  }
1769
1891
  }
1770
- function ExportNamedDeclaration(node, scope) {
1892
+ function ExportNamedDeclaration$1(node, scope) {
1771
1893
  const globalScope = scope.global();
1772
1894
  if (node.declaration) {
1773
1895
  if (node.declaration.type === 'FunctionDeclaration') {
1774
- const value = createFunc$1(node.declaration, scope);
1896
+ const value = createFunc(node.declaration, scope);
1775
1897
  scope.func(node.declaration.id.name, value);
1776
1898
  const variable = globalScope.find(EXPORTS);
1777
1899
  if (variable) {
@@ -1782,7 +1904,7 @@
1782
1904
  }
1783
1905
  }
1784
1906
  else if (node.declaration.type === 'ClassDeclaration') {
1785
- const value = createClass$1(node.declaration, scope);
1907
+ const value = createClass(node.declaration, scope);
1786
1908
  scope.func(node.declaration.id.name, value);
1787
1909
  const variable = globalScope.find(EXPORTS);
1788
1910
  if (variable) {
@@ -1793,7 +1915,7 @@
1793
1915
  }
1794
1916
  }
1795
1917
  else if (node.declaration.type === 'VariableDeclaration') {
1796
- VariableDeclaration(node.declaration, scope);
1918
+ VariableDeclaration$1(node.declaration, scope);
1797
1919
  const variable = globalScope.find(EXPORTS);
1798
1920
  if (variable) {
1799
1921
  const exports = variable.get();
@@ -1828,7 +1950,7 @@
1828
1950
  }
1829
1951
  }
1830
1952
  }
1831
- function ExportAllDeclaration(node, scope) {
1953
+ function ExportAllDeclaration$1(node, scope) {
1832
1954
  const globalScope = scope.global();
1833
1955
  const module = globalScope.find(IMPORT + node.source.value);
1834
1956
  let value;
@@ -1855,7 +1977,7 @@
1855
1977
  }
1856
1978
  }
1857
1979
 
1858
- function* Identifier$1(node, scope, options = {}) {
1980
+ function* Identifier(node, scope, options = {}) {
1859
1981
  const { getVar = false, throwErr = true } = options;
1860
1982
  if (node.name === 'undefined') {
1861
1983
  return undefined;
@@ -1883,21 +2005,21 @@
1883
2005
  }
1884
2006
  }
1885
2007
 
1886
- var identifier$1 = /*#__PURE__*/Object.freeze({
2008
+ var identifier = /*#__PURE__*/Object.freeze({
1887
2009
  __proto__: null,
1888
- Identifier: Identifier$1
2010
+ Identifier: Identifier
1889
2011
  });
1890
2012
 
1891
- function* Literal$1(node, scope) {
2013
+ function* Literal(node, scope) {
1892
2014
  return node.value;
1893
2015
  }
1894
2016
 
1895
- var literal$1 = /*#__PURE__*/Object.freeze({
2017
+ var literal = /*#__PURE__*/Object.freeze({
1896
2018
  __proto__: null,
1897
- Literal: Literal$1
2019
+ Literal: Literal
1898
2020
  });
1899
2021
 
1900
- function* ThisExpression$1(node, scope) {
2022
+ function* ThisExpression(node, scope) {
1901
2023
  const superCall = scope.find(SUPERCALL);
1902
2024
  if (superCall && !superCall.get()) {
1903
2025
  throw new ReferenceError('Must call super constructor in derived class '
@@ -1907,41 +2029,41 @@
1907
2029
  return scope.find('this').get();
1908
2030
  }
1909
2031
  }
1910
- function* ArrayExpression$1(node, scope) {
2032
+ function* ArrayExpression(node, scope) {
1911
2033
  let results = [];
1912
2034
  for (let i = 0; i < node.elements.length; i++) {
1913
2035
  const item = node.elements[i];
1914
2036
  if (item.type === 'SpreadElement') {
1915
- results = results.concat(yield* SpreadElement$1(item, scope));
2037
+ results = results.concat(yield* SpreadElement(item, scope));
1916
2038
  }
1917
2039
  else {
1918
- results.push(yield* evaluate$1(item, scope));
2040
+ results.push(yield* evaluate(item, scope));
1919
2041
  }
1920
2042
  }
1921
2043
  return results;
1922
2044
  }
1923
- function* ObjectExpression$1(node, scope) {
2045
+ function* ObjectExpression(node, scope) {
1924
2046
  const object = {};
1925
2047
  for (let i = 0; i < node.properties.length; i++) {
1926
2048
  const property = node.properties[i];
1927
2049
  if (property.type === 'SpreadElement') {
1928
- assign(object, yield* SpreadElement$1(property, scope));
2050
+ assign(object, yield* SpreadElement(property, scope));
1929
2051
  }
1930
2052
  else {
1931
2053
  let key;
1932
2054
  const propKey = property.key;
1933
2055
  if (property.computed) {
1934
- key = yield* evaluate$1(propKey, scope);
2056
+ key = yield* evaluate(propKey, scope);
1935
2057
  }
1936
2058
  else {
1937
2059
  if (propKey.type === 'Identifier') {
1938
2060
  key = propKey.name;
1939
2061
  }
1940
2062
  else {
1941
- key = '' + (yield* Literal$1(propKey));
2063
+ key = '' + (yield* Literal(propKey));
1942
2064
  }
1943
2065
  }
1944
- const value = yield* evaluate$1(property.value, scope);
2066
+ const value = yield* evaluate(property.value, scope);
1945
2067
  const propKind = property.kind;
1946
2068
  if (propKind === 'init') {
1947
2069
  object[key] = value;
@@ -1968,55 +2090,55 @@
1968
2090
  }
1969
2091
  return object;
1970
2092
  }
1971
- function* FunctionExpression$1(node, scope) {
2093
+ function* FunctionExpression(node, scope) {
1972
2094
  if (node.id && node.id.name) {
1973
2095
  const tmpScope = new Scope(scope);
1974
- const func = createFunc(node, tmpScope);
2096
+ const func = createFunc$1(node, tmpScope);
1975
2097
  tmpScope.const(node.id.name, func);
1976
2098
  return func;
1977
2099
  }
1978
2100
  else {
1979
- return createFunc(node, scope);
2101
+ return createFunc$1(node, scope);
1980
2102
  }
1981
2103
  }
1982
- function* UnaryExpression$1(node, scope) {
2104
+ function* UnaryExpression(node, scope) {
1983
2105
  const arg = node.argument;
1984
2106
  switch (node.operator) {
1985
- case '+': return +(yield* evaluate$1(arg, scope));
1986
- case '-': return -(yield* evaluate$1(arg, scope));
1987
- case '!': return !(yield* evaluate$1(arg, scope));
1988
- case '~': return ~(yield* evaluate$1(arg, scope));
1989
- case 'void': return void (yield* evaluate$1(arg, scope));
2107
+ case '+': return +(yield* evaluate(arg, scope));
2108
+ case '-': return -(yield* evaluate(arg, scope));
2109
+ case '!': return !(yield* evaluate(arg, scope));
2110
+ case '~': return ~(yield* evaluate(arg, scope));
2111
+ case 'void': return void (yield* evaluate(arg, scope));
1990
2112
  case 'typeof':
1991
2113
  if (arg.type === 'Identifier') {
1992
- return typeof (yield* Identifier$1(arg, scope, { throwErr: false }));
2114
+ return typeof (yield* Identifier(arg, scope, { throwErr: false }));
1993
2115
  }
1994
2116
  else {
1995
- return typeof (yield* evaluate$1(arg, scope));
2117
+ return typeof (yield* evaluate(arg, scope));
1996
2118
  }
1997
2119
  case 'delete':
1998
2120
  if (arg.type === 'MemberExpression') {
1999
- const variable = yield* MemberExpression$1(arg, scope, { getVar: true });
2121
+ const variable = yield* MemberExpression(arg, scope, { getVar: true });
2000
2122
  return variable.del();
2001
2123
  }
2002
2124
  else if (arg.type === 'Identifier') {
2003
2125
  throw new SyntaxError('Delete of an unqualified identifier in strict mode');
2004
2126
  }
2005
2127
  else {
2006
- yield* evaluate$1(arg, scope);
2128
+ yield* evaluate(arg, scope);
2007
2129
  return true;
2008
2130
  }
2009
2131
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2010
2132
  }
2011
2133
  }
2012
- function* UpdateExpression$1(node, scope) {
2134
+ function* UpdateExpression(node, scope) {
2013
2135
  const arg = node.argument;
2014
2136
  let variable;
2015
2137
  if (arg.type === 'Identifier') {
2016
- variable = yield* Identifier$1(arg, scope, { getVar: true });
2138
+ variable = yield* Identifier(arg, scope, { getVar: true });
2017
2139
  }
2018
2140
  else if (arg.type === 'MemberExpression') {
2019
- variable = yield* MemberExpression$1(arg, scope, { getVar: true });
2141
+ variable = yield* MemberExpression(arg, scope, { getVar: true });
2020
2142
  }
2021
2143
  else {
2022
2144
  throw new SyntaxError('Unexpected token');
@@ -2034,17 +2156,17 @@
2034
2156
  throw new SyntaxError(`Unexpected token ${node.operator}`);
2035
2157
  }
2036
2158
  }
2037
- function* BinaryExpression$1(node, scope) {
2159
+ function* BinaryExpression(node, scope) {
2038
2160
  let left;
2039
2161
  let right;
2040
2162
  if (node.left.type === 'PrivateIdentifier') {
2041
2163
  left = node.left.name;
2042
- right = yield* evaluate$1(node.right, scope);
2164
+ right = yield* evaluate(node.right, scope);
2043
2165
  right = right[PRIVATE];
2044
2166
  }
2045
2167
  else {
2046
- left = yield* evaluate$1(node.left, scope);
2047
- right = yield* evaluate$1(node.right, scope);
2168
+ left = yield* evaluate(node.left, scope);
2169
+ right = yield* evaluate(node.right, scope);
2048
2170
  }
2049
2171
  switch (node.operator) {
2050
2172
  case '==': return left == right;
@@ -2072,25 +2194,25 @@
2072
2194
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2073
2195
  }
2074
2196
  }
2075
- function* AssignmentExpression$1(node, scope) {
2197
+ function* AssignmentExpression(node, scope) {
2076
2198
  var _a;
2077
2199
  const left = node.left;
2078
2200
  let variable;
2079
2201
  if (left.type === 'Identifier') {
2080
- variable = yield* Identifier$1(left, scope, { getVar: true, throwErr: false });
2202
+ variable = yield* Identifier(left, scope, { getVar: true, throwErr: false });
2081
2203
  if (!variable) {
2082
2204
  const win = scope.global().find('window').get();
2083
2205
  variable = new Prop(win, left.name);
2084
2206
  }
2085
2207
  }
2086
2208
  else if (left.type === 'MemberExpression') {
2087
- variable = yield* MemberExpression$1(left, scope, { getVar: true });
2209
+ variable = yield* MemberExpression(left, scope, { getVar: true });
2088
2210
  }
2089
2211
  else {
2090
- const value = yield* evaluate$1(node.right, scope);
2091
- return yield* pattern$2(left, scope, { feed: value });
2212
+ const value = yield* evaluate(node.right, scope);
2213
+ return yield* pattern$1(left, scope, { feed: value });
2092
2214
  }
2093
- const value = yield* evaluate$1(node.right, scope);
2215
+ const value = yield* evaluate(node.right, scope);
2094
2216
  switch (node.operator) {
2095
2217
  case '=':
2096
2218
  variable.set(value);
@@ -2143,34 +2265,34 @@
2143
2265
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2144
2266
  }
2145
2267
  }
2146
- function* LogicalExpression$1(node, scope) {
2268
+ function* LogicalExpression(node, scope) {
2147
2269
  var _a;
2148
2270
  switch (node.operator) {
2149
2271
  case '||':
2150
- return (yield* evaluate$1(node.left, scope)) || (yield* evaluate$1(node.right, scope));
2272
+ return (yield* evaluate(node.left, scope)) || (yield* evaluate(node.right, scope));
2151
2273
  case '&&':
2152
- return (yield* evaluate$1(node.left, scope)) && (yield* evaluate$1(node.right, scope));
2274
+ return (yield* evaluate(node.left, scope)) && (yield* evaluate(node.right, scope));
2153
2275
  case '??':
2154
- return (_a = (yield* evaluate$1(node.left, scope))) !== null && _a !== void 0 ? _a : (yield* evaluate$1(node.right, scope));
2276
+ return (_a = (yield* evaluate(node.left, scope))) !== null && _a !== void 0 ? _a : (yield* evaluate(node.right, scope));
2155
2277
  default:
2156
2278
  throw new SyntaxError(`Unexpected token ${node.operator}`);
2157
2279
  }
2158
2280
  }
2159
- function* MemberExpression$1(node, scope, options = {}) {
2281
+ function* MemberExpression(node, scope, options = {}) {
2160
2282
  const { getObj = false, getVar = false } = options;
2161
2283
  let object;
2162
2284
  if (node.object.type === 'Super') {
2163
- object = yield* Super$1(node.object, scope, { getProto: true });
2285
+ object = yield* Super(node.object, scope, { getProto: true });
2164
2286
  }
2165
2287
  else {
2166
- object = yield* evaluate$1(node.object, scope);
2288
+ object = yield* evaluate(node.object, scope);
2167
2289
  }
2168
2290
  if (getObj)
2169
2291
  return object;
2170
2292
  let key;
2171
2293
  let priv = false;
2172
2294
  if (node.computed) {
2173
- key = yield* evaluate$1(node.property, scope);
2295
+ key = yield* evaluate(node.property, scope);
2174
2296
  }
2175
2297
  else if (node.property.type === 'PrivateIdentifier') {
2176
2298
  key = node.property.name;
@@ -2211,23 +2333,23 @@
2211
2333
  }
2212
2334
  }
2213
2335
  }
2214
- function* ConditionalExpression$1(node, scope) {
2215
- return (yield* evaluate$1(node.test, scope))
2216
- ? (yield* evaluate$1(node.consequent, scope))
2217
- : (yield* evaluate$1(node.alternate, scope));
2336
+ function* ConditionalExpression(node, scope) {
2337
+ return (yield* evaluate(node.test, scope))
2338
+ ? (yield* evaluate(node.consequent, scope))
2339
+ : (yield* evaluate(node.alternate, scope));
2218
2340
  }
2219
- function* CallExpression$1(node, scope) {
2341
+ function* CallExpression(node, scope) {
2220
2342
  let func;
2221
2343
  let object;
2222
2344
  if (node.callee.type === 'MemberExpression') {
2223
- object = yield* MemberExpression$1(node.callee, scope, { getObj: true });
2345
+ object = yield* MemberExpression(node.callee, scope, { getObj: true });
2224
2346
  if (node.callee.optional && object == null) {
2225
2347
  return undefined;
2226
2348
  }
2227
2349
  let key;
2228
2350
  let priv = false;
2229
2351
  if (node.callee.computed) {
2230
- key = yield* evaluate$1(node.callee.property, scope);
2352
+ key = yield* evaluate(node.callee.property, scope);
2231
2353
  }
2232
2354
  else if (node.callee.property.type === 'PrivateIdentifier') {
2233
2355
  key = node.callee.property.name;
@@ -2259,7 +2381,7 @@
2259
2381
  }
2260
2382
  else {
2261
2383
  object = scope.find('this').get();
2262
- func = yield* evaluate$1(node.callee, scope);
2384
+ func = yield* evaluate(node.callee, scope);
2263
2385
  if (node.optional && func == null) {
2264
2386
  return undefined;
2265
2387
  }
@@ -2288,10 +2410,10 @@
2288
2410
  for (let i = 0; i < node.arguments.length; i++) {
2289
2411
  const arg = node.arguments[i];
2290
2412
  if (arg.type === 'SpreadElement') {
2291
- args = args.concat(yield* SpreadElement$1(arg, scope));
2413
+ args = args.concat(yield* SpreadElement(arg, scope));
2292
2414
  }
2293
2415
  else {
2294
- args.push(yield* evaluate$1(arg, scope));
2416
+ args.push(yield* evaluate(arg, scope));
2295
2417
  }
2296
2418
  }
2297
2419
  if (node.callee.type === 'Super') {
@@ -2303,13 +2425,22 @@
2303
2425
  scope.find(SUPERCALL).set(true);
2304
2426
  }
2305
2427
  }
2306
- if (object && object[WINDOW] && func.toString().indexOf('[native code]') !== -1) {
2307
- return func.apply(object[WINDOW], args);
2428
+ try {
2429
+ return func.apply(object, args);
2430
+ }
2431
+ catch (err) {
2432
+ if (err instanceof TypeError && err.message === 'Illegal invocation'
2433
+ && func.toString().indexOf('[native code]') !== -1) {
2434
+ const win = scope.global().find('window').get();
2435
+ if (win && win[WINDOW]) {
2436
+ return func.apply(win[WINDOW], args);
2437
+ }
2438
+ }
2439
+ throw err;
2308
2440
  }
2309
- return func.apply(object, args);
2310
2441
  }
2311
- function* NewExpression$1(node, scope) {
2312
- const constructor = yield* evaluate$1(node.callee, scope);
2442
+ function* NewExpression(node, scope) {
2443
+ const constructor = yield* evaluate(node.callee, scope);
2313
2444
  if (typeof constructor !== 'function') {
2314
2445
  let name;
2315
2446
  if (node.callee.type === 'Identifier') {
@@ -2332,15 +2463,15 @@
2332
2463
  for (let i = 0; i < node.arguments.length; i++) {
2333
2464
  const arg = node.arguments[i];
2334
2465
  if (arg.type === 'SpreadElement') {
2335
- args = args.concat(yield* SpreadElement$1(arg, scope));
2466
+ args = args.concat(yield* SpreadElement(arg, scope));
2336
2467
  }
2337
2468
  else {
2338
- args.push(yield* evaluate$1(arg, scope));
2469
+ args.push(yield* evaluate(arg, scope));
2339
2470
  }
2340
2471
  }
2341
2472
  return new constructor(...args);
2342
2473
  }
2343
- function* MetaProperty$1(node, scope) {
2474
+ function* MetaProperty(node, scope) {
2344
2475
  if (node.meta.name === 'new' && node.property.name === 'target') {
2345
2476
  return scope.find(NEWTARGET).get();
2346
2477
  }
@@ -2348,33 +2479,33 @@
2348
2479
  return { url: '' };
2349
2480
  }
2350
2481
  }
2351
- function* SequenceExpression$1(node, scope) {
2482
+ function* SequenceExpression(node, scope) {
2352
2483
  let result;
2353
2484
  for (let i = 0; i < node.expressions.length; i++) {
2354
- result = yield* evaluate$1(node.expressions[i], scope);
2485
+ result = yield* evaluate(node.expressions[i], scope);
2355
2486
  }
2356
2487
  return result;
2357
2488
  }
2358
- function* ArrowFunctionExpression$1(node, scope) {
2359
- return createFunc(node, scope);
2489
+ function* ArrowFunctionExpression(node, scope) {
2490
+ return createFunc$1(node, scope);
2360
2491
  }
2361
- function* TemplateLiteral$1(node, scope) {
2492
+ function* TemplateLiteral(node, scope) {
2362
2493
  const quasis = node.quasis.slice();
2363
2494
  const expressions = node.expressions.slice();
2364
2495
  let result = '';
2365
2496
  let temEl;
2366
2497
  let expr;
2367
2498
  while (temEl = quasis.shift()) {
2368
- result += yield* TemplateElement$1(temEl);
2499
+ result += yield* TemplateElement(temEl);
2369
2500
  expr = expressions.shift();
2370
2501
  if (expr) {
2371
- result += yield* evaluate$1(expr, scope);
2502
+ result += yield* evaluate(expr, scope);
2372
2503
  }
2373
2504
  }
2374
2505
  return result;
2375
2506
  }
2376
- function* TaggedTemplateExpression$1(node, scope) {
2377
- const tagFunc = yield* evaluate$1(node.tag, scope);
2507
+ function* TaggedTemplateExpression(node, scope) {
2508
+ const tagFunc = yield* evaluate(node.tag, scope);
2378
2509
  const quasis = node.quasi.quasis;
2379
2510
  const str = quasis.map(v => v.value.cooked);
2380
2511
  const raw = quasis.map(v => v.value.raw);
@@ -2385,40 +2516,40 @@
2385
2516
  const args = [];
2386
2517
  if (expressions) {
2387
2518
  for (let i = 0; i < expressions.length; i++) {
2388
- args.push(yield* evaluate$1(expressions[i], scope));
2519
+ args.push(yield* evaluate(expressions[i], scope));
2389
2520
  }
2390
2521
  }
2391
2522
  return tagFunc(freeze(str), ...args);
2392
2523
  }
2393
- function* TemplateElement$1(node, scope) {
2524
+ function* TemplateElement(node, scope) {
2394
2525
  return node.value.raw;
2395
2526
  }
2396
- function* ClassExpression$1(node, scope) {
2527
+ function* ClassExpression(node, scope) {
2397
2528
  if (node.id && node.id.name) {
2398
2529
  const tmpScope = new Scope(scope);
2399
- const klass = yield* createClass(node, tmpScope);
2530
+ const klass = yield* createClass$1(node, tmpScope);
2400
2531
  tmpScope.const(node.id.name, klass);
2401
2532
  return klass;
2402
2533
  }
2403
2534
  else {
2404
- return yield* createClass(node, scope);
2535
+ return yield* createClass$1(node, scope);
2405
2536
  }
2406
2537
  }
2407
- function* Super$1(node, scope, options = {}) {
2538
+ function* Super(node, scope, options = {}) {
2408
2539
  const { getProto = false } = options;
2409
2540
  const superClass = scope.find(SUPER).get();
2410
2541
  return getProto ? superClass.prototype : superClass;
2411
2542
  }
2412
- function* SpreadElement$1(node, scope) {
2413
- const result = yield* evaluate$1(node.argument, scope);
2543
+ function* SpreadElement(node, scope) {
2544
+ const result = yield* evaluate(node.argument, scope);
2414
2545
  return typeof result === 'string' ? [...result] : result;
2415
2546
  }
2416
- function* ChainExpression$1(node, scope) {
2417
- return yield* evaluate$1(node.expression, scope);
2547
+ function* ChainExpression(node, scope) {
2548
+ return yield* evaluate(node.expression, scope);
2418
2549
  }
2419
- function* ImportExpression$1(node, scope) {
2550
+ function* ImportExpression(node, scope) {
2420
2551
  const globalScope = scope.global();
2421
- const source = yield* evaluate$1(node.source, scope);
2552
+ const source = yield* evaluate(node.source, scope);
2422
2553
  const module = globalScope.find(IMPORT + source);
2423
2554
  let value;
2424
2555
  if (module) {
@@ -2438,45 +2569,45 @@
2438
2569
  return Promise.resolve(value);
2439
2570
  }
2440
2571
  function* YieldExpression(node, scope) {
2441
- const res = yield* evaluate$1(node.argument, scope);
2572
+ const res = yield* evaluate(node.argument, scope);
2442
2573
  return node.delegate ? yield* res : yield res;
2443
2574
  }
2444
2575
  function* AwaitExpression(node, scope) {
2445
- AWAIT.RES = yield* evaluate$1(node.argument, scope);
2576
+ AWAIT.RES = yield* evaluate(node.argument, scope);
2446
2577
  return yield AWAIT;
2447
2578
  }
2448
2579
 
2449
- var expression$1 = /*#__PURE__*/Object.freeze({
2580
+ var expression = /*#__PURE__*/Object.freeze({
2450
2581
  __proto__: null,
2451
- ThisExpression: ThisExpression$1,
2452
- ArrayExpression: ArrayExpression$1,
2453
- ObjectExpression: ObjectExpression$1,
2454
- FunctionExpression: FunctionExpression$1,
2455
- UnaryExpression: UnaryExpression$1,
2456
- UpdateExpression: UpdateExpression$1,
2457
- BinaryExpression: BinaryExpression$1,
2458
- AssignmentExpression: AssignmentExpression$1,
2459
- LogicalExpression: LogicalExpression$1,
2460
- MemberExpression: MemberExpression$1,
2461
- ConditionalExpression: ConditionalExpression$1,
2462
- CallExpression: CallExpression$1,
2463
- NewExpression: NewExpression$1,
2464
- MetaProperty: MetaProperty$1,
2465
- SequenceExpression: SequenceExpression$1,
2466
- ArrowFunctionExpression: ArrowFunctionExpression$1,
2467
- TemplateLiteral: TemplateLiteral$1,
2468
- TaggedTemplateExpression: TaggedTemplateExpression$1,
2469
- TemplateElement: TemplateElement$1,
2470
- ClassExpression: ClassExpression$1,
2471
- Super: Super$1,
2472
- SpreadElement: SpreadElement$1,
2473
- ChainExpression: ChainExpression$1,
2474
- ImportExpression: ImportExpression$1,
2582
+ ThisExpression: ThisExpression,
2583
+ ArrayExpression: ArrayExpression,
2584
+ ObjectExpression: ObjectExpression,
2585
+ FunctionExpression: FunctionExpression,
2586
+ UnaryExpression: UnaryExpression,
2587
+ UpdateExpression: UpdateExpression,
2588
+ BinaryExpression: BinaryExpression,
2589
+ AssignmentExpression: AssignmentExpression,
2590
+ LogicalExpression: LogicalExpression,
2591
+ MemberExpression: MemberExpression,
2592
+ ConditionalExpression: ConditionalExpression,
2593
+ CallExpression: CallExpression,
2594
+ NewExpression: NewExpression,
2595
+ MetaProperty: MetaProperty,
2596
+ SequenceExpression: SequenceExpression,
2597
+ ArrowFunctionExpression: ArrowFunctionExpression,
2598
+ TemplateLiteral: TemplateLiteral,
2599
+ TaggedTemplateExpression: TaggedTemplateExpression,
2600
+ TemplateElement: TemplateElement,
2601
+ ClassExpression: ClassExpression,
2602
+ Super: Super,
2603
+ SpreadElement: SpreadElement,
2604
+ ChainExpression: ChainExpression,
2605
+ ImportExpression: ImportExpression,
2475
2606
  YieldExpression: YieldExpression,
2476
2607
  AwaitExpression: AwaitExpression
2477
2608
  });
2478
2609
 
2479
- function* ObjectPattern$1(node, scope, options = {}) {
2610
+ function* ObjectPattern(node, scope, options = {}) {
2480
2611
  const { kind = 'var', hoist = false, onlyBlock = false, feed = {} } = options;
2481
2612
  const fedKeys = [];
2482
2613
  for (let i = 0; i < node.properties.length; i++) {
@@ -2489,18 +2620,18 @@
2489
2620
  scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2490
2621
  }
2491
2622
  else {
2492
- yield* pattern$2(value, scope, { kind, hoist, onlyBlock });
2623
+ yield* pattern$1(value, scope, { kind, hoist, onlyBlock });
2493
2624
  }
2494
2625
  }
2495
2626
  else {
2496
- yield* RestElement$1(property, scope, { kind, hoist, onlyBlock });
2627
+ yield* RestElement(property, scope, { kind, hoist, onlyBlock });
2497
2628
  }
2498
2629
  }
2499
2630
  }
2500
2631
  else if (property.type === 'Property') {
2501
2632
  let key;
2502
2633
  if (property.computed) {
2503
- key = yield* evaluate$1(property.key, scope);
2634
+ key = yield* evaluate(property.key, scope);
2504
2635
  }
2505
2636
  else {
2506
2637
  key = property.key.name;
@@ -2511,18 +2642,18 @@
2511
2642
  scope[kind](value.name, feed[key]);
2512
2643
  }
2513
2644
  else {
2514
- yield* pattern$2(value, scope, { kind, feed: feed[key] });
2645
+ yield* pattern$1(value, scope, { kind, feed: feed[key] });
2515
2646
  }
2516
2647
  }
2517
2648
  else {
2518
2649
  const rest = assign({}, feed);
2519
2650
  for (let i = 0; i < fedKeys.length; i++)
2520
2651
  delete rest[fedKeys[i]];
2521
- yield* RestElement$1(property, scope, { kind, feed: rest });
2652
+ yield* RestElement(property, scope, { kind, feed: rest });
2522
2653
  }
2523
2654
  }
2524
2655
  }
2525
- function* ArrayPattern$1(node, scope, options = {}) {
2656
+ function* ArrayPattern(node, scope, options = {}) {
2526
2657
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
2527
2658
  const result = [];
2528
2659
  for (let i = 0; i < node.elements.length; i++) {
@@ -2535,7 +2666,7 @@
2535
2666
  scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2536
2667
  }
2537
2668
  else {
2538
- yield* pattern$2(element, scope, { kind, hoist, onlyBlock });
2669
+ yield* pattern$1(element, scope, { kind, hoist, onlyBlock });
2539
2670
  }
2540
2671
  }
2541
2672
  }
@@ -2544,23 +2675,23 @@
2544
2675
  scope[kind](element.name, feed[i]);
2545
2676
  }
2546
2677
  else {
2547
- const variable = yield* Identifier$1(element, scope, { getVar: true });
2678
+ const variable = yield* Identifier(element, scope, { getVar: true });
2548
2679
  variable.set(feed[i]);
2549
2680
  result.push(variable.get());
2550
2681
  }
2551
2682
  }
2552
2683
  else if (element.type === 'RestElement') {
2553
- yield* RestElement$1(element, scope, { kind, feed: feed.slice(i) });
2684
+ yield* RestElement(element, scope, { kind, feed: feed.slice(i) });
2554
2685
  }
2555
2686
  else {
2556
- yield* pattern$2(element, scope, { kind, feed: feed[i] });
2687
+ yield* pattern$1(element, scope, { kind, feed: feed[i] });
2557
2688
  }
2558
2689
  }
2559
2690
  if (result.length) {
2560
2691
  return result;
2561
2692
  }
2562
2693
  }
2563
- function* RestElement$1(node, scope, options = {}) {
2694
+ function* RestElement(node, scope, options = {}) {
2564
2695
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
2565
2696
  const arg = node.argument;
2566
2697
  if (hoist) {
@@ -2569,7 +2700,7 @@
2569
2700
  scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2570
2701
  }
2571
2702
  else {
2572
- yield* pattern$2(arg, scope, { kind, hoist, onlyBlock });
2703
+ yield* pattern$1(arg, scope, { kind, hoist, onlyBlock });
2573
2704
  }
2574
2705
  }
2575
2706
  }
@@ -2578,16 +2709,16 @@
2578
2709
  scope[kind](arg.name, feed);
2579
2710
  }
2580
2711
  else {
2581
- const variable = yield* Identifier$1(arg, scope, { getVar: true });
2712
+ const variable = yield* Identifier(arg, scope, { getVar: true });
2582
2713
  variable.set(feed);
2583
2714
  }
2584
2715
  }
2585
2716
  else {
2586
- yield* pattern$2(arg, scope, { kind, feed });
2717
+ yield* pattern$1(arg, scope, { kind, feed });
2587
2718
  }
2588
2719
  }
2589
- function* AssignmentPattern$1(node, scope, options = {}) {
2590
- const { kind = 'var', hoist = false, onlyBlock = false, feed = yield* evaluate$1(node.right, scope) } = options;
2720
+ function* AssignmentPattern(node, scope, options = {}) {
2721
+ const { kind = 'var', hoist = false, onlyBlock = false, feed = yield* evaluate(node.right, scope) } = options;
2591
2722
  const left = node.left;
2592
2723
  if (hoist) {
2593
2724
  if (onlyBlock || kind === 'var') {
@@ -2595,7 +2726,7 @@
2595
2726
  scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2596
2727
  }
2597
2728
  else {
2598
- yield* pattern$2(left, scope, { kind, hoist, onlyBlock });
2729
+ yield* pattern$1(left, scope, { kind, hoist, onlyBlock });
2599
2730
  }
2600
2731
  }
2601
2732
  }
@@ -2603,26 +2734,26 @@
2603
2734
  scope[kind](left.name, feed);
2604
2735
  }
2605
2736
  else {
2606
- yield* pattern$2(left, scope, { kind, feed });
2737
+ yield* pattern$1(left, scope, { kind, feed });
2607
2738
  }
2608
2739
  }
2609
2740
 
2610
- var pattern$1 = /*#__PURE__*/Object.freeze({
2741
+ var pattern$2 = /*#__PURE__*/Object.freeze({
2611
2742
  __proto__: null,
2612
- ObjectPattern: ObjectPattern$1,
2613
- ArrayPattern: ArrayPattern$1,
2614
- RestElement: RestElement$1,
2615
- AssignmentPattern: AssignmentPattern$1
2743
+ ObjectPattern: ObjectPattern,
2744
+ ArrayPattern: ArrayPattern,
2745
+ RestElement: RestElement,
2746
+ AssignmentPattern: AssignmentPattern
2616
2747
  });
2617
2748
 
2618
- let evaluateOps$1;
2619
- function* evaluate$1(node, scope) {
2749
+ let evaluateOps;
2750
+ function* evaluate(node, scope) {
2620
2751
  if (!node)
2621
2752
  return;
2622
- if (!evaluateOps$1) {
2623
- evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$1);
2753
+ if (!evaluateOps) {
2754
+ evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern$2);
2624
2755
  }
2625
- const handler = evaluateOps$1[node.type];
2756
+ const handler = evaluateOps[node.type];
2626
2757
  if (handler) {
2627
2758
  return yield* handler(node, scope);
2628
2759
  }
@@ -2631,59 +2762,126 @@
2631
2762
  }
2632
2763
  }
2633
2764
 
2634
- function* ExpressionStatement$1(node, scope) {
2635
- yield* evaluate$1(node.expression, scope);
2765
+ function* ExpressionStatement(node, scope) {
2766
+ yield* evaluate(node.expression, scope);
2636
2767
  }
2637
- function* BlockStatement$1(block, scope, options = {}) {
2768
+ function* BlockStatement(block, scope, options = {}) {
2638
2769
  const { invasived = false, hoisted = false, } = options;
2639
2770
  const subScope = invasived ? scope : new Scope(scope);
2640
2771
  if (!hoisted) {
2641
- yield* hoist(block, subScope, { onlyBlock: true });
2772
+ yield* hoist$1(block, subScope, { onlyBlock: true });
2642
2773
  }
2643
2774
  for (let i = 0; i < block.body.length; i++) {
2644
- const result = yield* evaluate$1(block.body[i], subScope);
2645
- if (result === BREAK || result === CONTINUE || result === RETURN) {
2775
+ const result = yield* evaluate(block.body[i], subScope);
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) {
2646
2783
  return result;
2647
2784
  }
2648
2785
  }
2649
2786
  }
2650
- function* EmptyStatement$1() {
2787
+ function* EmptyStatement() {
2651
2788
  }
2652
- function* DebuggerStatement$1() {
2789
+ function* DebuggerStatement() {
2653
2790
  debugger;
2654
2791
  }
2655
- function* ReturnStatement$1(node, scope) {
2656
- RETURN.RES = node.argument ? (yield* evaluate$1(node.argument, scope)) : undefined;
2792
+ function* ReturnStatement(node, scope) {
2793
+ RETURN.RES = node.argument ? (yield* evaluate(node.argument, scope)) : undefined;
2657
2794
  return RETURN;
2658
2795
  }
2659
- function* BreakStatement$1() {
2796
+ function* BreakStatement(node) {
2797
+ var _a;
2798
+ BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2660
2799
  return BREAK;
2661
2800
  }
2662
- function* ContinueStatement$1() {
2801
+ function* ContinueStatement(node) {
2802
+ var _a;
2803
+ CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2663
2804
  return CONTINUE;
2664
2805
  }
2665
- function* IfStatement$1(node, scope) {
2666
- if (yield* evaluate$1(node.test, scope)) {
2667
- return yield* evaluate$1(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 });
2668
2810
  }
2669
- else {
2670
- return yield* evaluate$1(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;
2671
2852
  }
2672
2853
  }
2673
- function* SwitchStatement$1(node, scope) {
2674
- const discriminant = yield* evaluate$1(node.discriminant, scope);
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;
2866
+ }
2867
+ }
2868
+ function* SwitchStatement(node, scope, options = {}) {
2869
+ const discriminant = yield* evaluate(node.discriminant, scope);
2675
2870
  let matched = false;
2676
2871
  for (let i = 0; i < node.cases.length; i++) {
2677
2872
  const eachCase = node.cases[i];
2678
2873
  if (!matched
2679
2874
  && (!eachCase.test
2680
- || (yield* evaluate$1(eachCase.test, scope)) === discriminant)) {
2875
+ || (yield* evaluate(eachCase.test, scope)) === discriminant)) {
2681
2876
  matched = true;
2682
2877
  }
2683
2878
  if (matched) {
2684
- const result = yield* SwitchCase$1(eachCase, scope);
2879
+ const result = yield* SwitchCase(eachCase, scope);
2685
2880
  if (result === BREAK) {
2686
- break;
2881
+ if (result.LABEL === options.label) {
2882
+ break;
2883
+ }
2884
+ return result;
2687
2885
  }
2688
2886
  if (result === CONTINUE || result === RETURN) {
2689
2887
  return result;
@@ -2691,20 +2889,21 @@
2691
2889
  }
2692
2890
  }
2693
2891
  }
2694
- function* SwitchCase$1(node, scope) {
2892
+ function* SwitchCase(node, scope) {
2695
2893
  for (let i = 0; i < node.consequent.length; i++) {
2696
- const result = yield* evaluate$1(node.consequent[i], scope);
2894
+ const result = yield* evaluate(node.consequent[i], scope);
2697
2895
  if (result === BREAK || result === CONTINUE || result === RETURN) {
2698
2896
  return result;
2699
2897
  }
2700
2898
  }
2701
2899
  }
2702
- function* ThrowStatement$1(node, scope) {
2703
- throw yield* evaluate$1(node.argument, scope);
2900
+ function* ThrowStatement(node, scope) {
2901
+ throw yield* evaluate(node.argument, scope);
2704
2902
  }
2705
- function* TryStatement$1(node, scope) {
2903
+ function* TryStatement(node, scope, options = {}) {
2904
+ let result;
2706
2905
  try {
2707
- return yield* BlockStatement$1(node.block, scope);
2906
+ result = yield* BlockStatement(node.block, scope);
2708
2907
  }
2709
2908
  catch (err) {
2710
2909
  if (node.handler) {
@@ -2716,10 +2915,10 @@
2716
2915
  subScope.var(name, err);
2717
2916
  }
2718
2917
  else {
2719
- yield* pattern$2(param, scope, { feed: err });
2918
+ yield* pattern$1(param, scope, { feed: err });
2720
2919
  }
2721
2920
  }
2722
- return yield* CatchClause$1(node.handler, subScope);
2921
+ result = yield* CatchClause(node.handler, subScope);
2723
2922
  }
2724
2923
  else {
2725
2924
  throw err;
@@ -2727,92 +2926,128 @@
2727
2926
  }
2728
2927
  finally {
2729
2928
  if (node.finalizer) {
2730
- const result = yield* BlockStatement$1(node.finalizer, scope);
2731
- if (result === BREAK || result === CONTINUE || result === RETURN) {
2732
- return result;
2733
- }
2929
+ result = yield* BlockStatement(node.finalizer, scope);
2930
+ }
2931
+ }
2932
+ if (result === BREAK) {
2933
+ if (result.LABEL && result.LABEL === options.label) {
2934
+ return;
2734
2935
  }
2936
+ return result;
2937
+ }
2938
+ if (result === CONTINUE || result === RETURN) {
2939
+ return result;
2735
2940
  }
2736
2941
  }
2737
- function* CatchClause$1(node, scope) {
2738
- return yield* BlockStatement$1(node.body, scope, { invasived: true });
2942
+ function* CatchClause(node, scope) {
2943
+ return yield* BlockStatement(node.body, scope, { invasived: true });
2739
2944
  }
2740
- function* WhileStatement$1(node, scope) {
2741
- while (yield* evaluate$1(node.test, scope)) {
2742
- const result = yield* evaluate$1(node.body, scope);
2945
+ function* WhileStatement(node, scope, options = {}) {
2946
+ while (yield* evaluate(node.test, scope)) {
2947
+ const result = yield* evaluate(node.body, scope);
2743
2948
  if (result === BREAK) {
2744
- break;
2949
+ if (result.LABEL === options.label) {
2950
+ break;
2951
+ }
2952
+ return result;
2745
2953
  }
2746
2954
  else if (result === CONTINUE) {
2747
- continue;
2955
+ if (result.LABEL === options.label) {
2956
+ continue;
2957
+ }
2958
+ return result;
2748
2959
  }
2749
2960
  else if (result === RETURN) {
2750
2961
  return result;
2751
2962
  }
2752
2963
  }
2753
2964
  }
2754
- function* DoWhileStatement$1(node, scope) {
2965
+ function* DoWhileStatement(node, scope, options = {}) {
2755
2966
  do {
2756
- const result = yield* evaluate$1(node.body, scope);
2967
+ const result = yield* evaluate(node.body, scope);
2757
2968
  if (result === BREAK) {
2758
- break;
2969
+ if (result.LABEL === options.label) {
2970
+ break;
2971
+ }
2972
+ return result;
2759
2973
  }
2760
2974
  else if (result === CONTINUE) {
2761
- continue;
2975
+ if (result.LABEL === options.label) {
2976
+ continue;
2977
+ }
2978
+ return result;
2762
2979
  }
2763
2980
  else if (result === RETURN) {
2764
2981
  return result;
2765
2982
  }
2766
- } while (yield* evaluate$1(node.test, scope));
2983
+ } while (yield* evaluate(node.test, scope));
2767
2984
  }
2768
- function* ForStatement$1(node, scope) {
2985
+ function* ForStatement(node, scope, options = {}) {
2769
2986
  const forScope = new Scope(scope);
2770
- for (yield* evaluate$1(node.init, forScope); node.test ? (yield* evaluate$1(node.test, forScope)) : true; yield* evaluate$1(node.update, forScope)) {
2987
+ for (yield* evaluate(node.init, forScope); node.test ? (yield* evaluate(node.test, forScope)) : true; yield* evaluate(node.update, forScope)) {
2771
2988
  const subScope = new Scope(forScope);
2772
2989
  let result;
2773
2990
  if (node.body.type === 'BlockStatement') {
2774
- result = yield* BlockStatement$1(node.body, subScope, { invasived: true });
2991
+ result = yield* BlockStatement(node.body, subScope, { invasived: true });
2775
2992
  }
2776
2993
  else {
2777
- result = yield* evaluate$1(node.body, subScope);
2994
+ result = yield* evaluate(node.body, subScope);
2778
2995
  }
2779
2996
  if (result === BREAK) {
2780
- break;
2997
+ if (result.LABEL === options.label) {
2998
+ break;
2999
+ }
3000
+ return result;
2781
3001
  }
2782
3002
  else if (result === CONTINUE) {
2783
- continue;
3003
+ if (result.LABEL === options.label) {
3004
+ continue;
3005
+ }
3006
+ return result;
2784
3007
  }
2785
3008
  else if (result === RETURN) {
2786
3009
  return result;
2787
3010
  }
2788
3011
  }
2789
3012
  }
2790
- function* ForInStatement$1(node, scope) {
2791
- for (const value in yield* evaluate$1(node.right, scope)) {
2792
- const result = yield* ForXHandler(node, scope, { value });
3013
+ function* ForInStatement(node, scope, options = {}) {
3014
+ for (const value in yield* evaluate(node.right, scope)) {
3015
+ const result = yield* ForXHandler$1(node, scope, { value });
2793
3016
  if (result === BREAK) {
2794
- break;
3017
+ if (result.LABEL === options.label) {
3018
+ break;
3019
+ }
3020
+ return result;
2795
3021
  }
2796
3022
  else if (result === CONTINUE) {
2797
- continue;
3023
+ if (result.LABEL === options.label) {
3024
+ continue;
3025
+ }
3026
+ return result;
2798
3027
  }
2799
3028
  else if (result === RETURN) {
2800
3029
  return result;
2801
3030
  }
2802
3031
  }
2803
3032
  }
2804
- function* ForOfStatement$1(node, scope) {
2805
- const right = yield* evaluate$1(node.right, scope);
3033
+ function* ForOfStatement(node, scope, options = {}) {
3034
+ const right = yield* evaluate(node.right, scope);
2806
3035
  if (node.await) {
2807
3036
  const iterator = getAsyncIterator(right);
2808
3037
  let ret;
2809
3038
  for (AWAIT.RES = iterator.next(), ret = yield AWAIT; !ret.done; AWAIT.RES = iterator.next(), ret = yield AWAIT) {
2810
- const result = yield* ForXHandler(node, scope, { value: ret.value });
3039
+ const result = yield* ForXHandler$1(node, scope, { value: ret.value });
2811
3040
  if (result === BREAK) {
2812
- break;
3041
+ if (result.LABEL === options.label) {
3042
+ break;
3043
+ }
3044
+ return result;
2813
3045
  }
2814
3046
  else if (result === CONTINUE) {
2815
- continue;
3047
+ if (result.LABEL === options.label) {
3048
+ continue;
3049
+ }
3050
+ return result;
2816
3051
  }
2817
3052
  else if (result === RETURN) {
2818
3053
  return result;
@@ -2821,12 +3056,18 @@
2821
3056
  }
2822
3057
  else {
2823
3058
  for (const value of right) {
2824
- const result = yield* ForXHandler(node, scope, { value });
3059
+ const result = yield* ForXHandler$1(node, scope, { value });
2825
3060
  if (result === BREAK) {
2826
- break;
3061
+ if (result.LABEL === options.label) {
3062
+ break;
3063
+ }
3064
+ return result;
2827
3065
  }
2828
3066
  else if (result === CONTINUE) {
2829
- continue;
3067
+ if (result.LABEL === options.label) {
3068
+ continue;
3069
+ }
3070
+ return result;
2830
3071
  }
2831
3072
  else if (result === RETURN) {
2832
3073
  return result;
@@ -2835,15 +3076,15 @@
2835
3076
  }
2836
3077
  }
2837
3078
 
2838
- function* FunctionDeclaration$1(node, scope) {
2839
- scope.func(node.id.name, createFunc(node, scope));
3079
+ function* FunctionDeclaration(node, scope) {
3080
+ scope.func(node.id.name, createFunc$1(node, scope));
2840
3081
  }
2841
- function* VariableDeclaration$1(node, scope, options = {}) {
3082
+ function* VariableDeclaration(node, scope, options = {}) {
2842
3083
  for (let i = 0; i < node.declarations.length; i++) {
2843
- yield* VariableDeclarator$1(node.declarations[i], scope, assign({ kind: node.kind }, options));
3084
+ yield* VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
2844
3085
  }
2845
3086
  }
2846
- function* VariableDeclarator$1(node, scope, options = {}) {
3087
+ function* VariableDeclarator(node, scope, options = {}) {
2847
3088
  const { kind = 'var', hoist = false, onlyBlock = false, feed } = options;
2848
3089
  if (hoist) {
2849
3090
  if (onlyBlock || kind === 'var') {
@@ -2851,13 +3092,13 @@
2851
3092
  scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2852
3093
  }
2853
3094
  else {
2854
- yield* pattern$2(node.id, scope, { kind, hoist, onlyBlock });
3095
+ yield* pattern$1(node.id, scope, { kind, hoist, onlyBlock });
2855
3096
  }
2856
3097
  }
2857
3098
  }
2858
3099
  else {
2859
3100
  const hasFeed = 'feed' in options;
2860
- const value = hasFeed ? feed : yield* evaluate$1(node.init, scope);
3101
+ const value = hasFeed ? feed : yield* evaluate(node.init, scope);
2861
3102
  if (node.id.type === 'Identifier') {
2862
3103
  const name = node.id.name;
2863
3104
  if (kind === 'var' && !node.init && !hasFeed) {
@@ -2877,34 +3118,34 @@
2877
3118
  }
2878
3119
  }
2879
3120
  else {
2880
- yield* pattern$2(node.id, scope, { kind, feed: value });
3121
+ yield* pattern$1(node.id, scope, { kind, feed: value });
2881
3122
  }
2882
3123
  }
2883
3124
  }
2884
- function* ClassDeclaration$1(node, scope) {
2885
- scope.func(node.id.name, yield* createClass(node, scope));
3125
+ function* ClassDeclaration(node, scope) {
3126
+ scope.func(node.id.name, yield* createClass$1(node, scope));
2886
3127
  }
2887
- function* ClassBody$1(node, scope, options = {}) {
3128
+ function* ClassBody(node, scope, options = {}) {
2888
3129
  const { klass, superClass } = options;
2889
3130
  for (let i = 0; i < node.body.length; i++) {
2890
3131
  const def = node.body[i];
2891
3132
  if (def.type === 'MethodDefinition') {
2892
- yield* MethodDefinition$1(def, scope, { klass, superClass });
3133
+ yield* MethodDefinition(def, scope, { klass, superClass });
2893
3134
  }
2894
3135
  else if (def.type === 'PropertyDefinition' && def.static) {
2895
- yield* PropertyDefinition$1(def, scope, { klass, superClass });
3136
+ yield* PropertyDefinition(def, scope, { klass, superClass });
2896
3137
  }
2897
3138
  else if (def.type === 'StaticBlock') {
2898
- yield* StaticBlock$1(def, scope, { klass, superClass });
3139
+ yield* StaticBlock(def, scope, { klass, superClass });
2899
3140
  }
2900
3141
  }
2901
3142
  }
2902
- function* MethodDefinition$1(node, scope, options = {}) {
3143
+ function* MethodDefinition(node, scope, options = {}) {
2903
3144
  const { klass, superClass } = options;
2904
3145
  let key;
2905
3146
  let priv = false;
2906
3147
  if (node.computed) {
2907
- key = yield* evaluate$1(node.key, scope);
3148
+ key = yield* evaluate(node.key, scope);
2908
3149
  }
2909
3150
  else if (node.key.type === 'Identifier') {
2910
3151
  key = node.key.name;
@@ -2923,7 +3164,7 @@
2923
3164
  }
2924
3165
  obj = obj[PRIVATE];
2925
3166
  }
2926
- const value = createFunc(node.value, scope, { superClass });
3167
+ const value = createFunc$1(node.value, scope, { superClass });
2927
3168
  switch (node.kind) {
2928
3169
  case 'constructor':
2929
3170
  break;
@@ -2956,12 +3197,12 @@
2956
3197
  throw new SyntaxError('Unexpected token');
2957
3198
  }
2958
3199
  }
2959
- function* PropertyDefinition$1(node, scope, options = {}) {
3200
+ function* PropertyDefinition(node, scope, options = {}) {
2960
3201
  const { klass, superClass } = options;
2961
3202
  let key;
2962
3203
  let priv = false;
2963
3204
  if (node.computed) {
2964
- key = yield* evaluate$1(node.key, scope);
3205
+ key = yield* evaluate(node.key, scope);
2965
3206
  }
2966
3207
  else if (node.key.type === 'Identifier') {
2967
3208
  key = node.key.name;
@@ -2983,19 +3224,19 @@
2983
3224
  obj = obj[PRIVATE];
2984
3225
  }
2985
3226
  if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
2986
- obj[key] = createFunc(node.value, subScope, { superClass });
3227
+ obj[key] = createFunc$1(node.value, subScope, { superClass });
2987
3228
  }
2988
3229
  else {
2989
- obj[key] = yield* evaluate$1(node.value, subScope);
3230
+ obj[key] = yield* evaluate(node.value, subScope);
2990
3231
  }
2991
3232
  }
2992
- function* StaticBlock$1(node, scope, options = {}) {
3233
+ function* StaticBlock(node, scope, options = {}) {
2993
3234
  const { klass } = options;
2994
3235
  const subScope = new Scope(scope, true);
2995
3236
  subScope.const('this', klass);
2996
- return yield* BlockStatement$1(node, subScope, { invasived: true });
3237
+ return yield* BlockStatement(node, subScope, { invasived: true });
2997
3238
  }
2998
- function* ImportDeclaration$1(node, scope) {
3239
+ function* ImportDeclaration(node, scope) {
2999
3240
  const globalScope = scope.global();
3000
3241
  const module = globalScope.find(IMPORT + node.source.value);
3001
3242
  let value;
@@ -3032,19 +3273,19 @@
3032
3273
  scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
3033
3274
  }
3034
3275
  }
3035
- function* ExportDefaultDeclaration$1(node, scope) {
3276
+ function* ExportDefaultDeclaration(node, scope) {
3036
3277
  const globalScope = scope.global();
3037
3278
  let value;
3038
3279
  if (node.declaration.type === 'FunctionDeclaration') {
3039
- value = createFunc(node.declaration, scope);
3280
+ value = createFunc$1(node.declaration, scope);
3040
3281
  scope.func(node.declaration.id.name, value);
3041
3282
  }
3042
3283
  else if (node.declaration.type === 'ClassDeclaration') {
3043
- value = yield* createClass(node.declaration, scope);
3284
+ value = yield* createClass$1(node.declaration, scope);
3044
3285
  scope.func(node.declaration.id.name, value);
3045
3286
  }
3046
3287
  else {
3047
- value = yield* evaluate$1(node.declaration, scope);
3288
+ value = yield* evaluate(node.declaration, scope);
3048
3289
  }
3049
3290
  const variable = globalScope.find(EXPORTS);
3050
3291
  if (variable) {
@@ -3054,11 +3295,11 @@
3054
3295
  }
3055
3296
  }
3056
3297
  }
3057
- function* ExportNamedDeclaration$1(node, scope) {
3298
+ function* ExportNamedDeclaration(node, scope) {
3058
3299
  const globalScope = scope.global();
3059
3300
  if (node.declaration) {
3060
3301
  if (node.declaration.type === 'FunctionDeclaration') {
3061
- const value = createFunc(node.declaration, scope);
3302
+ const value = createFunc$1(node.declaration, scope);
3062
3303
  scope.func(node.declaration.id.name, value);
3063
3304
  const variable = globalScope.find(EXPORTS);
3064
3305
  if (variable) {
@@ -3069,7 +3310,7 @@
3069
3310
  }
3070
3311
  }
3071
3312
  else if (node.declaration.type === 'ClassDeclaration') {
3072
- const value = yield* createClass(node.declaration, scope);
3313
+ const value = yield* createClass$1(node.declaration, scope);
3073
3314
  scope.func(node.declaration.id.name, value);
3074
3315
  const variable = globalScope.find(EXPORTS);
3075
3316
  if (variable) {
@@ -3080,7 +3321,7 @@
3080
3321
  }
3081
3322
  }
3082
3323
  else if (node.declaration.type === 'VariableDeclaration') {
3083
- yield* VariableDeclaration$1(node.declaration, scope);
3324
+ yield* VariableDeclaration(node.declaration, scope);
3084
3325
  const variable = globalScope.find(EXPORTS);
3085
3326
  if (variable) {
3086
3327
  const exports = variable.get();
@@ -3115,7 +3356,7 @@
3115
3356
  }
3116
3357
  }
3117
3358
  }
3118
- function* ExportAllDeclaration$1(node, scope) {
3359
+ function* ExportAllDeclaration(node, scope) {
3119
3360
  const globalScope = scope.global();
3120
3361
  const module = globalScope.find(IMPORT + node.source.value);
3121
3362
  let value;
@@ -3188,7 +3429,7 @@
3188
3429
  });
3189
3430
  }
3190
3431
 
3191
- function* hoist(block, scope, options = {}) {
3432
+ function* hoist$1(block, scope, options = {}) {
3192
3433
  const { onlyBlock = false } = options;
3193
3434
  const funcDclrList = [];
3194
3435
  const funcDclrIdxs = [];
@@ -3200,10 +3441,10 @@
3200
3441
  }
3201
3442
  else if (statement.type === 'VariableDeclaration'
3202
3443
  && ['const', 'let'].indexOf(statement.kind) !== -1) {
3203
- yield* VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
3444
+ yield* VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
3204
3445
  }
3205
3446
  else if (!onlyBlock) {
3206
- yield* hoistVarRecursion(statement, scope);
3447
+ yield* hoistVarRecursion$1(statement, scope);
3207
3448
  }
3208
3449
  }
3209
3450
  if (funcDclrIdxs.length) {
@@ -3213,80 +3454,81 @@
3213
3454
  block.body = funcDclrList.concat(block.body);
3214
3455
  }
3215
3456
  }
3216
- function* hoistVarRecursion(statement, scope) {
3457
+ function* hoistVarRecursion$1(statement, scope) {
3217
3458
  switch (statement.type) {
3218
3459
  case 'VariableDeclaration':
3219
- yield* VariableDeclaration$1(statement, scope, { hoist: true });
3460
+ yield* VariableDeclaration(statement, scope, { hoist: true });
3220
3461
  break;
3221
3462
  case 'ForInStatement':
3222
3463
  case 'ForOfStatement':
3223
3464
  if (statement.left.type === 'VariableDeclaration') {
3224
- yield* VariableDeclaration$1(statement.left, scope, { hoist: true });
3465
+ yield* VariableDeclaration(statement.left, scope, { hoist: true });
3225
3466
  }
3226
3467
  case 'ForStatement':
3227
3468
  if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
3228
- yield* VariableDeclaration$1(statement.init, scope, { hoist: true });
3469
+ yield* VariableDeclaration(statement.init, scope, { hoist: true });
3229
3470
  }
3230
3471
  case 'WhileStatement':
3231
3472
  case 'DoWhileStatement':
3232
- yield* hoistVarRecursion(statement.body, scope);
3473
+ yield* hoistVarRecursion$1(statement.body, scope);
3233
3474
  break;
3234
3475
  case 'IfStatement':
3235
- yield* hoistVarRecursion(statement.consequent, scope);
3476
+ yield* hoistVarRecursion$1(statement.consequent, scope);
3236
3477
  if (statement.alternate) {
3237
- yield* hoistVarRecursion(statement.alternate, scope);
3478
+ yield* hoistVarRecursion$1(statement.alternate, scope);
3238
3479
  }
3239
3480
  break;
3240
3481
  case 'BlockStatement':
3241
3482
  for (let i = 0; i < statement.body.length; i++) {
3242
- yield* hoistVarRecursion(statement.body[i], scope);
3483
+ yield* hoistVarRecursion$1(statement.body[i], scope);
3243
3484
  }
3244
3485
  break;
3245
3486
  case 'SwitchStatement':
3246
3487
  for (let i = 0; i < statement.cases.length; i++) {
3247
3488
  for (let j = 0; j < statement.cases[i].consequent.length; j++) {
3248
- yield* hoistVarRecursion(statement.cases[i].consequent[j], scope);
3489
+ yield* hoistVarRecursion$1(statement.cases[i].consequent[j], scope);
3249
3490
  }
3250
3491
  }
3251
3492
  break;
3252
3493
  case 'TryStatement': {
3253
3494
  const tryBlock = statement.block.body;
3254
3495
  for (let i = 0; i < tryBlock.length; i++) {
3255
- yield* hoistVarRecursion(tryBlock[i], scope);
3496
+ yield* hoistVarRecursion$1(tryBlock[i], scope);
3256
3497
  }
3257
3498
  const catchBlock = statement.handler && statement.handler.body.body;
3258
3499
  if (catchBlock) {
3259
3500
  for (let i = 0; i < catchBlock.length; i++) {
3260
- yield* hoistVarRecursion(catchBlock[i], scope);
3501
+ yield* hoistVarRecursion$1(catchBlock[i], scope);
3261
3502
  }
3262
3503
  }
3263
3504
  const finalBlock = statement.finalizer && statement.finalizer.body;
3264
3505
  if (finalBlock) {
3265
3506
  for (let i = 0; i < finalBlock.length; i++) {
3266
- yield* hoistVarRecursion(finalBlock[i], scope);
3507
+ yield* hoistVarRecursion$1(finalBlock[i], scope);
3267
3508
  }
3268
3509
  }
3269
3510
  break;
3270
3511
  }
3271
3512
  }
3272
3513
  }
3273
- function* pattern$2(node, scope, options = {}) {
3514
+ function* pattern$1(node, scope, options = {}) {
3274
3515
  switch (node.type) {
3275
3516
  case 'ObjectPattern':
3276
- return yield* ObjectPattern$1(node, scope, options);
3517
+ return yield* ObjectPattern(node, scope, options);
3277
3518
  case 'ArrayPattern':
3278
- return yield* ArrayPattern$1(node, scope, options);
3519
+ return yield* ArrayPattern(node, scope, options);
3279
3520
  case 'RestElement':
3280
- return yield* RestElement$1(node, scope, options);
3521
+ return yield* RestElement(node, scope, options);
3281
3522
  case 'AssignmentPattern':
3282
- return yield* AssignmentPattern$1(node, scope, options);
3523
+ return yield* AssignmentPattern(node, scope, options);
3283
3524
  default:
3284
3525
  throw new SyntaxError('Unexpected token');
3285
3526
  }
3286
3527
  }
3287
- function createFunc(node, scope, options = {}) {
3528
+ function createFunc$1(node, scope, options = {}) {
3529
+ var _a;
3288
3530
  if (!node.generator && !node.async) {
3289
- return createFunc$1(node, scope, options);
3531
+ return createFunc(node, scope, options);
3290
3532
  }
3291
3533
  const { superClass, construct } = options;
3292
3534
  const params = node.params;
@@ -3311,22 +3553,22 @@
3311
3553
  subScope.var(param.name, args[i]);
3312
3554
  }
3313
3555
  else if (param.type === 'RestElement') {
3314
- yield* RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
3556
+ yield* RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
3315
3557
  }
3316
3558
  else {
3317
- yield* pattern$2(param, subScope, { kind: 'var', feed: args[i] });
3559
+ yield* pattern$1(param, subScope, { kind: 'var', feed: args[i] });
3318
3560
  }
3319
3561
  }
3320
3562
  let result;
3321
3563
  if (node.body.type === 'BlockStatement') {
3322
- yield* hoist(node.body, subScope);
3323
- result = yield* BlockStatement$1(node.body, subScope, {
3564
+ yield* hoist$1(node.body, subScope);
3565
+ result = yield* BlockStatement(node.body, subScope, {
3324
3566
  invasived: true,
3325
3567
  hoisted: true
3326
3568
  });
3327
3569
  }
3328
3570
  else {
3329
- result = yield* evaluate$1(node.body, subScope);
3571
+ result = yield* evaluate(node.body, subScope);
3330
3572
  if (node.type === 'ArrowFunctionExpression') {
3331
3573
  RETURN.RES = result;
3332
3574
  result = RETURN;
@@ -3378,16 +3620,23 @@
3378
3620
  value: params.length,
3379
3621
  configurable: true
3380
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
+ }
3381
3630
  return func;
3382
3631
  }
3383
- function* createClass(node, scope) {
3384
- const superClass = yield* evaluate$1(node.superClass, scope);
3632
+ function* createClass$1(node, scope) {
3633
+ const superClass = yield* evaluate(node.superClass, scope);
3385
3634
  const methodBody = node.body.body;
3386
3635
  const construct = function* (object) {
3387
3636
  for (let i = 0; i < methodBody.length; i++) {
3388
3637
  const def = methodBody[i];
3389
3638
  if (def.type === 'PropertyDefinition' && !def.static) {
3390
- yield* PropertyDefinition$1(def, scope, { klass: object, superClass });
3639
+ yield* PropertyDefinition(def, scope, { klass: object, superClass });
3391
3640
  }
3392
3641
  }
3393
3642
  };
@@ -3400,14 +3649,14 @@
3400
3649
  for (let i = 0; i < methodBody.length; i++) {
3401
3650
  const method = methodBody[i];
3402
3651
  if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
3403
- klass = createFunc(method.value, scope, { superClass, construct });
3652
+ klass = createFunc$1(method.value, scope, { superClass, construct });
3404
3653
  break;
3405
3654
  }
3406
3655
  }
3407
3656
  if (superClass) {
3408
3657
  inherits(klass, superClass);
3409
3658
  }
3410
- yield* ClassBody$1(node.body, scope, { klass, superClass });
3659
+ yield* ClassBody(node.body, scope, { klass, superClass });
3411
3660
  define(klass, CLSCTOR, { value: true });
3412
3661
  define(klass, 'name', {
3413
3662
  value: node.id && node.id.name || '',
@@ -3415,31 +3664,31 @@
3415
3664
  });
3416
3665
  return klass;
3417
3666
  }
3418
- function* ForXHandler(node, scope, options) {
3667
+ function* ForXHandler$1(node, scope, options) {
3419
3668
  const { value } = options;
3420
3669
  const left = node.left;
3421
3670
  const subScope = new Scope(scope);
3422
3671
  if (left.type === 'VariableDeclaration') {
3423
- yield* VariableDeclaration$1(left, subScope, { feed: value });
3672
+ yield* VariableDeclaration(left, subScope, { feed: value });
3424
3673
  }
3425
3674
  else if (left.type === 'Identifier') {
3426
- const variable = yield* Identifier(left, scope, { getVar: true });
3675
+ const variable = yield* Identifier$1(left, scope, { getVar: true });
3427
3676
  variable.set(value);
3428
3677
  }
3429
3678
  else {
3430
- yield* pattern$2(left, scope, { feed: value });
3679
+ yield* pattern$1(left, scope, { feed: value });
3431
3680
  }
3432
3681
  let result;
3433
3682
  if (node.body.type === 'BlockStatement') {
3434
- result = yield* BlockStatement$1(node.body, subScope, { invasived: true });
3683
+ result = yield* BlockStatement(node.body, subScope, { invasived: true });
3435
3684
  }
3436
3685
  else {
3437
- result = yield* evaluate$1(node.body, subScope);
3686
+ result = yield* evaluate(node.body, subScope);
3438
3687
  }
3439
3688
  return result;
3440
3689
  }
3441
3690
 
3442
- function hoist$1(block, scope, options = {}) {
3691
+ function hoist(block, scope, options = {}) {
3443
3692
  const { onlyBlock = false } = options;
3444
3693
  const funcDclrList = [];
3445
3694
  const funcDclrIdxs = [];
@@ -3451,10 +3700,10 @@
3451
3700
  }
3452
3701
  else if (statement.type === 'VariableDeclaration'
3453
3702
  && ['const', 'let'].indexOf(statement.kind) !== -1) {
3454
- VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
3703
+ VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
3455
3704
  }
3456
3705
  else if (!onlyBlock) {
3457
- hoistVarRecursion$1(statement, scope);
3706
+ hoistVarRecursion(statement, scope);
3458
3707
  }
3459
3708
  }
3460
3709
  if (funcDclrIdxs.length) {
@@ -3464,80 +3713,81 @@
3464
3713
  block.body = funcDclrList.concat(block.body);
3465
3714
  }
3466
3715
  }
3467
- function hoistVarRecursion$1(statement, scope) {
3716
+ function hoistVarRecursion(statement, scope) {
3468
3717
  switch (statement.type) {
3469
3718
  case 'VariableDeclaration':
3470
- VariableDeclaration(statement, scope, { hoist: true });
3719
+ VariableDeclaration$1(statement, scope, { hoist: true });
3471
3720
  break;
3472
3721
  case 'ForInStatement':
3473
3722
  case 'ForOfStatement':
3474
3723
  if (statement.left.type === 'VariableDeclaration') {
3475
- VariableDeclaration(statement.left, scope, { hoist: true });
3724
+ VariableDeclaration$1(statement.left, scope, { hoist: true });
3476
3725
  }
3477
3726
  case 'ForStatement':
3478
3727
  if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
3479
- VariableDeclaration(statement.init, scope, { hoist: true });
3728
+ VariableDeclaration$1(statement.init, scope, { hoist: true });
3480
3729
  }
3481
3730
  case 'WhileStatement':
3482
3731
  case 'DoWhileStatement':
3483
- hoistVarRecursion$1(statement.body, scope);
3732
+ hoistVarRecursion(statement.body, scope);
3484
3733
  break;
3485
3734
  case 'IfStatement':
3486
- hoistVarRecursion$1(statement.consequent, scope);
3735
+ hoistVarRecursion(statement.consequent, scope);
3487
3736
  if (statement.alternate) {
3488
- hoistVarRecursion$1(statement.alternate, scope);
3737
+ hoistVarRecursion(statement.alternate, scope);
3489
3738
  }
3490
3739
  break;
3491
3740
  case 'BlockStatement':
3492
3741
  for (let i = 0; i < statement.body.length; i++) {
3493
- hoistVarRecursion$1(statement.body[i], scope);
3742
+ hoistVarRecursion(statement.body[i], scope);
3494
3743
  }
3495
3744
  break;
3496
3745
  case 'SwitchStatement':
3497
3746
  for (let i = 0; i < statement.cases.length; i++) {
3498
3747
  for (let j = 0; j < statement.cases[i].consequent.length; j++) {
3499
- hoistVarRecursion$1(statement.cases[i].consequent[j], scope);
3748
+ hoistVarRecursion(statement.cases[i].consequent[j], scope);
3500
3749
  }
3501
3750
  }
3502
3751
  break;
3503
3752
  case 'TryStatement': {
3504
3753
  const tryBlock = statement.block.body;
3505
3754
  for (let i = 0; i < tryBlock.length; i++) {
3506
- hoistVarRecursion$1(tryBlock[i], scope);
3755
+ hoistVarRecursion(tryBlock[i], scope);
3507
3756
  }
3508
3757
  const catchBlock = statement.handler && statement.handler.body.body;
3509
3758
  if (catchBlock) {
3510
3759
  for (let i = 0; i < catchBlock.length; i++) {
3511
- hoistVarRecursion$1(catchBlock[i], scope);
3760
+ hoistVarRecursion(catchBlock[i], scope);
3512
3761
  }
3513
3762
  }
3514
3763
  const finalBlock = statement.finalizer && statement.finalizer.body;
3515
3764
  if (finalBlock) {
3516
3765
  for (let i = 0; i < finalBlock.length; i++) {
3517
- hoistVarRecursion$1(finalBlock[i], scope);
3766
+ hoistVarRecursion(finalBlock[i], scope);
3518
3767
  }
3519
3768
  }
3520
3769
  break;
3521
3770
  }
3522
3771
  }
3523
3772
  }
3524
- function pattern$3(node, scope, options = {}) {
3773
+ function pattern(node, scope, options = {}) {
3525
3774
  switch (node.type) {
3526
3775
  case 'ObjectPattern':
3527
- return ObjectPattern(node, scope, options);
3776
+ return ObjectPattern$1(node, scope, options);
3528
3777
  case 'ArrayPattern':
3529
- return ArrayPattern(node, scope, options);
3778
+ return ArrayPattern$1(node, scope, options);
3530
3779
  case 'RestElement':
3531
- return RestElement(node, scope, options);
3780
+ return RestElement$1(node, scope, options);
3532
3781
  case 'AssignmentPattern':
3533
- return AssignmentPattern(node, scope, options);
3782
+ return AssignmentPattern$1(node, scope, options);
3534
3783
  default:
3535
3784
  throw new SyntaxError('Unexpected token');
3536
3785
  }
3537
3786
  }
3538
- function createFunc$1(node, scope, options = {}) {
3787
+ function createFunc(node, scope, options = {}) {
3788
+ var _a;
3539
3789
  if (node.generator || node.async) {
3540
- return createFunc(node, scope, options);
3790
+ return createFunc$1(node, scope, options);
3541
3791
  }
3542
3792
  const { superClass, construct } = options;
3543
3793
  const params = node.params;
@@ -3562,22 +3812,22 @@
3562
3812
  subScope.var(param.name, args[i]);
3563
3813
  }
3564
3814
  else if (param.type === 'RestElement') {
3565
- RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
3815
+ RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
3566
3816
  }
3567
3817
  else {
3568
- pattern$3(param, subScope, { kind: 'var', feed: args[i] });
3818
+ pattern(param, subScope, { kind: 'var', feed: args[i] });
3569
3819
  }
3570
3820
  }
3571
3821
  let result;
3572
3822
  if (node.body.type === 'BlockStatement') {
3573
- hoist$1(node.body, subScope);
3574
- result = BlockStatement(node.body, subScope, {
3823
+ hoist(node.body, subScope);
3824
+ result = BlockStatement$1(node.body, subScope, {
3575
3825
  invasived: true,
3576
3826
  hoisted: true
3577
3827
  });
3578
3828
  }
3579
3829
  else {
3580
- result = evaluate(node.body, subScope);
3830
+ result = evaluate$1(node.body, subScope);
3581
3831
  if (node.type === 'ArrowFunctionExpression') {
3582
3832
  RETURN.RES = result;
3583
3833
  result = RETURN;
@@ -3601,16 +3851,23 @@
3601
3851
  value: params.length,
3602
3852
  configurable: true
3603
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
+ }
3604
3861
  return func;
3605
3862
  }
3606
- function createClass$1(node, scope) {
3607
- const superClass = evaluate(node.superClass, scope);
3863
+ function createClass(node, scope) {
3864
+ const superClass = evaluate$1(node.superClass, scope);
3608
3865
  const methodBody = node.body.body;
3609
3866
  const construct = function (object) {
3610
3867
  for (let i = 0; i < methodBody.length; i++) {
3611
3868
  const def = methodBody[i];
3612
3869
  if (def.type === 'PropertyDefinition' && !def.static) {
3613
- PropertyDefinition(def, scope, { klass: object, superClass });
3870
+ PropertyDefinition$1(def, scope, { klass: object, superClass });
3614
3871
  }
3615
3872
  }
3616
3873
  };
@@ -3623,14 +3880,14 @@
3623
3880
  for (let i = 0; i < methodBody.length; i++) {
3624
3881
  const method = methodBody[i];
3625
3882
  if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
3626
- klass = createFunc$1(method.value, scope, { superClass, construct });
3883
+ klass = createFunc(method.value, scope, { superClass, construct });
3627
3884
  break;
3628
3885
  }
3629
3886
  }
3630
3887
  if (superClass) {
3631
3888
  inherits(klass, superClass);
3632
3889
  }
3633
- ClassBody(node.body, scope, { klass, superClass });
3890
+ ClassBody$1(node.body, scope, { klass, superClass });
3634
3891
  define(klass, CLSCTOR, { value: true });
3635
3892
  define(klass, 'name', {
3636
3893
  value: node.id && node.id.name || '',
@@ -3638,26 +3895,26 @@
3638
3895
  });
3639
3896
  return klass;
3640
3897
  }
3641
- function ForXHandler$1(node, scope, options) {
3898
+ function ForXHandler(node, scope, options) {
3642
3899
  const { value } = options;
3643
3900
  const left = node.left;
3644
3901
  const subScope = new Scope(scope);
3645
3902
  if (left.type === 'VariableDeclaration') {
3646
- VariableDeclaration(left, subScope, { feed: value });
3903
+ VariableDeclaration$1(left, subScope, { feed: value });
3647
3904
  }
3648
3905
  else if (left.type === 'Identifier') {
3649
- const variable = Identifier(left, scope, { getVar: true });
3906
+ const variable = Identifier$1(left, scope, { getVar: true });
3650
3907
  variable.set(value);
3651
3908
  }
3652
3909
  else {
3653
- pattern$3(left, scope, { feed: value });
3910
+ pattern(left, scope, { feed: value });
3654
3911
  }
3655
3912
  let result;
3656
3913
  if (node.body.type === 'BlockStatement') {
3657
- result = BlockStatement(node.body, subScope, { invasived: true });
3914
+ result = BlockStatement$1(node.body, subScope, { invasived: true });
3658
3915
  }
3659
3916
  else {
3660
- result = evaluate(node.body, subScope);
3917
+ result = evaluate$1(node.body, subScope);
3661
3918
  }
3662
3919
  return result;
3663
3920
  }
@@ -3711,12 +3968,12 @@
3711
3968
  }
3712
3969
  run(code) {
3713
3970
  const ast = typeof code === 'string' ? acorn.parse(code, this.options) : code;
3714
- hoist$1(ast, this.scope);
3715
- evaluate(ast, this.scope);
3971
+ hoist(ast, this.scope);
3972
+ evaluate$1(ast, this.scope);
3716
3973
  }
3717
3974
  }
3718
3975
  Sval.version = version;
3719
3976
 
3720
3977
  return Sval;
3721
3978
 
3722
- })));
3979
+ }));