sval 0.5.6 → 0.5.8

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
@@ -464,7 +464,7 @@
464
464
  const IMPORT = createSymbol('import');
465
465
  const EXPORTS = createSymbol('exports');
466
466
 
467
- var version = "0.5.6";
467
+ var version = "0.5.8";
468
468
 
469
469
  class Var {
470
470
  constructor(kind, value) {
@@ -594,7 +594,53 @@
594
594
  }
595
595
  }
596
596
 
597
- function Identifier$1(node, scope, options = {}) {
597
+ function runAsync(iterator, options = {}) {
598
+ const { res, err, ret, fullRet } = options;
599
+ return new Promise((resolve, reject) => {
600
+ if ('ret' in options) {
601
+ return resolve(iterator.return(ret));
602
+ }
603
+ if ('err' in options) {
604
+ onRejected(err);
605
+ }
606
+ else {
607
+ onFulfilled(res);
608
+ }
609
+ function onFulfilled(res) {
610
+ let ret;
611
+ try {
612
+ ret = iterator.next(res);
613
+ }
614
+ catch (e) {
615
+ return reject(e);
616
+ }
617
+ next(ret);
618
+ return null;
619
+ }
620
+ function onRejected(err) {
621
+ let ret;
622
+ try {
623
+ ret = iterator.throw(err);
624
+ }
625
+ catch (e) {
626
+ return reject(e);
627
+ }
628
+ next(ret);
629
+ }
630
+ function next(ret) {
631
+ if (ret.done)
632
+ return resolve(fullRet ? ret : ret.value);
633
+ if (ret.value !== AWAIT)
634
+ return resolve(ret);
635
+ const awaitValue = ret.value.RES;
636
+ const value = awaitValue && awaitValue.then === 'function'
637
+ ? awaitValue : Promise.resolve(awaitValue);
638
+ return value.then(onFulfilled, onRejected);
639
+ }
640
+ });
641
+ }
642
+
643
+ function* Identifier$1(node, scope, options = {}) {
598
644
  const { getVar = false, throwErr = true } = options;
599
645
  if (node.name === 'undefined') {
600
646
  return undefined;
@@ -627,7 +673,7 @@
627
673
  Identifier: Identifier$1
628
674
  });
629
675
 
630
- function Literal$1(node, scope) {
676
+ function* Literal$1(node, scope) {
631
677
  return node.value;
632
678
  }
633
679
 
@@ -636,7 +682,7 @@
636
682
  Literal: Literal$1
637
683
  });
638
684
 
639
- function ThisExpression$1(node, scope) {
685
+ function* ThisExpression$1(node, scope) {
640
686
  const superCall = scope.find(SUPERCALL);
641
687
  if (superCall && !superCall.get()) {
642
688
  throw new ReferenceError('Must call super constructor in derived class '
@@ -646,41 +692,41 @@
646
692
  return scope.find('this').get();
647
693
  }
648
694
  }
649
- function ArrayExpression$1(node, scope) {
695
+ function* ArrayExpression$1(node, scope) {
650
696
  let results = [];
651
697
  for (let i = 0; i < node.elements.length; i++) {
652
698
  const item = node.elements[i];
653
699
  if (item.type === 'SpreadElement') {
654
- results = results.concat(SpreadElement$1(item, scope));
700
+ results = results.concat(yield* SpreadElement$1(item, scope));
655
701
  }
656
702
  else {
657
- results.push(evaluate$1(item, scope));
703
+ results.push(yield* evaluate$1(item, scope));
658
704
  }
659
705
  }
660
706
  return results;
661
707
  }
662
- function ObjectExpression$1(node, scope) {
708
+ function* ObjectExpression$1(node, scope) {
663
709
  const object = {};
664
710
  for (let i = 0; i < node.properties.length; i++) {
665
711
  const property = node.properties[i];
666
712
  if (property.type === 'SpreadElement') {
667
- assign(object, SpreadElement$1(property, scope));
713
+ assign(object, yield* SpreadElement$1(property, scope));
668
714
  }
669
715
  else {
670
716
  let key;
671
717
  const propKey = property.key;
672
718
  if (property.computed) {
673
- key = evaluate$1(propKey, scope);
719
+ key = yield* evaluate$1(propKey, scope);
674
720
  }
675
721
  else {
676
722
  if (propKey.type === 'Identifier') {
677
723
  key = propKey.name;
678
724
  }
679
725
  else {
680
- key = '' + (Literal$1(propKey));
726
+ key = '' + (yield* Literal$1(propKey));
681
727
  }
682
728
  }
683
- const value = evaluate$1(property.value, scope);
729
+ const value = yield* evaluate$1(property.value, scope);
684
730
  const propKind = property.kind;
685
731
  if (propKind === 'init') {
686
732
  object[key] = value;
@@ -707,7 +753,7 @@
707
753
  }
708
754
  return object;
709
755
  }
710
- function FunctionExpression$1(node, scope) {
756
+ function* FunctionExpression$1(node, scope) {
711
757
  if (node.id && node.id.name) {
712
758
  const tmpScope = new Scope(scope);
713
759
  const func = createFunc(node, tmpScope);
@@ -718,44 +764,44 @@
718
764
  return createFunc(node, scope);
719
765
  }
720
766
  }
721
- function UnaryExpression$1(node, scope) {
767
+ function* UnaryExpression$1(node, scope) {
722
768
  const arg = node.argument;
723
769
  switch (node.operator) {
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));
770
+ case '+': return +(yield* evaluate$1(arg, scope));
771
+ case '-': return -(yield* evaluate$1(arg, scope));
772
+ case '!': return !(yield* evaluate$1(arg, scope));
773
+ case '~': return ~(yield* evaluate$1(arg, scope));
774
+ case 'void': return void (yield* evaluate$1(arg, scope));
729
775
  case 'typeof':
730
776
  if (arg.type === 'Identifier') {
731
- return typeof (Identifier$1(arg, scope, { throwErr: false }));
777
+ return typeof (yield* Identifier$1(arg, scope, { throwErr: false }));
732
778
  }
733
779
  else {
734
- return typeof (evaluate$1(arg, scope));
780
+ return typeof (yield* evaluate$1(arg, scope));
735
781
  }
736
782
  case 'delete':
737
783
  if (arg.type === 'MemberExpression') {
738
- const variable = MemberExpression$1(arg, scope, { getVar: true });
784
+ const variable = yield* MemberExpression$1(arg, scope, { getVar: true });
739
785
  return variable.del();
740
786
  }
741
787
  else if (arg.type === 'Identifier') {
742
788
  throw new SyntaxError('Delete of an unqualified identifier in strict mode');
743
789
  }
744
790
  else {
745
- evaluate$1(arg, scope);
791
+ yield* evaluate$1(arg, scope);
746
792
  return true;
747
793
  }
748
794
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
749
795
  }
750
796
  }
751
- function UpdateExpression$1(node, scope) {
797
+ function* UpdateExpression$1(node, scope) {
752
798
  const arg = node.argument;
753
799
  let variable;
754
800
  if (arg.type === 'Identifier') {
755
- variable = Identifier$1(arg, scope, { getVar: true });
801
+ variable = yield* Identifier$1(arg, scope, { getVar: true });
756
802
  }
757
803
  else if (arg.type === 'MemberExpression') {
758
- variable = MemberExpression$1(arg, scope, { getVar: true });
804
+ variable = yield* MemberExpression$1(arg, scope, { getVar: true });
759
805
  }
760
806
  else {
761
807
  throw new SyntaxError('Unexpected token');
@@ -773,17 +819,17 @@
773
819
  throw new SyntaxError(`Unexpected token ${node.operator}`);
774
820
  }
775
821
  }
776
- function BinaryExpression$1(node, scope) {
822
+ function* BinaryExpression$1(node, scope) {
777
823
  let left;
778
824
  let right;
779
825
  if (node.left.type === 'PrivateIdentifier') {
780
826
  left = node.left.name;
781
- right = evaluate$1(node.right, scope);
782
- right = right[PRIVATE];
827
+ right = yield* evaluate$1(node.right, scope);
828
+ right = right[PRIVATE] || {};
783
829
  }
784
830
  else {
785
- left = evaluate$1(node.left, scope);
786
- right = evaluate$1(node.right, scope);
831
+ left = yield* evaluate$1(node.left, scope);
832
+ right = yield* evaluate$1(node.right, scope);
787
833
  }
788
834
  switch (node.operator) {
789
835
  case '==': return left == right;
@@ -811,25 +857,25 @@
811
857
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
812
858
  }
813
859
  }
814
- function AssignmentExpression$1(node, scope) {
860
+ function* AssignmentExpression$1(node, scope) {
815
861
  var _a;
816
862
  const left = node.left;
817
863
  let variable;
818
864
  if (left.type === 'Identifier') {
819
- variable = Identifier$1(left, scope, { getVar: true, throwErr: false });
865
+ variable = yield* Identifier$1(left, scope, { getVar: true, throwErr: false });
820
866
  if (!variable) {
821
867
  const win = scope.global().find('window').get();
822
868
  variable = new Prop(win, left.name);
823
869
  }
824
870
  }
825
871
  else if (left.type === 'MemberExpression') {
826
- variable = MemberExpression$1(left, scope, { getVar: true });
872
+ variable = yield* MemberExpression$1(left, scope, { getVar: true });
827
873
  }
828
874
  else {
829
- const value = evaluate$1(node.right, scope);
830
- return pattern(left, scope, { feed: value });
875
+ const value = yield* evaluate$1(node.right, scope);
876
+ return yield* pattern(left, scope, { feed: value });
831
877
  }
832
- const value = evaluate$1(node.right, scope);
878
+ const value = yield* evaluate$1(node.right, scope);
833
879
  switch (node.operator) {
834
880
  case '=':
835
881
  variable.set(value);
@@ -882,34 +928,34 @@
882
928
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
883
929
  }
884
930
  }
885
- function LogicalExpression$1(node, scope) {
931
+ function* LogicalExpression$1(node, scope) {
886
932
  var _a;
887
933
  switch (node.operator) {
888
934
  case '||':
889
- return (evaluate$1(node.left, scope)) || (evaluate$1(node.right, scope));
935
+ return (yield* evaluate$1(node.left, scope)) || (yield* evaluate$1(node.right, scope));
890
936
  case '&&':
891
- return (evaluate$1(node.left, scope)) && (evaluate$1(node.right, scope));
937
+ return (yield* evaluate$1(node.left, scope)) && (yield* evaluate$1(node.right, scope));
892
938
  case '??':
893
- return (_a = (evaluate$1(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate$1(node.right, scope));
939
+ return (_a = (yield* evaluate$1(node.left, scope))) !== null && _a !== void 0 ? _a : (yield* evaluate$1(node.right, scope));
894
940
  default:
895
941
  throw new SyntaxError(`Unexpected token ${node.operator}`);
896
942
  }
897
943
  }
898
- function MemberExpression$1(node, scope, options = {}) {
944
+ function* MemberExpression$1(node, scope, options = {}) {
899
945
  const { getObj = false, getVar = false } = options;
900
946
  let object;
901
947
  if (node.object.type === 'Super') {
902
- object = Super$1(node.object, scope, { getProto: true });
948
+ object = yield* Super$1(node.object, scope, { getProto: true });
903
949
  }
904
950
  else {
905
- object = evaluate$1(node.object, scope);
951
+ object = yield* evaluate$1(node.object, scope);
906
952
  }
907
953
  if (getObj)
908
954
  return object;
909
955
  let key;
910
956
  let priv = false;
911
957
  if (node.computed) {
912
- key = evaluate$1(node.property, scope);
958
+ key = yield* evaluate$1(node.property, scope);
913
959
  }
914
960
  else if (node.property.type === 'PrivateIdentifier') {
915
961
  key = node.property.name;
@@ -950,23 +996,23 @@
950
996
  }
951
997
  }
952
998
  }
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));
999
+ function* ConditionalExpression$1(node, scope) {
1000
+ return (yield* evaluate$1(node.test, scope))
1001
+ ? (yield* evaluate$1(node.consequent, scope))
1002
+ : (yield* evaluate$1(node.alternate, scope));
957
1003
  }
958
- function CallExpression$1(node, scope) {
1004
+ function* CallExpression$1(node, scope) {
959
1005
  let func;
960
1006
  let object;
961
1007
  if (node.callee.type === 'MemberExpression') {
962
- object = MemberExpression$1(node.callee, scope, { getObj: true });
1008
+ object = yield* MemberExpression$1(node.callee, scope, { getObj: true });
963
1009
  if (node.callee.optional && object == null) {
964
1010
  return undefined;
965
1011
  }
966
1012
  let key;
967
1013
  let priv = false;
968
1014
  if (node.callee.computed) {
969
- key = evaluate$1(node.callee.property, scope);
1015
+ key = yield* evaluate$1(node.callee.property, scope);
970
1016
  }
971
1017
  else if (node.callee.property.type === 'PrivateIdentifier') {
972
1018
  key = node.callee.property.name;
@@ -998,7 +1044,7 @@
998
1044
  }
999
1045
  else {
1000
1046
  object = scope.find('this').get();
1001
- func = evaluate$1(node.callee, scope);
1047
+ func = yield* evaluate$1(node.callee, scope);
1002
1048
  if (node.optional && func == null) {
1003
1049
  return undefined;
1004
1050
  }
@@ -1027,10 +1073,10 @@
1027
1073
  for (let i = 0; i < node.arguments.length; i++) {
1028
1074
  const arg = node.arguments[i];
1029
1075
  if (arg.type === 'SpreadElement') {
1030
- args = args.concat(SpreadElement$1(arg, scope));
1076
+ args = args.concat(yield* SpreadElement$1(arg, scope));
1031
1077
  }
1032
1078
  else {
1033
- args.push(evaluate$1(arg, scope));
1079
+ args.push(yield* evaluate$1(arg, scope));
1034
1080
  }
1035
1081
  }
1036
1082
  if (node.callee.type === 'Super') {
@@ -1056,8 +1102,8 @@
1056
1102
  throw err;
1057
1103
  }
1058
1104
  }
1059
- function NewExpression$1(node, scope) {
1060
- const constructor = evaluate$1(node.callee, scope);
1105
+ function* NewExpression$1(node, scope) {
1106
+ const constructor = yield* evaluate$1(node.callee, scope);
1061
1107
  if (typeof constructor !== 'function') {
1062
1108
  let name;
1063
1109
  if (node.callee.type === 'Identifier') {
@@ -1080,15 +1126,15 @@
1080
1126
  for (let i = 0; i < node.arguments.length; i++) {
1081
1127
  const arg = node.arguments[i];
1082
1128
  if (arg.type === 'SpreadElement') {
1083
- args = args.concat(SpreadElement$1(arg, scope));
1129
+ args = args.concat(yield* SpreadElement$1(arg, scope));
1084
1130
  }
1085
1131
  else {
1086
- args.push(evaluate$1(arg, scope));
1132
+ args.push(yield* evaluate$1(arg, scope));
1087
1133
  }
1088
1134
  }
1089
1135
  return new constructor(...args);
1090
1136
  }
1091
- function MetaProperty$1(node, scope) {
1137
+ function* MetaProperty$1(node, scope) {
1092
1138
  if (node.meta.name === 'new' && node.property.name === 'target') {
1093
1139
  return scope.find(NEWTARGET).get();
1094
1140
  }
@@ -1096,33 +1142,33 @@
1096
1142
  return { url: '' };
1097
1143
  }
1098
1144
  }
1099
- function SequenceExpression$1(node, scope) {
1145
+ function* SequenceExpression$1(node, scope) {
1100
1146
  let result;
1101
1147
  for (let i = 0; i < node.expressions.length; i++) {
1102
- result = evaluate$1(node.expressions[i], scope);
1148
+ result = yield* evaluate$1(node.expressions[i], scope);
1103
1149
  }
1104
1150
  return result;
1105
1151
  }
1106
- function ArrowFunctionExpression$1(node, scope) {
1152
+ function* ArrowFunctionExpression$1(node, scope) {
1107
1153
  return createFunc(node, scope);
1108
1154
  }
1109
- function TemplateLiteral$1(node, scope) {
1155
+ function* TemplateLiteral$1(node, scope) {
1110
1156
  const quasis = node.quasis.slice();
1111
1157
  const expressions = node.expressions.slice();
1112
1158
  let result = '';
1113
1159
  let temEl;
1114
1160
  let expr;
1115
1161
  while (temEl = quasis.shift()) {
1116
- result += TemplateElement$1(temEl);
1162
+ result += yield* TemplateElement$1(temEl);
1117
1163
  expr = expressions.shift();
1118
1164
  if (expr) {
1119
- result += evaluate$1(expr, scope);
1165
+ result += yield* evaluate$1(expr, scope);
1120
1166
  }
1121
1167
  }
1122
1168
  return result;
1123
1169
  }
1124
- function TaggedTemplateExpression$1(node, scope) {
1125
- const tagFunc = evaluate$1(node.tag, scope);
1170
+ function* TaggedTemplateExpression$1(node, scope) {
1171
+ const tagFunc = yield* evaluate$1(node.tag, scope);
1126
1172
  const quasis = node.quasi.quasis;
1127
1173
  const str = quasis.map(v => v.value.cooked);
1128
1174
  const raw = quasis.map(v => v.value.raw);
@@ -1133,40 +1179,40 @@
1133
1179
  const args = [];
1134
1180
  if (expressions) {
1135
1181
  for (let i = 0; i < expressions.length; i++) {
1136
- args.push(evaluate$1(expressions[i], scope));
1182
+ args.push(yield* evaluate$1(expressions[i], scope));
1137
1183
  }
1138
1184
  }
1139
1185
  return tagFunc(freeze(str), ...args);
1140
1186
  }
1141
- function TemplateElement$1(node, scope) {
1187
+ function* TemplateElement$1(node, scope) {
1142
1188
  return node.value.raw;
1143
1189
  }
1144
- function ClassExpression$1(node, scope) {
1190
+ function* ClassExpression$1(node, scope) {
1145
1191
  if (node.id && node.id.name) {
1146
1192
  const tmpScope = new Scope(scope);
1147
- const klass = createClass(node, tmpScope);
1193
+ const klass = yield* createClass(node, tmpScope);
1148
1194
  tmpScope.const(node.id.name, klass);
1149
1195
  return klass;
1150
1196
  }
1151
1197
  else {
1152
- return createClass(node, scope);
1198
+ return yield* createClass(node, scope);
1153
1199
  }
1154
1200
  }
1155
- function Super$1(node, scope, options = {}) {
1201
+ function* Super$1(node, scope, options = {}) {
1156
1202
  const { getProto = false } = options;
1157
1203
  const superClass = scope.find(SUPER).get();
1158
1204
  return getProto ? superClass.prototype : superClass;
1159
1205
  }
1160
- function SpreadElement$1(node, scope) {
1161
- const result = evaluate$1(node.argument, scope);
1206
+ function* SpreadElement$1(node, scope) {
1207
+ const result = yield* evaluate$1(node.argument, scope);
1162
1208
  return typeof result === 'string' ? [...result] : result;
1163
1209
  }
1164
- function ChainExpression$1(node, scope) {
1165
- return evaluate$1(node.expression, scope);
1210
+ function* ChainExpression$1(node, scope) {
1211
+ return yield* evaluate$1(node.expression, scope);
1166
1212
  }
1167
- function ImportExpression$1(node, scope) {
1213
+ function* ImportExpression$1(node, scope) {
1168
1214
  const globalScope = scope.global();
1169
- const source = evaluate$1(node.source, scope);
1215
+ const source = yield* evaluate$1(node.source, scope);
1170
1216
  const module = globalScope.find(IMPORT + source);
1171
1217
  let value;
1172
1218
  if (module) {
@@ -1184,6 +1230,14 @@
1184
1230
  return Promise.reject(new TypeError(`Failed to resolve module specifier "${source}"`));
1185
1231
  }
1186
1232
  return Promise.resolve(value);
1233
+ }
1234
+ function* YieldExpression(node, scope) {
1235
+ const res = yield* evaluate$1(node.argument, scope);
1236
+ return node.delegate ? yield* res : yield res;
1237
+ }
1238
+ function* AwaitExpression(node, scope) {
1239
+ AWAIT.RES = yield* evaluate$1(node.argument, scope);
1240
+ return yield AWAIT;
1187
1241
  }
1188
1242
 
1189
1243
  var expression$1 = /*#__PURE__*/Object.freeze({
@@ -1211,10 +1265,12 @@
1211
1265
  Super: Super$1,
1212
1266
  SpreadElement: SpreadElement$1,
1213
1267
  ChainExpression: ChainExpression$1,
1214
- ImportExpression: ImportExpression$1
1268
+ ImportExpression: ImportExpression$1,
1269
+ YieldExpression: YieldExpression,
1270
+ AwaitExpression: AwaitExpression
1215
1271
  });
1216
1272
 
1217
- function ObjectPattern$1(node, scope, options = {}) {
1273
+ function* ObjectPattern$1(node, scope, options = {}) {
1218
1274
  const { kind = 'var', hoist = false, onlyBlock = false, feed = {} } = options;
1219
1275
  const fedKeys = [];
1220
1276
  for (let i = 0; i < node.properties.length; i++) {
@@ -1227,18 +1283,18 @@
1227
1283
  scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1228
1284
  }
1229
1285
  else {
1230
- pattern(value, scope, { kind, hoist, onlyBlock });
1286
+ yield* pattern(value, scope, { kind, hoist, onlyBlock });
1231
1287
  }
1232
1288
  }
1233
1289
  else {
1234
- RestElement$1(property, scope, { kind, hoist, onlyBlock });
1290
+ yield* RestElement$1(property, scope, { kind, hoist, onlyBlock });
1235
1291
  }
1236
1292
  }
1237
1293
  }
1238
1294
  else if (property.type === 'Property') {
1239
1295
  let key;
1240
1296
  if (property.computed) {
1241
- key = evaluate$1(property.key, scope);
1297
+ key = yield* evaluate$1(property.key, scope);
1242
1298
  }
1243
1299
  else {
1244
1300
  key = property.key.name;
@@ -1249,18 +1305,18 @@
1249
1305
  scope[kind](value.name, feed[key]);
1250
1306
  }
1251
1307
  else {
1252
- pattern(value, scope, { kind, feed: feed[key] });
1308
+ yield* pattern(value, scope, { kind, feed: feed[key] });
1253
1309
  }
1254
1310
  }
1255
1311
  else {
1256
1312
  const rest = assign({}, feed);
1257
1313
  for (let i = 0; i < fedKeys.length; i++)
1258
1314
  delete rest[fedKeys[i]];
1259
- RestElement$1(property, scope, { kind, feed: rest });
1315
+ yield* RestElement$1(property, scope, { kind, feed: rest });
1260
1316
  }
1261
1317
  }
1262
1318
  }
1263
- function ArrayPattern$1(node, scope, options = {}) {
1319
+ function* ArrayPattern$1(node, scope, options = {}) {
1264
1320
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
1265
1321
  const result = [];
1266
1322
  for (let i = 0; i < node.elements.length; i++) {
@@ -1273,7 +1329,7 @@
1273
1329
  scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1274
1330
  }
1275
1331
  else {
1276
- pattern(element, scope, { kind, hoist, onlyBlock });
1332
+ yield* pattern(element, scope, { kind, hoist, onlyBlock });
1277
1333
  }
1278
1334
  }
1279
1335
  }
@@ -1282,23 +1338,23 @@
1282
1338
  scope[kind](element.name, feed[i]);
1283
1339
  }
1284
1340
  else {
1285
- const variable = Identifier$1(element, scope, { getVar: true });
1341
+ const variable = yield* Identifier$1(element, scope, { getVar: true });
1286
1342
  variable.set(feed[i]);
1287
1343
  result.push(variable.get());
1288
1344
  }
1289
1345
  }
1290
1346
  else if (element.type === 'RestElement') {
1291
- RestElement$1(element, scope, { kind, feed: feed.slice(i) });
1347
+ yield* RestElement$1(element, scope, { kind, feed: feed.slice(i) });
1292
1348
  }
1293
1349
  else {
1294
- pattern(element, scope, { kind, feed: feed[i] });
1350
+ yield* pattern(element, scope, { kind, feed: feed[i] });
1295
1351
  }
1296
1352
  }
1297
1353
  if (result.length) {
1298
1354
  return result;
1299
1355
  }
1300
1356
  }
1301
- function RestElement$1(node, scope, options = {}) {
1357
+ function* RestElement$1(node, scope, options = {}) {
1302
1358
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
1303
1359
  const arg = node.argument;
1304
1360
  if (hoist) {
@@ -1307,7 +1363,7 @@
1307
1363
  scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1308
1364
  }
1309
1365
  else {
1310
- pattern(arg, scope, { kind, hoist, onlyBlock });
1366
+ yield* pattern(arg, scope, { kind, hoist, onlyBlock });
1311
1367
  }
1312
1368
  }
1313
1369
  }
@@ -1316,16 +1372,16 @@
1316
1372
  scope[kind](arg.name, feed);
1317
1373
  }
1318
1374
  else {
1319
- const variable = Identifier$1(arg, scope, { getVar: true });
1375
+ const variable = yield* Identifier$1(arg, scope, { getVar: true });
1320
1376
  variable.set(feed);
1321
1377
  }
1322
1378
  }
1323
1379
  else {
1324
- pattern(arg, scope, { kind, feed });
1380
+ yield* pattern(arg, scope, { kind, feed });
1325
1381
  }
1326
1382
  }
1327
- function AssignmentPattern$1(node, scope, options = {}) {
1328
- const { kind = 'var', hoist = false, onlyBlock = false, feed = evaluate$1(node.right, scope) } = options;
1383
+ function* AssignmentPattern$1(node, scope, options = {}) {
1384
+ const { kind = 'var', hoist = false, onlyBlock = false, feed = yield* evaluate$1(node.right, scope) } = options;
1329
1385
  const left = node.left;
1330
1386
  if (hoist) {
1331
1387
  if (onlyBlock || kind === 'var') {
@@ -1333,7 +1389,7 @@
1333
1389
  scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1334
1390
  }
1335
1391
  else {
1336
- pattern(left, scope, { kind, hoist, onlyBlock });
1392
+ yield* pattern(left, scope, { kind, hoist, onlyBlock });
1337
1393
  }
1338
1394
  }
1339
1395
  }
@@ -1341,7 +1397,7 @@
1341
1397
  scope[kind](left.name, feed);
1342
1398
  }
1343
1399
  else {
1344
- pattern(left, scope, { kind, feed });
1400
+ yield* pattern(left, scope, { kind, feed });
1345
1401
  }
1346
1402
  }
1347
1403
 
@@ -1353,44 +1409,44 @@
1353
1409
  AssignmentPattern: AssignmentPattern$1
1354
1410
  });
1355
1411
 
1356
- function Program(program, scope) {
1412
+ function* Program$1(program, scope) {
1357
1413
  for (let i = 0; i < program.body.length; i++) {
1358
- evaluate$1(program.body[i], scope);
1414
+ yield* evaluate$1(program.body[i], scope);
1359
1415
  }
1360
1416
  }
1361
1417
 
1362
- var program = /*#__PURE__*/Object.freeze({
1418
+ var program$1 = /*#__PURE__*/Object.freeze({
1363
1419
  __proto__: null,
1364
- Program: Program
1420
+ Program: Program$1
1365
1421
  });
1366
1422
 
1367
1423
  let evaluateOps$1;
1368
- function evaluate$1(node, scope) {
1424
+ function* evaluate$1(node, scope) {
1369
1425
  if (!node)
1370
1426
  return;
1371
1427
  if (!evaluateOps$1) {
1372
- evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$3, program);
1428
+ evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$3, program$1);
1373
1429
  }
1374
1430
  const handler = evaluateOps$1[node.type];
1375
1431
  if (handler) {
1376
- return handler(node, scope);
1432
+ return yield* handler(node, scope);
1377
1433
  }
1378
1434
  else {
1379
1435
  throw new Error(`${node.type} isn't implemented`);
1380
1436
  }
1381
1437
  }
1382
1438
 
1383
- function ExpressionStatement$1(node, scope) {
1384
- evaluate$1(node.expression, scope);
1439
+ function* ExpressionStatement$1(node, scope) {
1440
+ yield* evaluate$1(node.expression, scope);
1385
1441
  }
1386
- function BlockStatement$1(block, scope, options = {}) {
1442
+ function* BlockStatement$1(block, scope, options = {}) {
1387
1443
  const { invasived = false, hoisted = false, } = options;
1388
1444
  const subScope = invasived ? scope : new Scope(scope);
1389
1445
  if (!hoisted) {
1390
- hoist(block, subScope, { onlyBlock: true });
1446
+ yield* hoist(block, subScope, { onlyBlock: true });
1391
1447
  }
1392
1448
  for (let i = 0; i < block.body.length; i++) {
1393
- const result = evaluate$1(block.body[i], subScope);
1449
+ const result = yield* evaluate$1(block.body[i], subScope);
1394
1450
  if (result === BREAK) {
1395
1451
  if (result.LABEL && result.LABEL === options.label) {
1396
1452
  break;
@@ -1402,63 +1458,63 @@
1402
1458
  }
1403
1459
  }
1404
1460
  }
1405
- function EmptyStatement$1() {
1461
+ function* EmptyStatement$1() {
1406
1462
  }
1407
- function DebuggerStatement$1() {
1463
+ function* DebuggerStatement$1() {
1408
1464
  debugger;
1409
1465
  }
1410
- function ReturnStatement$1(node, scope) {
1411
- RETURN.RES = node.argument ? (evaluate$1(node.argument, scope)) : undefined;
1466
+ function* ReturnStatement$1(node, scope) {
1467
+ RETURN.RES = node.argument ? (yield* evaluate$1(node.argument, scope)) : undefined;
1412
1468
  return RETURN;
1413
1469
  }
1414
- function BreakStatement$1(node) {
1470
+ function* BreakStatement$1(node) {
1415
1471
  var _a;
1416
1472
  BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
1417
1473
  return BREAK;
1418
1474
  }
1419
- function ContinueStatement$1(node) {
1475
+ function* ContinueStatement$1(node) {
1420
1476
  var _a;
1421
1477
  CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
1422
1478
  return CONTINUE;
1423
1479
  }
1424
- function LabeledStatement$1(node, scope) {
1480
+ function* LabeledStatement$1(node, scope) {
1425
1481
  const label = node.label.name;
1426
1482
  if (node.body.type === 'WhileStatement') {
1427
- return WhileStatement$1(node.body, scope, { label });
1483
+ return yield* WhileStatement$1(node.body, scope, { label });
1428
1484
  }
1429
1485
  if (node.body.type === 'DoWhileStatement') {
1430
- return DoWhileStatement$1(node.body, scope, { label });
1486
+ return yield* DoWhileStatement$1(node.body, scope, { label });
1431
1487
  }
1432
1488
  if (node.body.type === 'ForStatement') {
1433
- return ForStatement$1(node.body, scope, { label });
1489
+ return yield* ForStatement$1(node.body, scope, { label });
1434
1490
  }
1435
1491
  if (node.body.type === 'ForInStatement') {
1436
- return ForInStatement$1(node.body, scope, { label });
1492
+ return yield* ForInStatement$1(node.body, scope, { label });
1437
1493
  }
1438
1494
  if (node.body.type === 'ForOfStatement') {
1439
- return ForOfStatement$1(node.body, scope, { label });
1495
+ return yield* ForOfStatement$1(node.body, scope, { label });
1440
1496
  }
1441
1497
  if (node.body.type === 'BlockStatement') {
1442
- return BlockStatement$1(node.body, scope, { label });
1498
+ return yield* BlockStatement$1(node.body, scope, { label });
1443
1499
  }
1444
1500
  if (node.body.type === 'WithStatement') {
1445
- return WithStatement$1(node.body, scope, { label });
1501
+ return yield* WithStatement$1(node.body, scope, { label });
1446
1502
  }
1447
1503
  if (node.body.type === 'IfStatement') {
1448
- return IfStatement$1(node.body, scope, { label });
1504
+ return yield* IfStatement$1(node.body, scope, { label });
1449
1505
  }
1450
1506
  if (node.body.type === 'SwitchStatement') {
1451
- return SwitchStatement$1(node.body, scope, { label });
1507
+ return yield* SwitchStatement$1(node.body, scope, { label });
1452
1508
  }
1453
1509
  if (node.body.type === 'TryStatement') {
1454
- return TryStatement$1(node.body, scope, { label });
1510
+ return yield* TryStatement$1(node.body, scope, { label });
1455
1511
  }
1456
1512
  throw new SyntaxError(`${node.body.type} cannot be labeled`);
1457
1513
  }
1458
- function WithStatement$1(node, scope, options = {}) {
1514
+ function* WithStatement$1(node, scope, options = {}) {
1459
1515
  const withScope = new Scope(scope);
1460
- withScope.with(evaluate$1(node.object, scope));
1461
- const result = evaluate$1(node.body, withScope);
1516
+ withScope.with(yield* evaluate$1(node.object, scope));
1517
+ const result = yield* evaluate$1(node.body, withScope);
1462
1518
  if (result === BREAK) {
1463
1519
  if (result.LABEL && result.LABEL === options.label) {
1464
1520
  return;
@@ -1469,13 +1525,13 @@
1469
1525
  return result;
1470
1526
  }
1471
1527
  }
1472
- function IfStatement$1(node, scope, options = {}) {
1528
+ function* IfStatement$1(node, scope, options = {}) {
1473
1529
  let result;
1474
- if (evaluate$1(node.test, scope)) {
1475
- result = evaluate$1(node.consequent, scope);
1530
+ if (yield* evaluate$1(node.test, scope)) {
1531
+ result = yield* evaluate$1(node.consequent, scope);
1476
1532
  }
1477
1533
  else {
1478
- result = evaluate$1(node.alternate, scope);
1534
+ result = yield* evaluate$1(node.alternate, scope);
1479
1535
  }
1480
1536
  if (result === BREAK) {
1481
1537
  if (result.LABEL && result.LABEL === options.label) {
@@ -1487,18 +1543,18 @@
1487
1543
  return result;
1488
1544
  }
1489
1545
  }
1490
- function SwitchStatement$1(node, scope, options = {}) {
1491
- const discriminant = evaluate$1(node.discriminant, scope);
1546
+ function* SwitchStatement$1(node, scope, options = {}) {
1547
+ const discriminant = yield* evaluate$1(node.discriminant, scope);
1492
1548
  let matched = false;
1493
1549
  for (let i = 0; i < node.cases.length; i++) {
1494
1550
  const eachCase = node.cases[i];
1495
1551
  if (!matched
1496
1552
  && (!eachCase.test
1497
- || (evaluate$1(eachCase.test, scope)) === discriminant)) {
1553
+ || (yield* evaluate$1(eachCase.test, scope)) === discriminant)) {
1498
1554
  matched = true;
1499
1555
  }
1500
1556
  if (matched) {
1501
- const result = SwitchCase$1(eachCase, scope);
1557
+ const result = yield* SwitchCase$1(eachCase, scope);
1502
1558
  if (result === BREAK) {
1503
1559
  if (result.LABEL === options.label) {
1504
1560
  break;
@@ -1511,21 +1567,21 @@
1511
1567
  }
1512
1568
  }
1513
1569
  }
1514
- function SwitchCase$1(node, scope) {
1570
+ function* SwitchCase$1(node, scope) {
1515
1571
  for (let i = 0; i < node.consequent.length; i++) {
1516
- const result = evaluate$1(node.consequent[i], scope);
1572
+ const result = yield* evaluate$1(node.consequent[i], scope);
1517
1573
  if (result === BREAK || result === CONTINUE || result === RETURN) {
1518
1574
  return result;
1519
1575
  }
1520
1576
  }
1521
1577
  }
1522
- function ThrowStatement$1(node, scope) {
1523
- throw evaluate$1(node.argument, scope);
1578
+ function* ThrowStatement$1(node, scope) {
1579
+ throw yield* evaluate$1(node.argument, scope);
1524
1580
  }
1525
- function TryStatement$1(node, scope, options = {}) {
1581
+ function* TryStatement$1(node, scope, options = {}) {
1526
1582
  let result;
1527
1583
  try {
1528
- result = BlockStatement$1(node.block, scope);
1584
+ result = yield* BlockStatement$1(node.block, scope);
1529
1585
  }
1530
1586
  catch (err) {
1531
1587
  if (node.handler) {
@@ -1537,10 +1593,10 @@
1537
1593
  subScope.var(name, err);
1538
1594
  }
1539
1595
  else {
1540
- pattern(param, scope, { feed: err });
1596
+ yield* pattern(param, scope, { feed: err });
1541
1597
  }
1542
1598
  }
1543
- result = CatchClause$1(node.handler, subScope);
1599
+ result = yield* CatchClause$1(node.handler, subScope);
1544
1600
  }
1545
1601
  else {
1546
1602
  throw err;
@@ -1548,7 +1604,7 @@
1548
1604
  }
1549
1605
  finally {
1550
1606
  if (node.finalizer) {
1551
- result = BlockStatement$1(node.finalizer, scope);
1607
+ result = yield* BlockStatement$1(node.finalizer, scope);
1552
1608
  }
1553
1609
  }
1554
1610
  if (result === BREAK) {
@@ -1561,12 +1617,12 @@
1561
1617
  return result;
1562
1618
  }
1563
1619
  }
1564
- function CatchClause$1(node, scope) {
1565
- return BlockStatement$1(node.body, scope, { invasived: true });
1620
+ function* CatchClause$1(node, scope) {
1621
+ return yield* BlockStatement$1(node.body, scope, { invasived: true });
1566
1622
  }
1567
- function WhileStatement$1(node, scope, options = {}) {
1568
- while (evaluate$1(node.test, scope)) {
1569
- const result = evaluate$1(node.body, scope);
1623
+ function* WhileStatement$1(node, scope, options = {}) {
1624
+ while (yield* evaluate$1(node.test, scope)) {
1625
+ const result = yield* evaluate$1(node.body, scope);
1570
1626
  if (result === BREAK) {
1571
1627
  if (result.LABEL === options.label) {
1572
1628
  break;
@@ -1584,9 +1640,9 @@
1584
1640
  }
1585
1641
  }
1586
1642
  }
1587
- function DoWhileStatement$1(node, scope, options = {}) {
1643
+ function* DoWhileStatement$1(node, scope, options = {}) {
1588
1644
  do {
1589
- const result = evaluate$1(node.body, scope);
1645
+ const result = yield* evaluate$1(node.body, scope);
1590
1646
  if (result === BREAK) {
1591
1647
  if (result.LABEL === options.label) {
1592
1648
  break;
@@ -1602,18 +1658,18 @@
1602
1658
  else if (result === RETURN) {
1603
1659
  return result;
1604
1660
  }
1605
- } while (evaluate$1(node.test, scope));
1661
+ } while (yield* evaluate$1(node.test, scope));
1606
1662
  }
1607
- function ForStatement$1(node, scope, options = {}) {
1663
+ function* ForStatement$1(node, scope, options = {}) {
1608
1664
  const forScope = new Scope(scope);
1609
- for (evaluate$1(node.init, forScope); node.test ? (evaluate$1(node.test, forScope)) : true; evaluate$1(node.update, forScope)) {
1665
+ for (yield* evaluate$1(node.init, forScope); node.test ? (yield* evaluate$1(node.test, forScope)) : true; yield* evaluate$1(node.update, forScope)) {
1610
1666
  const subScope = new Scope(forScope);
1611
1667
  let result;
1612
1668
  if (node.body.type === 'BlockStatement') {
1613
- result = BlockStatement$1(node.body, subScope, { invasived: true });
1669
+ result = yield* BlockStatement$1(node.body, subScope, { invasived: true });
1614
1670
  }
1615
1671
  else {
1616
- result = evaluate$1(node.body, subScope);
1672
+ result = yield* evaluate$1(node.body, subScope);
1617
1673
  }
1618
1674
  if (result === BREAK) {
1619
1675
  if (result.LABEL === options.label) {
@@ -1632,9 +1688,9 @@
1632
1688
  }
1633
1689
  }
1634
1690
  }
1635
- function ForInStatement$1(node, scope, options = {}) {
1636
- for (const value in evaluate$1(node.right, scope)) {
1637
- const result = ForXHandler(node, scope, { value });
1691
+ function* ForInStatement$1(node, scope, options = {}) {
1692
+ for (const value in yield* evaluate$1(node.right, scope)) {
1693
+ const result = yield* ForXHandler(node, scope, { value });
1638
1694
  if (result === BREAK) {
1639
1695
  if (result.LABEL === options.label) {
1640
1696
  break;
@@ -1652,37 +1708,61 @@
1652
1708
  }
1653
1709
  }
1654
1710
  }
1655
- function ForOfStatement$1(node, scope, options = {}) {
1656
- const right = evaluate$1(node.right, scope);
1657
- for (const value of right) {
1658
- const result = ForXHandler(node, scope, { value });
1659
- if (result === BREAK) {
1660
- if (result.LABEL === options.label) {
1661
- break;
1711
+ function* ForOfStatement$1(node, scope, options = {}) {
1712
+ const right = yield* evaluate$1(node.right, scope);
1713
+ if (node.await) {
1714
+ const iterator = getAsyncIterator(right);
1715
+ let ret;
1716
+ for (AWAIT.RES = iterator.next(), ret = yield AWAIT; !ret.done; AWAIT.RES = iterator.next(), ret = yield AWAIT) {
1717
+ const result = yield* ForXHandler(node, scope, { value: ret.value });
1718
+ if (result === BREAK) {
1719
+ if (result.LABEL === options.label) {
1720
+ break;
1721
+ }
1722
+ return result;
1662
1723
  }
1663
- return result;
1664
- }
1665
- else if (result === CONTINUE) {
1666
- if (result.LABEL === options.label) {
1667
- continue;
1724
+ else if (result === CONTINUE) {
1725
+ if (result.LABEL === options.label) {
1726
+ continue;
1727
+ }
1728
+ return result;
1729
+ }
1730
+ else if (result === RETURN) {
1731
+ return result;
1668
1732
  }
1669
- return result;
1670
1733
  }
1671
- else if (result === RETURN) {
1672
- return result;
1734
+ }
1735
+ else {
1736
+ for (const value of right) {
1737
+ const result = yield* ForXHandler(node, scope, { value });
1738
+ if (result === BREAK) {
1739
+ if (result.LABEL === options.label) {
1740
+ break;
1741
+ }
1742
+ return result;
1743
+ }
1744
+ else if (result === CONTINUE) {
1745
+ if (result.LABEL === options.label) {
1746
+ continue;
1747
+ }
1748
+ return result;
1749
+ }
1750
+ else if (result === RETURN) {
1751
+ return result;
1752
+ }
1673
1753
  }
1674
1754
  }
1675
1755
  }
1676
1756
 
1677
- function FunctionDeclaration$1(node, scope) {
1757
+ function* FunctionDeclaration$1(node, scope) {
1678
1758
  scope.func(node.id.name, createFunc(node, scope));
1679
1759
  }
1680
- function VariableDeclaration$1(node, scope, options = {}) {
1760
+ function* VariableDeclaration$1(node, scope, options = {}) {
1681
1761
  for (let i = 0; i < node.declarations.length; i++) {
1682
- VariableDeclarator$1(node.declarations[i], scope, assign({ kind: node.kind }, options));
1762
+ yield* VariableDeclarator$1(node.declarations[i], scope, assign({ kind: node.kind }, options));
1683
1763
  }
1684
1764
  }
1685
- function VariableDeclarator$1(node, scope, options = {}) {
1765
+ function* VariableDeclarator$1(node, scope, options = {}) {
1686
1766
  const { kind = 'var', hoist = false, onlyBlock = false, feed } = options;
1687
1767
  if (hoist) {
1688
1768
  if (onlyBlock || kind === 'var') {
@@ -1690,13 +1770,13 @@
1690
1770
  scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
1691
1771
  }
1692
1772
  else {
1693
- pattern(node.id, scope, { kind, hoist, onlyBlock });
1773
+ yield* pattern(node.id, scope, { kind, hoist, onlyBlock });
1694
1774
  }
1695
1775
  }
1696
1776
  }
1697
1777
  else {
1698
1778
  const hasFeed = 'feed' in options;
1699
- const value = hasFeed ? feed : evaluate$1(node.init, scope);
1779
+ const value = hasFeed ? feed : yield* evaluate$1(node.init, scope);
1700
1780
  if (node.id.type === 'Identifier') {
1701
1781
  const name = node.id.name;
1702
1782
  if (kind === 'var' && !node.init && !hasFeed) {
@@ -1716,34 +1796,34 @@
1716
1796
  }
1717
1797
  }
1718
1798
  else {
1719
- pattern(node.id, scope, { kind, feed: value });
1799
+ yield* pattern(node.id, scope, { kind, feed: value });
1720
1800
  }
1721
1801
  }
1722
1802
  }
1723
- function ClassDeclaration$1(node, scope) {
1724
- scope.func(node.id.name, createClass(node, scope));
1803
+ function* ClassDeclaration$1(node, scope) {
1804
+ scope.func(node.id.name, yield* createClass(node, scope));
1725
1805
  }
1726
- function ClassBody$1(node, scope, options = {}) {
1806
+ function* ClassBody$1(node, scope, options = {}) {
1727
1807
  const { klass, superClass } = options;
1728
1808
  for (let i = 0; i < node.body.length; i++) {
1729
1809
  const def = node.body[i];
1730
1810
  if (def.type === 'MethodDefinition') {
1731
- MethodDefinition$1(def, scope, { klass, superClass });
1811
+ yield* MethodDefinition$1(def, scope, { klass, superClass });
1732
1812
  }
1733
1813
  else if (def.type === 'PropertyDefinition' && def.static) {
1734
- PropertyDefinition$1(def, scope, { klass, superClass });
1814
+ yield* PropertyDefinition$1(def, scope, { klass, superClass });
1735
1815
  }
1736
1816
  else if (def.type === 'StaticBlock') {
1737
- StaticBlock$1(def, scope, { klass, superClass });
1817
+ yield* StaticBlock$1(def, scope, { klass, superClass });
1738
1818
  }
1739
1819
  }
1740
1820
  }
1741
- function MethodDefinition$1(node, scope, options = {}) {
1821
+ function* MethodDefinition$1(node, scope, options = {}) {
1742
1822
  const { klass, superClass } = options;
1743
1823
  let key;
1744
1824
  let priv = false;
1745
1825
  if (node.computed) {
1746
- key = evaluate$1(node.key, scope);
1826
+ key = yield* evaluate$1(node.key, scope);
1747
1827
  }
1748
1828
  else if (node.key.type === 'Identifier') {
1749
1829
  key = node.key.name;
@@ -1795,12 +1875,12 @@
1795
1875
  throw new SyntaxError('Unexpected token');
1796
1876
  }
1797
1877
  }
1798
- function PropertyDefinition$1(node, scope, options = {}) {
1878
+ function* PropertyDefinition$1(node, scope, options = {}) {
1799
1879
  const { klass, superClass } = options;
1800
1880
  let key;
1801
1881
  let priv = false;
1802
1882
  if (node.computed) {
1803
- key = evaluate$1(node.key, scope);
1883
+ key = yield* evaluate$1(node.key, scope);
1804
1884
  }
1805
1885
  else if (node.key.type === 'Identifier') {
1806
1886
  key = node.key.name;
@@ -1824,20 +1904,20 @@
1824
1904
  if (!node.value) {
1825
1905
  obj[key] = undefined;
1826
1906
  }
1827
- if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
1907
+ else if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
1828
1908
  obj[key] = createFunc(node.value, subScope, { superClass });
1829
1909
  }
1830
1910
  else {
1831
- obj[key] = evaluate$1(node.value, subScope);
1911
+ obj[key] = yield* evaluate$1(node.value, subScope);
1832
1912
  }
1833
1913
  }
1834
- function StaticBlock$1(node, scope, options = {}) {
1914
+ function* StaticBlock$1(node, scope, options = {}) {
1835
1915
  const { klass } = options;
1836
1916
  const subScope = new Scope(scope, true);
1837
1917
  subScope.const('this', klass);
1838
- return BlockStatement$1(node, subScope, { invasived: true });
1918
+ return yield* BlockStatement$1(node, subScope, { invasived: true });
1839
1919
  }
1840
- function ImportDeclaration$1(node, scope) {
1920
+ function* ImportDeclaration$1(node, scope) {
1841
1921
  const globalScope = scope.global();
1842
1922
  const module = globalScope.find(IMPORT + node.source.value);
1843
1923
  let value;
@@ -1874,7 +1954,7 @@
1874
1954
  scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
1875
1955
  }
1876
1956
  }
1877
- function ExportDefaultDeclaration$1(node, scope) {
1957
+ function* ExportDefaultDeclaration$1(node, scope) {
1878
1958
  const globalScope = scope.global();
1879
1959
  let value;
1880
1960
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -1882,11 +1962,11 @@
1882
1962
  scope.func(node.declaration.id.name, value);
1883
1963
  }
1884
1964
  else if (node.declaration.type === 'ClassDeclaration') {
1885
- value = createClass(node.declaration, scope);
1965
+ value = yield* createClass(node.declaration, scope);
1886
1966
  scope.func(node.declaration.id.name, value);
1887
1967
  }
1888
1968
  else {
1889
- value = evaluate$1(node.declaration, scope);
1969
+ value = yield* evaluate$1(node.declaration, scope);
1890
1970
  }
1891
1971
  const variable = globalScope.find(EXPORTS);
1892
1972
  if (variable) {
@@ -1896,7 +1976,7 @@
1896
1976
  }
1897
1977
  }
1898
1978
  }
1899
- function ExportNamedDeclaration$1(node, scope) {
1979
+ function* ExportNamedDeclaration$1(node, scope) {
1900
1980
  const globalScope = scope.global();
1901
1981
  if (node.declaration) {
1902
1982
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -1911,7 +1991,7 @@
1911
1991
  }
1912
1992
  }
1913
1993
  else if (node.declaration.type === 'ClassDeclaration') {
1914
- const value = createClass(node.declaration, scope);
1994
+ const value = yield* createClass(node.declaration, scope);
1915
1995
  scope.func(node.declaration.id.name, value);
1916
1996
  const variable = globalScope.find(EXPORTS);
1917
1997
  if (variable) {
@@ -1922,7 +2002,7 @@
1922
2002
  }
1923
2003
  }
1924
2004
  else if (node.declaration.type === 'VariableDeclaration') {
1925
- VariableDeclaration$1(node.declaration, scope);
2005
+ yield* VariableDeclaration$1(node.declaration, scope);
1926
2006
  const variable = globalScope.find(EXPORTS);
1927
2007
  if (variable) {
1928
2008
  const exports = variable.get();
@@ -1957,7 +2037,7 @@
1957
2037
  }
1958
2038
  }
1959
2039
  }
1960
- function ExportAllDeclaration$1(node, scope) {
2040
+ function* ExportAllDeclaration$1(node, scope) {
1961
2041
  const globalScope = scope.global();
1962
2042
  const module = globalScope.find(IMPORT + node.source.value);
1963
2043
  let value;
@@ -1984,7 +2064,7 @@
1984
2064
  }
1985
2065
  }
1986
2066
 
1987
- function* Identifier(node, scope, options = {}) {
2067
+ function Identifier(node, scope, options = {}) {
1988
2068
  const { getVar = false, throwErr = true } = options;
1989
2069
  if (node.name === 'undefined') {
1990
2070
  return undefined;
@@ -2017,7 +2097,7 @@
2017
2097
  Identifier: Identifier
2018
2098
  });
2019
2099
 
2020
- function* Literal(node, scope) {
2100
+ function Literal(node, scope) {
2021
2101
  return node.value;
2022
2102
  }
2023
2103
 
@@ -2026,7 +2106,7 @@
2026
2106
  Literal: Literal
2027
2107
  });
2028
2108
 
2029
- function* ThisExpression(node, scope) {
2109
+ function ThisExpression(node, scope) {
2030
2110
  const superCall = scope.find(SUPERCALL);
2031
2111
  if (superCall && !superCall.get()) {
2032
2112
  throw new ReferenceError('Must call super constructor in derived class '
@@ -2036,41 +2116,41 @@
2036
2116
  return scope.find('this').get();
2037
2117
  }
2038
2118
  }
2039
- function* ArrayExpression(node, scope) {
2119
+ function ArrayExpression(node, scope) {
2040
2120
  let results = [];
2041
2121
  for (let i = 0; i < node.elements.length; i++) {
2042
2122
  const item = node.elements[i];
2043
2123
  if (item.type === 'SpreadElement') {
2044
- results = results.concat(yield* SpreadElement(item, scope));
2124
+ results = results.concat(SpreadElement(item, scope));
2045
2125
  }
2046
2126
  else {
2047
- results.push(yield* evaluate(item, scope));
2127
+ results.push(evaluate(item, scope));
2048
2128
  }
2049
2129
  }
2050
2130
  return results;
2051
2131
  }
2052
- function* ObjectExpression(node, scope) {
2132
+ function ObjectExpression(node, scope) {
2053
2133
  const object = {};
2054
2134
  for (let i = 0; i < node.properties.length; i++) {
2055
2135
  const property = node.properties[i];
2056
2136
  if (property.type === 'SpreadElement') {
2057
- assign(object, yield* SpreadElement(property, scope));
2137
+ assign(object, SpreadElement(property, scope));
2058
2138
  }
2059
2139
  else {
2060
2140
  let key;
2061
2141
  const propKey = property.key;
2062
2142
  if (property.computed) {
2063
- key = yield* evaluate(propKey, scope);
2143
+ key = evaluate(propKey, scope);
2064
2144
  }
2065
2145
  else {
2066
2146
  if (propKey.type === 'Identifier') {
2067
2147
  key = propKey.name;
2068
2148
  }
2069
2149
  else {
2070
- key = '' + (yield* Literal(propKey));
2150
+ key = '' + (Literal(propKey));
2071
2151
  }
2072
2152
  }
2073
- const value = yield* evaluate(property.value, scope);
2153
+ const value = evaluate(property.value, scope);
2074
2154
  const propKind = property.kind;
2075
2155
  if (propKind === 'init') {
2076
2156
  object[key] = value;
@@ -2097,7 +2177,7 @@
2097
2177
  }
2098
2178
  return object;
2099
2179
  }
2100
- function* FunctionExpression(node, scope) {
2180
+ function FunctionExpression(node, scope) {
2101
2181
  if (node.id && node.id.name) {
2102
2182
  const tmpScope = new Scope(scope);
2103
2183
  const func = createFunc$1(node, tmpScope);
@@ -2108,44 +2188,44 @@
2108
2188
  return createFunc$1(node, scope);
2109
2189
  }
2110
2190
  }
2111
- function* UnaryExpression(node, scope) {
2191
+ function UnaryExpression(node, scope) {
2112
2192
  const arg = node.argument;
2113
2193
  switch (node.operator) {
2114
- case '+': return +(yield* evaluate(arg, scope));
2115
- case '-': return -(yield* evaluate(arg, scope));
2116
- case '!': return !(yield* evaluate(arg, scope));
2117
- case '~': return ~(yield* evaluate(arg, scope));
2118
- case 'void': return void (yield* evaluate(arg, scope));
2194
+ case '+': return +(evaluate(arg, scope));
2195
+ case '-': return -(evaluate(arg, scope));
2196
+ case '!': return !(evaluate(arg, scope));
2197
+ case '~': return ~(evaluate(arg, scope));
2198
+ case 'void': return void (evaluate(arg, scope));
2119
2199
  case 'typeof':
2120
2200
  if (arg.type === 'Identifier') {
2121
- return typeof (yield* Identifier(arg, scope, { throwErr: false }));
2201
+ return typeof (Identifier(arg, scope, { throwErr: false }));
2122
2202
  }
2123
2203
  else {
2124
- return typeof (yield* evaluate(arg, scope));
2204
+ return typeof (evaluate(arg, scope));
2125
2205
  }
2126
2206
  case 'delete':
2127
2207
  if (arg.type === 'MemberExpression') {
2128
- const variable = yield* MemberExpression(arg, scope, { getVar: true });
2208
+ const variable = MemberExpression(arg, scope, { getVar: true });
2129
2209
  return variable.del();
2130
2210
  }
2131
2211
  else if (arg.type === 'Identifier') {
2132
2212
  throw new SyntaxError('Delete of an unqualified identifier in strict mode');
2133
2213
  }
2134
2214
  else {
2135
- yield* evaluate(arg, scope);
2215
+ evaluate(arg, scope);
2136
2216
  return true;
2137
2217
  }
2138
2218
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2139
2219
  }
2140
2220
  }
2141
- function* UpdateExpression(node, scope) {
2221
+ function UpdateExpression(node, scope) {
2142
2222
  const arg = node.argument;
2143
2223
  let variable;
2144
2224
  if (arg.type === 'Identifier') {
2145
- variable = yield* Identifier(arg, scope, { getVar: true });
2225
+ variable = Identifier(arg, scope, { getVar: true });
2146
2226
  }
2147
2227
  else if (arg.type === 'MemberExpression') {
2148
- variable = yield* MemberExpression(arg, scope, { getVar: true });
2228
+ variable = MemberExpression(arg, scope, { getVar: true });
2149
2229
  }
2150
2230
  else {
2151
2231
  throw new SyntaxError('Unexpected token');
@@ -2163,17 +2243,17 @@
2163
2243
  throw new SyntaxError(`Unexpected token ${node.operator}`);
2164
2244
  }
2165
2245
  }
2166
- function* BinaryExpression(node, scope) {
2246
+ function BinaryExpression(node, scope) {
2167
2247
  let left;
2168
2248
  let right;
2169
2249
  if (node.left.type === 'PrivateIdentifier') {
2170
2250
  left = node.left.name;
2171
- right = yield* evaluate(node.right, scope);
2172
- right = right[PRIVATE];
2251
+ right = evaluate(node.right, scope);
2252
+ right = right[PRIVATE] || {};
2173
2253
  }
2174
2254
  else {
2175
- left = yield* evaluate(node.left, scope);
2176
- right = yield* evaluate(node.right, scope);
2255
+ left = evaluate(node.left, scope);
2256
+ right = evaluate(node.right, scope);
2177
2257
  }
2178
2258
  switch (node.operator) {
2179
2259
  case '==': return left == right;
@@ -2201,25 +2281,25 @@
2201
2281
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2202
2282
  }
2203
2283
  }
2204
- function* AssignmentExpression(node, scope) {
2284
+ function AssignmentExpression(node, scope) {
2205
2285
  var _a;
2206
2286
  const left = node.left;
2207
2287
  let variable;
2208
2288
  if (left.type === 'Identifier') {
2209
- variable = yield* Identifier(left, scope, { getVar: true, throwErr: false });
2289
+ variable = Identifier(left, scope, { getVar: true, throwErr: false });
2210
2290
  if (!variable) {
2211
2291
  const win = scope.global().find('window').get();
2212
2292
  variable = new Prop(win, left.name);
2213
2293
  }
2214
2294
  }
2215
2295
  else if (left.type === 'MemberExpression') {
2216
- variable = yield* MemberExpression(left, scope, { getVar: true });
2296
+ variable = MemberExpression(left, scope, { getVar: true });
2217
2297
  }
2218
2298
  else {
2219
- const value = yield* evaluate(node.right, scope);
2220
- return yield* pattern$1(left, scope, { feed: value });
2299
+ const value = evaluate(node.right, scope);
2300
+ return pattern$1(left, scope, { feed: value });
2221
2301
  }
2222
- const value = yield* evaluate(node.right, scope);
2302
+ const value = evaluate(node.right, scope);
2223
2303
  switch (node.operator) {
2224
2304
  case '=':
2225
2305
  variable.set(value);
@@ -2272,34 +2352,34 @@
2272
2352
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2273
2353
  }
2274
2354
  }
2275
- function* LogicalExpression(node, scope) {
2355
+ function LogicalExpression(node, scope) {
2276
2356
  var _a;
2277
2357
  switch (node.operator) {
2278
2358
  case '||':
2279
- return (yield* evaluate(node.left, scope)) || (yield* evaluate(node.right, scope));
2359
+ return (evaluate(node.left, scope)) || (evaluate(node.right, scope));
2280
2360
  case '&&':
2281
- return (yield* evaluate(node.left, scope)) && (yield* evaluate(node.right, scope));
2361
+ return (evaluate(node.left, scope)) && (evaluate(node.right, scope));
2282
2362
  case '??':
2283
- return (_a = (yield* evaluate(node.left, scope))) !== null && _a !== void 0 ? _a : (yield* evaluate(node.right, scope));
2363
+ return (_a = (evaluate(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate(node.right, scope));
2284
2364
  default:
2285
2365
  throw new SyntaxError(`Unexpected token ${node.operator}`);
2286
2366
  }
2287
2367
  }
2288
- function* MemberExpression(node, scope, options = {}) {
2368
+ function MemberExpression(node, scope, options = {}) {
2289
2369
  const { getObj = false, getVar = false } = options;
2290
2370
  let object;
2291
2371
  if (node.object.type === 'Super') {
2292
- object = yield* Super(node.object, scope, { getProto: true });
2372
+ object = Super(node.object, scope, { getProto: true });
2293
2373
  }
2294
2374
  else {
2295
- object = yield* evaluate(node.object, scope);
2375
+ object = evaluate(node.object, scope);
2296
2376
  }
2297
2377
  if (getObj)
2298
2378
  return object;
2299
2379
  let key;
2300
2380
  let priv = false;
2301
2381
  if (node.computed) {
2302
- key = yield* evaluate(node.property, scope);
2382
+ key = evaluate(node.property, scope);
2303
2383
  }
2304
2384
  else if (node.property.type === 'PrivateIdentifier') {
2305
2385
  key = node.property.name;
@@ -2340,23 +2420,23 @@
2340
2420
  }
2341
2421
  }
2342
2422
  }
2343
- function* ConditionalExpression(node, scope) {
2344
- return (yield* evaluate(node.test, scope))
2345
- ? (yield* evaluate(node.consequent, scope))
2346
- : (yield* evaluate(node.alternate, scope));
2423
+ function ConditionalExpression(node, scope) {
2424
+ return (evaluate(node.test, scope))
2425
+ ? (evaluate(node.consequent, scope))
2426
+ : (evaluate(node.alternate, scope));
2347
2427
  }
2348
- function* CallExpression(node, scope) {
2428
+ function CallExpression(node, scope) {
2349
2429
  let func;
2350
2430
  let object;
2351
2431
  if (node.callee.type === 'MemberExpression') {
2352
- object = yield* MemberExpression(node.callee, scope, { getObj: true });
2432
+ object = MemberExpression(node.callee, scope, { getObj: true });
2353
2433
  if (node.callee.optional && object == null) {
2354
2434
  return undefined;
2355
2435
  }
2356
2436
  let key;
2357
2437
  let priv = false;
2358
2438
  if (node.callee.computed) {
2359
- key = yield* evaluate(node.callee.property, scope);
2439
+ key = evaluate(node.callee.property, scope);
2360
2440
  }
2361
2441
  else if (node.callee.property.type === 'PrivateIdentifier') {
2362
2442
  key = node.callee.property.name;
@@ -2388,7 +2468,7 @@
2388
2468
  }
2389
2469
  else {
2390
2470
  object = scope.find('this').get();
2391
- func = yield* evaluate(node.callee, scope);
2471
+ func = evaluate(node.callee, scope);
2392
2472
  if (node.optional && func == null) {
2393
2473
  return undefined;
2394
2474
  }
@@ -2417,10 +2497,10 @@
2417
2497
  for (let i = 0; i < node.arguments.length; i++) {
2418
2498
  const arg = node.arguments[i];
2419
2499
  if (arg.type === 'SpreadElement') {
2420
- args = args.concat(yield* SpreadElement(arg, scope));
2500
+ args = args.concat(SpreadElement(arg, scope));
2421
2501
  }
2422
2502
  else {
2423
- args.push(yield* evaluate(arg, scope));
2503
+ args.push(evaluate(arg, scope));
2424
2504
  }
2425
2505
  }
2426
2506
  if (node.callee.type === 'Super') {
@@ -2446,8 +2526,8 @@
2446
2526
  throw err;
2447
2527
  }
2448
2528
  }
2449
- function* NewExpression(node, scope) {
2450
- const constructor = yield* evaluate(node.callee, scope);
2529
+ function NewExpression(node, scope) {
2530
+ const constructor = evaluate(node.callee, scope);
2451
2531
  if (typeof constructor !== 'function') {
2452
2532
  let name;
2453
2533
  if (node.callee.type === 'Identifier') {
@@ -2470,15 +2550,15 @@
2470
2550
  for (let i = 0; i < node.arguments.length; i++) {
2471
2551
  const arg = node.arguments[i];
2472
2552
  if (arg.type === 'SpreadElement') {
2473
- args = args.concat(yield* SpreadElement(arg, scope));
2553
+ args = args.concat(SpreadElement(arg, scope));
2474
2554
  }
2475
2555
  else {
2476
- args.push(yield* evaluate(arg, scope));
2556
+ args.push(evaluate(arg, scope));
2477
2557
  }
2478
2558
  }
2479
2559
  return new constructor(...args);
2480
2560
  }
2481
- function* MetaProperty(node, scope) {
2561
+ function MetaProperty(node, scope) {
2482
2562
  if (node.meta.name === 'new' && node.property.name === 'target') {
2483
2563
  return scope.find(NEWTARGET).get();
2484
2564
  }
@@ -2486,33 +2566,33 @@
2486
2566
  return { url: '' };
2487
2567
  }
2488
2568
  }
2489
- function* SequenceExpression(node, scope) {
2569
+ function SequenceExpression(node, scope) {
2490
2570
  let result;
2491
2571
  for (let i = 0; i < node.expressions.length; i++) {
2492
- result = yield* evaluate(node.expressions[i], scope);
2572
+ result = evaluate(node.expressions[i], scope);
2493
2573
  }
2494
2574
  return result;
2495
2575
  }
2496
- function* ArrowFunctionExpression(node, scope) {
2576
+ function ArrowFunctionExpression(node, scope) {
2497
2577
  return createFunc$1(node, scope);
2498
2578
  }
2499
- function* TemplateLiteral(node, scope) {
2579
+ function TemplateLiteral(node, scope) {
2500
2580
  const quasis = node.quasis.slice();
2501
2581
  const expressions = node.expressions.slice();
2502
2582
  let result = '';
2503
2583
  let temEl;
2504
2584
  let expr;
2505
2585
  while (temEl = quasis.shift()) {
2506
- result += yield* TemplateElement(temEl);
2586
+ result += TemplateElement(temEl);
2507
2587
  expr = expressions.shift();
2508
2588
  if (expr) {
2509
- result += yield* evaluate(expr, scope);
2589
+ result += evaluate(expr, scope);
2510
2590
  }
2511
2591
  }
2512
2592
  return result;
2513
2593
  }
2514
- function* TaggedTemplateExpression(node, scope) {
2515
- const tagFunc = yield* evaluate(node.tag, scope);
2594
+ function TaggedTemplateExpression(node, scope) {
2595
+ const tagFunc = evaluate(node.tag, scope);
2516
2596
  const quasis = node.quasi.quasis;
2517
2597
  const str = quasis.map(v => v.value.cooked);
2518
2598
  const raw = quasis.map(v => v.value.raw);
@@ -2523,40 +2603,40 @@
2523
2603
  const args = [];
2524
2604
  if (expressions) {
2525
2605
  for (let i = 0; i < expressions.length; i++) {
2526
- args.push(yield* evaluate(expressions[i], scope));
2606
+ args.push(evaluate(expressions[i], scope));
2527
2607
  }
2528
2608
  }
2529
2609
  return tagFunc(freeze(str), ...args);
2530
2610
  }
2531
- function* TemplateElement(node, scope) {
2611
+ function TemplateElement(node, scope) {
2532
2612
  return node.value.raw;
2533
2613
  }
2534
- function* ClassExpression(node, scope) {
2614
+ function ClassExpression(node, scope) {
2535
2615
  if (node.id && node.id.name) {
2536
2616
  const tmpScope = new Scope(scope);
2537
- const klass = yield* createClass$1(node, tmpScope);
2617
+ const klass = createClass$1(node, tmpScope);
2538
2618
  tmpScope.const(node.id.name, klass);
2539
2619
  return klass;
2540
2620
  }
2541
2621
  else {
2542
- return yield* createClass$1(node, scope);
2622
+ return createClass$1(node, scope);
2543
2623
  }
2544
2624
  }
2545
- function* Super(node, scope, options = {}) {
2625
+ function Super(node, scope, options = {}) {
2546
2626
  const { getProto = false } = options;
2547
2627
  const superClass = scope.find(SUPER).get();
2548
2628
  return getProto ? superClass.prototype : superClass;
2549
2629
  }
2550
- function* SpreadElement(node, scope) {
2551
- const result = yield* evaluate(node.argument, scope);
2630
+ function SpreadElement(node, scope) {
2631
+ const result = evaluate(node.argument, scope);
2552
2632
  return typeof result === 'string' ? [...result] : result;
2553
2633
  }
2554
- function* ChainExpression(node, scope) {
2555
- return yield* evaluate(node.expression, scope);
2634
+ function ChainExpression(node, scope) {
2635
+ return evaluate(node.expression, scope);
2556
2636
  }
2557
- function* ImportExpression(node, scope) {
2637
+ function ImportExpression(node, scope) {
2558
2638
  const globalScope = scope.global();
2559
- const source = yield* evaluate(node.source, scope);
2639
+ const source = evaluate(node.source, scope);
2560
2640
  const module = globalScope.find(IMPORT + source);
2561
2641
  let value;
2562
2642
  if (module) {
@@ -2574,14 +2654,6 @@
2574
2654
  return Promise.reject(new TypeError(`Failed to resolve module specifier "${source}"`));
2575
2655
  }
2576
2656
  return Promise.resolve(value);
2577
- }
2578
- function* YieldExpression(node, scope) {
2579
- const res = yield* evaluate(node.argument, scope);
2580
- return node.delegate ? yield* res : yield res;
2581
- }
2582
- function* AwaitExpression(node, scope) {
2583
- AWAIT.RES = yield* evaluate(node.argument, scope);
2584
- return yield AWAIT;
2585
2657
  }
2586
2658
 
2587
2659
  var expression = /*#__PURE__*/Object.freeze({
@@ -2609,12 +2681,10 @@
2609
2681
  Super: Super,
2610
2682
  SpreadElement: SpreadElement,
2611
2683
  ChainExpression: ChainExpression,
2612
- ImportExpression: ImportExpression,
2613
- YieldExpression: YieldExpression,
2614
- AwaitExpression: AwaitExpression
2684
+ ImportExpression: ImportExpression
2615
2685
  });
2616
2686
 
2617
- function* ObjectPattern(node, scope, options = {}) {
2687
+ function ObjectPattern(node, scope, options = {}) {
2618
2688
  const { kind = 'var', hoist = false, onlyBlock = false, feed = {} } = options;
2619
2689
  const fedKeys = [];
2620
2690
  for (let i = 0; i < node.properties.length; i++) {
@@ -2627,18 +2697,18 @@
2627
2697
  scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2628
2698
  }
2629
2699
  else {
2630
- yield* pattern$1(value, scope, { kind, hoist, onlyBlock });
2700
+ pattern$1(value, scope, { kind, hoist, onlyBlock });
2631
2701
  }
2632
2702
  }
2633
2703
  else {
2634
- yield* RestElement(property, scope, { kind, hoist, onlyBlock });
2704
+ RestElement(property, scope, { kind, hoist, onlyBlock });
2635
2705
  }
2636
2706
  }
2637
2707
  }
2638
2708
  else if (property.type === 'Property') {
2639
2709
  let key;
2640
2710
  if (property.computed) {
2641
- key = yield* evaluate(property.key, scope);
2711
+ key = evaluate(property.key, scope);
2642
2712
  }
2643
2713
  else {
2644
2714
  key = property.key.name;
@@ -2649,18 +2719,18 @@
2649
2719
  scope[kind](value.name, feed[key]);
2650
2720
  }
2651
2721
  else {
2652
- yield* pattern$1(value, scope, { kind, feed: feed[key] });
2722
+ pattern$1(value, scope, { kind, feed: feed[key] });
2653
2723
  }
2654
2724
  }
2655
2725
  else {
2656
2726
  const rest = assign({}, feed);
2657
2727
  for (let i = 0; i < fedKeys.length; i++)
2658
2728
  delete rest[fedKeys[i]];
2659
- yield* RestElement(property, scope, { kind, feed: rest });
2729
+ RestElement(property, scope, { kind, feed: rest });
2660
2730
  }
2661
2731
  }
2662
2732
  }
2663
- function* ArrayPattern(node, scope, options = {}) {
2733
+ function ArrayPattern(node, scope, options = {}) {
2664
2734
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
2665
2735
  const result = [];
2666
2736
  for (let i = 0; i < node.elements.length; i++) {
@@ -2673,7 +2743,7 @@
2673
2743
  scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2674
2744
  }
2675
2745
  else {
2676
- yield* pattern$1(element, scope, { kind, hoist, onlyBlock });
2746
+ pattern$1(element, scope, { kind, hoist, onlyBlock });
2677
2747
  }
2678
2748
  }
2679
2749
  }
@@ -2682,23 +2752,23 @@
2682
2752
  scope[kind](element.name, feed[i]);
2683
2753
  }
2684
2754
  else {
2685
- const variable = yield* Identifier(element, scope, { getVar: true });
2755
+ const variable = Identifier(element, scope, { getVar: true });
2686
2756
  variable.set(feed[i]);
2687
2757
  result.push(variable.get());
2688
2758
  }
2689
2759
  }
2690
2760
  else if (element.type === 'RestElement') {
2691
- yield* RestElement(element, scope, { kind, feed: feed.slice(i) });
2761
+ RestElement(element, scope, { kind, feed: feed.slice(i) });
2692
2762
  }
2693
2763
  else {
2694
- yield* pattern$1(element, scope, { kind, feed: feed[i] });
2764
+ pattern$1(element, scope, { kind, feed: feed[i] });
2695
2765
  }
2696
2766
  }
2697
2767
  if (result.length) {
2698
2768
  return result;
2699
2769
  }
2700
2770
  }
2701
- function* RestElement(node, scope, options = {}) {
2771
+ function RestElement(node, scope, options = {}) {
2702
2772
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
2703
2773
  const arg = node.argument;
2704
2774
  if (hoist) {
@@ -2707,7 +2777,7 @@
2707
2777
  scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2708
2778
  }
2709
2779
  else {
2710
- yield* pattern$1(arg, scope, { kind, hoist, onlyBlock });
2780
+ pattern$1(arg, scope, { kind, hoist, onlyBlock });
2711
2781
  }
2712
2782
  }
2713
2783
  }
@@ -2716,16 +2786,16 @@
2716
2786
  scope[kind](arg.name, feed);
2717
2787
  }
2718
2788
  else {
2719
- const variable = yield* Identifier(arg, scope, { getVar: true });
2789
+ const variable = Identifier(arg, scope, { getVar: true });
2720
2790
  variable.set(feed);
2721
2791
  }
2722
2792
  }
2723
2793
  else {
2724
- yield* pattern$1(arg, scope, { kind, feed });
2794
+ pattern$1(arg, scope, { kind, feed });
2725
2795
  }
2726
2796
  }
2727
- function* AssignmentPattern(node, scope, options = {}) {
2728
- const { kind = 'var', hoist = false, onlyBlock = false, feed = yield* evaluate(node.right, scope) } = options;
2797
+ function AssignmentPattern(node, scope, options = {}) {
2798
+ const { kind = 'var', hoist = false, onlyBlock = false, feed = evaluate(node.right, scope) } = options;
2729
2799
  const left = node.left;
2730
2800
  if (hoist) {
2731
2801
  if (onlyBlock || kind === 'var') {
@@ -2733,7 +2803,7 @@
2733
2803
  scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2734
2804
  }
2735
2805
  else {
2736
- yield* pattern$1(left, scope, { kind, hoist, onlyBlock });
2806
+ pattern$1(left, scope, { kind, hoist, onlyBlock });
2737
2807
  }
2738
2808
  }
2739
2809
  }
@@ -2741,7 +2811,7 @@
2741
2811
  scope[kind](left.name, feed);
2742
2812
  }
2743
2813
  else {
2744
- yield* pattern$1(left, scope, { kind, feed });
2814
+ pattern$1(left, scope, { kind, feed });
2745
2815
  }
2746
2816
  }
2747
2817
 
@@ -2753,33 +2823,44 @@
2753
2823
  AssignmentPattern: AssignmentPattern
2754
2824
  });
2755
2825
 
2826
+ function Program(program, scope) {
2827
+ for (let i = 0; i < program.body.length; i++) {
2828
+ evaluate(program.body[i], scope);
2829
+ }
2830
+ }
2831
+
2832
+ var program = /*#__PURE__*/Object.freeze({
2833
+ __proto__: null,
2834
+ Program: Program
2835
+ });
2836
+
2756
2837
  let evaluateOps;
2757
- function* evaluate(node, scope) {
2838
+ function evaluate(node, scope) {
2758
2839
  if (!node)
2759
2840
  return;
2760
2841
  if (!evaluateOps) {
2761
- evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern$2);
2842
+ evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern$2, program);
2762
2843
  }
2763
2844
  const handler = evaluateOps[node.type];
2764
2845
  if (handler) {
2765
- return yield* handler(node, scope);
2846
+ return handler(node, scope);
2766
2847
  }
2767
2848
  else {
2768
2849
  throw new Error(`${node.type} isn't implemented`);
2769
2850
  }
2770
2851
  }
2771
2852
 
2772
- function* ExpressionStatement(node, scope) {
2773
- yield* evaluate(node.expression, scope);
2853
+ function ExpressionStatement(node, scope) {
2854
+ evaluate(node.expression, scope);
2774
2855
  }
2775
- function* BlockStatement(block, scope, options = {}) {
2856
+ function BlockStatement(block, scope, options = {}) {
2776
2857
  const { invasived = false, hoisted = false, } = options;
2777
2858
  const subScope = invasived ? scope : new Scope(scope);
2778
2859
  if (!hoisted) {
2779
- yield* hoist$1(block, subScope, { onlyBlock: true });
2860
+ hoist$1(block, subScope, { onlyBlock: true });
2780
2861
  }
2781
2862
  for (let i = 0; i < block.body.length; i++) {
2782
- const result = yield* evaluate(block.body[i], subScope);
2863
+ const result = evaluate(block.body[i], subScope);
2783
2864
  if (result === BREAK) {
2784
2865
  if (result.LABEL && result.LABEL === options.label) {
2785
2866
  break;
@@ -2791,63 +2872,63 @@
2791
2872
  }
2792
2873
  }
2793
2874
  }
2794
- function* EmptyStatement() {
2875
+ function EmptyStatement() {
2795
2876
  }
2796
- function* DebuggerStatement() {
2877
+ function DebuggerStatement() {
2797
2878
  debugger;
2798
2879
  }
2799
- function* ReturnStatement(node, scope) {
2800
- RETURN.RES = node.argument ? (yield* evaluate(node.argument, scope)) : undefined;
2880
+ function ReturnStatement(node, scope) {
2881
+ RETURN.RES = node.argument ? (evaluate(node.argument, scope)) : undefined;
2801
2882
  return RETURN;
2802
2883
  }
2803
- function* BreakStatement(node) {
2884
+ function BreakStatement(node) {
2804
2885
  var _a;
2805
2886
  BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2806
2887
  return BREAK;
2807
2888
  }
2808
- function* ContinueStatement(node) {
2889
+ function ContinueStatement(node) {
2809
2890
  var _a;
2810
2891
  CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2811
2892
  return CONTINUE;
2812
2893
  }
2813
- function* LabeledStatement(node, scope) {
2894
+ function LabeledStatement(node, scope) {
2814
2895
  const label = node.label.name;
2815
2896
  if (node.body.type === 'WhileStatement') {
2816
- return yield* WhileStatement(node.body, scope, { label });
2897
+ return WhileStatement(node.body, scope, { label });
2817
2898
  }
2818
2899
  if (node.body.type === 'DoWhileStatement') {
2819
- return yield* DoWhileStatement(node.body, scope, { label });
2900
+ return DoWhileStatement(node.body, scope, { label });
2820
2901
  }
2821
2902
  if (node.body.type === 'ForStatement') {
2822
- return yield* ForStatement(node.body, scope, { label });
2903
+ return ForStatement(node.body, scope, { label });
2823
2904
  }
2824
2905
  if (node.body.type === 'ForInStatement') {
2825
- return yield* ForInStatement(node.body, scope, { label });
2906
+ return ForInStatement(node.body, scope, { label });
2826
2907
  }
2827
2908
  if (node.body.type === 'ForOfStatement') {
2828
- return yield* ForOfStatement(node.body, scope, { label });
2909
+ return ForOfStatement(node.body, scope, { label });
2829
2910
  }
2830
2911
  if (node.body.type === 'BlockStatement') {
2831
- return yield* BlockStatement(node.body, scope, { label });
2912
+ return BlockStatement(node.body, scope, { label });
2832
2913
  }
2833
2914
  if (node.body.type === 'WithStatement') {
2834
- return yield* WithStatement(node.body, scope, { label });
2915
+ return WithStatement(node.body, scope, { label });
2835
2916
  }
2836
2917
  if (node.body.type === 'IfStatement') {
2837
- return yield* IfStatement(node.body, scope, { label });
2918
+ return IfStatement(node.body, scope, { label });
2838
2919
  }
2839
2920
  if (node.body.type === 'SwitchStatement') {
2840
- return yield* SwitchStatement(node.body, scope, { label });
2921
+ return SwitchStatement(node.body, scope, { label });
2841
2922
  }
2842
2923
  if (node.body.type === 'TryStatement') {
2843
- return yield* TryStatement(node.body, scope, { label });
2924
+ return TryStatement(node.body, scope, { label });
2844
2925
  }
2845
2926
  throw new SyntaxError(`${node.body.type} cannot be labeled`);
2846
2927
  }
2847
- function* WithStatement(node, scope, options = {}) {
2928
+ function WithStatement(node, scope, options = {}) {
2848
2929
  const withScope = new Scope(scope);
2849
- withScope.with(yield* evaluate(node.object, scope));
2850
- const result = yield* evaluate(node.body, withScope);
2930
+ withScope.with(evaluate(node.object, scope));
2931
+ const result = evaluate(node.body, withScope);
2851
2932
  if (result === BREAK) {
2852
2933
  if (result.LABEL && result.LABEL === options.label) {
2853
2934
  return;
@@ -2858,13 +2939,13 @@
2858
2939
  return result;
2859
2940
  }
2860
2941
  }
2861
- function* IfStatement(node, scope, options = {}) {
2942
+ function IfStatement(node, scope, options = {}) {
2862
2943
  let result;
2863
- if (yield* evaluate(node.test, scope)) {
2864
- result = yield* evaluate(node.consequent, scope);
2944
+ if (evaluate(node.test, scope)) {
2945
+ result = evaluate(node.consequent, scope);
2865
2946
  }
2866
2947
  else {
2867
- result = yield* evaluate(node.alternate, scope);
2948
+ result = evaluate(node.alternate, scope);
2868
2949
  }
2869
2950
  if (result === BREAK) {
2870
2951
  if (result.LABEL && result.LABEL === options.label) {
@@ -2876,18 +2957,18 @@
2876
2957
  return result;
2877
2958
  }
2878
2959
  }
2879
- function* SwitchStatement(node, scope, options = {}) {
2880
- const discriminant = yield* evaluate(node.discriminant, scope);
2960
+ function SwitchStatement(node, scope, options = {}) {
2961
+ const discriminant = evaluate(node.discriminant, scope);
2881
2962
  let matched = false;
2882
2963
  for (let i = 0; i < node.cases.length; i++) {
2883
2964
  const eachCase = node.cases[i];
2884
2965
  if (!matched
2885
2966
  && (!eachCase.test
2886
- || (yield* evaluate(eachCase.test, scope)) === discriminant)) {
2967
+ || (evaluate(eachCase.test, scope)) === discriminant)) {
2887
2968
  matched = true;
2888
2969
  }
2889
2970
  if (matched) {
2890
- const result = yield* SwitchCase(eachCase, scope);
2971
+ const result = SwitchCase(eachCase, scope);
2891
2972
  if (result === BREAK) {
2892
2973
  if (result.LABEL === options.label) {
2893
2974
  break;
@@ -2900,21 +2981,21 @@
2900
2981
  }
2901
2982
  }
2902
2983
  }
2903
- function* SwitchCase(node, scope) {
2984
+ function SwitchCase(node, scope) {
2904
2985
  for (let i = 0; i < node.consequent.length; i++) {
2905
- const result = yield* evaluate(node.consequent[i], scope);
2986
+ const result = evaluate(node.consequent[i], scope);
2906
2987
  if (result === BREAK || result === CONTINUE || result === RETURN) {
2907
2988
  return result;
2908
2989
  }
2909
2990
  }
2910
2991
  }
2911
- function* ThrowStatement(node, scope) {
2912
- throw yield* evaluate(node.argument, scope);
2992
+ function ThrowStatement(node, scope) {
2993
+ throw evaluate(node.argument, scope);
2913
2994
  }
2914
- function* TryStatement(node, scope, options = {}) {
2995
+ function TryStatement(node, scope, options = {}) {
2915
2996
  let result;
2916
2997
  try {
2917
- result = yield* BlockStatement(node.block, scope);
2998
+ result = BlockStatement(node.block, scope);
2918
2999
  }
2919
3000
  catch (err) {
2920
3001
  if (node.handler) {
@@ -2926,10 +3007,10 @@
2926
3007
  subScope.var(name, err);
2927
3008
  }
2928
3009
  else {
2929
- yield* pattern$1(param, scope, { feed: err });
3010
+ pattern$1(param, scope, { feed: err });
2930
3011
  }
2931
3012
  }
2932
- result = yield* CatchClause(node.handler, subScope);
3013
+ result = CatchClause(node.handler, subScope);
2933
3014
  }
2934
3015
  else {
2935
3016
  throw err;
@@ -2937,7 +3018,7 @@
2937
3018
  }
2938
3019
  finally {
2939
3020
  if (node.finalizer) {
2940
- result = yield* BlockStatement(node.finalizer, scope);
3021
+ result = BlockStatement(node.finalizer, scope);
2941
3022
  }
2942
3023
  }
2943
3024
  if (result === BREAK) {
@@ -2950,12 +3031,12 @@
2950
3031
  return result;
2951
3032
  }
2952
3033
  }
2953
- function* CatchClause(node, scope) {
2954
- return yield* BlockStatement(node.body, scope, { invasived: true });
3034
+ function CatchClause(node, scope) {
3035
+ return BlockStatement(node.body, scope, { invasived: true });
2955
3036
  }
2956
- function* WhileStatement(node, scope, options = {}) {
2957
- while (yield* evaluate(node.test, scope)) {
2958
- const result = yield* evaluate(node.body, scope);
3037
+ function WhileStatement(node, scope, options = {}) {
3038
+ while (evaluate(node.test, scope)) {
3039
+ const result = evaluate(node.body, scope);
2959
3040
  if (result === BREAK) {
2960
3041
  if (result.LABEL === options.label) {
2961
3042
  break;
@@ -2973,9 +3054,9 @@
2973
3054
  }
2974
3055
  }
2975
3056
  }
2976
- function* DoWhileStatement(node, scope, options = {}) {
3057
+ function DoWhileStatement(node, scope, options = {}) {
2977
3058
  do {
2978
- const result = yield* evaluate(node.body, scope);
3059
+ const result = evaluate(node.body, scope);
2979
3060
  if (result === BREAK) {
2980
3061
  if (result.LABEL === options.label) {
2981
3062
  break;
@@ -2991,18 +3072,18 @@
2991
3072
  else if (result === RETURN) {
2992
3073
  return result;
2993
3074
  }
2994
- } while (yield* evaluate(node.test, scope));
3075
+ } while (evaluate(node.test, scope));
2995
3076
  }
2996
- function* ForStatement(node, scope, options = {}) {
3077
+ function ForStatement(node, scope, options = {}) {
2997
3078
  const forScope = new Scope(scope);
2998
- for (yield* evaluate(node.init, forScope); node.test ? (yield* evaluate(node.test, forScope)) : true; yield* evaluate(node.update, forScope)) {
3079
+ for (evaluate(node.init, forScope); node.test ? (evaluate(node.test, forScope)) : true; evaluate(node.update, forScope)) {
2999
3080
  const subScope = new Scope(forScope);
3000
3081
  let result;
3001
3082
  if (node.body.type === 'BlockStatement') {
3002
- result = yield* BlockStatement(node.body, subScope, { invasived: true });
3083
+ result = BlockStatement(node.body, subScope, { invasived: true });
3003
3084
  }
3004
3085
  else {
3005
- result = yield* evaluate(node.body, subScope);
3086
+ result = evaluate(node.body, subScope);
3006
3087
  }
3007
3088
  if (result === BREAK) {
3008
3089
  if (result.LABEL === options.label) {
@@ -3021,9 +3102,9 @@
3021
3102
  }
3022
3103
  }
3023
3104
  }
3024
- function* ForInStatement(node, scope, options = {}) {
3025
- for (const value in yield* evaluate(node.right, scope)) {
3026
- const result = yield* ForXHandler$1(node, scope, { value });
3105
+ function ForInStatement(node, scope, options = {}) {
3106
+ for (const value in evaluate(node.right, scope)) {
3107
+ const result = ForXHandler$1(node, scope, { value });
3027
3108
  if (result === BREAK) {
3028
3109
  if (result.LABEL === options.label) {
3029
3110
  break;
@@ -3041,61 +3122,37 @@
3041
3122
  }
3042
3123
  }
3043
3124
  }
3044
- function* ForOfStatement(node, scope, options = {}) {
3045
- const right = yield* evaluate(node.right, scope);
3046
- if (node.await) {
3047
- const iterator = getAsyncIterator(right);
3048
- let ret;
3049
- for (AWAIT.RES = iterator.next(), ret = yield AWAIT; !ret.done; AWAIT.RES = iterator.next(), ret = yield AWAIT) {
3050
- const result = yield* ForXHandler$1(node, scope, { value: ret.value });
3051
- if (result === BREAK) {
3052
- if (result.LABEL === options.label) {
3053
- break;
3054
- }
3055
- return result;
3056
- }
3057
- else if (result === CONTINUE) {
3058
- if (result.LABEL === options.label) {
3059
- continue;
3060
- }
3061
- return result;
3062
- }
3063
- else if (result === RETURN) {
3064
- return result;
3125
+ function ForOfStatement(node, scope, options = {}) {
3126
+ const right = evaluate(node.right, scope);
3127
+ for (const value of right) {
3128
+ const result = ForXHandler$1(node, scope, { value });
3129
+ if (result === BREAK) {
3130
+ if (result.LABEL === options.label) {
3131
+ break;
3065
3132
  }
3133
+ return result;
3066
3134
  }
3067
- }
3068
- else {
3069
- for (const value of right) {
3070
- const result = yield* ForXHandler$1(node, scope, { value });
3071
- if (result === BREAK) {
3072
- if (result.LABEL === options.label) {
3073
- break;
3074
- }
3075
- return result;
3076
- }
3077
- else if (result === CONTINUE) {
3078
- if (result.LABEL === options.label) {
3079
- continue;
3080
- }
3081
- return result;
3082
- }
3083
- else if (result === RETURN) {
3084
- return result;
3135
+ else if (result === CONTINUE) {
3136
+ if (result.LABEL === options.label) {
3137
+ continue;
3085
3138
  }
3139
+ return result;
3140
+ }
3141
+ else if (result === RETURN) {
3142
+ return result;
3086
3143
  }
3087
3144
  }
3088
3145
  }
3089
3146
 
3090
- function* FunctionDeclaration(node, scope) {
3147
+ function FunctionDeclaration(node, scope) {
3091
3148
  scope.func(node.id.name, createFunc$1(node, scope));
3092
3149
  }
3093
- function* VariableDeclaration(node, scope, options = {}) {
3150
+ function VariableDeclaration(node, scope, options = {}) {
3094
3151
  for (let i = 0; i < node.declarations.length; i++) {
3095
- yield* VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
3152
+ VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
3096
3153
  }
3097
3154
  }
3098
- function* VariableDeclarator(node, scope, options = {}) {
3155
+ function VariableDeclarator(node, scope, options = {}) {
3099
3156
  const { kind = 'var', hoist = false, onlyBlock = false, feed } = options;
3100
3157
  if (hoist) {
3101
3158
  if (onlyBlock || kind === 'var') {
@@ -3103,13 +3160,13 @@
3103
3160
  scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
3104
3161
  }
3105
3162
  else {
3106
- yield* pattern$1(node.id, scope, { kind, hoist, onlyBlock });
3163
+ pattern$1(node.id, scope, { kind, hoist, onlyBlock });
3107
3164
  }
3108
3165
  }
3109
3166
  }
3110
3167
  else {
3111
3168
  const hasFeed = 'feed' in options;
3112
- const value = hasFeed ? feed : yield* evaluate(node.init, scope);
3169
+ const value = hasFeed ? feed : evaluate(node.init, scope);
3113
3170
  if (node.id.type === 'Identifier') {
3114
3171
  const name = node.id.name;
3115
3172
  if (kind === 'var' && !node.init && !hasFeed) {
@@ -3129,34 +3186,34 @@
3129
3186
  }
3130
3187
  }
3131
3188
  else {
3132
- yield* pattern$1(node.id, scope, { kind, feed: value });
3189
+ pattern$1(node.id, scope, { kind, feed: value });
3133
3190
  }
3134
3191
  }
3135
3192
  }
3136
- function* ClassDeclaration(node, scope) {
3137
- scope.func(node.id.name, yield* createClass$1(node, scope));
3193
+ function ClassDeclaration(node, scope) {
3194
+ scope.func(node.id.name, createClass$1(node, scope));
3138
3195
  }
3139
- function* ClassBody(node, scope, options = {}) {
3196
+ function ClassBody(node, scope, options = {}) {
3140
3197
  const { klass, superClass } = options;
3141
3198
  for (let i = 0; i < node.body.length; i++) {
3142
3199
  const def = node.body[i];
3143
3200
  if (def.type === 'MethodDefinition') {
3144
- yield* MethodDefinition(def, scope, { klass, superClass });
3201
+ MethodDefinition(def, scope, { klass, superClass });
3145
3202
  }
3146
3203
  else if (def.type === 'PropertyDefinition' && def.static) {
3147
- yield* PropertyDefinition(def, scope, { klass, superClass });
3204
+ PropertyDefinition(def, scope, { klass, superClass });
3148
3205
  }
3149
3206
  else if (def.type === 'StaticBlock') {
3150
- yield* StaticBlock(def, scope, { klass, superClass });
3207
+ StaticBlock(def, scope, { klass, superClass });
3151
3208
  }
3152
3209
  }
3153
3210
  }
3154
- function* MethodDefinition(node, scope, options = {}) {
3211
+ function MethodDefinition(node, scope, options = {}) {
3155
3212
  const { klass, superClass } = options;
3156
3213
  let key;
3157
3214
  let priv = false;
3158
3215
  if (node.computed) {
3159
- key = yield* evaluate(node.key, scope);
3216
+ key = evaluate(node.key, scope);
3160
3217
  }
3161
3218
  else if (node.key.type === 'Identifier') {
3162
3219
  key = node.key.name;
@@ -3208,12 +3265,12 @@
3208
3265
  throw new SyntaxError('Unexpected token');
3209
3266
  }
3210
3267
  }
3211
- function* PropertyDefinition(node, scope, options = {}) {
3268
+ function PropertyDefinition(node, scope, options = {}) {
3212
3269
  const { klass, superClass } = options;
3213
3270
  let key;
3214
3271
  let priv = false;
3215
3272
  if (node.computed) {
3216
- key = yield* evaluate(node.key, scope);
3273
+ key = evaluate(node.key, scope);
3217
3274
  }
3218
3275
  else if (node.key.type === 'Identifier') {
3219
3276
  key = node.key.name;
@@ -3237,20 +3294,20 @@
3237
3294
  if (!node.value) {
3238
3295
  obj[key] = undefined;
3239
3296
  }
3240
- if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
3297
+ else if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
3241
3298
  obj[key] = createFunc$1(node.value, subScope, { superClass });
3242
3299
  }
3243
3300
  else {
3244
- obj[key] = yield* evaluate(node.value, subScope);
3301
+ obj[key] = evaluate(node.value, subScope);
3245
3302
  }
3246
3303
  }
3247
- function* StaticBlock(node, scope, options = {}) {
3304
+ function StaticBlock(node, scope, options = {}) {
3248
3305
  const { klass } = options;
3249
3306
  const subScope = new Scope(scope, true);
3250
3307
  subScope.const('this', klass);
3251
- return yield* BlockStatement(node, subScope, { invasived: true });
3308
+ return BlockStatement(node, subScope, { invasived: true });
3252
3309
  }
3253
- function* ImportDeclaration(node, scope) {
3310
+ function ImportDeclaration(node, scope) {
3254
3311
  const globalScope = scope.global();
3255
3312
  const module = globalScope.find(IMPORT + node.source.value);
3256
3313
  let value;
@@ -3287,7 +3344,7 @@
3287
3344
  scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
3288
3345
  }
3289
3346
  }
3290
- function* ExportDefaultDeclaration(node, scope) {
3347
+ function ExportDefaultDeclaration(node, scope) {
3291
3348
  const globalScope = scope.global();
3292
3349
  let value;
3293
3350
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -3295,11 +3352,11 @@
3295
3352
  scope.func(node.declaration.id.name, value);
3296
3353
  }
3297
3354
  else if (node.declaration.type === 'ClassDeclaration') {
3298
- value = yield* createClass$1(node.declaration, scope);
3355
+ value = createClass$1(node.declaration, scope);
3299
3356
  scope.func(node.declaration.id.name, value);
3300
3357
  }
3301
3358
  else {
3302
- value = yield* evaluate(node.declaration, scope);
3359
+ value = evaluate(node.declaration, scope);
3303
3360
  }
3304
3361
  const variable = globalScope.find(EXPORTS);
3305
3362
  if (variable) {
@@ -3309,7 +3366,7 @@
3309
3366
  }
3310
3367
  }
3311
3368
  }
3312
- function* ExportNamedDeclaration(node, scope) {
3369
+ function ExportNamedDeclaration(node, scope) {
3313
3370
  const globalScope = scope.global();
3314
3371
  if (node.declaration) {
3315
3372
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -3324,7 +3381,7 @@
3324
3381
  }
3325
3382
  }
3326
3383
  else if (node.declaration.type === 'ClassDeclaration') {
3327
- const value = yield* createClass$1(node.declaration, scope);
3384
+ const value = createClass$1(node.declaration, scope);
3328
3385
  scope.func(node.declaration.id.name, value);
3329
3386
  const variable = globalScope.find(EXPORTS);
3330
3387
  if (variable) {
@@ -3335,7 +3392,7 @@
3335
3392
  }
3336
3393
  }
3337
3394
  else if (node.declaration.type === 'VariableDeclaration') {
3338
- yield* VariableDeclaration(node.declaration, scope);
3395
+ VariableDeclaration(node.declaration, scope);
3339
3396
  const variable = globalScope.find(EXPORTS);
3340
3397
  if (variable) {
3341
3398
  const exports = variable.get();
@@ -3370,7 +3427,7 @@
3370
3427
  }
3371
3428
  }
3372
3429
  }
3373
- function* ExportAllDeclaration(node, scope) {
3430
+ function ExportAllDeclaration(node, scope) {
3374
3431
  const globalScope = scope.global();
3375
3432
  const module = globalScope.find(IMPORT + node.source.value);
3376
3433
  let value;
@@ -3397,53 +3454,7 @@
3397
3454
  }
3398
3455
  }
3399
3456
 
3400
- function runAsync(iterator, options = {}) {
3401
- const { res, err, ret, fullRet } = options;
3402
- return new Promise((resolve, reject) => {
3403
- if ('ret' in options) {
3404
- return resolve(iterator.return(ret));
3405
- }
3406
- if ('err' in options) {
3407
- onRejected(err);
3408
- }
3409
- else {
3410
- onFulfilled(res);
3411
- }
3412
- function onFulfilled(res) {
3413
- let ret;
3414
- try {
3415
- ret = iterator.next(res);
3416
- }
3417
- catch (e) {
3418
- return reject(e);
3419
- }
3420
- next(ret);
3421
- return null;
3422
- }
3423
- function onRejected(err) {
3424
- let ret;
3425
- try {
3426
- ret = iterator.throw(err);
3427
- }
3428
- catch (e) {
3429
- return reject(e);
3430
- }
3431
- next(ret);
3432
- }
3433
- function next(ret) {
3434
- if (ret.done)
3435
- return resolve(fullRet ? ret : ret.value);
3436
- if (ret.value !== AWAIT)
3437
- return resolve(ret);
3438
- const awaitValue = ret.value.RES;
3439
- const value = awaitValue && awaitValue.then === 'function'
3440
- ? awaitValue : Promise.resolve(awaitValue);
3441
- return value.then(onFulfilled, onRejected);
3442
- }
3443
- });
3444
- }
3445
-
3446
- function* hoist$1(block, scope, options = {}) {
3457
+ function hoist$1(block, scope, options = {}) {
3447
3458
  const { onlyBlock = false } = options;
3448
3459
  const funcDclrList = [];
3449
3460
  const funcDclrIdxs = [];
@@ -3455,10 +3466,10 @@
3455
3466
  }
3456
3467
  else if (statement.type === 'VariableDeclaration'
3457
3468
  && ['const', 'let'].indexOf(statement.kind) !== -1) {
3458
- yield* VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
3469
+ VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
3459
3470
  }
3460
3471
  else if (!onlyBlock) {
3461
- yield* hoistVarRecursion$1(statement, scope);
3472
+ hoistVarRecursion$1(statement, scope);
3462
3473
  }
3463
3474
  }
3464
3475
  if (funcDclrIdxs.length) {
@@ -3468,92 +3479,92 @@
3468
3479
  block.body = funcDclrList.concat(block.body);
3469
3480
  }
3470
3481
  }
3471
- function* hoistVarRecursion$1(statement, scope) {
3482
+ function hoistVarRecursion$1(statement, scope) {
3472
3483
  switch (statement.type) {
3473
3484
  case 'VariableDeclaration':
3474
- yield* VariableDeclaration(statement, scope, { hoist: true });
3485
+ VariableDeclaration(statement, scope, { hoist: true });
3475
3486
  break;
3476
3487
  case 'ForInStatement':
3477
3488
  case 'ForOfStatement':
3478
3489
  if (statement.left.type === 'VariableDeclaration') {
3479
- yield* VariableDeclaration(statement.left, scope, { hoist: true });
3490
+ VariableDeclaration(statement.left, scope, { hoist: true });
3480
3491
  }
3481
3492
  case 'ForStatement':
3482
3493
  if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
3483
- yield* VariableDeclaration(statement.init, scope, { hoist: true });
3494
+ VariableDeclaration(statement.init, scope, { hoist: true });
3484
3495
  }
3485
3496
  case 'WhileStatement':
3486
3497
  case 'DoWhileStatement':
3487
- yield* hoistVarRecursion$1(statement.body, scope);
3498
+ hoistVarRecursion$1(statement.body, scope);
3488
3499
  break;
3489
3500
  case 'IfStatement':
3490
- yield* hoistVarRecursion$1(statement.consequent, scope);
3501
+ hoistVarRecursion$1(statement.consequent, scope);
3491
3502
  if (statement.alternate) {
3492
- yield* hoistVarRecursion$1(statement.alternate, scope);
3503
+ hoistVarRecursion$1(statement.alternate, scope);
3493
3504
  }
3494
3505
  break;
3495
3506
  case 'BlockStatement':
3496
3507
  for (let i = 0; i < statement.body.length; i++) {
3497
- yield* hoistVarRecursion$1(statement.body[i], scope);
3508
+ hoistVarRecursion$1(statement.body[i], scope);
3498
3509
  }
3499
3510
  break;
3500
3511
  case 'SwitchStatement':
3501
3512
  for (let i = 0; i < statement.cases.length; i++) {
3502
3513
  for (let j = 0; j < statement.cases[i].consequent.length; j++) {
3503
- yield* hoistVarRecursion$1(statement.cases[i].consequent[j], scope);
3514
+ hoistVarRecursion$1(statement.cases[i].consequent[j], scope);
3504
3515
  }
3505
3516
  }
3506
3517
  break;
3507
3518
  case 'TryStatement': {
3508
3519
  const tryBlock = statement.block.body;
3509
3520
  for (let i = 0; i < tryBlock.length; i++) {
3510
- yield* hoistVarRecursion$1(tryBlock[i], scope);
3521
+ hoistVarRecursion$1(tryBlock[i], scope);
3511
3522
  }
3512
3523
  const catchBlock = statement.handler && statement.handler.body.body;
3513
3524
  if (catchBlock) {
3514
3525
  for (let i = 0; i < catchBlock.length; i++) {
3515
- yield* hoistVarRecursion$1(catchBlock[i], scope);
3526
+ hoistVarRecursion$1(catchBlock[i], scope);
3516
3527
  }
3517
3528
  }
3518
3529
  const finalBlock = statement.finalizer && statement.finalizer.body;
3519
3530
  if (finalBlock) {
3520
3531
  for (let i = 0; i < finalBlock.length; i++) {
3521
- yield* hoistVarRecursion$1(finalBlock[i], scope);
3532
+ hoistVarRecursion$1(finalBlock[i], scope);
3522
3533
  }
3523
3534
  }
3524
3535
  break;
3525
3536
  }
3526
3537
  }
3527
3538
  }
3528
- function* pattern$1(node, scope, options = {}) {
3539
+ function pattern$1(node, scope, options = {}) {
3529
3540
  switch (node.type) {
3530
3541
  case 'ObjectPattern':
3531
- return yield* ObjectPattern(node, scope, options);
3542
+ return ObjectPattern(node, scope, options);
3532
3543
  case 'ArrayPattern':
3533
- return yield* ArrayPattern(node, scope, options);
3544
+ return ArrayPattern(node, scope, options);
3534
3545
  case 'RestElement':
3535
- return yield* RestElement(node, scope, options);
3546
+ return RestElement(node, scope, options);
3536
3547
  case 'AssignmentPattern':
3537
- return yield* AssignmentPattern(node, scope, options);
3548
+ return AssignmentPattern(node, scope, options);
3538
3549
  default:
3539
3550
  throw new SyntaxError('Unexpected token');
3540
3551
  }
3541
3552
  }
3542
3553
  function createFunc$1(node, scope, options = {}) {
3543
3554
  var _a;
3544
- if (!node.generator && !node.async) {
3555
+ if (node.generator || node.async) {
3545
3556
  return createFunc(node, scope, options);
3546
3557
  }
3547
3558
  const { superClass, construct } = options;
3548
3559
  const params = node.params;
3549
- const tmpFunc = function* (...args) {
3560
+ const tmpFunc = function (...args) {
3550
3561
  const subScope = new Scope(scope, true);
3551
3562
  if (node.type !== 'ArrowFunctionExpression') {
3552
3563
  subScope.const('this', this);
3553
3564
  subScope.let('arguments', arguments);
3554
3565
  subScope.const(NEWTARGET, new.target);
3555
3566
  if (construct) {
3556
- yield* construct(this);
3567
+ construct(this);
3557
3568
  }
3558
3569
  if (superClass) {
3559
3570
  subScope.const(SUPER, superClass);
@@ -3567,22 +3578,22 @@
3567
3578
  subScope.var(param.name, args[i]);
3568
3579
  }
3569
3580
  else if (param.type === 'RestElement') {
3570
- yield* RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
3581
+ RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
3571
3582
  }
3572
3583
  else {
3573
- yield* pattern$1(param, subScope, { kind: 'var', feed: args[i] });
3584
+ pattern$1(param, subScope, { kind: 'var', feed: args[i] });
3574
3585
  }
3575
3586
  }
3576
3587
  let result;
3577
3588
  if (node.body.type === 'BlockStatement') {
3578
- yield* hoist$1(node.body, subScope);
3579
- result = yield* BlockStatement(node.body, subScope, {
3589
+ hoist$1(node.body, subScope);
3590
+ result = BlockStatement(node.body, subScope, {
3580
3591
  invasived: true,
3581
3592
  hoisted: true
3582
3593
  });
3583
3594
  }
3584
3595
  else {
3585
- result = yield* evaluate(node.body, subScope);
3596
+ result = evaluate(node.body, subScope);
3586
3597
  if (node.type === 'ArrowFunctionExpression') {
3587
3598
  RETURN.RES = result;
3588
3599
  result = RETURN;
@@ -3592,38 +3603,10 @@
3592
3603
  return result.RES;
3593
3604
  }
3594
3605
  };
3595
- let func;
3596
- if (node.async && node.generator) {
3597
- func = function () {
3598
- const iterator = tmpFunc.apply(this, arguments);
3599
- let last = Promise.resolve();
3600
- let hasCatch = false;
3601
- const run = (opts) => last = last
3602
- .then(() => runAsync(iterator, assign({ fullRet: true }, opts)))
3603
- .catch(err => {
3604
- if (!hasCatch) {
3605
- hasCatch = true;
3606
- return Promise.reject(err);
3607
- }
3608
- });
3609
- const asyncIterator = {
3610
- next: (res) => run({ res }),
3611
- throw: (err) => run({ err }),
3612
- return: (ret) => run({ ret })
3613
- };
3614
- if (typeof Symbol === 'function') {
3615
- asyncIterator[Symbol.iterator] = function () { return this; };
3616
- }
3617
- return asyncIterator;
3618
- };
3619
- }
3620
- else if (node.async) {
3621
- func = function () { return runAsync(tmpFunc.apply(this, arguments)); };
3622
- }
3623
- else {
3624
- func = tmpFunc;
3606
+ let func = tmpFunc;
3607
+ if (node.type === 'ArrowFunctionExpression') {
3608
+ define(func, NOCTOR, { value: true });
3625
3609
  }
3626
- define(func, NOCTOR, { value: true });
3627
3610
  define(func, 'name', {
3628
3611
  value: node.id
3629
3612
  && node.id.name
@@ -3643,19 +3626,19 @@
3643
3626
  }
3644
3627
  return func;
3645
3628
  }
3646
- function* createClass$1(node, scope) {
3647
- const superClass = yield* evaluate(node.superClass, scope);
3629
+ function createClass$1(node, scope) {
3630
+ const superClass = evaluate(node.superClass, scope);
3648
3631
  const methodBody = node.body.body;
3649
- const construct = function* (object) {
3632
+ const construct = function (object) {
3650
3633
  for (let i = 0; i < methodBody.length; i++) {
3651
3634
  const def = methodBody[i];
3652
3635
  if (def.type === 'PropertyDefinition' && !def.static) {
3653
- yield* PropertyDefinition(def, scope, { klass: object, superClass });
3636
+ PropertyDefinition(def, scope, { klass: object, superClass });
3654
3637
  }
3655
3638
  }
3656
3639
  };
3657
- let klass = function* () {
3658
- yield* construct(this);
3640
+ let klass = function () {
3641
+ construct(this);
3659
3642
  if (superClass) {
3660
3643
  superClass.apply(this);
3661
3644
  }
@@ -3670,7 +3653,7 @@
3670
3653
  if (superClass) {
3671
3654
  inherits(klass, superClass);
3672
3655
  }
3673
- yield* ClassBody(node.body, scope, { klass, superClass });
3656
+ ClassBody(node.body, scope, { klass, superClass });
3674
3657
  define(klass, CLSCTOR, { value: true });
3675
3658
  define(klass, 'name', {
3676
3659
  value: node.id && node.id.name || '',
@@ -3678,31 +3661,31 @@
3678
3661
  });
3679
3662
  return klass;
3680
3663
  }
3681
- function* ForXHandler$1(node, scope, options) {
3664
+ function ForXHandler$1(node, scope, options) {
3682
3665
  const { value } = options;
3683
3666
  const left = node.left;
3684
3667
  const subScope = new Scope(scope);
3685
3668
  if (left.type === 'VariableDeclaration') {
3686
- yield* VariableDeclaration(left, subScope, { feed: value });
3669
+ VariableDeclaration(left, subScope, { feed: value });
3687
3670
  }
3688
3671
  else if (left.type === 'Identifier') {
3689
- const variable = yield* Identifier$1(left, scope, { getVar: true });
3672
+ const variable = Identifier(left, scope, { getVar: true });
3690
3673
  variable.set(value);
3691
3674
  }
3692
3675
  else {
3693
- yield* pattern$1(left, scope, { feed: value });
3676
+ pattern$1(left, scope, { feed: value });
3694
3677
  }
3695
3678
  let result;
3696
3679
  if (node.body.type === 'BlockStatement') {
3697
- result = yield* BlockStatement(node.body, subScope, { invasived: true });
3680
+ result = BlockStatement(node.body, subScope, { invasived: true });
3698
3681
  }
3699
3682
  else {
3700
- result = yield* evaluate(node.body, subScope);
3683
+ result = evaluate(node.body, subScope);
3701
3684
  }
3702
3685
  return result;
3703
3686
  }
3704
3687
 
3705
- function hoist(block, scope, options = {}) {
3688
+ function* hoist(block, scope, options = {}) {
3706
3689
  const { onlyBlock = false } = options;
3707
3690
  const funcDclrList = [];
3708
3691
  const funcDclrIdxs = [];
@@ -3714,10 +3697,10 @@
3714
3697
  }
3715
3698
  else if (statement.type === 'VariableDeclaration'
3716
3699
  && ['const', 'let'].indexOf(statement.kind) !== -1) {
3717
- VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
3700
+ yield* VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
3718
3701
  }
3719
3702
  else if (!onlyBlock) {
3720
- hoistVarRecursion(statement, scope);
3703
+ yield* hoistVarRecursion(statement, scope);
3721
3704
  }
3722
3705
  }
3723
3706
  if (funcDclrIdxs.length) {
@@ -3727,92 +3710,92 @@
3727
3710
  block.body = funcDclrList.concat(block.body);
3728
3711
  }
3729
3712
  }
3730
- function hoistVarRecursion(statement, scope) {
3713
+ function* hoistVarRecursion(statement, scope) {
3731
3714
  switch (statement.type) {
3732
3715
  case 'VariableDeclaration':
3733
- VariableDeclaration$1(statement, scope, { hoist: true });
3716
+ yield* VariableDeclaration$1(statement, scope, { hoist: true });
3734
3717
  break;
3735
3718
  case 'ForInStatement':
3736
3719
  case 'ForOfStatement':
3737
3720
  if (statement.left.type === 'VariableDeclaration') {
3738
- VariableDeclaration$1(statement.left, scope, { hoist: true });
3721
+ yield* VariableDeclaration$1(statement.left, scope, { hoist: true });
3739
3722
  }
3740
3723
  case 'ForStatement':
3741
3724
  if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
3742
- VariableDeclaration$1(statement.init, scope, { hoist: true });
3725
+ yield* VariableDeclaration$1(statement.init, scope, { hoist: true });
3743
3726
  }
3744
3727
  case 'WhileStatement':
3745
3728
  case 'DoWhileStatement':
3746
- hoistVarRecursion(statement.body, scope);
3729
+ yield* hoistVarRecursion(statement.body, scope);
3747
3730
  break;
3748
3731
  case 'IfStatement':
3749
- hoistVarRecursion(statement.consequent, scope);
3732
+ yield* hoistVarRecursion(statement.consequent, scope);
3750
3733
  if (statement.alternate) {
3751
- hoistVarRecursion(statement.alternate, scope);
3734
+ yield* hoistVarRecursion(statement.alternate, scope);
3752
3735
  }
3753
3736
  break;
3754
3737
  case 'BlockStatement':
3755
3738
  for (let i = 0; i < statement.body.length; i++) {
3756
- hoistVarRecursion(statement.body[i], scope);
3739
+ yield* hoistVarRecursion(statement.body[i], scope);
3757
3740
  }
3758
3741
  break;
3759
3742
  case 'SwitchStatement':
3760
3743
  for (let i = 0; i < statement.cases.length; i++) {
3761
3744
  for (let j = 0; j < statement.cases[i].consequent.length; j++) {
3762
- hoistVarRecursion(statement.cases[i].consequent[j], scope);
3745
+ yield* hoistVarRecursion(statement.cases[i].consequent[j], scope);
3763
3746
  }
3764
3747
  }
3765
3748
  break;
3766
3749
  case 'TryStatement': {
3767
3750
  const tryBlock = statement.block.body;
3768
3751
  for (let i = 0; i < tryBlock.length; i++) {
3769
- hoistVarRecursion(tryBlock[i], scope);
3752
+ yield* hoistVarRecursion(tryBlock[i], scope);
3770
3753
  }
3771
3754
  const catchBlock = statement.handler && statement.handler.body.body;
3772
3755
  if (catchBlock) {
3773
3756
  for (let i = 0; i < catchBlock.length; i++) {
3774
- hoistVarRecursion(catchBlock[i], scope);
3757
+ yield* hoistVarRecursion(catchBlock[i], scope);
3775
3758
  }
3776
3759
  }
3777
3760
  const finalBlock = statement.finalizer && statement.finalizer.body;
3778
3761
  if (finalBlock) {
3779
3762
  for (let i = 0; i < finalBlock.length; i++) {
3780
- hoistVarRecursion(finalBlock[i], scope);
3763
+ yield* hoistVarRecursion(finalBlock[i], scope);
3781
3764
  }
3782
3765
  }
3783
3766
  break;
3784
3767
  }
3785
3768
  }
3786
3769
  }
3787
- function pattern(node, scope, options = {}) {
3770
+ function* pattern(node, scope, options = {}) {
3788
3771
  switch (node.type) {
3789
3772
  case 'ObjectPattern':
3790
- return ObjectPattern$1(node, scope, options);
3773
+ return yield* ObjectPattern$1(node, scope, options);
3791
3774
  case 'ArrayPattern':
3792
- return ArrayPattern$1(node, scope, options);
3775
+ return yield* ArrayPattern$1(node, scope, options);
3793
3776
  case 'RestElement':
3794
- return RestElement$1(node, scope, options);
3777
+ return yield* RestElement$1(node, scope, options);
3795
3778
  case 'AssignmentPattern':
3796
- return AssignmentPattern$1(node, scope, options);
3779
+ return yield* AssignmentPattern$1(node, scope, options);
3797
3780
  default:
3798
3781
  throw new SyntaxError('Unexpected token');
3799
3782
  }
3800
3783
  }
3801
3784
  function createFunc(node, scope, options = {}) {
3802
3785
  var _a;
3803
- if (node.generator || node.async) {
3786
+ if (!node.generator && !node.async) {
3804
3787
  return createFunc$1(node, scope, options);
3805
3788
  }
3806
3789
  const { superClass, construct } = options;
3807
3790
  const params = node.params;
3808
- const tmpFunc = function (...args) {
3791
+ const tmpFunc = function* (...args) {
3809
3792
  const subScope = new Scope(scope, true);
3810
3793
  if (node.type !== 'ArrowFunctionExpression') {
3811
3794
  subScope.const('this', this);
3812
3795
  subScope.let('arguments', arguments);
3813
3796
  subScope.const(NEWTARGET, new.target);
3814
3797
  if (construct) {
3815
- construct(this);
3798
+ yield* construct(this);
3816
3799
  }
3817
3800
  if (superClass) {
3818
3801
  subScope.const(SUPER, superClass);
@@ -3826,22 +3809,22 @@
3826
3809
  subScope.var(param.name, args[i]);
3827
3810
  }
3828
3811
  else if (param.type === 'RestElement') {
3829
- RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
3812
+ yield* RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
3830
3813
  }
3831
3814
  else {
3832
- pattern(param, subScope, { kind: 'var', feed: args[i] });
3815
+ yield* pattern(param, subScope, { kind: 'var', feed: args[i] });
3833
3816
  }
3834
3817
  }
3835
3818
  let result;
3836
3819
  if (node.body.type === 'BlockStatement') {
3837
- hoist(node.body, subScope);
3838
- result = BlockStatement$1(node.body, subScope, {
3820
+ yield* hoist(node.body, subScope);
3821
+ result = yield* BlockStatement$1(node.body, subScope, {
3839
3822
  invasived: true,
3840
3823
  hoisted: true
3841
3824
  });
3842
3825
  }
3843
3826
  else {
3844
- result = evaluate$1(node.body, subScope);
3827
+ result = yield* evaluate$1(node.body, subScope);
3845
3828
  if (node.type === 'ArrowFunctionExpression') {
3846
3829
  RETURN.RES = result;
3847
3830
  result = RETURN;
@@ -3851,10 +3834,38 @@
3851
3834
  return result.RES;
3852
3835
  }
3853
3836
  };
3854
- let func = tmpFunc;
3855
- if (node.type === 'ArrowFunctionExpression') {
3856
- define(func, NOCTOR, { value: true });
3837
+ let func;
3838
+ if (node.async && node.generator) {
3839
+ func = function () {
3840
+ const iterator = tmpFunc.apply(this, arguments);
3841
+ let last = Promise.resolve();
3842
+ let hasCatch = false;
3843
+ const run = (opts) => last = last
3844
+ .then(() => runAsync(iterator, assign({ fullRet: true }, opts)))
3845
+ .catch(err => {
3846
+ if (!hasCatch) {
3847
+ hasCatch = true;
3848
+ return Promise.reject(err);
3849
+ }
3850
+ });
3851
+ const asyncIterator = {
3852
+ next: (res) => run({ res }),
3853
+ throw: (err) => run({ err }),
3854
+ return: (ret) => run({ ret })
3855
+ };
3856
+ if (typeof Symbol === 'function') {
3857
+ asyncIterator[Symbol.iterator] = function () { return this; };
3858
+ }
3859
+ return asyncIterator;
3860
+ };
3861
+ }
3862
+ else if (node.async) {
3863
+ func = function () { return runAsync(tmpFunc.apply(this, arguments)); };
3857
3864
  }
3865
+ else {
3866
+ func = tmpFunc;
3867
+ }
3868
+ define(func, NOCTOR, { value: true });
3858
3869
  define(func, 'name', {
3859
3870
  value: node.id
3860
3871
  && node.id.name
@@ -3874,19 +3885,19 @@
3874
3885
  }
3875
3886
  return func;
3876
3887
  }
3877
- function createClass(node, scope) {
3878
- const superClass = evaluate$1(node.superClass, scope);
3888
+ function* createClass(node, scope) {
3889
+ const superClass = yield* evaluate$1(node.superClass, scope);
3879
3890
  const methodBody = node.body.body;
3880
- const construct = function (object) {
3891
+ const construct = function* (object) {
3881
3892
  for (let i = 0; i < methodBody.length; i++) {
3882
3893
  const def = methodBody[i];
3883
3894
  if (def.type === 'PropertyDefinition' && !def.static) {
3884
- PropertyDefinition$1(def, scope, { klass: object, superClass });
3895
+ yield* PropertyDefinition$1(def, scope, { klass: object, superClass });
3885
3896
  }
3886
3897
  }
3887
3898
  };
3888
- let klass = function () {
3889
- construct(this);
3899
+ let klass = function* () {
3900
+ yield* construct(this);
3890
3901
  if (superClass) {
3891
3902
  superClass.apply(this);
3892
3903
  }
@@ -3901,7 +3912,7 @@
3901
3912
  if (superClass) {
3902
3913
  inherits(klass, superClass);
3903
3914
  }
3904
- ClassBody$1(node.body, scope, { klass, superClass });
3915
+ yield* ClassBody$1(node.body, scope, { klass, superClass });
3905
3916
  define(klass, CLSCTOR, { value: true });
3906
3917
  define(klass, 'name', {
3907
3918
  value: node.id && node.id.name || '',
@@ -3909,26 +3920,26 @@
3909
3920
  });
3910
3921
  return klass;
3911
3922
  }
3912
- function ForXHandler(node, scope, options) {
3923
+ function* ForXHandler(node, scope, options) {
3913
3924
  const { value } = options;
3914
3925
  const left = node.left;
3915
3926
  const subScope = new Scope(scope);
3916
3927
  if (left.type === 'VariableDeclaration') {
3917
- VariableDeclaration$1(left, subScope, { feed: value });
3928
+ yield* VariableDeclaration$1(left, subScope, { feed: value });
3918
3929
  }
3919
3930
  else if (left.type === 'Identifier') {
3920
- const variable = Identifier$1(left, scope, { getVar: true });
3931
+ const variable = yield* Identifier(left, scope, { getVar: true });
3921
3932
  variable.set(value);
3922
3933
  }
3923
3934
  else {
3924
- pattern(left, scope, { feed: value });
3935
+ yield* pattern(left, scope, { feed: value });
3925
3936
  }
3926
3937
  let result;
3927
3938
  if (node.body.type === 'BlockStatement') {
3928
- result = BlockStatement$1(node.body, subScope, { invasived: true });
3939
+ result = yield* BlockStatement$1(node.body, subScope, { invasived: true });
3929
3940
  }
3930
3941
  else {
3931
- result = evaluate$1(node.body, subScope);
3942
+ result = yield* evaluate$1(node.body, subScope);
3932
3943
  }
3933
3944
  return result;
3934
3945
  }
@@ -3981,9 +3992,19 @@
3981
3992
  return acorn.parse(code, this.options);
3982
3993
  }
3983
3994
  run(code) {
3984
- const ast = typeof code === 'string' ? acorn.parse(code, this.options) : code;
3985
- hoist(ast, this.scope);
3986
- evaluate$1(ast, this.scope);
3995
+ const ast = typeof code === 'string' ? this.parse(code) : code;
3996
+ const scope = this.scope;
3997
+ if (this.options.sourceType === 'module' && (this.options.ecmaVersion === 'latest'
3998
+ || this.options.ecmaVersion >= 13)) {
3999
+ runAsync((function* () {
4000
+ yield* hoist(ast, scope);
4001
+ yield* evaluate$1(ast, scope);
4002
+ })());
4003
+ }
4004
+ else {
4005
+ hoist$1(ast, scope);
4006
+ evaluate(ast, scope);
4007
+ }
3987
4008
  }
3988
4009
  }
3989
4010
  Sval.version = version;