sval 0.5.5 → 0.5.7

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.5";
467
+ var version = "0.5.7";
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;
@@ -1821,20 +1901,23 @@
1821
1901
  }
1822
1902
  obj = obj[PRIVATE];
1823
1903
  }
1904
+ if (!node.value) {
1905
+ obj[key] = undefined;
1906
+ }
1824
1907
  if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
1825
1908
  obj[key] = createFunc(node.value, subScope, { superClass });
1826
1909
  }
1827
1910
  else {
1828
- obj[key] = evaluate$1(node.value, subScope);
1911
+ obj[key] = yield* evaluate$1(node.value, subScope);
1829
1912
  }
1830
1913
  }
1831
- function StaticBlock$1(node, scope, options = {}) {
1914
+ function* StaticBlock$1(node, scope, options = {}) {
1832
1915
  const { klass } = options;
1833
1916
  const subScope = new Scope(scope, true);
1834
1917
  subScope.const('this', klass);
1835
- return BlockStatement$1(node, subScope, { invasived: true });
1918
+ return yield* BlockStatement$1(node, subScope, { invasived: true });
1836
1919
  }
1837
- function ImportDeclaration$1(node, scope) {
1920
+ function* ImportDeclaration$1(node, scope) {
1838
1921
  const globalScope = scope.global();
1839
1922
  const module = globalScope.find(IMPORT + node.source.value);
1840
1923
  let value;
@@ -1871,7 +1954,7 @@
1871
1954
  scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
1872
1955
  }
1873
1956
  }
1874
- function ExportDefaultDeclaration$1(node, scope) {
1957
+ function* ExportDefaultDeclaration$1(node, scope) {
1875
1958
  const globalScope = scope.global();
1876
1959
  let value;
1877
1960
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -1879,11 +1962,11 @@
1879
1962
  scope.func(node.declaration.id.name, value);
1880
1963
  }
1881
1964
  else if (node.declaration.type === 'ClassDeclaration') {
1882
- value = createClass(node.declaration, scope);
1965
+ value = yield* createClass(node.declaration, scope);
1883
1966
  scope.func(node.declaration.id.name, value);
1884
1967
  }
1885
1968
  else {
1886
- value = evaluate$1(node.declaration, scope);
1969
+ value = yield* evaluate$1(node.declaration, scope);
1887
1970
  }
1888
1971
  const variable = globalScope.find(EXPORTS);
1889
1972
  if (variable) {
@@ -1893,7 +1976,7 @@
1893
1976
  }
1894
1977
  }
1895
1978
  }
1896
- function ExportNamedDeclaration$1(node, scope) {
1979
+ function* ExportNamedDeclaration$1(node, scope) {
1897
1980
  const globalScope = scope.global();
1898
1981
  if (node.declaration) {
1899
1982
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -1908,7 +1991,7 @@
1908
1991
  }
1909
1992
  }
1910
1993
  else if (node.declaration.type === 'ClassDeclaration') {
1911
- const value = createClass(node.declaration, scope);
1994
+ const value = yield* createClass(node.declaration, scope);
1912
1995
  scope.func(node.declaration.id.name, value);
1913
1996
  const variable = globalScope.find(EXPORTS);
1914
1997
  if (variable) {
@@ -1919,7 +2002,7 @@
1919
2002
  }
1920
2003
  }
1921
2004
  else if (node.declaration.type === 'VariableDeclaration') {
1922
- VariableDeclaration$1(node.declaration, scope);
2005
+ yield* VariableDeclaration$1(node.declaration, scope);
1923
2006
  const variable = globalScope.find(EXPORTS);
1924
2007
  if (variable) {
1925
2008
  const exports = variable.get();
@@ -1954,7 +2037,7 @@
1954
2037
  }
1955
2038
  }
1956
2039
  }
1957
- function ExportAllDeclaration$1(node, scope) {
2040
+ function* ExportAllDeclaration$1(node, scope) {
1958
2041
  const globalScope = scope.global();
1959
2042
  const module = globalScope.find(IMPORT + node.source.value);
1960
2043
  let value;
@@ -1981,7 +2064,7 @@
1981
2064
  }
1982
2065
  }
1983
2066
 
1984
- function* Identifier(node, scope, options = {}) {
2067
+ function Identifier(node, scope, options = {}) {
1985
2068
  const { getVar = false, throwErr = true } = options;
1986
2069
  if (node.name === 'undefined') {
1987
2070
  return undefined;
@@ -2014,7 +2097,7 @@
2014
2097
  Identifier: Identifier
2015
2098
  });
2016
2099
 
2017
- function* Literal(node, scope) {
2100
+ function Literal(node, scope) {
2018
2101
  return node.value;
2019
2102
  }
2020
2103
 
@@ -2023,7 +2106,7 @@
2023
2106
  Literal: Literal
2024
2107
  });
2025
2108
 
2026
- function* ThisExpression(node, scope) {
2109
+ function ThisExpression(node, scope) {
2027
2110
  const superCall = scope.find(SUPERCALL);
2028
2111
  if (superCall && !superCall.get()) {
2029
2112
  throw new ReferenceError('Must call super constructor in derived class '
@@ -2033,41 +2116,41 @@
2033
2116
  return scope.find('this').get();
2034
2117
  }
2035
2118
  }
2036
- function* ArrayExpression(node, scope) {
2119
+ function ArrayExpression(node, scope) {
2037
2120
  let results = [];
2038
2121
  for (let i = 0; i < node.elements.length; i++) {
2039
2122
  const item = node.elements[i];
2040
2123
  if (item.type === 'SpreadElement') {
2041
- results = results.concat(yield* SpreadElement(item, scope));
2124
+ results = results.concat(SpreadElement(item, scope));
2042
2125
  }
2043
2126
  else {
2044
- results.push(yield* evaluate(item, scope));
2127
+ results.push(evaluate(item, scope));
2045
2128
  }
2046
2129
  }
2047
2130
  return results;
2048
2131
  }
2049
- function* ObjectExpression(node, scope) {
2132
+ function ObjectExpression(node, scope) {
2050
2133
  const object = {};
2051
2134
  for (let i = 0; i < node.properties.length; i++) {
2052
2135
  const property = node.properties[i];
2053
2136
  if (property.type === 'SpreadElement') {
2054
- assign(object, yield* SpreadElement(property, scope));
2137
+ assign(object, SpreadElement(property, scope));
2055
2138
  }
2056
2139
  else {
2057
2140
  let key;
2058
2141
  const propKey = property.key;
2059
2142
  if (property.computed) {
2060
- key = yield* evaluate(propKey, scope);
2143
+ key = evaluate(propKey, scope);
2061
2144
  }
2062
2145
  else {
2063
2146
  if (propKey.type === 'Identifier') {
2064
2147
  key = propKey.name;
2065
2148
  }
2066
2149
  else {
2067
- key = '' + (yield* Literal(propKey));
2150
+ key = '' + (Literal(propKey));
2068
2151
  }
2069
2152
  }
2070
- const value = yield* evaluate(property.value, scope);
2153
+ const value = evaluate(property.value, scope);
2071
2154
  const propKind = property.kind;
2072
2155
  if (propKind === 'init') {
2073
2156
  object[key] = value;
@@ -2094,7 +2177,7 @@
2094
2177
  }
2095
2178
  return object;
2096
2179
  }
2097
- function* FunctionExpression(node, scope) {
2180
+ function FunctionExpression(node, scope) {
2098
2181
  if (node.id && node.id.name) {
2099
2182
  const tmpScope = new Scope(scope);
2100
2183
  const func = createFunc$1(node, tmpScope);
@@ -2105,44 +2188,44 @@
2105
2188
  return createFunc$1(node, scope);
2106
2189
  }
2107
2190
  }
2108
- function* UnaryExpression(node, scope) {
2191
+ function UnaryExpression(node, scope) {
2109
2192
  const arg = node.argument;
2110
2193
  switch (node.operator) {
2111
- case '+': return +(yield* evaluate(arg, scope));
2112
- case '-': return -(yield* evaluate(arg, scope));
2113
- case '!': return !(yield* evaluate(arg, scope));
2114
- case '~': return ~(yield* evaluate(arg, scope));
2115
- 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));
2116
2199
  case 'typeof':
2117
2200
  if (arg.type === 'Identifier') {
2118
- return typeof (yield* Identifier(arg, scope, { throwErr: false }));
2201
+ return typeof (Identifier(arg, scope, { throwErr: false }));
2119
2202
  }
2120
2203
  else {
2121
- return typeof (yield* evaluate(arg, scope));
2204
+ return typeof (evaluate(arg, scope));
2122
2205
  }
2123
2206
  case 'delete':
2124
2207
  if (arg.type === 'MemberExpression') {
2125
- const variable = yield* MemberExpression(arg, scope, { getVar: true });
2208
+ const variable = MemberExpression(arg, scope, { getVar: true });
2126
2209
  return variable.del();
2127
2210
  }
2128
2211
  else if (arg.type === 'Identifier') {
2129
2212
  throw new SyntaxError('Delete of an unqualified identifier in strict mode');
2130
2213
  }
2131
2214
  else {
2132
- yield* evaluate(arg, scope);
2215
+ evaluate(arg, scope);
2133
2216
  return true;
2134
2217
  }
2135
2218
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2136
2219
  }
2137
2220
  }
2138
- function* UpdateExpression(node, scope) {
2221
+ function UpdateExpression(node, scope) {
2139
2222
  const arg = node.argument;
2140
2223
  let variable;
2141
2224
  if (arg.type === 'Identifier') {
2142
- variable = yield* Identifier(arg, scope, { getVar: true });
2225
+ variable = Identifier(arg, scope, { getVar: true });
2143
2226
  }
2144
2227
  else if (arg.type === 'MemberExpression') {
2145
- variable = yield* MemberExpression(arg, scope, { getVar: true });
2228
+ variable = MemberExpression(arg, scope, { getVar: true });
2146
2229
  }
2147
2230
  else {
2148
2231
  throw new SyntaxError('Unexpected token');
@@ -2160,17 +2243,17 @@
2160
2243
  throw new SyntaxError(`Unexpected token ${node.operator}`);
2161
2244
  }
2162
2245
  }
2163
- function* BinaryExpression(node, scope) {
2246
+ function BinaryExpression(node, scope) {
2164
2247
  let left;
2165
2248
  let right;
2166
2249
  if (node.left.type === 'PrivateIdentifier') {
2167
2250
  left = node.left.name;
2168
- right = yield* evaluate(node.right, scope);
2169
- right = right[PRIVATE];
2251
+ right = evaluate(node.right, scope);
2252
+ right = right[PRIVATE] || {};
2170
2253
  }
2171
2254
  else {
2172
- left = yield* evaluate(node.left, scope);
2173
- right = yield* evaluate(node.right, scope);
2255
+ left = evaluate(node.left, scope);
2256
+ right = evaluate(node.right, scope);
2174
2257
  }
2175
2258
  switch (node.operator) {
2176
2259
  case '==': return left == right;
@@ -2198,25 +2281,25 @@
2198
2281
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2199
2282
  }
2200
2283
  }
2201
- function* AssignmentExpression(node, scope) {
2284
+ function AssignmentExpression(node, scope) {
2202
2285
  var _a;
2203
2286
  const left = node.left;
2204
2287
  let variable;
2205
2288
  if (left.type === 'Identifier') {
2206
- variable = yield* Identifier(left, scope, { getVar: true, throwErr: false });
2289
+ variable = Identifier(left, scope, { getVar: true, throwErr: false });
2207
2290
  if (!variable) {
2208
2291
  const win = scope.global().find('window').get();
2209
2292
  variable = new Prop(win, left.name);
2210
2293
  }
2211
2294
  }
2212
2295
  else if (left.type === 'MemberExpression') {
2213
- variable = yield* MemberExpression(left, scope, { getVar: true });
2296
+ variable = MemberExpression(left, scope, { getVar: true });
2214
2297
  }
2215
2298
  else {
2216
- const value = yield* evaluate(node.right, scope);
2217
- return yield* pattern$1(left, scope, { feed: value });
2299
+ const value = evaluate(node.right, scope);
2300
+ return pattern$1(left, scope, { feed: value });
2218
2301
  }
2219
- const value = yield* evaluate(node.right, scope);
2302
+ const value = evaluate(node.right, scope);
2220
2303
  switch (node.operator) {
2221
2304
  case '=':
2222
2305
  variable.set(value);
@@ -2269,34 +2352,34 @@
2269
2352
  default: throw new SyntaxError(`Unexpected token ${node.operator}`);
2270
2353
  }
2271
2354
  }
2272
- function* LogicalExpression(node, scope) {
2355
+ function LogicalExpression(node, scope) {
2273
2356
  var _a;
2274
2357
  switch (node.operator) {
2275
2358
  case '||':
2276
- return (yield* evaluate(node.left, scope)) || (yield* evaluate(node.right, scope));
2359
+ return (evaluate(node.left, scope)) || (evaluate(node.right, scope));
2277
2360
  case '&&':
2278
- return (yield* evaluate(node.left, scope)) && (yield* evaluate(node.right, scope));
2361
+ return (evaluate(node.left, scope)) && (evaluate(node.right, scope));
2279
2362
  case '??':
2280
- 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));
2281
2364
  default:
2282
2365
  throw new SyntaxError(`Unexpected token ${node.operator}`);
2283
2366
  }
2284
2367
  }
2285
- function* MemberExpression(node, scope, options = {}) {
2368
+ function MemberExpression(node, scope, options = {}) {
2286
2369
  const { getObj = false, getVar = false } = options;
2287
2370
  let object;
2288
2371
  if (node.object.type === 'Super') {
2289
- object = yield* Super(node.object, scope, { getProto: true });
2372
+ object = Super(node.object, scope, { getProto: true });
2290
2373
  }
2291
2374
  else {
2292
- object = yield* evaluate(node.object, scope);
2375
+ object = evaluate(node.object, scope);
2293
2376
  }
2294
2377
  if (getObj)
2295
2378
  return object;
2296
2379
  let key;
2297
2380
  let priv = false;
2298
2381
  if (node.computed) {
2299
- key = yield* evaluate(node.property, scope);
2382
+ key = evaluate(node.property, scope);
2300
2383
  }
2301
2384
  else if (node.property.type === 'PrivateIdentifier') {
2302
2385
  key = node.property.name;
@@ -2337,23 +2420,23 @@
2337
2420
  }
2338
2421
  }
2339
2422
  }
2340
- function* ConditionalExpression(node, scope) {
2341
- return (yield* evaluate(node.test, scope))
2342
- ? (yield* evaluate(node.consequent, scope))
2343
- : (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));
2344
2427
  }
2345
- function* CallExpression(node, scope) {
2428
+ function CallExpression(node, scope) {
2346
2429
  let func;
2347
2430
  let object;
2348
2431
  if (node.callee.type === 'MemberExpression') {
2349
- object = yield* MemberExpression(node.callee, scope, { getObj: true });
2432
+ object = MemberExpression(node.callee, scope, { getObj: true });
2350
2433
  if (node.callee.optional && object == null) {
2351
2434
  return undefined;
2352
2435
  }
2353
2436
  let key;
2354
2437
  let priv = false;
2355
2438
  if (node.callee.computed) {
2356
- key = yield* evaluate(node.callee.property, scope);
2439
+ key = evaluate(node.callee.property, scope);
2357
2440
  }
2358
2441
  else if (node.callee.property.type === 'PrivateIdentifier') {
2359
2442
  key = node.callee.property.name;
@@ -2385,7 +2468,7 @@
2385
2468
  }
2386
2469
  else {
2387
2470
  object = scope.find('this').get();
2388
- func = yield* evaluate(node.callee, scope);
2471
+ func = evaluate(node.callee, scope);
2389
2472
  if (node.optional && func == null) {
2390
2473
  return undefined;
2391
2474
  }
@@ -2414,10 +2497,10 @@
2414
2497
  for (let i = 0; i < node.arguments.length; i++) {
2415
2498
  const arg = node.arguments[i];
2416
2499
  if (arg.type === 'SpreadElement') {
2417
- args = args.concat(yield* SpreadElement(arg, scope));
2500
+ args = args.concat(SpreadElement(arg, scope));
2418
2501
  }
2419
2502
  else {
2420
- args.push(yield* evaluate(arg, scope));
2503
+ args.push(evaluate(arg, scope));
2421
2504
  }
2422
2505
  }
2423
2506
  if (node.callee.type === 'Super') {
@@ -2443,8 +2526,8 @@
2443
2526
  throw err;
2444
2527
  }
2445
2528
  }
2446
- function* NewExpression(node, scope) {
2447
- const constructor = yield* evaluate(node.callee, scope);
2529
+ function NewExpression(node, scope) {
2530
+ const constructor = evaluate(node.callee, scope);
2448
2531
  if (typeof constructor !== 'function') {
2449
2532
  let name;
2450
2533
  if (node.callee.type === 'Identifier') {
@@ -2467,15 +2550,15 @@
2467
2550
  for (let i = 0; i < node.arguments.length; i++) {
2468
2551
  const arg = node.arguments[i];
2469
2552
  if (arg.type === 'SpreadElement') {
2470
- args = args.concat(yield* SpreadElement(arg, scope));
2553
+ args = args.concat(SpreadElement(arg, scope));
2471
2554
  }
2472
2555
  else {
2473
- args.push(yield* evaluate(arg, scope));
2556
+ args.push(evaluate(arg, scope));
2474
2557
  }
2475
2558
  }
2476
2559
  return new constructor(...args);
2477
2560
  }
2478
- function* MetaProperty(node, scope) {
2561
+ function MetaProperty(node, scope) {
2479
2562
  if (node.meta.name === 'new' && node.property.name === 'target') {
2480
2563
  return scope.find(NEWTARGET).get();
2481
2564
  }
@@ -2483,33 +2566,33 @@
2483
2566
  return { url: '' };
2484
2567
  }
2485
2568
  }
2486
- function* SequenceExpression(node, scope) {
2569
+ function SequenceExpression(node, scope) {
2487
2570
  let result;
2488
2571
  for (let i = 0; i < node.expressions.length; i++) {
2489
- result = yield* evaluate(node.expressions[i], scope);
2572
+ result = evaluate(node.expressions[i], scope);
2490
2573
  }
2491
2574
  return result;
2492
2575
  }
2493
- function* ArrowFunctionExpression(node, scope) {
2576
+ function ArrowFunctionExpression(node, scope) {
2494
2577
  return createFunc$1(node, scope);
2495
2578
  }
2496
- function* TemplateLiteral(node, scope) {
2579
+ function TemplateLiteral(node, scope) {
2497
2580
  const quasis = node.quasis.slice();
2498
2581
  const expressions = node.expressions.slice();
2499
2582
  let result = '';
2500
2583
  let temEl;
2501
2584
  let expr;
2502
2585
  while (temEl = quasis.shift()) {
2503
- result += yield* TemplateElement(temEl);
2586
+ result += TemplateElement(temEl);
2504
2587
  expr = expressions.shift();
2505
2588
  if (expr) {
2506
- result += yield* evaluate(expr, scope);
2589
+ result += evaluate(expr, scope);
2507
2590
  }
2508
2591
  }
2509
2592
  return result;
2510
2593
  }
2511
- function* TaggedTemplateExpression(node, scope) {
2512
- const tagFunc = yield* evaluate(node.tag, scope);
2594
+ function TaggedTemplateExpression(node, scope) {
2595
+ const tagFunc = evaluate(node.tag, scope);
2513
2596
  const quasis = node.quasi.quasis;
2514
2597
  const str = quasis.map(v => v.value.cooked);
2515
2598
  const raw = quasis.map(v => v.value.raw);
@@ -2520,40 +2603,40 @@
2520
2603
  const args = [];
2521
2604
  if (expressions) {
2522
2605
  for (let i = 0; i < expressions.length; i++) {
2523
- args.push(yield* evaluate(expressions[i], scope));
2606
+ args.push(evaluate(expressions[i], scope));
2524
2607
  }
2525
2608
  }
2526
2609
  return tagFunc(freeze(str), ...args);
2527
2610
  }
2528
- function* TemplateElement(node, scope) {
2611
+ function TemplateElement(node, scope) {
2529
2612
  return node.value.raw;
2530
2613
  }
2531
- function* ClassExpression(node, scope) {
2614
+ function ClassExpression(node, scope) {
2532
2615
  if (node.id && node.id.name) {
2533
2616
  const tmpScope = new Scope(scope);
2534
- const klass = yield* createClass$1(node, tmpScope);
2617
+ const klass = createClass$1(node, tmpScope);
2535
2618
  tmpScope.const(node.id.name, klass);
2536
2619
  return klass;
2537
2620
  }
2538
2621
  else {
2539
- return yield* createClass$1(node, scope);
2622
+ return createClass$1(node, scope);
2540
2623
  }
2541
2624
  }
2542
- function* Super(node, scope, options = {}) {
2625
+ function Super(node, scope, options = {}) {
2543
2626
  const { getProto = false } = options;
2544
2627
  const superClass = scope.find(SUPER).get();
2545
2628
  return getProto ? superClass.prototype : superClass;
2546
2629
  }
2547
- function* SpreadElement(node, scope) {
2548
- const result = yield* evaluate(node.argument, scope);
2630
+ function SpreadElement(node, scope) {
2631
+ const result = evaluate(node.argument, scope);
2549
2632
  return typeof result === 'string' ? [...result] : result;
2550
2633
  }
2551
- function* ChainExpression(node, scope) {
2552
- return yield* evaluate(node.expression, scope);
2634
+ function ChainExpression(node, scope) {
2635
+ return evaluate(node.expression, scope);
2553
2636
  }
2554
- function* ImportExpression(node, scope) {
2637
+ function ImportExpression(node, scope) {
2555
2638
  const globalScope = scope.global();
2556
- const source = yield* evaluate(node.source, scope);
2639
+ const source = evaluate(node.source, scope);
2557
2640
  const module = globalScope.find(IMPORT + source);
2558
2641
  let value;
2559
2642
  if (module) {
@@ -2571,14 +2654,6 @@
2571
2654
  return Promise.reject(new TypeError(`Failed to resolve module specifier "${source}"`));
2572
2655
  }
2573
2656
  return Promise.resolve(value);
2574
- }
2575
- function* YieldExpression(node, scope) {
2576
- const res = yield* evaluate(node.argument, scope);
2577
- return node.delegate ? yield* res : yield res;
2578
- }
2579
- function* AwaitExpression(node, scope) {
2580
- AWAIT.RES = yield* evaluate(node.argument, scope);
2581
- return yield AWAIT;
2582
2657
  }
2583
2658
 
2584
2659
  var expression = /*#__PURE__*/Object.freeze({
@@ -2606,12 +2681,10 @@
2606
2681
  Super: Super,
2607
2682
  SpreadElement: SpreadElement,
2608
2683
  ChainExpression: ChainExpression,
2609
- ImportExpression: ImportExpression,
2610
- YieldExpression: YieldExpression,
2611
- AwaitExpression: AwaitExpression
2684
+ ImportExpression: ImportExpression
2612
2685
  });
2613
2686
 
2614
- function* ObjectPattern(node, scope, options = {}) {
2687
+ function ObjectPattern(node, scope, options = {}) {
2615
2688
  const { kind = 'var', hoist = false, onlyBlock = false, feed = {} } = options;
2616
2689
  const fedKeys = [];
2617
2690
  for (let i = 0; i < node.properties.length; i++) {
@@ -2624,18 +2697,18 @@
2624
2697
  scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2625
2698
  }
2626
2699
  else {
2627
- yield* pattern$1(value, scope, { kind, hoist, onlyBlock });
2700
+ pattern$1(value, scope, { kind, hoist, onlyBlock });
2628
2701
  }
2629
2702
  }
2630
2703
  else {
2631
- yield* RestElement(property, scope, { kind, hoist, onlyBlock });
2704
+ RestElement(property, scope, { kind, hoist, onlyBlock });
2632
2705
  }
2633
2706
  }
2634
2707
  }
2635
2708
  else if (property.type === 'Property') {
2636
2709
  let key;
2637
2710
  if (property.computed) {
2638
- key = yield* evaluate(property.key, scope);
2711
+ key = evaluate(property.key, scope);
2639
2712
  }
2640
2713
  else {
2641
2714
  key = property.key.name;
@@ -2646,18 +2719,18 @@
2646
2719
  scope[kind](value.name, feed[key]);
2647
2720
  }
2648
2721
  else {
2649
- yield* pattern$1(value, scope, { kind, feed: feed[key] });
2722
+ pattern$1(value, scope, { kind, feed: feed[key] });
2650
2723
  }
2651
2724
  }
2652
2725
  else {
2653
2726
  const rest = assign({}, feed);
2654
2727
  for (let i = 0; i < fedKeys.length; i++)
2655
2728
  delete rest[fedKeys[i]];
2656
- yield* RestElement(property, scope, { kind, feed: rest });
2729
+ RestElement(property, scope, { kind, feed: rest });
2657
2730
  }
2658
2731
  }
2659
2732
  }
2660
- function* ArrayPattern(node, scope, options = {}) {
2733
+ function ArrayPattern(node, scope, options = {}) {
2661
2734
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
2662
2735
  const result = [];
2663
2736
  for (let i = 0; i < node.elements.length; i++) {
@@ -2670,7 +2743,7 @@
2670
2743
  scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2671
2744
  }
2672
2745
  else {
2673
- yield* pattern$1(element, scope, { kind, hoist, onlyBlock });
2746
+ pattern$1(element, scope, { kind, hoist, onlyBlock });
2674
2747
  }
2675
2748
  }
2676
2749
  }
@@ -2679,23 +2752,23 @@
2679
2752
  scope[kind](element.name, feed[i]);
2680
2753
  }
2681
2754
  else {
2682
- const variable = yield* Identifier(element, scope, { getVar: true });
2755
+ const variable = Identifier(element, scope, { getVar: true });
2683
2756
  variable.set(feed[i]);
2684
2757
  result.push(variable.get());
2685
2758
  }
2686
2759
  }
2687
2760
  else if (element.type === 'RestElement') {
2688
- yield* RestElement(element, scope, { kind, feed: feed.slice(i) });
2761
+ RestElement(element, scope, { kind, feed: feed.slice(i) });
2689
2762
  }
2690
2763
  else {
2691
- yield* pattern$1(element, scope, { kind, feed: feed[i] });
2764
+ pattern$1(element, scope, { kind, feed: feed[i] });
2692
2765
  }
2693
2766
  }
2694
2767
  if (result.length) {
2695
2768
  return result;
2696
2769
  }
2697
2770
  }
2698
- function* RestElement(node, scope, options = {}) {
2771
+ function RestElement(node, scope, options = {}) {
2699
2772
  const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
2700
2773
  const arg = node.argument;
2701
2774
  if (hoist) {
@@ -2704,7 +2777,7 @@
2704
2777
  scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2705
2778
  }
2706
2779
  else {
2707
- yield* pattern$1(arg, scope, { kind, hoist, onlyBlock });
2780
+ pattern$1(arg, scope, { kind, hoist, onlyBlock });
2708
2781
  }
2709
2782
  }
2710
2783
  }
@@ -2713,16 +2786,16 @@
2713
2786
  scope[kind](arg.name, feed);
2714
2787
  }
2715
2788
  else {
2716
- const variable = yield* Identifier(arg, scope, { getVar: true });
2789
+ const variable = Identifier(arg, scope, { getVar: true });
2717
2790
  variable.set(feed);
2718
2791
  }
2719
2792
  }
2720
2793
  else {
2721
- yield* pattern$1(arg, scope, { kind, feed });
2794
+ pattern$1(arg, scope, { kind, feed });
2722
2795
  }
2723
2796
  }
2724
- function* AssignmentPattern(node, scope, options = {}) {
2725
- 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;
2726
2799
  const left = node.left;
2727
2800
  if (hoist) {
2728
2801
  if (onlyBlock || kind === 'var') {
@@ -2730,7 +2803,7 @@
2730
2803
  scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
2731
2804
  }
2732
2805
  else {
2733
- yield* pattern$1(left, scope, { kind, hoist, onlyBlock });
2806
+ pattern$1(left, scope, { kind, hoist, onlyBlock });
2734
2807
  }
2735
2808
  }
2736
2809
  }
@@ -2738,7 +2811,7 @@
2738
2811
  scope[kind](left.name, feed);
2739
2812
  }
2740
2813
  else {
2741
- yield* pattern$1(left, scope, { kind, feed });
2814
+ pattern$1(left, scope, { kind, feed });
2742
2815
  }
2743
2816
  }
2744
2817
 
@@ -2750,33 +2823,44 @@
2750
2823
  AssignmentPattern: AssignmentPattern
2751
2824
  });
2752
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
+
2753
2837
  let evaluateOps;
2754
- function* evaluate(node, scope) {
2838
+ function evaluate(node, scope) {
2755
2839
  if (!node)
2756
2840
  return;
2757
2841
  if (!evaluateOps) {
2758
- evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern$2);
2842
+ evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern$2, program);
2759
2843
  }
2760
2844
  const handler = evaluateOps[node.type];
2761
2845
  if (handler) {
2762
- return yield* handler(node, scope);
2846
+ return handler(node, scope);
2763
2847
  }
2764
2848
  else {
2765
2849
  throw new Error(`${node.type} isn't implemented`);
2766
2850
  }
2767
2851
  }
2768
2852
 
2769
- function* ExpressionStatement(node, scope) {
2770
- yield* evaluate(node.expression, scope);
2853
+ function ExpressionStatement(node, scope) {
2854
+ evaluate(node.expression, scope);
2771
2855
  }
2772
- function* BlockStatement(block, scope, options = {}) {
2856
+ function BlockStatement(block, scope, options = {}) {
2773
2857
  const { invasived = false, hoisted = false, } = options;
2774
2858
  const subScope = invasived ? scope : new Scope(scope);
2775
2859
  if (!hoisted) {
2776
- yield* hoist$1(block, subScope, { onlyBlock: true });
2860
+ hoist$1(block, subScope, { onlyBlock: true });
2777
2861
  }
2778
2862
  for (let i = 0; i < block.body.length; i++) {
2779
- const result = yield* evaluate(block.body[i], subScope);
2863
+ const result = evaluate(block.body[i], subScope);
2780
2864
  if (result === BREAK) {
2781
2865
  if (result.LABEL && result.LABEL === options.label) {
2782
2866
  break;
@@ -2788,63 +2872,63 @@
2788
2872
  }
2789
2873
  }
2790
2874
  }
2791
- function* EmptyStatement() {
2875
+ function EmptyStatement() {
2792
2876
  }
2793
- function* DebuggerStatement() {
2877
+ function DebuggerStatement() {
2794
2878
  debugger;
2795
2879
  }
2796
- function* ReturnStatement(node, scope) {
2797
- 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;
2798
2882
  return RETURN;
2799
2883
  }
2800
- function* BreakStatement(node) {
2884
+ function BreakStatement(node) {
2801
2885
  var _a;
2802
2886
  BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2803
2887
  return BREAK;
2804
2888
  }
2805
- function* ContinueStatement(node) {
2889
+ function ContinueStatement(node) {
2806
2890
  var _a;
2807
2891
  CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
2808
2892
  return CONTINUE;
2809
2893
  }
2810
- function* LabeledStatement(node, scope) {
2894
+ function LabeledStatement(node, scope) {
2811
2895
  const label = node.label.name;
2812
2896
  if (node.body.type === 'WhileStatement') {
2813
- return yield* WhileStatement(node.body, scope, { label });
2897
+ return WhileStatement(node.body, scope, { label });
2814
2898
  }
2815
2899
  if (node.body.type === 'DoWhileStatement') {
2816
- return yield* DoWhileStatement(node.body, scope, { label });
2900
+ return DoWhileStatement(node.body, scope, { label });
2817
2901
  }
2818
2902
  if (node.body.type === 'ForStatement') {
2819
- return yield* ForStatement(node.body, scope, { label });
2903
+ return ForStatement(node.body, scope, { label });
2820
2904
  }
2821
2905
  if (node.body.type === 'ForInStatement') {
2822
- return yield* ForInStatement(node.body, scope, { label });
2906
+ return ForInStatement(node.body, scope, { label });
2823
2907
  }
2824
2908
  if (node.body.type === 'ForOfStatement') {
2825
- return yield* ForOfStatement(node.body, scope, { label });
2909
+ return ForOfStatement(node.body, scope, { label });
2826
2910
  }
2827
2911
  if (node.body.type === 'BlockStatement') {
2828
- return yield* BlockStatement(node.body, scope, { label });
2912
+ return BlockStatement(node.body, scope, { label });
2829
2913
  }
2830
2914
  if (node.body.type === 'WithStatement') {
2831
- return yield* WithStatement(node.body, scope, { label });
2915
+ return WithStatement(node.body, scope, { label });
2832
2916
  }
2833
2917
  if (node.body.type === 'IfStatement') {
2834
- return yield* IfStatement(node.body, scope, { label });
2918
+ return IfStatement(node.body, scope, { label });
2835
2919
  }
2836
2920
  if (node.body.type === 'SwitchStatement') {
2837
- return yield* SwitchStatement(node.body, scope, { label });
2921
+ return SwitchStatement(node.body, scope, { label });
2838
2922
  }
2839
2923
  if (node.body.type === 'TryStatement') {
2840
- return yield* TryStatement(node.body, scope, { label });
2924
+ return TryStatement(node.body, scope, { label });
2841
2925
  }
2842
2926
  throw new SyntaxError(`${node.body.type} cannot be labeled`);
2843
2927
  }
2844
- function* WithStatement(node, scope, options = {}) {
2928
+ function WithStatement(node, scope, options = {}) {
2845
2929
  const withScope = new Scope(scope);
2846
- withScope.with(yield* evaluate(node.object, scope));
2847
- const result = yield* evaluate(node.body, withScope);
2930
+ withScope.with(evaluate(node.object, scope));
2931
+ const result = evaluate(node.body, withScope);
2848
2932
  if (result === BREAK) {
2849
2933
  if (result.LABEL && result.LABEL === options.label) {
2850
2934
  return;
@@ -2855,13 +2939,13 @@
2855
2939
  return result;
2856
2940
  }
2857
2941
  }
2858
- function* IfStatement(node, scope, options = {}) {
2942
+ function IfStatement(node, scope, options = {}) {
2859
2943
  let result;
2860
- if (yield* evaluate(node.test, scope)) {
2861
- result = yield* evaluate(node.consequent, scope);
2944
+ if (evaluate(node.test, scope)) {
2945
+ result = evaluate(node.consequent, scope);
2862
2946
  }
2863
2947
  else {
2864
- result = yield* evaluate(node.alternate, scope);
2948
+ result = evaluate(node.alternate, scope);
2865
2949
  }
2866
2950
  if (result === BREAK) {
2867
2951
  if (result.LABEL && result.LABEL === options.label) {
@@ -2873,18 +2957,18 @@
2873
2957
  return result;
2874
2958
  }
2875
2959
  }
2876
- function* SwitchStatement(node, scope, options = {}) {
2877
- const discriminant = yield* evaluate(node.discriminant, scope);
2960
+ function SwitchStatement(node, scope, options = {}) {
2961
+ const discriminant = evaluate(node.discriminant, scope);
2878
2962
  let matched = false;
2879
2963
  for (let i = 0; i < node.cases.length; i++) {
2880
2964
  const eachCase = node.cases[i];
2881
2965
  if (!matched
2882
2966
  && (!eachCase.test
2883
- || (yield* evaluate(eachCase.test, scope)) === discriminant)) {
2967
+ || (evaluate(eachCase.test, scope)) === discriminant)) {
2884
2968
  matched = true;
2885
2969
  }
2886
2970
  if (matched) {
2887
- const result = yield* SwitchCase(eachCase, scope);
2971
+ const result = SwitchCase(eachCase, scope);
2888
2972
  if (result === BREAK) {
2889
2973
  if (result.LABEL === options.label) {
2890
2974
  break;
@@ -2897,21 +2981,21 @@
2897
2981
  }
2898
2982
  }
2899
2983
  }
2900
- function* SwitchCase(node, scope) {
2984
+ function SwitchCase(node, scope) {
2901
2985
  for (let i = 0; i < node.consequent.length; i++) {
2902
- const result = yield* evaluate(node.consequent[i], scope);
2986
+ const result = evaluate(node.consequent[i], scope);
2903
2987
  if (result === BREAK || result === CONTINUE || result === RETURN) {
2904
2988
  return result;
2905
2989
  }
2906
2990
  }
2907
2991
  }
2908
- function* ThrowStatement(node, scope) {
2909
- throw yield* evaluate(node.argument, scope);
2992
+ function ThrowStatement(node, scope) {
2993
+ throw evaluate(node.argument, scope);
2910
2994
  }
2911
- function* TryStatement(node, scope, options = {}) {
2995
+ function TryStatement(node, scope, options = {}) {
2912
2996
  let result;
2913
2997
  try {
2914
- result = yield* BlockStatement(node.block, scope);
2998
+ result = BlockStatement(node.block, scope);
2915
2999
  }
2916
3000
  catch (err) {
2917
3001
  if (node.handler) {
@@ -2923,10 +3007,10 @@
2923
3007
  subScope.var(name, err);
2924
3008
  }
2925
3009
  else {
2926
- yield* pattern$1(param, scope, { feed: err });
3010
+ pattern$1(param, scope, { feed: err });
2927
3011
  }
2928
3012
  }
2929
- result = yield* CatchClause(node.handler, subScope);
3013
+ result = CatchClause(node.handler, subScope);
2930
3014
  }
2931
3015
  else {
2932
3016
  throw err;
@@ -2934,7 +3018,7 @@
2934
3018
  }
2935
3019
  finally {
2936
3020
  if (node.finalizer) {
2937
- result = yield* BlockStatement(node.finalizer, scope);
3021
+ result = BlockStatement(node.finalizer, scope);
2938
3022
  }
2939
3023
  }
2940
3024
  if (result === BREAK) {
@@ -2947,12 +3031,12 @@
2947
3031
  return result;
2948
3032
  }
2949
3033
  }
2950
- function* CatchClause(node, scope) {
2951
- return yield* BlockStatement(node.body, scope, { invasived: true });
3034
+ function CatchClause(node, scope) {
3035
+ return BlockStatement(node.body, scope, { invasived: true });
2952
3036
  }
2953
- function* WhileStatement(node, scope, options = {}) {
2954
- while (yield* evaluate(node.test, scope)) {
2955
- 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);
2956
3040
  if (result === BREAK) {
2957
3041
  if (result.LABEL === options.label) {
2958
3042
  break;
@@ -2970,9 +3054,9 @@
2970
3054
  }
2971
3055
  }
2972
3056
  }
2973
- function* DoWhileStatement(node, scope, options = {}) {
3057
+ function DoWhileStatement(node, scope, options = {}) {
2974
3058
  do {
2975
- const result = yield* evaluate(node.body, scope);
3059
+ const result = evaluate(node.body, scope);
2976
3060
  if (result === BREAK) {
2977
3061
  if (result.LABEL === options.label) {
2978
3062
  break;
@@ -2988,18 +3072,18 @@
2988
3072
  else if (result === RETURN) {
2989
3073
  return result;
2990
3074
  }
2991
- } while (yield* evaluate(node.test, scope));
3075
+ } while (evaluate(node.test, scope));
2992
3076
  }
2993
- function* ForStatement(node, scope, options = {}) {
3077
+ function ForStatement(node, scope, options = {}) {
2994
3078
  const forScope = new Scope(scope);
2995
- 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)) {
2996
3080
  const subScope = new Scope(forScope);
2997
3081
  let result;
2998
3082
  if (node.body.type === 'BlockStatement') {
2999
- result = yield* BlockStatement(node.body, subScope, { invasived: true });
3083
+ result = BlockStatement(node.body, subScope, { invasived: true });
3000
3084
  }
3001
3085
  else {
3002
- result = yield* evaluate(node.body, subScope);
3086
+ result = evaluate(node.body, subScope);
3003
3087
  }
3004
3088
  if (result === BREAK) {
3005
3089
  if (result.LABEL === options.label) {
@@ -3018,9 +3102,9 @@
3018
3102
  }
3019
3103
  }
3020
3104
  }
3021
- function* ForInStatement(node, scope, options = {}) {
3022
- for (const value in yield* evaluate(node.right, scope)) {
3023
- 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 });
3024
3108
  if (result === BREAK) {
3025
3109
  if (result.LABEL === options.label) {
3026
3110
  break;
@@ -3038,61 +3122,37 @@
3038
3122
  }
3039
3123
  }
3040
3124
  }
3041
- function* ForOfStatement(node, scope, options = {}) {
3042
- const right = yield* evaluate(node.right, scope);
3043
- if (node.await) {
3044
- const iterator = getAsyncIterator(right);
3045
- let ret;
3046
- for (AWAIT.RES = iterator.next(), ret = yield AWAIT; !ret.done; AWAIT.RES = iterator.next(), ret = yield AWAIT) {
3047
- const result = yield* ForXHandler$1(node, scope, { value: ret.value });
3048
- if (result === BREAK) {
3049
- if (result.LABEL === options.label) {
3050
- break;
3051
- }
3052
- return result;
3053
- }
3054
- else if (result === CONTINUE) {
3055
- if (result.LABEL === options.label) {
3056
- continue;
3057
- }
3058
- return result;
3059
- }
3060
- else if (result === RETURN) {
3061
- 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;
3062
3132
  }
3133
+ return result;
3063
3134
  }
3064
- }
3065
- else {
3066
- for (const value of right) {
3067
- const result = yield* ForXHandler$1(node, scope, { value });
3068
- if (result === BREAK) {
3069
- if (result.LABEL === options.label) {
3070
- break;
3071
- }
3072
- return result;
3073
- }
3074
- else if (result === CONTINUE) {
3075
- if (result.LABEL === options.label) {
3076
- continue;
3077
- }
3078
- return result;
3079
- }
3080
- else if (result === RETURN) {
3081
- return result;
3135
+ else if (result === CONTINUE) {
3136
+ if (result.LABEL === options.label) {
3137
+ continue;
3082
3138
  }
3139
+ return result;
3140
+ }
3141
+ else if (result === RETURN) {
3142
+ return result;
3083
3143
  }
3084
3144
  }
3085
3145
  }
3086
3146
 
3087
- function* FunctionDeclaration(node, scope) {
3147
+ function FunctionDeclaration(node, scope) {
3088
3148
  scope.func(node.id.name, createFunc$1(node, scope));
3089
3149
  }
3090
- function* VariableDeclaration(node, scope, options = {}) {
3150
+ function VariableDeclaration(node, scope, options = {}) {
3091
3151
  for (let i = 0; i < node.declarations.length; i++) {
3092
- yield* VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
3152
+ VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
3093
3153
  }
3094
3154
  }
3095
- function* VariableDeclarator(node, scope, options = {}) {
3155
+ function VariableDeclarator(node, scope, options = {}) {
3096
3156
  const { kind = 'var', hoist = false, onlyBlock = false, feed } = options;
3097
3157
  if (hoist) {
3098
3158
  if (onlyBlock || kind === 'var') {
@@ -3100,13 +3160,13 @@
3100
3160
  scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
3101
3161
  }
3102
3162
  else {
3103
- yield* pattern$1(node.id, scope, { kind, hoist, onlyBlock });
3163
+ pattern$1(node.id, scope, { kind, hoist, onlyBlock });
3104
3164
  }
3105
3165
  }
3106
3166
  }
3107
3167
  else {
3108
3168
  const hasFeed = 'feed' in options;
3109
- const value = hasFeed ? feed : yield* evaluate(node.init, scope);
3169
+ const value = hasFeed ? feed : evaluate(node.init, scope);
3110
3170
  if (node.id.type === 'Identifier') {
3111
3171
  const name = node.id.name;
3112
3172
  if (kind === 'var' && !node.init && !hasFeed) {
@@ -3126,34 +3186,34 @@
3126
3186
  }
3127
3187
  }
3128
3188
  else {
3129
- yield* pattern$1(node.id, scope, { kind, feed: value });
3189
+ pattern$1(node.id, scope, { kind, feed: value });
3130
3190
  }
3131
3191
  }
3132
3192
  }
3133
- function* ClassDeclaration(node, scope) {
3134
- 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));
3135
3195
  }
3136
- function* ClassBody(node, scope, options = {}) {
3196
+ function ClassBody(node, scope, options = {}) {
3137
3197
  const { klass, superClass } = options;
3138
3198
  for (let i = 0; i < node.body.length; i++) {
3139
3199
  const def = node.body[i];
3140
3200
  if (def.type === 'MethodDefinition') {
3141
- yield* MethodDefinition(def, scope, { klass, superClass });
3201
+ MethodDefinition(def, scope, { klass, superClass });
3142
3202
  }
3143
3203
  else if (def.type === 'PropertyDefinition' && def.static) {
3144
- yield* PropertyDefinition(def, scope, { klass, superClass });
3204
+ PropertyDefinition(def, scope, { klass, superClass });
3145
3205
  }
3146
3206
  else if (def.type === 'StaticBlock') {
3147
- yield* StaticBlock(def, scope, { klass, superClass });
3207
+ StaticBlock(def, scope, { klass, superClass });
3148
3208
  }
3149
3209
  }
3150
3210
  }
3151
- function* MethodDefinition(node, scope, options = {}) {
3211
+ function MethodDefinition(node, scope, options = {}) {
3152
3212
  const { klass, superClass } = options;
3153
3213
  let key;
3154
3214
  let priv = false;
3155
3215
  if (node.computed) {
3156
- key = yield* evaluate(node.key, scope);
3216
+ key = evaluate(node.key, scope);
3157
3217
  }
3158
3218
  else if (node.key.type === 'Identifier') {
3159
3219
  key = node.key.name;
@@ -3205,12 +3265,12 @@
3205
3265
  throw new SyntaxError('Unexpected token');
3206
3266
  }
3207
3267
  }
3208
- function* PropertyDefinition(node, scope, options = {}) {
3268
+ function PropertyDefinition(node, scope, options = {}) {
3209
3269
  const { klass, superClass } = options;
3210
3270
  let key;
3211
3271
  let priv = false;
3212
3272
  if (node.computed) {
3213
- key = yield* evaluate(node.key, scope);
3273
+ key = evaluate(node.key, scope);
3214
3274
  }
3215
3275
  else if (node.key.type === 'Identifier') {
3216
3276
  key = node.key.name;
@@ -3231,20 +3291,23 @@
3231
3291
  }
3232
3292
  obj = obj[PRIVATE];
3233
3293
  }
3294
+ if (!node.value) {
3295
+ obj[key] = undefined;
3296
+ }
3234
3297
  if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
3235
3298
  obj[key] = createFunc$1(node.value, subScope, { superClass });
3236
3299
  }
3237
3300
  else {
3238
- obj[key] = yield* evaluate(node.value, subScope);
3301
+ obj[key] = evaluate(node.value, subScope);
3239
3302
  }
3240
3303
  }
3241
- function* StaticBlock(node, scope, options = {}) {
3304
+ function StaticBlock(node, scope, options = {}) {
3242
3305
  const { klass } = options;
3243
3306
  const subScope = new Scope(scope, true);
3244
3307
  subScope.const('this', klass);
3245
- return yield* BlockStatement(node, subScope, { invasived: true });
3308
+ return BlockStatement(node, subScope, { invasived: true });
3246
3309
  }
3247
- function* ImportDeclaration(node, scope) {
3310
+ function ImportDeclaration(node, scope) {
3248
3311
  const globalScope = scope.global();
3249
3312
  const module = globalScope.find(IMPORT + node.source.value);
3250
3313
  let value;
@@ -3281,7 +3344,7 @@
3281
3344
  scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
3282
3345
  }
3283
3346
  }
3284
- function* ExportDefaultDeclaration(node, scope) {
3347
+ function ExportDefaultDeclaration(node, scope) {
3285
3348
  const globalScope = scope.global();
3286
3349
  let value;
3287
3350
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -3289,11 +3352,11 @@
3289
3352
  scope.func(node.declaration.id.name, value);
3290
3353
  }
3291
3354
  else if (node.declaration.type === 'ClassDeclaration') {
3292
- value = yield* createClass$1(node.declaration, scope);
3355
+ value = createClass$1(node.declaration, scope);
3293
3356
  scope.func(node.declaration.id.name, value);
3294
3357
  }
3295
3358
  else {
3296
- value = yield* evaluate(node.declaration, scope);
3359
+ value = evaluate(node.declaration, scope);
3297
3360
  }
3298
3361
  const variable = globalScope.find(EXPORTS);
3299
3362
  if (variable) {
@@ -3303,7 +3366,7 @@
3303
3366
  }
3304
3367
  }
3305
3368
  }
3306
- function* ExportNamedDeclaration(node, scope) {
3369
+ function ExportNamedDeclaration(node, scope) {
3307
3370
  const globalScope = scope.global();
3308
3371
  if (node.declaration) {
3309
3372
  if (node.declaration.type === 'FunctionDeclaration') {
@@ -3318,7 +3381,7 @@
3318
3381
  }
3319
3382
  }
3320
3383
  else if (node.declaration.type === 'ClassDeclaration') {
3321
- const value = yield* createClass$1(node.declaration, scope);
3384
+ const value = createClass$1(node.declaration, scope);
3322
3385
  scope.func(node.declaration.id.name, value);
3323
3386
  const variable = globalScope.find(EXPORTS);
3324
3387
  if (variable) {
@@ -3329,7 +3392,7 @@
3329
3392
  }
3330
3393
  }
3331
3394
  else if (node.declaration.type === 'VariableDeclaration') {
3332
- yield* VariableDeclaration(node.declaration, scope);
3395
+ VariableDeclaration(node.declaration, scope);
3333
3396
  const variable = globalScope.find(EXPORTS);
3334
3397
  if (variable) {
3335
3398
  const exports = variable.get();
@@ -3364,7 +3427,7 @@
3364
3427
  }
3365
3428
  }
3366
3429
  }
3367
- function* ExportAllDeclaration(node, scope) {
3430
+ function ExportAllDeclaration(node, scope) {
3368
3431
  const globalScope = scope.global();
3369
3432
  const module = globalScope.find(IMPORT + node.source.value);
3370
3433
  let value;
@@ -3391,53 +3454,7 @@
3391
3454
  }
3392
3455
  }
3393
3456
 
3394
- function runAsync(iterator, options = {}) {
3395
- const { res, err, ret, fullRet } = options;
3396
- return new Promise((resolve, reject) => {
3397
- if ('ret' in options) {
3398
- return resolve(iterator.return(ret));
3399
- }
3400
- if ('err' in options) {
3401
- onRejected(err);
3402
- }
3403
- else {
3404
- onFulfilled(res);
3405
- }
3406
- function onFulfilled(res) {
3407
- let ret;
3408
- try {
3409
- ret = iterator.next(res);
3410
- }
3411
- catch (e) {
3412
- return reject(e);
3413
- }
3414
- next(ret);
3415
- return null;
3416
- }
3417
- function onRejected(err) {
3418
- let ret;
3419
- try {
3420
- ret = iterator.throw(err);
3421
- }
3422
- catch (e) {
3423
- return reject(e);
3424
- }
3425
- next(ret);
3426
- }
3427
- function next(ret) {
3428
- if (ret.done)
3429
- return resolve(fullRet ? ret : ret.value);
3430
- if (ret.value !== AWAIT)
3431
- return resolve(ret);
3432
- const awaitValue = ret.value.RES;
3433
- const value = awaitValue && awaitValue.then === 'function'
3434
- ? awaitValue : Promise.resolve(awaitValue);
3435
- return value.then(onFulfilled, onRejected);
3436
- }
3437
- });
3438
- }
3439
-
3440
- function* hoist$1(block, scope, options = {}) {
3457
+ function hoist$1(block, scope, options = {}) {
3441
3458
  const { onlyBlock = false } = options;
3442
3459
  const funcDclrList = [];
3443
3460
  const funcDclrIdxs = [];
@@ -3449,10 +3466,10 @@
3449
3466
  }
3450
3467
  else if (statement.type === 'VariableDeclaration'
3451
3468
  && ['const', 'let'].indexOf(statement.kind) !== -1) {
3452
- yield* VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
3469
+ VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
3453
3470
  }
3454
3471
  else if (!onlyBlock) {
3455
- yield* hoistVarRecursion$1(statement, scope);
3472
+ hoistVarRecursion$1(statement, scope);
3456
3473
  }
3457
3474
  }
3458
3475
  if (funcDclrIdxs.length) {
@@ -3462,92 +3479,92 @@
3462
3479
  block.body = funcDclrList.concat(block.body);
3463
3480
  }
3464
3481
  }
3465
- function* hoistVarRecursion$1(statement, scope) {
3482
+ function hoistVarRecursion$1(statement, scope) {
3466
3483
  switch (statement.type) {
3467
3484
  case 'VariableDeclaration':
3468
- yield* VariableDeclaration(statement, scope, { hoist: true });
3485
+ VariableDeclaration(statement, scope, { hoist: true });
3469
3486
  break;
3470
3487
  case 'ForInStatement':
3471
3488
  case 'ForOfStatement':
3472
3489
  if (statement.left.type === 'VariableDeclaration') {
3473
- yield* VariableDeclaration(statement.left, scope, { hoist: true });
3490
+ VariableDeclaration(statement.left, scope, { hoist: true });
3474
3491
  }
3475
3492
  case 'ForStatement':
3476
3493
  if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
3477
- yield* VariableDeclaration(statement.init, scope, { hoist: true });
3494
+ VariableDeclaration(statement.init, scope, { hoist: true });
3478
3495
  }
3479
3496
  case 'WhileStatement':
3480
3497
  case 'DoWhileStatement':
3481
- yield* hoistVarRecursion$1(statement.body, scope);
3498
+ hoistVarRecursion$1(statement.body, scope);
3482
3499
  break;
3483
3500
  case 'IfStatement':
3484
- yield* hoistVarRecursion$1(statement.consequent, scope);
3501
+ hoistVarRecursion$1(statement.consequent, scope);
3485
3502
  if (statement.alternate) {
3486
- yield* hoistVarRecursion$1(statement.alternate, scope);
3503
+ hoistVarRecursion$1(statement.alternate, scope);
3487
3504
  }
3488
3505
  break;
3489
3506
  case 'BlockStatement':
3490
3507
  for (let i = 0; i < statement.body.length; i++) {
3491
- yield* hoistVarRecursion$1(statement.body[i], scope);
3508
+ hoistVarRecursion$1(statement.body[i], scope);
3492
3509
  }
3493
3510
  break;
3494
3511
  case 'SwitchStatement':
3495
3512
  for (let i = 0; i < statement.cases.length; i++) {
3496
3513
  for (let j = 0; j < statement.cases[i].consequent.length; j++) {
3497
- yield* hoistVarRecursion$1(statement.cases[i].consequent[j], scope);
3514
+ hoistVarRecursion$1(statement.cases[i].consequent[j], scope);
3498
3515
  }
3499
3516
  }
3500
3517
  break;
3501
3518
  case 'TryStatement': {
3502
3519
  const tryBlock = statement.block.body;
3503
3520
  for (let i = 0; i < tryBlock.length; i++) {
3504
- yield* hoistVarRecursion$1(tryBlock[i], scope);
3521
+ hoistVarRecursion$1(tryBlock[i], scope);
3505
3522
  }
3506
3523
  const catchBlock = statement.handler && statement.handler.body.body;
3507
3524
  if (catchBlock) {
3508
3525
  for (let i = 0; i < catchBlock.length; i++) {
3509
- yield* hoistVarRecursion$1(catchBlock[i], scope);
3526
+ hoistVarRecursion$1(catchBlock[i], scope);
3510
3527
  }
3511
3528
  }
3512
3529
  const finalBlock = statement.finalizer && statement.finalizer.body;
3513
3530
  if (finalBlock) {
3514
3531
  for (let i = 0; i < finalBlock.length; i++) {
3515
- yield* hoistVarRecursion$1(finalBlock[i], scope);
3532
+ hoistVarRecursion$1(finalBlock[i], scope);
3516
3533
  }
3517
3534
  }
3518
3535
  break;
3519
3536
  }
3520
3537
  }
3521
3538
  }
3522
- function* pattern$1(node, scope, options = {}) {
3539
+ function pattern$1(node, scope, options = {}) {
3523
3540
  switch (node.type) {
3524
3541
  case 'ObjectPattern':
3525
- return yield* ObjectPattern(node, scope, options);
3542
+ return ObjectPattern(node, scope, options);
3526
3543
  case 'ArrayPattern':
3527
- return yield* ArrayPattern(node, scope, options);
3544
+ return ArrayPattern(node, scope, options);
3528
3545
  case 'RestElement':
3529
- return yield* RestElement(node, scope, options);
3546
+ return RestElement(node, scope, options);
3530
3547
  case 'AssignmentPattern':
3531
- return yield* AssignmentPattern(node, scope, options);
3548
+ return AssignmentPattern(node, scope, options);
3532
3549
  default:
3533
3550
  throw new SyntaxError('Unexpected token');
3534
3551
  }
3535
3552
  }
3536
3553
  function createFunc$1(node, scope, options = {}) {
3537
3554
  var _a;
3538
- if (!node.generator && !node.async) {
3555
+ if (node.generator || node.async) {
3539
3556
  return createFunc(node, scope, options);
3540
3557
  }
3541
3558
  const { superClass, construct } = options;
3542
3559
  const params = node.params;
3543
- const tmpFunc = function* (...args) {
3560
+ const tmpFunc = function (...args) {
3544
3561
  const subScope = new Scope(scope, true);
3545
3562
  if (node.type !== 'ArrowFunctionExpression') {
3546
3563
  subScope.const('this', this);
3547
3564
  subScope.let('arguments', arguments);
3548
3565
  subScope.const(NEWTARGET, new.target);
3549
3566
  if (construct) {
3550
- yield* construct(this);
3567
+ construct(this);
3551
3568
  }
3552
3569
  if (superClass) {
3553
3570
  subScope.const(SUPER, superClass);
@@ -3561,22 +3578,22 @@
3561
3578
  subScope.var(param.name, args[i]);
3562
3579
  }
3563
3580
  else if (param.type === 'RestElement') {
3564
- yield* RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
3581
+ RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
3565
3582
  }
3566
3583
  else {
3567
- yield* pattern$1(param, subScope, { kind: 'var', feed: args[i] });
3584
+ pattern$1(param, subScope, { kind: 'var', feed: args[i] });
3568
3585
  }
3569
3586
  }
3570
3587
  let result;
3571
3588
  if (node.body.type === 'BlockStatement') {
3572
- yield* hoist$1(node.body, subScope);
3573
- result = yield* BlockStatement(node.body, subScope, {
3589
+ hoist$1(node.body, subScope);
3590
+ result = BlockStatement(node.body, subScope, {
3574
3591
  invasived: true,
3575
3592
  hoisted: true
3576
3593
  });
3577
3594
  }
3578
3595
  else {
3579
- result = yield* evaluate(node.body, subScope);
3596
+ result = evaluate(node.body, subScope);
3580
3597
  if (node.type === 'ArrowFunctionExpression') {
3581
3598
  RETURN.RES = result;
3582
3599
  result = RETURN;
@@ -3586,38 +3603,10 @@
3586
3603
  return result.RES;
3587
3604
  }
3588
3605
  };
3589
- let func;
3590
- if (node.async && node.generator) {
3591
- func = function () {
3592
- const iterator = tmpFunc.apply(this, arguments);
3593
- let last = Promise.resolve();
3594
- let hasCatch = false;
3595
- const run = (opts) => last = last
3596
- .then(() => runAsync(iterator, assign({ fullRet: true }, opts)))
3597
- .catch(err => {
3598
- if (!hasCatch) {
3599
- hasCatch = true;
3600
- return Promise.reject(err);
3601
- }
3602
- });
3603
- const asyncIterator = {
3604
- next: (res) => run({ res }),
3605
- throw: (err) => run({ err }),
3606
- return: (ret) => run({ ret })
3607
- };
3608
- if (typeof Symbol === 'function') {
3609
- asyncIterator[Symbol.iterator] = function () { return this; };
3610
- }
3611
- return asyncIterator;
3612
- };
3613
- }
3614
- else if (node.async) {
3615
- func = function () { return runAsync(tmpFunc.apply(this, arguments)); };
3616
- }
3617
- else {
3618
- func = tmpFunc;
3606
+ let func = tmpFunc;
3607
+ if (node.type === 'ArrowFunctionExpression') {
3608
+ define(func, NOCTOR, { value: true });
3619
3609
  }
3620
- define(func, NOCTOR, { value: true });
3621
3610
  define(func, 'name', {
3622
3611
  value: node.id
3623
3612
  && node.id.name
@@ -3637,19 +3626,19 @@
3637
3626
  }
3638
3627
  return func;
3639
3628
  }
3640
- function* createClass$1(node, scope) {
3641
- const superClass = yield* evaluate(node.superClass, scope);
3629
+ function createClass$1(node, scope) {
3630
+ const superClass = evaluate(node.superClass, scope);
3642
3631
  const methodBody = node.body.body;
3643
- const construct = function* (object) {
3632
+ const construct = function (object) {
3644
3633
  for (let i = 0; i < methodBody.length; i++) {
3645
3634
  const def = methodBody[i];
3646
3635
  if (def.type === 'PropertyDefinition' && !def.static) {
3647
- yield* PropertyDefinition(def, scope, { klass: object, superClass });
3636
+ PropertyDefinition(def, scope, { klass: object, superClass });
3648
3637
  }
3649
3638
  }
3650
3639
  };
3651
- let klass = function* () {
3652
- yield* construct(this);
3640
+ let klass = function () {
3641
+ construct(this);
3653
3642
  if (superClass) {
3654
3643
  superClass.apply(this);
3655
3644
  }
@@ -3664,7 +3653,7 @@
3664
3653
  if (superClass) {
3665
3654
  inherits(klass, superClass);
3666
3655
  }
3667
- yield* ClassBody(node.body, scope, { klass, superClass });
3656
+ ClassBody(node.body, scope, { klass, superClass });
3668
3657
  define(klass, CLSCTOR, { value: true });
3669
3658
  define(klass, 'name', {
3670
3659
  value: node.id && node.id.name || '',
@@ -3672,31 +3661,31 @@
3672
3661
  });
3673
3662
  return klass;
3674
3663
  }
3675
- function* ForXHandler$1(node, scope, options) {
3664
+ function ForXHandler$1(node, scope, options) {
3676
3665
  const { value } = options;
3677
3666
  const left = node.left;
3678
3667
  const subScope = new Scope(scope);
3679
3668
  if (left.type === 'VariableDeclaration') {
3680
- yield* VariableDeclaration(left, subScope, { feed: value });
3669
+ VariableDeclaration(left, subScope, { feed: value });
3681
3670
  }
3682
3671
  else if (left.type === 'Identifier') {
3683
- const variable = yield* Identifier$1(left, scope, { getVar: true });
3672
+ const variable = Identifier(left, scope, { getVar: true });
3684
3673
  variable.set(value);
3685
3674
  }
3686
3675
  else {
3687
- yield* pattern$1(left, scope, { feed: value });
3676
+ pattern$1(left, scope, { feed: value });
3688
3677
  }
3689
3678
  let result;
3690
3679
  if (node.body.type === 'BlockStatement') {
3691
- result = yield* BlockStatement(node.body, subScope, { invasived: true });
3680
+ result = BlockStatement(node.body, subScope, { invasived: true });
3692
3681
  }
3693
3682
  else {
3694
- result = yield* evaluate(node.body, subScope);
3683
+ result = evaluate(node.body, subScope);
3695
3684
  }
3696
3685
  return result;
3697
3686
  }
3698
3687
 
3699
- function hoist(block, scope, options = {}) {
3688
+ function* hoist(block, scope, options = {}) {
3700
3689
  const { onlyBlock = false } = options;
3701
3690
  const funcDclrList = [];
3702
3691
  const funcDclrIdxs = [];
@@ -3708,10 +3697,10 @@
3708
3697
  }
3709
3698
  else if (statement.type === 'VariableDeclaration'
3710
3699
  && ['const', 'let'].indexOf(statement.kind) !== -1) {
3711
- VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
3700
+ yield* VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
3712
3701
  }
3713
3702
  else if (!onlyBlock) {
3714
- hoistVarRecursion(statement, scope);
3703
+ yield* hoistVarRecursion(statement, scope);
3715
3704
  }
3716
3705
  }
3717
3706
  if (funcDclrIdxs.length) {
@@ -3721,92 +3710,92 @@
3721
3710
  block.body = funcDclrList.concat(block.body);
3722
3711
  }
3723
3712
  }
3724
- function hoistVarRecursion(statement, scope) {
3713
+ function* hoistVarRecursion(statement, scope) {
3725
3714
  switch (statement.type) {
3726
3715
  case 'VariableDeclaration':
3727
- VariableDeclaration$1(statement, scope, { hoist: true });
3716
+ yield* VariableDeclaration$1(statement, scope, { hoist: true });
3728
3717
  break;
3729
3718
  case 'ForInStatement':
3730
3719
  case 'ForOfStatement':
3731
3720
  if (statement.left.type === 'VariableDeclaration') {
3732
- VariableDeclaration$1(statement.left, scope, { hoist: true });
3721
+ yield* VariableDeclaration$1(statement.left, scope, { hoist: true });
3733
3722
  }
3734
3723
  case 'ForStatement':
3735
3724
  if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
3736
- VariableDeclaration$1(statement.init, scope, { hoist: true });
3725
+ yield* VariableDeclaration$1(statement.init, scope, { hoist: true });
3737
3726
  }
3738
3727
  case 'WhileStatement':
3739
3728
  case 'DoWhileStatement':
3740
- hoistVarRecursion(statement.body, scope);
3729
+ yield* hoistVarRecursion(statement.body, scope);
3741
3730
  break;
3742
3731
  case 'IfStatement':
3743
- hoistVarRecursion(statement.consequent, scope);
3732
+ yield* hoistVarRecursion(statement.consequent, scope);
3744
3733
  if (statement.alternate) {
3745
- hoistVarRecursion(statement.alternate, scope);
3734
+ yield* hoistVarRecursion(statement.alternate, scope);
3746
3735
  }
3747
3736
  break;
3748
3737
  case 'BlockStatement':
3749
3738
  for (let i = 0; i < statement.body.length; i++) {
3750
- hoistVarRecursion(statement.body[i], scope);
3739
+ yield* hoistVarRecursion(statement.body[i], scope);
3751
3740
  }
3752
3741
  break;
3753
3742
  case 'SwitchStatement':
3754
3743
  for (let i = 0; i < statement.cases.length; i++) {
3755
3744
  for (let j = 0; j < statement.cases[i].consequent.length; j++) {
3756
- hoistVarRecursion(statement.cases[i].consequent[j], scope);
3745
+ yield* hoistVarRecursion(statement.cases[i].consequent[j], scope);
3757
3746
  }
3758
3747
  }
3759
3748
  break;
3760
3749
  case 'TryStatement': {
3761
3750
  const tryBlock = statement.block.body;
3762
3751
  for (let i = 0; i < tryBlock.length; i++) {
3763
- hoistVarRecursion(tryBlock[i], scope);
3752
+ yield* hoistVarRecursion(tryBlock[i], scope);
3764
3753
  }
3765
3754
  const catchBlock = statement.handler && statement.handler.body.body;
3766
3755
  if (catchBlock) {
3767
3756
  for (let i = 0; i < catchBlock.length; i++) {
3768
- hoistVarRecursion(catchBlock[i], scope);
3757
+ yield* hoistVarRecursion(catchBlock[i], scope);
3769
3758
  }
3770
3759
  }
3771
3760
  const finalBlock = statement.finalizer && statement.finalizer.body;
3772
3761
  if (finalBlock) {
3773
3762
  for (let i = 0; i < finalBlock.length; i++) {
3774
- hoistVarRecursion(finalBlock[i], scope);
3763
+ yield* hoistVarRecursion(finalBlock[i], scope);
3775
3764
  }
3776
3765
  }
3777
3766
  break;
3778
3767
  }
3779
3768
  }
3780
3769
  }
3781
- function pattern(node, scope, options = {}) {
3770
+ function* pattern(node, scope, options = {}) {
3782
3771
  switch (node.type) {
3783
3772
  case 'ObjectPattern':
3784
- return ObjectPattern$1(node, scope, options);
3773
+ return yield* ObjectPattern$1(node, scope, options);
3785
3774
  case 'ArrayPattern':
3786
- return ArrayPattern$1(node, scope, options);
3775
+ return yield* ArrayPattern$1(node, scope, options);
3787
3776
  case 'RestElement':
3788
- return RestElement$1(node, scope, options);
3777
+ return yield* RestElement$1(node, scope, options);
3789
3778
  case 'AssignmentPattern':
3790
- return AssignmentPattern$1(node, scope, options);
3779
+ return yield* AssignmentPattern$1(node, scope, options);
3791
3780
  default:
3792
3781
  throw new SyntaxError('Unexpected token');
3793
3782
  }
3794
3783
  }
3795
3784
  function createFunc(node, scope, options = {}) {
3796
3785
  var _a;
3797
- if (node.generator || node.async) {
3786
+ if (!node.generator && !node.async) {
3798
3787
  return createFunc$1(node, scope, options);
3799
3788
  }
3800
3789
  const { superClass, construct } = options;
3801
3790
  const params = node.params;
3802
- const tmpFunc = function (...args) {
3791
+ const tmpFunc = function* (...args) {
3803
3792
  const subScope = new Scope(scope, true);
3804
3793
  if (node.type !== 'ArrowFunctionExpression') {
3805
3794
  subScope.const('this', this);
3806
3795
  subScope.let('arguments', arguments);
3807
3796
  subScope.const(NEWTARGET, new.target);
3808
3797
  if (construct) {
3809
- construct(this);
3798
+ yield* construct(this);
3810
3799
  }
3811
3800
  if (superClass) {
3812
3801
  subScope.const(SUPER, superClass);
@@ -3820,22 +3809,22 @@
3820
3809
  subScope.var(param.name, args[i]);
3821
3810
  }
3822
3811
  else if (param.type === 'RestElement') {
3823
- RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
3812
+ yield* RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
3824
3813
  }
3825
3814
  else {
3826
- pattern(param, subScope, { kind: 'var', feed: args[i] });
3815
+ yield* pattern(param, subScope, { kind: 'var', feed: args[i] });
3827
3816
  }
3828
3817
  }
3829
3818
  let result;
3830
3819
  if (node.body.type === 'BlockStatement') {
3831
- hoist(node.body, subScope);
3832
- result = BlockStatement$1(node.body, subScope, {
3820
+ yield* hoist(node.body, subScope);
3821
+ result = yield* BlockStatement$1(node.body, subScope, {
3833
3822
  invasived: true,
3834
3823
  hoisted: true
3835
3824
  });
3836
3825
  }
3837
3826
  else {
3838
- result = evaluate$1(node.body, subScope);
3827
+ result = yield* evaluate$1(node.body, subScope);
3839
3828
  if (node.type === 'ArrowFunctionExpression') {
3840
3829
  RETURN.RES = result;
3841
3830
  result = RETURN;
@@ -3845,10 +3834,38 @@
3845
3834
  return result.RES;
3846
3835
  }
3847
3836
  };
3848
- let func = tmpFunc;
3849
- if (node.type === 'ArrowFunctionExpression') {
3850
- 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)); };
3851
3864
  }
3865
+ else {
3866
+ func = tmpFunc;
3867
+ }
3868
+ define(func, NOCTOR, { value: true });
3852
3869
  define(func, 'name', {
3853
3870
  value: node.id
3854
3871
  && node.id.name
@@ -3868,19 +3885,19 @@
3868
3885
  }
3869
3886
  return func;
3870
3887
  }
3871
- function createClass(node, scope) {
3872
- const superClass = evaluate$1(node.superClass, scope);
3888
+ function* createClass(node, scope) {
3889
+ const superClass = yield* evaluate$1(node.superClass, scope);
3873
3890
  const methodBody = node.body.body;
3874
- const construct = function (object) {
3891
+ const construct = function* (object) {
3875
3892
  for (let i = 0; i < methodBody.length; i++) {
3876
3893
  const def = methodBody[i];
3877
3894
  if (def.type === 'PropertyDefinition' && !def.static) {
3878
- PropertyDefinition$1(def, scope, { klass: object, superClass });
3895
+ yield* PropertyDefinition$1(def, scope, { klass: object, superClass });
3879
3896
  }
3880
3897
  }
3881
3898
  };
3882
- let klass = function () {
3883
- construct(this);
3899
+ let klass = function* () {
3900
+ yield* construct(this);
3884
3901
  if (superClass) {
3885
3902
  superClass.apply(this);
3886
3903
  }
@@ -3895,7 +3912,7 @@
3895
3912
  if (superClass) {
3896
3913
  inherits(klass, superClass);
3897
3914
  }
3898
- ClassBody$1(node.body, scope, { klass, superClass });
3915
+ yield* ClassBody$1(node.body, scope, { klass, superClass });
3899
3916
  define(klass, CLSCTOR, { value: true });
3900
3917
  define(klass, 'name', {
3901
3918
  value: node.id && node.id.name || '',
@@ -3903,26 +3920,26 @@
3903
3920
  });
3904
3921
  return klass;
3905
3922
  }
3906
- function ForXHandler(node, scope, options) {
3923
+ function* ForXHandler(node, scope, options) {
3907
3924
  const { value } = options;
3908
3925
  const left = node.left;
3909
3926
  const subScope = new Scope(scope);
3910
3927
  if (left.type === 'VariableDeclaration') {
3911
- VariableDeclaration$1(left, subScope, { feed: value });
3928
+ yield* VariableDeclaration$1(left, subScope, { feed: value });
3912
3929
  }
3913
3930
  else if (left.type === 'Identifier') {
3914
- const variable = Identifier$1(left, scope, { getVar: true });
3931
+ const variable = yield* Identifier(left, scope, { getVar: true });
3915
3932
  variable.set(value);
3916
3933
  }
3917
3934
  else {
3918
- pattern(left, scope, { feed: value });
3935
+ yield* pattern(left, scope, { feed: value });
3919
3936
  }
3920
3937
  let result;
3921
3938
  if (node.body.type === 'BlockStatement') {
3922
- result = BlockStatement$1(node.body, subScope, { invasived: true });
3939
+ result = yield* BlockStatement$1(node.body, subScope, { invasived: true });
3923
3940
  }
3924
3941
  else {
3925
- result = evaluate$1(node.body, subScope);
3942
+ result = yield* evaluate$1(node.body, subScope);
3926
3943
  }
3927
3944
  return result;
3928
3945
  }
@@ -3975,9 +3992,19 @@
3975
3992
  return acorn.parse(code, this.options);
3976
3993
  }
3977
3994
  run(code) {
3978
- const ast = typeof code === 'string' ? acorn.parse(code, this.options) : code;
3979
- hoist(ast, this.scope);
3980
- 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
+ }
3981
4008
  }
3982
4009
  }
3983
4010
  Sval.version = version;