sval 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/sval.es6.js +865 -608
- package/dist/sval.js +944 -626
- package/dist/sval.min.js +1 -1
- package/package.json +2 -2
package/dist/sval.js
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('acorn')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['acorn'], factory) :
|
|
4
|
-
(global = global || self, global.Sval = factory(global.acorn));
|
|
5
|
-
}(this, (function (acorn) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Sval = factory(global.acorn));
|
|
5
|
+
})(this, (function (acorn) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var statement = /*#__PURE__*/Object.freeze({
|
|
8
|
-
__proto__: null,
|
|
9
|
-
get ExpressionStatement () { return ExpressionStatement; },
|
|
10
|
-
get BlockStatement () { return BlockStatement; },
|
|
11
|
-
get EmptyStatement () { return EmptyStatement; },
|
|
12
|
-
get DebuggerStatement () { return DebuggerStatement; },
|
|
13
|
-
get ReturnStatement () { return ReturnStatement; },
|
|
14
|
-
get BreakStatement () { return BreakStatement; },
|
|
15
|
-
get ContinueStatement () { return ContinueStatement; },
|
|
16
|
-
get IfStatement () { return IfStatement; },
|
|
17
|
-
get SwitchStatement () { return SwitchStatement; },
|
|
18
|
-
get SwitchCase () { return SwitchCase; },
|
|
19
|
-
get ThrowStatement () { return ThrowStatement; },
|
|
20
|
-
get TryStatement () { return TryStatement; },
|
|
21
|
-
get CatchClause () { return CatchClause; },
|
|
22
|
-
get WhileStatement () { return WhileStatement; },
|
|
23
|
-
get DoWhileStatement () { return DoWhileStatement; },
|
|
24
|
-
get ForStatement () { return ForStatement; },
|
|
25
|
-
get ForInStatement () { return ForInStatement; },
|
|
26
|
-
get ForOfStatement () { return ForOfStatement; }
|
|
27
|
-
});
|
|
28
|
-
var declaration = /*#__PURE__*/Object.freeze({
|
|
29
|
-
__proto__: null,
|
|
30
|
-
get FunctionDeclaration () { return FunctionDeclaration; },
|
|
31
|
-
get VariableDeclaration () { return VariableDeclaration; },
|
|
32
|
-
get VariableDeclarator () { return VariableDeclarator; },
|
|
33
|
-
get ClassDeclaration () { return ClassDeclaration; },
|
|
34
|
-
get ClassBody () { return ClassBody; },
|
|
35
|
-
get MethodDefinition () { return MethodDefinition; },
|
|
36
|
-
get PropertyDefinition () { return PropertyDefinition; },
|
|
37
|
-
get StaticBlock () { return StaticBlock; },
|
|
38
|
-
get ImportDeclaration () { return ImportDeclaration; },
|
|
39
|
-
get ExportDefaultDeclaration () { return ExportDefaultDeclaration; },
|
|
40
|
-
get ExportNamedDeclaration () { return ExportNamedDeclaration; },
|
|
41
|
-
get ExportAllDeclaration () { return ExportAllDeclaration; }
|
|
42
|
-
});
|
|
43
7
|
var statement$1 = /*#__PURE__*/Object.freeze({
|
|
44
8
|
__proto__: null,
|
|
45
9
|
get ExpressionStatement () { return ExpressionStatement$1; },
|
|
@@ -49,6 +13,8 @@
|
|
|
49
13
|
get ReturnStatement () { return ReturnStatement$1; },
|
|
50
14
|
get BreakStatement () { return BreakStatement$1; },
|
|
51
15
|
get ContinueStatement () { return ContinueStatement$1; },
|
|
16
|
+
get LabeledStatement () { return LabeledStatement$1; },
|
|
17
|
+
get WithStatement () { return WithStatement$1; },
|
|
52
18
|
get IfStatement () { return IfStatement$1; },
|
|
53
19
|
get SwitchStatement () { return SwitchStatement$1; },
|
|
54
20
|
get SwitchCase () { return SwitchCase$1; },
|
|
@@ -76,6 +42,44 @@
|
|
|
76
42
|
get ExportNamedDeclaration () { return ExportNamedDeclaration$1; },
|
|
77
43
|
get ExportAllDeclaration () { return ExportAllDeclaration$1; }
|
|
78
44
|
});
|
|
45
|
+
var statement = /*#__PURE__*/Object.freeze({
|
|
46
|
+
__proto__: null,
|
|
47
|
+
get ExpressionStatement () { return ExpressionStatement; },
|
|
48
|
+
get BlockStatement () { return BlockStatement; },
|
|
49
|
+
get EmptyStatement () { return EmptyStatement; },
|
|
50
|
+
get DebuggerStatement () { return DebuggerStatement; },
|
|
51
|
+
get ReturnStatement () { return ReturnStatement; },
|
|
52
|
+
get BreakStatement () { return BreakStatement; },
|
|
53
|
+
get ContinueStatement () { return ContinueStatement; },
|
|
54
|
+
get LabeledStatement () { return LabeledStatement; },
|
|
55
|
+
get WithStatement () { return WithStatement; },
|
|
56
|
+
get IfStatement () { return IfStatement; },
|
|
57
|
+
get SwitchStatement () { return SwitchStatement; },
|
|
58
|
+
get SwitchCase () { return SwitchCase; },
|
|
59
|
+
get ThrowStatement () { return ThrowStatement; },
|
|
60
|
+
get TryStatement () { return TryStatement; },
|
|
61
|
+
get CatchClause () { return CatchClause; },
|
|
62
|
+
get WhileStatement () { return WhileStatement; },
|
|
63
|
+
get DoWhileStatement () { return DoWhileStatement; },
|
|
64
|
+
get ForStatement () { return ForStatement; },
|
|
65
|
+
get ForInStatement () { return ForInStatement; },
|
|
66
|
+
get ForOfStatement () { return ForOfStatement; }
|
|
67
|
+
});
|
|
68
|
+
var declaration = /*#__PURE__*/Object.freeze({
|
|
69
|
+
__proto__: null,
|
|
70
|
+
get FunctionDeclaration () { return FunctionDeclaration; },
|
|
71
|
+
get VariableDeclaration () { return VariableDeclaration; },
|
|
72
|
+
get VariableDeclarator () { return VariableDeclarator; },
|
|
73
|
+
get ClassDeclaration () { return ClassDeclaration; },
|
|
74
|
+
get ClassBody () { return ClassBody; },
|
|
75
|
+
get MethodDefinition () { return MethodDefinition; },
|
|
76
|
+
get PropertyDefinition () { return PropertyDefinition; },
|
|
77
|
+
get StaticBlock () { return StaticBlock; },
|
|
78
|
+
get ImportDeclaration () { return ImportDeclaration; },
|
|
79
|
+
get ExportDefaultDeclaration () { return ExportDefaultDeclaration; },
|
|
80
|
+
get ExportNamedDeclaration () { return ExportNamedDeclaration; },
|
|
81
|
+
get ExportAllDeclaration () { return ExportAllDeclaration; }
|
|
82
|
+
});
|
|
79
83
|
|
|
80
84
|
var freeze = Object.freeze;
|
|
81
85
|
var define = Object.defineProperty;
|
|
@@ -395,6 +399,10 @@
|
|
|
395
399
|
globalObj.crypto = crypto;
|
|
396
400
|
}
|
|
397
401
|
catch (err) { }
|
|
402
|
+
try {
|
|
403
|
+
globalObj.URL = URL;
|
|
404
|
+
}
|
|
405
|
+
catch (err) { }
|
|
398
406
|
names = getOwnNames(globalObj);
|
|
399
407
|
}
|
|
400
408
|
}
|
|
@@ -444,8 +452,8 @@
|
|
|
444
452
|
|
|
445
453
|
var AWAIT = { RES: undefined };
|
|
446
454
|
var RETURN = { RES: undefined };
|
|
447
|
-
var CONTINUE =
|
|
448
|
-
var BREAK =
|
|
455
|
+
var CONTINUE = { LABEL: undefined };
|
|
456
|
+
var BREAK = { LABEL: undefined };
|
|
449
457
|
var SUPER = createSymbol('super');
|
|
450
458
|
var SUPERCALL = createSymbol('supercall');
|
|
451
459
|
var NOCTOR = createSymbol('noctor');
|
|
@@ -457,7 +465,7 @@
|
|
|
457
465
|
var IMPORT = createSymbol('import');
|
|
458
466
|
var EXPORTS = createSymbol('exports');
|
|
459
467
|
|
|
460
|
-
var version = "0.5.
|
|
468
|
+
var version = "0.5.3";
|
|
461
469
|
|
|
462
470
|
var Var = (function () {
|
|
463
471
|
function Var(kind, value) {
|
|
@@ -500,6 +508,7 @@
|
|
|
500
508
|
if (parent === void 0) { parent = null; }
|
|
501
509
|
if (isolated === void 0) { isolated = false; }
|
|
502
510
|
this.context = create(null);
|
|
511
|
+
this.withContext = create(null);
|
|
503
512
|
this.parent = parent;
|
|
504
513
|
this.isolated = isolated;
|
|
505
514
|
}
|
|
@@ -510,18 +519,13 @@
|
|
|
510
519
|
}
|
|
511
520
|
return scope;
|
|
512
521
|
};
|
|
513
|
-
Scope.prototype.clone = function () {
|
|
514
|
-
var cloneScope = new Scope(this.parent, this.isolated);
|
|
515
|
-
for (var name_1 in this.context) {
|
|
516
|
-
var variable = this.context[name_1];
|
|
517
|
-
cloneScope[variable.kind](name_1, variable.get());
|
|
518
|
-
}
|
|
519
|
-
return cloneScope;
|
|
520
|
-
};
|
|
521
522
|
Scope.prototype.find = function (name) {
|
|
522
523
|
if (this.context[name]) {
|
|
523
524
|
return this.context[name];
|
|
524
525
|
}
|
|
526
|
+
else if (name in this.withContext) {
|
|
527
|
+
return new Prop(this.withContext, name);
|
|
528
|
+
}
|
|
525
529
|
else if (this.parent) {
|
|
526
530
|
return this.parent.find(name);
|
|
527
531
|
}
|
|
@@ -588,6 +592,11 @@
|
|
|
588
592
|
throw new SyntaxError("Identifier '" + name + "' has already been declared");
|
|
589
593
|
}
|
|
590
594
|
};
|
|
595
|
+
Scope.prototype.with = function (value) {
|
|
596
|
+
if (Object.keys(value)) {
|
|
597
|
+
this.withContext = value;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
591
600
|
return Scope;
|
|
592
601
|
}());
|
|
593
602
|
|
|
@@ -668,7 +677,7 @@
|
|
|
668
677
|
return ar;
|
|
669
678
|
}
|
|
670
679
|
|
|
671
|
-
function Identifier(node, scope, options) {
|
|
680
|
+
function Identifier$1(node, scope, options) {
|
|
672
681
|
if (options === void 0) { options = {}; }
|
|
673
682
|
var _a = options.getVar, getVar = _a === void 0 ? false : _a, _b = options.throwErr, throwErr = _b === void 0 ? true : _b;
|
|
674
683
|
if (node.name === 'undefined') {
|
|
@@ -697,21 +706,21 @@
|
|
|
697
706
|
}
|
|
698
707
|
}
|
|
699
708
|
|
|
700
|
-
var identifier = /*#__PURE__*/Object.freeze({
|
|
709
|
+
var identifier$1 = /*#__PURE__*/Object.freeze({
|
|
701
710
|
__proto__: null,
|
|
702
|
-
Identifier: Identifier
|
|
711
|
+
Identifier: Identifier$1
|
|
703
712
|
});
|
|
704
713
|
|
|
705
|
-
function Literal(node, scope) {
|
|
714
|
+
function Literal$1(node, scope) {
|
|
706
715
|
return node.value;
|
|
707
716
|
}
|
|
708
717
|
|
|
709
|
-
var literal = /*#__PURE__*/Object.freeze({
|
|
718
|
+
var literal$1 = /*#__PURE__*/Object.freeze({
|
|
710
719
|
__proto__: null,
|
|
711
|
-
Literal: Literal
|
|
720
|
+
Literal: Literal$1
|
|
712
721
|
});
|
|
713
722
|
|
|
714
|
-
function ThisExpression(node, scope) {
|
|
723
|
+
function ThisExpression$1(node, scope) {
|
|
715
724
|
var superCall = scope.find(SUPERCALL);
|
|
716
725
|
if (superCall && !superCall.get()) {
|
|
717
726
|
throw new ReferenceError('Must call super constructor in derived class '
|
|
@@ -721,41 +730,41 @@
|
|
|
721
730
|
return scope.find('this').get();
|
|
722
731
|
}
|
|
723
732
|
}
|
|
724
|
-
function ArrayExpression(node, scope) {
|
|
733
|
+
function ArrayExpression$1(node, scope) {
|
|
725
734
|
var results = [];
|
|
726
735
|
for (var i = 0; i < node.elements.length; i++) {
|
|
727
736
|
var item = node.elements[i];
|
|
728
737
|
if (item.type === 'SpreadElement') {
|
|
729
|
-
results = results.concat(SpreadElement(item, scope));
|
|
738
|
+
results = results.concat(SpreadElement$1(item, scope));
|
|
730
739
|
}
|
|
731
740
|
else {
|
|
732
|
-
results.push(evaluate(item, scope));
|
|
741
|
+
results.push(evaluate$1(item, scope));
|
|
733
742
|
}
|
|
734
743
|
}
|
|
735
744
|
return results;
|
|
736
745
|
}
|
|
737
|
-
function ObjectExpression(node, scope) {
|
|
746
|
+
function ObjectExpression$1(node, scope) {
|
|
738
747
|
var object = {};
|
|
739
748
|
for (var i = 0; i < node.properties.length; i++) {
|
|
740
749
|
var property = node.properties[i];
|
|
741
750
|
if (property.type === 'SpreadElement') {
|
|
742
|
-
assign(object, SpreadElement(property, scope));
|
|
751
|
+
assign(object, SpreadElement$1(property, scope));
|
|
743
752
|
}
|
|
744
753
|
else {
|
|
745
754
|
var key = void 0;
|
|
746
755
|
var propKey = property.key;
|
|
747
756
|
if (property.computed) {
|
|
748
|
-
key = evaluate(propKey, scope);
|
|
757
|
+
key = evaluate$1(propKey, scope);
|
|
749
758
|
}
|
|
750
759
|
else {
|
|
751
760
|
if (propKey.type === 'Identifier') {
|
|
752
761
|
key = propKey.name;
|
|
753
762
|
}
|
|
754
763
|
else {
|
|
755
|
-
key = '' + (Literal(propKey));
|
|
764
|
+
key = '' + (Literal$1(propKey));
|
|
756
765
|
}
|
|
757
766
|
}
|
|
758
|
-
var value = evaluate(property.value, scope);
|
|
767
|
+
var value = evaluate$1(property.value, scope);
|
|
759
768
|
var propKind = property.kind;
|
|
760
769
|
if (propKind === 'init') {
|
|
761
770
|
object[key] = value;
|
|
@@ -782,55 +791,55 @@
|
|
|
782
791
|
}
|
|
783
792
|
return object;
|
|
784
793
|
}
|
|
785
|
-
function FunctionExpression(node, scope) {
|
|
794
|
+
function FunctionExpression$1(node, scope) {
|
|
786
795
|
if (node.id && node.id.name) {
|
|
787
796
|
var tmpScope = new Scope(scope);
|
|
788
|
-
var func = createFunc
|
|
797
|
+
var func = createFunc(node, tmpScope);
|
|
789
798
|
tmpScope.const(node.id.name, func);
|
|
790
799
|
return func;
|
|
791
800
|
}
|
|
792
801
|
else {
|
|
793
|
-
return createFunc
|
|
802
|
+
return createFunc(node, scope);
|
|
794
803
|
}
|
|
795
804
|
}
|
|
796
|
-
function UnaryExpression(node, scope) {
|
|
805
|
+
function UnaryExpression$1(node, scope) {
|
|
797
806
|
var arg = node.argument;
|
|
798
807
|
switch (node.operator) {
|
|
799
|
-
case '+': return +(evaluate(arg, scope));
|
|
800
|
-
case '-': return -(evaluate(arg, scope));
|
|
801
|
-
case '!': return !(evaluate(arg, scope));
|
|
802
|
-
case '~': return ~(evaluate(arg, scope));
|
|
803
|
-
case 'void': return void (evaluate(arg, scope));
|
|
808
|
+
case '+': return +(evaluate$1(arg, scope));
|
|
809
|
+
case '-': return -(evaluate$1(arg, scope));
|
|
810
|
+
case '!': return !(evaluate$1(arg, scope));
|
|
811
|
+
case '~': return ~(evaluate$1(arg, scope));
|
|
812
|
+
case 'void': return void (evaluate$1(arg, scope));
|
|
804
813
|
case 'typeof':
|
|
805
814
|
if (arg.type === 'Identifier') {
|
|
806
|
-
return typeof (Identifier(arg, scope, { throwErr: false }));
|
|
815
|
+
return typeof (Identifier$1(arg, scope, { throwErr: false }));
|
|
807
816
|
}
|
|
808
817
|
else {
|
|
809
|
-
return typeof (evaluate(arg, scope));
|
|
818
|
+
return typeof (evaluate$1(arg, scope));
|
|
810
819
|
}
|
|
811
820
|
case 'delete':
|
|
812
821
|
if (arg.type === 'MemberExpression') {
|
|
813
|
-
var variable = MemberExpression(arg, scope, { getVar: true });
|
|
822
|
+
var variable = MemberExpression$1(arg, scope, { getVar: true });
|
|
814
823
|
return variable.del();
|
|
815
824
|
}
|
|
816
825
|
else if (arg.type === 'Identifier') {
|
|
817
826
|
throw new SyntaxError('Delete of an unqualified identifier in strict mode');
|
|
818
827
|
}
|
|
819
828
|
else {
|
|
820
|
-
evaluate(arg, scope);
|
|
829
|
+
evaluate$1(arg, scope);
|
|
821
830
|
return true;
|
|
822
831
|
}
|
|
823
832
|
default: throw new SyntaxError("Unexpected token " + node.operator);
|
|
824
833
|
}
|
|
825
834
|
}
|
|
826
|
-
function UpdateExpression(node, scope) {
|
|
835
|
+
function UpdateExpression$1(node, scope) {
|
|
827
836
|
var arg = node.argument;
|
|
828
837
|
var variable;
|
|
829
838
|
if (arg.type === 'Identifier') {
|
|
830
|
-
variable = Identifier(arg, scope, { getVar: true });
|
|
839
|
+
variable = Identifier$1(arg, scope, { getVar: true });
|
|
831
840
|
}
|
|
832
841
|
else if (arg.type === 'MemberExpression') {
|
|
833
|
-
variable = MemberExpression(arg, scope, { getVar: true });
|
|
842
|
+
variable = MemberExpression$1(arg, scope, { getVar: true });
|
|
834
843
|
}
|
|
835
844
|
else {
|
|
836
845
|
throw new SyntaxError('Unexpected token');
|
|
@@ -848,17 +857,17 @@
|
|
|
848
857
|
throw new SyntaxError("Unexpected token " + node.operator);
|
|
849
858
|
}
|
|
850
859
|
}
|
|
851
|
-
function BinaryExpression(node, scope) {
|
|
860
|
+
function BinaryExpression$1(node, scope) {
|
|
852
861
|
var left;
|
|
853
862
|
var right;
|
|
854
863
|
if (node.left.type === 'PrivateIdentifier') {
|
|
855
864
|
left = node.left.name;
|
|
856
|
-
right = evaluate(node.right, scope);
|
|
865
|
+
right = evaluate$1(node.right, scope);
|
|
857
866
|
right = right[PRIVATE];
|
|
858
867
|
}
|
|
859
868
|
else {
|
|
860
|
-
left = evaluate(node.left, scope);
|
|
861
|
-
right = evaluate(node.right, scope);
|
|
869
|
+
left = evaluate$1(node.left, scope);
|
|
870
|
+
right = evaluate$1(node.right, scope);
|
|
862
871
|
}
|
|
863
872
|
switch (node.operator) {
|
|
864
873
|
case '==': return left == right;
|
|
@@ -886,25 +895,25 @@
|
|
|
886
895
|
default: throw new SyntaxError("Unexpected token " + node.operator);
|
|
887
896
|
}
|
|
888
897
|
}
|
|
889
|
-
function AssignmentExpression(node, scope) {
|
|
898
|
+
function AssignmentExpression$1(node, scope) {
|
|
890
899
|
var _a;
|
|
891
900
|
var left = node.left;
|
|
892
901
|
var variable;
|
|
893
902
|
if (left.type === 'Identifier') {
|
|
894
|
-
variable = Identifier(left, scope, { getVar: true, throwErr: false });
|
|
903
|
+
variable = Identifier$1(left, scope, { getVar: true, throwErr: false });
|
|
895
904
|
if (!variable) {
|
|
896
905
|
var win = scope.global().find('window').get();
|
|
897
906
|
variable = new Prop(win, left.name);
|
|
898
907
|
}
|
|
899
908
|
}
|
|
900
909
|
else if (left.type === 'MemberExpression') {
|
|
901
|
-
variable = MemberExpression(left, scope, { getVar: true });
|
|
910
|
+
variable = MemberExpression$1(left, scope, { getVar: true });
|
|
902
911
|
}
|
|
903
912
|
else {
|
|
904
|
-
var value_1 = evaluate(node.right, scope);
|
|
905
|
-
return pattern
|
|
913
|
+
var value_1 = evaluate$1(node.right, scope);
|
|
914
|
+
return pattern(left, scope, { feed: value_1 });
|
|
906
915
|
}
|
|
907
|
-
var value = evaluate(node.right, scope);
|
|
916
|
+
var value = evaluate$1(node.right, scope);
|
|
908
917
|
switch (node.operator) {
|
|
909
918
|
case '=':
|
|
910
919
|
variable.set(value);
|
|
@@ -957,35 +966,35 @@
|
|
|
957
966
|
default: throw new SyntaxError("Unexpected token " + node.operator);
|
|
958
967
|
}
|
|
959
968
|
}
|
|
960
|
-
function LogicalExpression(node, scope) {
|
|
969
|
+
function LogicalExpression$1(node, scope) {
|
|
961
970
|
var _a;
|
|
962
971
|
switch (node.operator) {
|
|
963
972
|
case '||':
|
|
964
|
-
return (evaluate(node.left, scope)) || (evaluate(node.right, scope));
|
|
973
|
+
return (evaluate$1(node.left, scope)) || (evaluate$1(node.right, scope));
|
|
965
974
|
case '&&':
|
|
966
|
-
return (evaluate(node.left, scope)) && (evaluate(node.right, scope));
|
|
975
|
+
return (evaluate$1(node.left, scope)) && (evaluate$1(node.right, scope));
|
|
967
976
|
case '??':
|
|
968
|
-
return (_a = (evaluate(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate(node.right, scope));
|
|
977
|
+
return (_a = (evaluate$1(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate$1(node.right, scope));
|
|
969
978
|
default:
|
|
970
979
|
throw new SyntaxError("Unexpected token " + node.operator);
|
|
971
980
|
}
|
|
972
981
|
}
|
|
973
|
-
function MemberExpression(node, scope, options) {
|
|
982
|
+
function MemberExpression$1(node, scope, options) {
|
|
974
983
|
if (options === void 0) { options = {}; }
|
|
975
984
|
var _a = options.getObj, getObj = _a === void 0 ? false : _a, _b = options.getVar, getVar = _b === void 0 ? false : _b;
|
|
976
985
|
var object;
|
|
977
986
|
if (node.object.type === 'Super') {
|
|
978
|
-
object = Super(node.object, scope, { getProto: true });
|
|
987
|
+
object = Super$1(node.object, scope, { getProto: true });
|
|
979
988
|
}
|
|
980
989
|
else {
|
|
981
|
-
object = evaluate(node.object, scope);
|
|
990
|
+
object = evaluate$1(node.object, scope);
|
|
982
991
|
}
|
|
983
992
|
if (getObj)
|
|
984
993
|
return object;
|
|
985
994
|
var key;
|
|
986
995
|
var priv = false;
|
|
987
996
|
if (node.computed) {
|
|
988
|
-
key = evaluate(node.property, scope);
|
|
997
|
+
key = evaluate$1(node.property, scope);
|
|
989
998
|
}
|
|
990
999
|
else if (node.property.type === 'PrivateIdentifier') {
|
|
991
1000
|
key = node.property.name;
|
|
@@ -1026,23 +1035,23 @@
|
|
|
1026
1035
|
}
|
|
1027
1036
|
}
|
|
1028
1037
|
}
|
|
1029
|
-
function ConditionalExpression(node, scope) {
|
|
1030
|
-
return (evaluate(node.test, scope))
|
|
1031
|
-
? (evaluate(node.consequent, scope))
|
|
1032
|
-
: (evaluate(node.alternate, scope));
|
|
1038
|
+
function ConditionalExpression$1(node, scope) {
|
|
1039
|
+
return (evaluate$1(node.test, scope))
|
|
1040
|
+
? (evaluate$1(node.consequent, scope))
|
|
1041
|
+
: (evaluate$1(node.alternate, scope));
|
|
1033
1042
|
}
|
|
1034
|
-
function CallExpression(node, scope) {
|
|
1043
|
+
function CallExpression$1(node, scope) {
|
|
1035
1044
|
var func;
|
|
1036
1045
|
var object;
|
|
1037
1046
|
if (node.callee.type === 'MemberExpression') {
|
|
1038
|
-
object = MemberExpression(node.callee, scope, { getObj: true });
|
|
1047
|
+
object = MemberExpression$1(node.callee, scope, { getObj: true });
|
|
1039
1048
|
if (node.callee.optional && object == null) {
|
|
1040
1049
|
return undefined;
|
|
1041
1050
|
}
|
|
1042
1051
|
var key = void 0;
|
|
1043
1052
|
var priv = false;
|
|
1044
1053
|
if (node.callee.computed) {
|
|
1045
|
-
key = evaluate(node.callee.property, scope);
|
|
1054
|
+
key = evaluate$1(node.callee.property, scope);
|
|
1046
1055
|
}
|
|
1047
1056
|
else if (node.callee.property.type === 'PrivateIdentifier') {
|
|
1048
1057
|
key = node.callee.property.name;
|
|
@@ -1074,7 +1083,7 @@
|
|
|
1074
1083
|
}
|
|
1075
1084
|
else {
|
|
1076
1085
|
object = scope.find('this').get();
|
|
1077
|
-
func = evaluate(node.callee, scope);
|
|
1086
|
+
func = evaluate$1(node.callee, scope);
|
|
1078
1087
|
if (node.optional && func == null) {
|
|
1079
1088
|
return undefined;
|
|
1080
1089
|
}
|
|
@@ -1103,10 +1112,10 @@
|
|
|
1103
1112
|
for (var i = 0; i < node.arguments.length; i++) {
|
|
1104
1113
|
var arg = node.arguments[i];
|
|
1105
1114
|
if (arg.type === 'SpreadElement') {
|
|
1106
|
-
args = args.concat(SpreadElement(arg, scope));
|
|
1115
|
+
args = args.concat(SpreadElement$1(arg, scope));
|
|
1107
1116
|
}
|
|
1108
1117
|
else {
|
|
1109
|
-
args.push(evaluate(arg, scope));
|
|
1118
|
+
args.push(evaluate$1(arg, scope));
|
|
1110
1119
|
}
|
|
1111
1120
|
}
|
|
1112
1121
|
if (node.callee.type === 'Super') {
|
|
@@ -1118,13 +1127,22 @@
|
|
|
1118
1127
|
scope.find(SUPERCALL).set(true);
|
|
1119
1128
|
}
|
|
1120
1129
|
}
|
|
1121
|
-
|
|
1122
|
-
return func.apply(object
|
|
1130
|
+
try {
|
|
1131
|
+
return func.apply(object, args);
|
|
1132
|
+
}
|
|
1133
|
+
catch (err) {
|
|
1134
|
+
if (err instanceof TypeError && err.message === 'Illegal invocation'
|
|
1135
|
+
&& func.toString().indexOf('[native code]') !== -1) {
|
|
1136
|
+
var win = scope.global().find('window').get();
|
|
1137
|
+
if (win && win[WINDOW]) {
|
|
1138
|
+
return func.apply(win[WINDOW], args);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
throw err;
|
|
1123
1142
|
}
|
|
1124
|
-
return func.apply(object, args);
|
|
1125
1143
|
}
|
|
1126
|
-
function NewExpression(node, scope) {
|
|
1127
|
-
var constructor = evaluate(node.callee, scope);
|
|
1144
|
+
function NewExpression$1(node, scope) {
|
|
1145
|
+
var constructor = evaluate$1(node.callee, scope);
|
|
1128
1146
|
if (typeof constructor !== 'function') {
|
|
1129
1147
|
var name_2;
|
|
1130
1148
|
if (node.callee.type === 'Identifier') {
|
|
@@ -1147,15 +1165,15 @@
|
|
|
1147
1165
|
for (var i = 0; i < node.arguments.length; i++) {
|
|
1148
1166
|
var arg = node.arguments[i];
|
|
1149
1167
|
if (arg.type === 'SpreadElement') {
|
|
1150
|
-
args = args.concat(SpreadElement(arg, scope));
|
|
1168
|
+
args = args.concat(SpreadElement$1(arg, scope));
|
|
1151
1169
|
}
|
|
1152
1170
|
else {
|
|
1153
|
-
args.push(evaluate(arg, scope));
|
|
1171
|
+
args.push(evaluate$1(arg, scope));
|
|
1154
1172
|
}
|
|
1155
1173
|
}
|
|
1156
1174
|
return new (constructor.bind.apply(constructor, __spread([void 0], args)))();
|
|
1157
1175
|
}
|
|
1158
|
-
function MetaProperty(node, scope) {
|
|
1176
|
+
function MetaProperty$1(node, scope) {
|
|
1159
1177
|
if (node.meta.name === 'new' && node.property.name === 'target') {
|
|
1160
1178
|
return scope.find(NEWTARGET).get();
|
|
1161
1179
|
}
|
|
@@ -1163,33 +1181,33 @@
|
|
|
1163
1181
|
return { url: '' };
|
|
1164
1182
|
}
|
|
1165
1183
|
}
|
|
1166
|
-
function SequenceExpression(node, scope) {
|
|
1184
|
+
function SequenceExpression$1(node, scope) {
|
|
1167
1185
|
var result;
|
|
1168
1186
|
for (var i = 0; i < node.expressions.length; i++) {
|
|
1169
|
-
result = evaluate(node.expressions[i], scope);
|
|
1187
|
+
result = evaluate$1(node.expressions[i], scope);
|
|
1170
1188
|
}
|
|
1171
1189
|
return result;
|
|
1172
1190
|
}
|
|
1173
|
-
function ArrowFunctionExpression(node, scope) {
|
|
1174
|
-
return createFunc
|
|
1191
|
+
function ArrowFunctionExpression$1(node, scope) {
|
|
1192
|
+
return createFunc(node, scope);
|
|
1175
1193
|
}
|
|
1176
|
-
function TemplateLiteral(node, scope) {
|
|
1194
|
+
function TemplateLiteral$1(node, scope) {
|
|
1177
1195
|
var quasis = node.quasis.slice();
|
|
1178
1196
|
var expressions = node.expressions.slice();
|
|
1179
1197
|
var result = '';
|
|
1180
1198
|
var temEl;
|
|
1181
1199
|
var expr;
|
|
1182
1200
|
while (temEl = quasis.shift()) {
|
|
1183
|
-
result += TemplateElement(temEl);
|
|
1201
|
+
result += TemplateElement$1(temEl);
|
|
1184
1202
|
expr = expressions.shift();
|
|
1185
1203
|
if (expr) {
|
|
1186
|
-
result += evaluate(expr, scope);
|
|
1204
|
+
result += evaluate$1(expr, scope);
|
|
1187
1205
|
}
|
|
1188
1206
|
}
|
|
1189
1207
|
return result;
|
|
1190
1208
|
}
|
|
1191
|
-
function TaggedTemplateExpression(node, scope) {
|
|
1192
|
-
var tagFunc = evaluate(node.tag, scope);
|
|
1209
|
+
function TaggedTemplateExpression$1(node, scope) {
|
|
1210
|
+
var tagFunc = evaluate$1(node.tag, scope);
|
|
1193
1211
|
var quasis = node.quasi.quasis;
|
|
1194
1212
|
var str = quasis.map(function (v) { return v.value.cooked; });
|
|
1195
1213
|
var raw = quasis.map(function (v) { return v.value.raw; });
|
|
@@ -1200,41 +1218,41 @@
|
|
|
1200
1218
|
var args = [];
|
|
1201
1219
|
if (expressions) {
|
|
1202
1220
|
for (var i = 0; i < expressions.length; i++) {
|
|
1203
|
-
args.push(evaluate(expressions[i], scope));
|
|
1221
|
+
args.push(evaluate$1(expressions[i], scope));
|
|
1204
1222
|
}
|
|
1205
1223
|
}
|
|
1206
1224
|
return tagFunc.apply(void 0, __spread([freeze(str)], args));
|
|
1207
1225
|
}
|
|
1208
|
-
function TemplateElement(node, scope) {
|
|
1226
|
+
function TemplateElement$1(node, scope) {
|
|
1209
1227
|
return node.value.raw;
|
|
1210
1228
|
}
|
|
1211
|
-
function ClassExpression(node, scope) {
|
|
1229
|
+
function ClassExpression$1(node, scope) {
|
|
1212
1230
|
if (node.id && node.id.name) {
|
|
1213
1231
|
var tmpScope = new Scope(scope);
|
|
1214
|
-
var klass = createClass
|
|
1232
|
+
var klass = createClass(node, tmpScope);
|
|
1215
1233
|
tmpScope.const(node.id.name, klass);
|
|
1216
1234
|
return klass;
|
|
1217
1235
|
}
|
|
1218
1236
|
else {
|
|
1219
|
-
return createClass
|
|
1237
|
+
return createClass(node, scope);
|
|
1220
1238
|
}
|
|
1221
1239
|
}
|
|
1222
|
-
function Super(node, scope, options) {
|
|
1240
|
+
function Super$1(node, scope, options) {
|
|
1223
1241
|
if (options === void 0) { options = {}; }
|
|
1224
1242
|
var _a = options.getProto, getProto = _a === void 0 ? false : _a;
|
|
1225
1243
|
var superClass = scope.find(SUPER).get();
|
|
1226
1244
|
return getProto ? superClass.prototype : superClass;
|
|
1227
1245
|
}
|
|
1228
|
-
function SpreadElement(node, scope) {
|
|
1229
|
-
var result = evaluate(node.argument, scope);
|
|
1246
|
+
function SpreadElement$1(node, scope) {
|
|
1247
|
+
var result = evaluate$1(node.argument, scope);
|
|
1230
1248
|
return typeof result === 'string' ? __spread(result) : result;
|
|
1231
1249
|
}
|
|
1232
|
-
function ChainExpression(node, scope) {
|
|
1233
|
-
return evaluate(node.expression, scope);
|
|
1250
|
+
function ChainExpression$1(node, scope) {
|
|
1251
|
+
return evaluate$1(node.expression, scope);
|
|
1234
1252
|
}
|
|
1235
|
-
function ImportExpression(node, scope) {
|
|
1253
|
+
function ImportExpression$1(node, scope) {
|
|
1236
1254
|
var globalScope = scope.global();
|
|
1237
|
-
var source = evaluate(node.source, scope);
|
|
1255
|
+
var source = evaluate$1(node.source, scope);
|
|
1238
1256
|
var module = globalScope.find(IMPORT + source);
|
|
1239
1257
|
var value;
|
|
1240
1258
|
if (module) {
|
|
@@ -1254,35 +1272,35 @@
|
|
|
1254
1272
|
return Promise.resolve(value);
|
|
1255
1273
|
}
|
|
1256
1274
|
|
|
1257
|
-
var expression = /*#__PURE__*/Object.freeze({
|
|
1275
|
+
var expression$1 = /*#__PURE__*/Object.freeze({
|
|
1258
1276
|
__proto__: null,
|
|
1259
|
-
ThisExpression: ThisExpression,
|
|
1260
|
-
ArrayExpression: ArrayExpression,
|
|
1261
|
-
ObjectExpression: ObjectExpression,
|
|
1262
|
-
FunctionExpression: FunctionExpression,
|
|
1263
|
-
UnaryExpression: UnaryExpression,
|
|
1264
|
-
UpdateExpression: UpdateExpression,
|
|
1265
|
-
BinaryExpression: BinaryExpression,
|
|
1266
|
-
AssignmentExpression: AssignmentExpression,
|
|
1267
|
-
LogicalExpression: LogicalExpression,
|
|
1268
|
-
MemberExpression: MemberExpression,
|
|
1269
|
-
ConditionalExpression: ConditionalExpression,
|
|
1270
|
-
CallExpression: CallExpression,
|
|
1271
|
-
NewExpression: NewExpression,
|
|
1272
|
-
MetaProperty: MetaProperty,
|
|
1273
|
-
SequenceExpression: SequenceExpression,
|
|
1274
|
-
ArrowFunctionExpression: ArrowFunctionExpression,
|
|
1275
|
-
TemplateLiteral: TemplateLiteral,
|
|
1276
|
-
TaggedTemplateExpression: TaggedTemplateExpression,
|
|
1277
|
-
TemplateElement: TemplateElement,
|
|
1278
|
-
ClassExpression: ClassExpression,
|
|
1279
|
-
Super: Super,
|
|
1280
|
-
SpreadElement: SpreadElement,
|
|
1281
|
-
ChainExpression: ChainExpression,
|
|
1282
|
-
ImportExpression: ImportExpression
|
|
1277
|
+
ThisExpression: ThisExpression$1,
|
|
1278
|
+
ArrayExpression: ArrayExpression$1,
|
|
1279
|
+
ObjectExpression: ObjectExpression$1,
|
|
1280
|
+
FunctionExpression: FunctionExpression$1,
|
|
1281
|
+
UnaryExpression: UnaryExpression$1,
|
|
1282
|
+
UpdateExpression: UpdateExpression$1,
|
|
1283
|
+
BinaryExpression: BinaryExpression$1,
|
|
1284
|
+
AssignmentExpression: AssignmentExpression$1,
|
|
1285
|
+
LogicalExpression: LogicalExpression$1,
|
|
1286
|
+
MemberExpression: MemberExpression$1,
|
|
1287
|
+
ConditionalExpression: ConditionalExpression$1,
|
|
1288
|
+
CallExpression: CallExpression$1,
|
|
1289
|
+
NewExpression: NewExpression$1,
|
|
1290
|
+
MetaProperty: MetaProperty$1,
|
|
1291
|
+
SequenceExpression: SequenceExpression$1,
|
|
1292
|
+
ArrowFunctionExpression: ArrowFunctionExpression$1,
|
|
1293
|
+
TemplateLiteral: TemplateLiteral$1,
|
|
1294
|
+
TaggedTemplateExpression: TaggedTemplateExpression$1,
|
|
1295
|
+
TemplateElement: TemplateElement$1,
|
|
1296
|
+
ClassExpression: ClassExpression$1,
|
|
1297
|
+
Super: Super$1,
|
|
1298
|
+
SpreadElement: SpreadElement$1,
|
|
1299
|
+
ChainExpression: ChainExpression$1,
|
|
1300
|
+
ImportExpression: ImportExpression$1
|
|
1283
1301
|
});
|
|
1284
1302
|
|
|
1285
|
-
function ObjectPattern(node, scope, options) {
|
|
1303
|
+
function ObjectPattern$1(node, scope, options) {
|
|
1286
1304
|
if (options === void 0) { options = {}; }
|
|
1287
1305
|
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? {} : _d;
|
|
1288
1306
|
var fedKeys = [];
|
|
@@ -1296,18 +1314,18 @@
|
|
|
1296
1314
|
scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1297
1315
|
}
|
|
1298
1316
|
else {
|
|
1299
|
-
pattern
|
|
1317
|
+
pattern(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1300
1318
|
}
|
|
1301
1319
|
}
|
|
1302
1320
|
else {
|
|
1303
|
-
RestElement(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1321
|
+
RestElement$1(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1304
1322
|
}
|
|
1305
1323
|
}
|
|
1306
1324
|
}
|
|
1307
1325
|
else if (property.type === 'Property') {
|
|
1308
1326
|
var key = void 0;
|
|
1309
1327
|
if (property.computed) {
|
|
1310
|
-
key = evaluate(property.key, scope);
|
|
1328
|
+
key = evaluate$1(property.key, scope);
|
|
1311
1329
|
}
|
|
1312
1330
|
else {
|
|
1313
1331
|
key = property.key.name;
|
|
@@ -1318,18 +1336,18 @@
|
|
|
1318
1336
|
scope[kind](value.name, feed[key]);
|
|
1319
1337
|
}
|
|
1320
1338
|
else {
|
|
1321
|
-
pattern
|
|
1339
|
+
pattern(value, scope, { kind: kind, feed: feed[key] });
|
|
1322
1340
|
}
|
|
1323
1341
|
}
|
|
1324
1342
|
else {
|
|
1325
1343
|
var rest = assign({}, feed);
|
|
1326
1344
|
for (var i_1 = 0; i_1 < fedKeys.length; i_1++)
|
|
1327
1345
|
delete rest[fedKeys[i_1]];
|
|
1328
|
-
RestElement(property, scope, { kind: kind, feed: rest });
|
|
1346
|
+
RestElement$1(property, scope, { kind: kind, feed: rest });
|
|
1329
1347
|
}
|
|
1330
1348
|
}
|
|
1331
1349
|
}
|
|
1332
|
-
function ArrayPattern(node, scope, options) {
|
|
1350
|
+
function ArrayPattern$1(node, scope, options) {
|
|
1333
1351
|
if (options === void 0) { options = {}; }
|
|
1334
1352
|
var kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
1335
1353
|
var result = [];
|
|
@@ -1343,7 +1361,7 @@
|
|
|
1343
1361
|
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1344
1362
|
}
|
|
1345
1363
|
else {
|
|
1346
|
-
pattern
|
|
1364
|
+
pattern(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1347
1365
|
}
|
|
1348
1366
|
}
|
|
1349
1367
|
}
|
|
@@ -1352,23 +1370,23 @@
|
|
|
1352
1370
|
scope[kind](element.name, feed[i]);
|
|
1353
1371
|
}
|
|
1354
1372
|
else {
|
|
1355
|
-
var variable = Identifier(element, scope, { getVar: true });
|
|
1373
|
+
var variable = Identifier$1(element, scope, { getVar: true });
|
|
1356
1374
|
variable.set(feed[i]);
|
|
1357
1375
|
result.push(variable.get());
|
|
1358
1376
|
}
|
|
1359
1377
|
}
|
|
1360
1378
|
else if (element.type === 'RestElement') {
|
|
1361
|
-
RestElement(element, scope, { kind: kind, feed: feed.slice(i) });
|
|
1379
|
+
RestElement$1(element, scope, { kind: kind, feed: feed.slice(i) });
|
|
1362
1380
|
}
|
|
1363
1381
|
else {
|
|
1364
|
-
pattern
|
|
1382
|
+
pattern(element, scope, { kind: kind, feed: feed[i] });
|
|
1365
1383
|
}
|
|
1366
1384
|
}
|
|
1367
1385
|
if (result.length) {
|
|
1368
1386
|
return result;
|
|
1369
1387
|
}
|
|
1370
1388
|
}
|
|
1371
|
-
function RestElement(node, scope, options) {
|
|
1389
|
+
function RestElement$1(node, scope, options) {
|
|
1372
1390
|
if (options === void 0) { options = {}; }
|
|
1373
1391
|
var kind = options.kind, _a = options.hoist, hoist = _a === void 0 ? false : _a, _b = options.onlyBlock, onlyBlock = _b === void 0 ? false : _b, _c = options.feed, feed = _c === void 0 ? [] : _c;
|
|
1374
1392
|
var arg = node.argument;
|
|
@@ -1378,7 +1396,7 @@
|
|
|
1378
1396
|
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1379
1397
|
}
|
|
1380
1398
|
else {
|
|
1381
|
-
pattern
|
|
1399
|
+
pattern(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1382
1400
|
}
|
|
1383
1401
|
}
|
|
1384
1402
|
}
|
|
@@ -1387,17 +1405,17 @@
|
|
|
1387
1405
|
scope[kind](arg.name, feed);
|
|
1388
1406
|
}
|
|
1389
1407
|
else {
|
|
1390
|
-
var variable = Identifier(arg, scope, { getVar: true });
|
|
1408
|
+
var variable = Identifier$1(arg, scope, { getVar: true });
|
|
1391
1409
|
variable.set(feed);
|
|
1392
1410
|
}
|
|
1393
1411
|
}
|
|
1394
1412
|
else {
|
|
1395
|
-
pattern
|
|
1413
|
+
pattern(arg, scope, { kind: kind, feed: feed });
|
|
1396
1414
|
}
|
|
1397
1415
|
}
|
|
1398
|
-
function AssignmentPattern(node, scope, options) {
|
|
1416
|
+
function AssignmentPattern$1(node, scope, options) {
|
|
1399
1417
|
if (options === void 0) { options = {}; }
|
|
1400
|
-
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? evaluate(node.right, scope) : _d;
|
|
1418
|
+
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed, feed = _d === void 0 ? evaluate$1(node.right, scope) : _d;
|
|
1401
1419
|
var left = node.left;
|
|
1402
1420
|
if (hoist) {
|
|
1403
1421
|
if (onlyBlock || kind === 'var') {
|
|
@@ -1405,7 +1423,7 @@
|
|
|
1405
1423
|
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1406
1424
|
}
|
|
1407
1425
|
else {
|
|
1408
|
-
pattern
|
|
1426
|
+
pattern(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1409
1427
|
}
|
|
1410
1428
|
}
|
|
1411
1429
|
}
|
|
@@ -1413,21 +1431,21 @@
|
|
|
1413
1431
|
scope[kind](left.name, feed);
|
|
1414
1432
|
}
|
|
1415
1433
|
else {
|
|
1416
|
-
pattern
|
|
1434
|
+
pattern(left, scope, { kind: kind, feed: feed });
|
|
1417
1435
|
}
|
|
1418
1436
|
}
|
|
1419
1437
|
|
|
1420
|
-
var pattern = /*#__PURE__*/Object.freeze({
|
|
1438
|
+
var pattern$3 = /*#__PURE__*/Object.freeze({
|
|
1421
1439
|
__proto__: null,
|
|
1422
|
-
ObjectPattern: ObjectPattern,
|
|
1423
|
-
ArrayPattern: ArrayPattern,
|
|
1424
|
-
RestElement: RestElement,
|
|
1425
|
-
AssignmentPattern: AssignmentPattern
|
|
1440
|
+
ObjectPattern: ObjectPattern$1,
|
|
1441
|
+
ArrayPattern: ArrayPattern$1,
|
|
1442
|
+
RestElement: RestElement$1,
|
|
1443
|
+
AssignmentPattern: AssignmentPattern$1
|
|
1426
1444
|
});
|
|
1427
1445
|
|
|
1428
1446
|
function Program(program, scope) {
|
|
1429
1447
|
for (var i = 0; i < program.body.length; i++) {
|
|
1430
|
-
evaluate(program.body[i], scope);
|
|
1448
|
+
evaluate$1(program.body[i], scope);
|
|
1431
1449
|
}
|
|
1432
1450
|
}
|
|
1433
1451
|
|
|
@@ -1436,14 +1454,14 @@
|
|
|
1436
1454
|
Program: Program
|
|
1437
1455
|
});
|
|
1438
1456
|
|
|
1439
|
-
var evaluateOps;
|
|
1440
|
-
function evaluate(node, scope) {
|
|
1457
|
+
var evaluateOps$1;
|
|
1458
|
+
function evaluate$1(node, scope) {
|
|
1441
1459
|
if (!node)
|
|
1442
1460
|
return;
|
|
1443
|
-
if (!evaluateOps) {
|
|
1444
|
-
evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern, program);
|
|
1461
|
+
if (!evaluateOps$1) {
|
|
1462
|
+
evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$3, program);
|
|
1445
1463
|
}
|
|
1446
|
-
var handler = evaluateOps[node.type];
|
|
1464
|
+
var handler = evaluateOps$1[node.type];
|
|
1447
1465
|
if (handler) {
|
|
1448
1466
|
return handler(node, scope);
|
|
1449
1467
|
}
|
|
@@ -1452,60 +1470,130 @@
|
|
|
1452
1470
|
}
|
|
1453
1471
|
}
|
|
1454
1472
|
|
|
1455
|
-
function ExpressionStatement(node, scope) {
|
|
1456
|
-
evaluate(node.expression, scope);
|
|
1473
|
+
function ExpressionStatement$1(node, scope) {
|
|
1474
|
+
evaluate$1(node.expression, scope);
|
|
1457
1475
|
}
|
|
1458
|
-
function BlockStatement(block, scope, options) {
|
|
1476
|
+
function BlockStatement$1(block, scope, options) {
|
|
1459
1477
|
if (options === void 0) { options = {}; }
|
|
1460
1478
|
var _a = options.invasived, invasived = _a === void 0 ? false : _a, _b = options.hoisted, hoisted = _b === void 0 ? false : _b;
|
|
1461
1479
|
var subScope = invasived ? scope : new Scope(scope);
|
|
1462
1480
|
if (!hoisted) {
|
|
1463
|
-
hoist
|
|
1481
|
+
hoist(block, subScope, { onlyBlock: true });
|
|
1464
1482
|
}
|
|
1465
1483
|
for (var i = 0; i < block.body.length; i++) {
|
|
1466
|
-
var result = evaluate(block.body[i], subScope);
|
|
1467
|
-
if (result === BREAK
|
|
1484
|
+
var result = evaluate$1(block.body[i], subScope);
|
|
1485
|
+
if (result === BREAK) {
|
|
1486
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1487
|
+
break;
|
|
1488
|
+
}
|
|
1489
|
+
return result;
|
|
1490
|
+
}
|
|
1491
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1468
1492
|
return result;
|
|
1469
1493
|
}
|
|
1470
1494
|
}
|
|
1471
1495
|
}
|
|
1472
|
-
function EmptyStatement() {
|
|
1496
|
+
function EmptyStatement$1() {
|
|
1473
1497
|
}
|
|
1474
|
-
function DebuggerStatement() {
|
|
1498
|
+
function DebuggerStatement$1() {
|
|
1475
1499
|
debugger;
|
|
1476
1500
|
}
|
|
1477
|
-
function ReturnStatement(node, scope) {
|
|
1478
|
-
RETURN.RES = node.argument ? (evaluate(node.argument, scope)) : undefined;
|
|
1501
|
+
function ReturnStatement$1(node, scope) {
|
|
1502
|
+
RETURN.RES = node.argument ? (evaluate$1(node.argument, scope)) : undefined;
|
|
1479
1503
|
return RETURN;
|
|
1480
1504
|
}
|
|
1481
|
-
function BreakStatement() {
|
|
1505
|
+
function BreakStatement$1(node) {
|
|
1506
|
+
var _a;
|
|
1507
|
+
BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
1482
1508
|
return BREAK;
|
|
1483
1509
|
}
|
|
1484
|
-
function ContinueStatement() {
|
|
1510
|
+
function ContinueStatement$1(node) {
|
|
1511
|
+
var _a;
|
|
1512
|
+
CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
1485
1513
|
return CONTINUE;
|
|
1486
1514
|
}
|
|
1487
|
-
function
|
|
1488
|
-
|
|
1489
|
-
|
|
1515
|
+
function LabeledStatement$1(node, scope) {
|
|
1516
|
+
var label = node.label.name;
|
|
1517
|
+
if (node.body.type === 'WhileStatement') {
|
|
1518
|
+
return WhileStatement$1(node.body, scope, { label: label });
|
|
1490
1519
|
}
|
|
1491
|
-
|
|
1492
|
-
return
|
|
1520
|
+
if (node.body.type === 'DoWhileStatement') {
|
|
1521
|
+
return DoWhileStatement$1(node.body, scope, { label: label });
|
|
1522
|
+
}
|
|
1523
|
+
if (node.body.type === 'ForStatement') {
|
|
1524
|
+
return ForStatement$1(node.body, scope, { label: label });
|
|
1525
|
+
}
|
|
1526
|
+
if (node.body.type === 'ForInStatement') {
|
|
1527
|
+
return ForInStatement$1(node.body, scope, { label: label });
|
|
1528
|
+
}
|
|
1529
|
+
if (node.body.type === 'ForOfStatement') {
|
|
1530
|
+
return ForOfStatement$1(node.body, scope, { label: label });
|
|
1531
|
+
}
|
|
1532
|
+
if (node.body.type === 'BlockStatement') {
|
|
1533
|
+
return BlockStatement$1(node.body, scope, { label: label });
|
|
1534
|
+
}
|
|
1535
|
+
if (node.body.type === 'WithStatement') {
|
|
1536
|
+
return WithStatement$1(node.body, scope, { label: label });
|
|
1537
|
+
}
|
|
1538
|
+
if (node.body.type === 'IfStatement') {
|
|
1539
|
+
return IfStatement$1(node.body, scope, { label: label });
|
|
1540
|
+
}
|
|
1541
|
+
if (node.body.type === 'SwitchStatement') {
|
|
1542
|
+
return SwitchStatement$1(node.body, scope, { label: label });
|
|
1543
|
+
}
|
|
1544
|
+
if (node.body.type === 'TryStatement') {
|
|
1545
|
+
return TryStatement$1(node.body, scope, { label: label });
|
|
1546
|
+
}
|
|
1547
|
+
throw new SyntaxError(node.body.type + " cannot be labeled");
|
|
1548
|
+
}
|
|
1549
|
+
function WithStatement$1(node, scope, options) {
|
|
1550
|
+
if (options === void 0) { options = {}; }
|
|
1551
|
+
var withScope = new Scope(scope);
|
|
1552
|
+
withScope.with(evaluate$1(node.object, scope));
|
|
1553
|
+
var result = evaluate$1(node.body, withScope);
|
|
1554
|
+
if (result === BREAK) {
|
|
1555
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
return result;
|
|
1559
|
+
}
|
|
1560
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1561
|
+
return result;
|
|
1493
1562
|
}
|
|
1494
1563
|
}
|
|
1495
|
-
function
|
|
1496
|
-
|
|
1564
|
+
function IfStatement$1(node, scope, options) {
|
|
1565
|
+
if (options === void 0) { options = {}; }
|
|
1566
|
+
var result = evaluate$1(node.test, scope)
|
|
1567
|
+
? evaluate$1(node.consequent, scope)
|
|
1568
|
+
: evaluate$1(node.alternate, scope);
|
|
1569
|
+
if (result === BREAK) {
|
|
1570
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
return result;
|
|
1574
|
+
}
|
|
1575
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1576
|
+
return result;
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
function SwitchStatement$1(node, scope, options) {
|
|
1580
|
+
if (options === void 0) { options = {}; }
|
|
1581
|
+
var discriminant = evaluate$1(node.discriminant, scope);
|
|
1497
1582
|
var matched = false;
|
|
1498
1583
|
for (var i = 0; i < node.cases.length; i++) {
|
|
1499
1584
|
var eachCase = node.cases[i];
|
|
1500
1585
|
if (!matched
|
|
1501
1586
|
&& (!eachCase.test
|
|
1502
|
-
|| (evaluate(eachCase.test, scope)) === discriminant)) {
|
|
1587
|
+
|| (evaluate$1(eachCase.test, scope)) === discriminant)) {
|
|
1503
1588
|
matched = true;
|
|
1504
1589
|
}
|
|
1505
1590
|
if (matched) {
|
|
1506
|
-
var result = SwitchCase(eachCase, scope);
|
|
1591
|
+
var result = SwitchCase$1(eachCase, scope);
|
|
1507
1592
|
if (result === BREAK) {
|
|
1508
|
-
|
|
1593
|
+
if (result.LABEL === options.label) {
|
|
1594
|
+
break;
|
|
1595
|
+
}
|
|
1596
|
+
return result;
|
|
1509
1597
|
}
|
|
1510
1598
|
if (result === CONTINUE || result === RETURN) {
|
|
1511
1599
|
return result;
|
|
@@ -1513,20 +1601,22 @@
|
|
|
1513
1601
|
}
|
|
1514
1602
|
}
|
|
1515
1603
|
}
|
|
1516
|
-
function SwitchCase(node, scope) {
|
|
1604
|
+
function SwitchCase$1(node, scope) {
|
|
1517
1605
|
for (var i = 0; i < node.consequent.length; i++) {
|
|
1518
|
-
var result = evaluate(node.consequent[i], scope);
|
|
1606
|
+
var result = evaluate$1(node.consequent[i], scope);
|
|
1519
1607
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
1520
1608
|
return result;
|
|
1521
1609
|
}
|
|
1522
1610
|
}
|
|
1523
1611
|
}
|
|
1524
|
-
function ThrowStatement(node, scope) {
|
|
1525
|
-
throw evaluate(node.argument, scope);
|
|
1612
|
+
function ThrowStatement$1(node, scope) {
|
|
1613
|
+
throw evaluate$1(node.argument, scope);
|
|
1526
1614
|
}
|
|
1527
|
-
function TryStatement(node, scope) {
|
|
1615
|
+
function TryStatement$1(node, scope, options) {
|
|
1616
|
+
if (options === void 0) { options = {}; }
|
|
1617
|
+
var result;
|
|
1528
1618
|
try {
|
|
1529
|
-
|
|
1619
|
+
result = BlockStatement$1(node.block, scope);
|
|
1530
1620
|
}
|
|
1531
1621
|
catch (err) {
|
|
1532
1622
|
if (node.handler) {
|
|
@@ -1538,10 +1628,10 @@
|
|
|
1538
1628
|
subScope.var(name_1, err);
|
|
1539
1629
|
}
|
|
1540
1630
|
else {
|
|
1541
|
-
pattern
|
|
1631
|
+
pattern(param, scope, { feed: err });
|
|
1542
1632
|
}
|
|
1543
1633
|
}
|
|
1544
|
-
|
|
1634
|
+
result = CatchClause$1(node.handler, subScope);
|
|
1545
1635
|
}
|
|
1546
1636
|
else {
|
|
1547
1637
|
throw err;
|
|
@@ -1549,92 +1639,133 @@
|
|
|
1549
1639
|
}
|
|
1550
1640
|
finally {
|
|
1551
1641
|
if (node.finalizer) {
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1642
|
+
result = BlockStatement$1(node.finalizer, scope);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
if (result === BREAK) {
|
|
1646
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
1647
|
+
return;
|
|
1556
1648
|
}
|
|
1649
|
+
return result;
|
|
1650
|
+
}
|
|
1651
|
+
if (result === CONTINUE || result === RETURN) {
|
|
1652
|
+
return result;
|
|
1557
1653
|
}
|
|
1558
1654
|
}
|
|
1559
|
-
function CatchClause(node, scope) {
|
|
1560
|
-
return BlockStatement(node.body, scope, { invasived: true });
|
|
1655
|
+
function CatchClause$1(node, scope) {
|
|
1656
|
+
return BlockStatement$1(node.body, scope, { invasived: true });
|
|
1561
1657
|
}
|
|
1562
|
-
function WhileStatement(node, scope) {
|
|
1563
|
-
|
|
1564
|
-
|
|
1658
|
+
function WhileStatement$1(node, scope, options) {
|
|
1659
|
+
if (options === void 0) { options = {}; }
|
|
1660
|
+
while (evaluate$1(node.test, scope)) {
|
|
1661
|
+
var result = evaluate$1(node.body, scope);
|
|
1565
1662
|
if (result === BREAK) {
|
|
1566
|
-
|
|
1663
|
+
if (result.LABEL === options.label) {
|
|
1664
|
+
break;
|
|
1665
|
+
}
|
|
1666
|
+
return result;
|
|
1567
1667
|
}
|
|
1568
1668
|
else if (result === CONTINUE) {
|
|
1569
|
-
|
|
1669
|
+
if (result.LABEL === options.label) {
|
|
1670
|
+
continue;
|
|
1671
|
+
}
|
|
1672
|
+
return result;
|
|
1570
1673
|
}
|
|
1571
1674
|
else if (result === RETURN) {
|
|
1572
1675
|
return result;
|
|
1573
1676
|
}
|
|
1574
1677
|
}
|
|
1575
1678
|
}
|
|
1576
|
-
function DoWhileStatement(node, scope) {
|
|
1679
|
+
function DoWhileStatement$1(node, scope, options) {
|
|
1680
|
+
if (options === void 0) { options = {}; }
|
|
1577
1681
|
do {
|
|
1578
|
-
var result = evaluate(node.body, scope);
|
|
1682
|
+
var result = evaluate$1(node.body, scope);
|
|
1579
1683
|
if (result === BREAK) {
|
|
1580
|
-
|
|
1684
|
+
if (result.LABEL === options.label) {
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
return result;
|
|
1581
1688
|
}
|
|
1582
1689
|
else if (result === CONTINUE) {
|
|
1583
|
-
|
|
1690
|
+
if (result.LABEL === options.label) {
|
|
1691
|
+
continue;
|
|
1692
|
+
}
|
|
1693
|
+
return result;
|
|
1584
1694
|
}
|
|
1585
1695
|
else if (result === RETURN) {
|
|
1586
1696
|
return result;
|
|
1587
1697
|
}
|
|
1588
|
-
} while (evaluate(node.test, scope));
|
|
1698
|
+
} while (evaluate$1(node.test, scope));
|
|
1589
1699
|
}
|
|
1590
|
-
function ForStatement(node, scope) {
|
|
1700
|
+
function ForStatement$1(node, scope, options) {
|
|
1701
|
+
if (options === void 0) { options = {}; }
|
|
1591
1702
|
var forScope = new Scope(scope);
|
|
1592
|
-
for (evaluate(node.init, forScope); node.test ? (evaluate(node.test, forScope)) : true; evaluate(node.update, forScope)) {
|
|
1703
|
+
for (evaluate$1(node.init, forScope); node.test ? (evaluate$1(node.test, forScope)) : true; evaluate$1(node.update, forScope)) {
|
|
1593
1704
|
var subScope = new Scope(forScope);
|
|
1594
1705
|
var result = void 0;
|
|
1595
1706
|
if (node.body.type === 'BlockStatement') {
|
|
1596
|
-
result = BlockStatement(node.body, subScope, { invasived: true });
|
|
1707
|
+
result = BlockStatement$1(node.body, subScope, { invasived: true });
|
|
1597
1708
|
}
|
|
1598
1709
|
else {
|
|
1599
|
-
result = evaluate(node.body, subScope);
|
|
1710
|
+
result = evaluate$1(node.body, subScope);
|
|
1600
1711
|
}
|
|
1601
1712
|
if (result === BREAK) {
|
|
1602
|
-
|
|
1713
|
+
if (result.LABEL === options.label) {
|
|
1714
|
+
break;
|
|
1715
|
+
}
|
|
1716
|
+
return result;
|
|
1603
1717
|
}
|
|
1604
1718
|
else if (result === CONTINUE) {
|
|
1605
|
-
|
|
1719
|
+
if (result.LABEL === options.label) {
|
|
1720
|
+
continue;
|
|
1721
|
+
}
|
|
1722
|
+
return result;
|
|
1606
1723
|
}
|
|
1607
1724
|
else if (result === RETURN) {
|
|
1608
1725
|
return result;
|
|
1609
1726
|
}
|
|
1610
1727
|
}
|
|
1611
1728
|
}
|
|
1612
|
-
function ForInStatement(node, scope) {
|
|
1613
|
-
|
|
1614
|
-
|
|
1729
|
+
function ForInStatement$1(node, scope, options) {
|
|
1730
|
+
if (options === void 0) { options = {}; }
|
|
1731
|
+
for (var value in evaluate$1(node.right, scope)) {
|
|
1732
|
+
var result = ForXHandler(node, scope, { value: value });
|
|
1615
1733
|
if (result === BREAK) {
|
|
1616
|
-
|
|
1734
|
+
if (result.LABEL === options.label) {
|
|
1735
|
+
break;
|
|
1736
|
+
}
|
|
1737
|
+
return result;
|
|
1617
1738
|
}
|
|
1618
1739
|
else if (result === CONTINUE) {
|
|
1619
|
-
|
|
1740
|
+
if (result.LABEL === options.label) {
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
return result;
|
|
1620
1744
|
}
|
|
1621
1745
|
else if (result === RETURN) {
|
|
1622
1746
|
return result;
|
|
1623
1747
|
}
|
|
1624
1748
|
}
|
|
1625
1749
|
}
|
|
1626
|
-
function ForOfStatement(node, scope) {
|
|
1750
|
+
function ForOfStatement$1(node, scope, options) {
|
|
1627
1751
|
var e_1, _a;
|
|
1628
|
-
|
|
1752
|
+
if (options === void 0) { options = {}; }
|
|
1753
|
+
var right = evaluate$1(node.right, scope);
|
|
1629
1754
|
try {
|
|
1630
1755
|
for (var right_1 = __values(right), right_1_1 = right_1.next(); !right_1_1.done; right_1_1 = right_1.next()) {
|
|
1631
1756
|
var value = right_1_1.value;
|
|
1632
|
-
var result = ForXHandler
|
|
1757
|
+
var result = ForXHandler(node, scope, { value: value });
|
|
1633
1758
|
if (result === BREAK) {
|
|
1634
|
-
|
|
1759
|
+
if (result.LABEL === options.label) {
|
|
1760
|
+
break;
|
|
1761
|
+
}
|
|
1762
|
+
return result;
|
|
1635
1763
|
}
|
|
1636
1764
|
else if (result === CONTINUE) {
|
|
1637
|
-
|
|
1765
|
+
if (result.LABEL === options.label) {
|
|
1766
|
+
continue;
|
|
1767
|
+
}
|
|
1768
|
+
return result;
|
|
1638
1769
|
}
|
|
1639
1770
|
else if (result === RETURN) {
|
|
1640
1771
|
return result;
|
|
@@ -1650,16 +1781,16 @@
|
|
|
1650
1781
|
}
|
|
1651
1782
|
}
|
|
1652
1783
|
|
|
1653
|
-
function FunctionDeclaration(node, scope) {
|
|
1654
|
-
scope.func(node.id.name, createFunc
|
|
1784
|
+
function FunctionDeclaration$1(node, scope) {
|
|
1785
|
+
scope.func(node.id.name, createFunc(node, scope));
|
|
1655
1786
|
}
|
|
1656
|
-
function VariableDeclaration(node, scope, options) {
|
|
1787
|
+
function VariableDeclaration$1(node, scope, options) {
|
|
1657
1788
|
if (options === void 0) { options = {}; }
|
|
1658
1789
|
for (var i = 0; i < node.declarations.length; i++) {
|
|
1659
|
-
VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
|
|
1790
|
+
VariableDeclarator$1(node.declarations[i], scope, assign({ kind: node.kind }, options));
|
|
1660
1791
|
}
|
|
1661
1792
|
}
|
|
1662
|
-
function VariableDeclarator(node, scope, options) {
|
|
1793
|
+
function VariableDeclarator$1(node, scope, options) {
|
|
1663
1794
|
if (options === void 0) { options = {}; }
|
|
1664
1795
|
var _a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, feed = options.feed;
|
|
1665
1796
|
if (hoist) {
|
|
@@ -1668,13 +1799,13 @@
|
|
|
1668
1799
|
scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1669
1800
|
}
|
|
1670
1801
|
else {
|
|
1671
|
-
pattern
|
|
1802
|
+
pattern(node.id, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock });
|
|
1672
1803
|
}
|
|
1673
1804
|
}
|
|
1674
1805
|
}
|
|
1675
1806
|
else {
|
|
1676
1807
|
var hasFeed = 'feed' in options;
|
|
1677
|
-
var value = hasFeed ? feed : evaluate(node.init, scope);
|
|
1808
|
+
var value = hasFeed ? feed : evaluate$1(node.init, scope);
|
|
1678
1809
|
if (node.id.type === 'Identifier') {
|
|
1679
1810
|
var name_1 = node.id.name;
|
|
1680
1811
|
if (kind === 'var' && !node.init && !hasFeed) {
|
|
@@ -1694,36 +1825,36 @@
|
|
|
1694
1825
|
}
|
|
1695
1826
|
}
|
|
1696
1827
|
else {
|
|
1697
|
-
pattern
|
|
1828
|
+
pattern(node.id, scope, { kind: kind, feed: value });
|
|
1698
1829
|
}
|
|
1699
1830
|
}
|
|
1700
1831
|
}
|
|
1701
|
-
function ClassDeclaration(node, scope) {
|
|
1702
|
-
scope.func(node.id.name, createClass
|
|
1832
|
+
function ClassDeclaration$1(node, scope) {
|
|
1833
|
+
scope.func(node.id.name, createClass(node, scope));
|
|
1703
1834
|
}
|
|
1704
|
-
function ClassBody(node, scope, options) {
|
|
1835
|
+
function ClassBody$1(node, scope, options) {
|
|
1705
1836
|
if (options === void 0) { options = {}; }
|
|
1706
1837
|
var klass = options.klass, superClass = options.superClass;
|
|
1707
1838
|
for (var i = 0; i < node.body.length; i++) {
|
|
1708
1839
|
var def = node.body[i];
|
|
1709
1840
|
if (def.type === 'MethodDefinition') {
|
|
1710
|
-
MethodDefinition(def, scope, { klass: klass, superClass: superClass });
|
|
1841
|
+
MethodDefinition$1(def, scope, { klass: klass, superClass: superClass });
|
|
1711
1842
|
}
|
|
1712
1843
|
else if (def.type === 'PropertyDefinition' && def.static) {
|
|
1713
|
-
PropertyDefinition(def, scope, { klass: klass, superClass: superClass });
|
|
1844
|
+
PropertyDefinition$1(def, scope, { klass: klass, superClass: superClass });
|
|
1714
1845
|
}
|
|
1715
1846
|
else if (def.type === 'StaticBlock') {
|
|
1716
|
-
StaticBlock(def, scope, { klass: klass, superClass: superClass });
|
|
1847
|
+
StaticBlock$1(def, scope, { klass: klass, superClass: superClass });
|
|
1717
1848
|
}
|
|
1718
1849
|
}
|
|
1719
1850
|
}
|
|
1720
|
-
function MethodDefinition(node, scope, options) {
|
|
1851
|
+
function MethodDefinition$1(node, scope, options) {
|
|
1721
1852
|
if (options === void 0) { options = {}; }
|
|
1722
1853
|
var klass = options.klass, superClass = options.superClass;
|
|
1723
1854
|
var key;
|
|
1724
1855
|
var priv = false;
|
|
1725
1856
|
if (node.computed) {
|
|
1726
|
-
key = evaluate(node.key, scope);
|
|
1857
|
+
key = evaluate$1(node.key, scope);
|
|
1727
1858
|
}
|
|
1728
1859
|
else if (node.key.type === 'Identifier') {
|
|
1729
1860
|
key = node.key.name;
|
|
@@ -1742,7 +1873,7 @@
|
|
|
1742
1873
|
}
|
|
1743
1874
|
obj = obj[PRIVATE];
|
|
1744
1875
|
}
|
|
1745
|
-
var value = createFunc
|
|
1876
|
+
var value = createFunc(node.value, scope, { superClass: superClass });
|
|
1746
1877
|
switch (node.kind) {
|
|
1747
1878
|
case 'constructor':
|
|
1748
1879
|
break;
|
|
@@ -1775,13 +1906,13 @@
|
|
|
1775
1906
|
throw new SyntaxError('Unexpected token');
|
|
1776
1907
|
}
|
|
1777
1908
|
}
|
|
1778
|
-
function PropertyDefinition(node, scope, options) {
|
|
1909
|
+
function PropertyDefinition$1(node, scope, options) {
|
|
1779
1910
|
if (options === void 0) { options = {}; }
|
|
1780
1911
|
var klass = options.klass, superClass = options.superClass;
|
|
1781
1912
|
var key;
|
|
1782
1913
|
var priv = false;
|
|
1783
1914
|
if (node.computed) {
|
|
1784
|
-
key = evaluate(node.key, scope);
|
|
1915
|
+
key = evaluate$1(node.key, scope);
|
|
1785
1916
|
}
|
|
1786
1917
|
else if (node.key.type === 'Identifier') {
|
|
1787
1918
|
key = node.key.name;
|
|
@@ -1803,20 +1934,20 @@
|
|
|
1803
1934
|
obj = obj[PRIVATE];
|
|
1804
1935
|
}
|
|
1805
1936
|
if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
|
|
1806
|
-
obj[key] = createFunc
|
|
1937
|
+
obj[key] = createFunc(node.value, subScope, { superClass: superClass });
|
|
1807
1938
|
}
|
|
1808
1939
|
else {
|
|
1809
|
-
obj[key] = evaluate(node.value, subScope);
|
|
1940
|
+
obj[key] = evaluate$1(node.value, subScope);
|
|
1810
1941
|
}
|
|
1811
1942
|
}
|
|
1812
|
-
function StaticBlock(node, scope, options) {
|
|
1943
|
+
function StaticBlock$1(node, scope, options) {
|
|
1813
1944
|
if (options === void 0) { options = {}; }
|
|
1814
1945
|
var klass = options.klass;
|
|
1815
1946
|
var subScope = new Scope(scope, true);
|
|
1816
1947
|
subScope.const('this', klass);
|
|
1817
|
-
return BlockStatement(node, subScope, { invasived: true });
|
|
1948
|
+
return BlockStatement$1(node, subScope, { invasived: true });
|
|
1818
1949
|
}
|
|
1819
|
-
function ImportDeclaration(node, scope) {
|
|
1950
|
+
function ImportDeclaration$1(node, scope) {
|
|
1820
1951
|
var globalScope = scope.global();
|
|
1821
1952
|
var module = globalScope.find(IMPORT + node.source.value);
|
|
1822
1953
|
var value;
|
|
@@ -1853,19 +1984,19 @@
|
|
|
1853
1984
|
scope.var(spec.local.name, name_2 === '*' ? assign({}, value) : value[name_2]);
|
|
1854
1985
|
}
|
|
1855
1986
|
}
|
|
1856
|
-
function ExportDefaultDeclaration(node, scope) {
|
|
1987
|
+
function ExportDefaultDeclaration$1(node, scope) {
|
|
1857
1988
|
var globalScope = scope.global();
|
|
1858
1989
|
var value;
|
|
1859
1990
|
if (node.declaration.type === 'FunctionDeclaration') {
|
|
1860
|
-
value = createFunc
|
|
1991
|
+
value = createFunc(node.declaration, scope);
|
|
1861
1992
|
scope.func(node.declaration.id.name, value);
|
|
1862
1993
|
}
|
|
1863
1994
|
else if (node.declaration.type === 'ClassDeclaration') {
|
|
1864
|
-
value = createClass
|
|
1995
|
+
value = createClass(node.declaration, scope);
|
|
1865
1996
|
scope.func(node.declaration.id.name, value);
|
|
1866
1997
|
}
|
|
1867
1998
|
else {
|
|
1868
|
-
value = evaluate(node.declaration, scope);
|
|
1999
|
+
value = evaluate$1(node.declaration, scope);
|
|
1869
2000
|
}
|
|
1870
2001
|
var variable = globalScope.find(EXPORTS);
|
|
1871
2002
|
if (variable) {
|
|
@@ -1875,11 +2006,11 @@
|
|
|
1875
2006
|
}
|
|
1876
2007
|
}
|
|
1877
2008
|
}
|
|
1878
|
-
function ExportNamedDeclaration(node, scope) {
|
|
2009
|
+
function ExportNamedDeclaration$1(node, scope) {
|
|
1879
2010
|
var globalScope = scope.global();
|
|
1880
2011
|
if (node.declaration) {
|
|
1881
2012
|
if (node.declaration.type === 'FunctionDeclaration') {
|
|
1882
|
-
var value = createFunc
|
|
2013
|
+
var value = createFunc(node.declaration, scope);
|
|
1883
2014
|
scope.func(node.declaration.id.name, value);
|
|
1884
2015
|
var variable = globalScope.find(EXPORTS);
|
|
1885
2016
|
if (variable) {
|
|
@@ -1890,7 +2021,7 @@
|
|
|
1890
2021
|
}
|
|
1891
2022
|
}
|
|
1892
2023
|
else if (node.declaration.type === 'ClassDeclaration') {
|
|
1893
|
-
var value = createClass
|
|
2024
|
+
var value = createClass(node.declaration, scope);
|
|
1894
2025
|
scope.func(node.declaration.id.name, value);
|
|
1895
2026
|
var variable = globalScope.find(EXPORTS);
|
|
1896
2027
|
if (variable) {
|
|
@@ -1901,7 +2032,7 @@
|
|
|
1901
2032
|
}
|
|
1902
2033
|
}
|
|
1903
2034
|
else if (node.declaration.type === 'VariableDeclaration') {
|
|
1904
|
-
VariableDeclaration(node.declaration, scope);
|
|
2035
|
+
VariableDeclaration$1(node.declaration, scope);
|
|
1905
2036
|
var variable = globalScope.find(EXPORTS);
|
|
1906
2037
|
if (variable) {
|
|
1907
2038
|
var exports_4 = variable.get();
|
|
@@ -1936,7 +2067,7 @@
|
|
|
1936
2067
|
}
|
|
1937
2068
|
}
|
|
1938
2069
|
}
|
|
1939
|
-
function ExportAllDeclaration(node, scope) {
|
|
2070
|
+
function ExportAllDeclaration$1(node, scope) {
|
|
1940
2071
|
var globalScope = scope.global();
|
|
1941
2072
|
var module = globalScope.find(IMPORT + node.source.value);
|
|
1942
2073
|
var value;
|
|
@@ -1963,7 +2094,7 @@
|
|
|
1963
2094
|
}
|
|
1964
2095
|
}
|
|
1965
2096
|
|
|
1966
|
-
function Identifier
|
|
2097
|
+
function Identifier(node, scope, options) {
|
|
1967
2098
|
var _a, getVar, _b, throwErr, variable, value;
|
|
1968
2099
|
if (options === void 0) { options = {}; }
|
|
1969
2100
|
return __generator(this, function (_c) {
|
|
@@ -1995,23 +2126,23 @@
|
|
|
1995
2126
|
});
|
|
1996
2127
|
}
|
|
1997
2128
|
|
|
1998
|
-
var identifier
|
|
2129
|
+
var identifier = /*#__PURE__*/Object.freeze({
|
|
1999
2130
|
__proto__: null,
|
|
2000
|
-
Identifier: Identifier
|
|
2131
|
+
Identifier: Identifier
|
|
2001
2132
|
});
|
|
2002
2133
|
|
|
2003
|
-
function Literal
|
|
2134
|
+
function Literal(node, scope) {
|
|
2004
2135
|
return __generator(this, function (_a) {
|
|
2005
2136
|
return [2, node.value];
|
|
2006
2137
|
});
|
|
2007
2138
|
}
|
|
2008
2139
|
|
|
2009
|
-
var literal
|
|
2140
|
+
var literal = /*#__PURE__*/Object.freeze({
|
|
2010
2141
|
__proto__: null,
|
|
2011
|
-
Literal: Literal
|
|
2142
|
+
Literal: Literal
|
|
2012
2143
|
});
|
|
2013
2144
|
|
|
2014
|
-
function ThisExpression
|
|
2145
|
+
function ThisExpression(node, scope) {
|
|
2015
2146
|
var superCall;
|
|
2016
2147
|
return __generator(this, function (_a) {
|
|
2017
2148
|
superCall = scope.find(SUPERCALL);
|
|
@@ -2024,7 +2155,7 @@
|
|
|
2024
2155
|
}
|
|
2025
2156
|
});
|
|
2026
2157
|
}
|
|
2027
|
-
function ArrayExpression
|
|
2158
|
+
function ArrayExpression(node, scope) {
|
|
2028
2159
|
var results, i, item, _a, _b, _c, _d;
|
|
2029
2160
|
return __generator(this, function (_e) {
|
|
2030
2161
|
switch (_e.label) {
|
|
@@ -2037,13 +2168,13 @@
|
|
|
2037
2168
|
item = node.elements[i];
|
|
2038
2169
|
if (!(item.type === 'SpreadElement')) return [3, 3];
|
|
2039
2170
|
_b = (_a = results).concat;
|
|
2040
|
-
return [5, __values(SpreadElement
|
|
2171
|
+
return [5, __values(SpreadElement(item, scope))];
|
|
2041
2172
|
case 2:
|
|
2042
2173
|
results = _b.apply(_a, [_e.sent()]);
|
|
2043
2174
|
return [3, 5];
|
|
2044
2175
|
case 3:
|
|
2045
2176
|
_d = (_c = results).push;
|
|
2046
|
-
return [5, __values(evaluate
|
|
2177
|
+
return [5, __values(evaluate(item, scope))];
|
|
2047
2178
|
case 4:
|
|
2048
2179
|
_d.apply(_c, [_e.sent()]);
|
|
2049
2180
|
_e.label = 5;
|
|
@@ -2054,7 +2185,7 @@
|
|
|
2054
2185
|
}
|
|
2055
2186
|
});
|
|
2056
2187
|
}
|
|
2057
|
-
function ObjectExpression
|
|
2188
|
+
function ObjectExpression(node, scope) {
|
|
2058
2189
|
var object, i, property, _a, _b, key, propKey, _c, value, propKind, oriDptor, oriDptor;
|
|
2059
2190
|
return __generator(this, function (_d) {
|
|
2060
2191
|
switch (_d.label) {
|
|
@@ -2068,7 +2199,7 @@
|
|
|
2068
2199
|
if (!(property.type === 'SpreadElement')) return [3, 3];
|
|
2069
2200
|
_a = assign;
|
|
2070
2201
|
_b = [object];
|
|
2071
|
-
return [5, __values(SpreadElement
|
|
2202
|
+
return [5, __values(SpreadElement(property, scope))];
|
|
2072
2203
|
case 2:
|
|
2073
2204
|
_a.apply(void 0, _b.concat([_d.sent()]));
|
|
2074
2205
|
return [3, 10];
|
|
@@ -2076,7 +2207,7 @@
|
|
|
2076
2207
|
key = void 0;
|
|
2077
2208
|
propKey = property.key;
|
|
2078
2209
|
if (!property.computed) return [3, 5];
|
|
2079
|
-
return [5, __values(evaluate
|
|
2210
|
+
return [5, __values(evaluate(propKey, scope))];
|
|
2080
2211
|
case 4:
|
|
2081
2212
|
key = _d.sent();
|
|
2082
2213
|
return [3, 8];
|
|
@@ -2086,11 +2217,11 @@
|
|
|
2086
2217
|
return [3, 8];
|
|
2087
2218
|
case 6:
|
|
2088
2219
|
_c = '';
|
|
2089
|
-
return [5, __values(Literal
|
|
2220
|
+
return [5, __values(Literal(propKey))];
|
|
2090
2221
|
case 7:
|
|
2091
2222
|
key = _c + (_d.sent());
|
|
2092
2223
|
_d.label = 8;
|
|
2093
|
-
case 8: return [5, __values(evaluate
|
|
2224
|
+
case 8: return [5, __values(evaluate(property.value, scope))];
|
|
2094
2225
|
case 9:
|
|
2095
2226
|
value = _d.sent();
|
|
2096
2227
|
propKind = property.kind;
|
|
@@ -2123,21 +2254,21 @@
|
|
|
2123
2254
|
}
|
|
2124
2255
|
});
|
|
2125
2256
|
}
|
|
2126
|
-
function FunctionExpression
|
|
2257
|
+
function FunctionExpression(node, scope) {
|
|
2127
2258
|
var tmpScope, func;
|
|
2128
2259
|
return __generator(this, function (_a) {
|
|
2129
2260
|
if (node.id && node.id.name) {
|
|
2130
2261
|
tmpScope = new Scope(scope);
|
|
2131
|
-
func = createFunc(node, tmpScope);
|
|
2262
|
+
func = createFunc$1(node, tmpScope);
|
|
2132
2263
|
tmpScope.const(node.id.name, func);
|
|
2133
2264
|
return [2, func];
|
|
2134
2265
|
}
|
|
2135
2266
|
else {
|
|
2136
|
-
return [2, createFunc(node, scope)];
|
|
2267
|
+
return [2, createFunc$1(node, scope)];
|
|
2137
2268
|
}
|
|
2138
2269
|
});
|
|
2139
2270
|
}
|
|
2140
|
-
function UnaryExpression
|
|
2271
|
+
function UnaryExpression(node, scope) {
|
|
2141
2272
|
var arg, _a, variable;
|
|
2142
2273
|
return __generator(this, function (_b) {
|
|
2143
2274
|
switch (_b.label) {
|
|
@@ -2154,32 +2285,32 @@
|
|
|
2154
2285
|
case 'delete': return [3, 15];
|
|
2155
2286
|
}
|
|
2156
2287
|
return [3, 20];
|
|
2157
|
-
case 1: return [5, __values(evaluate
|
|
2288
|
+
case 1: return [5, __values(evaluate(arg, scope))];
|
|
2158
2289
|
case 2: return [2, +(_b.sent())];
|
|
2159
|
-
case 3: return [5, __values(evaluate
|
|
2290
|
+
case 3: return [5, __values(evaluate(arg, scope))];
|
|
2160
2291
|
case 4: return [2, -(_b.sent())];
|
|
2161
|
-
case 5: return [5, __values(evaluate
|
|
2292
|
+
case 5: return [5, __values(evaluate(arg, scope))];
|
|
2162
2293
|
case 6: return [2, !(_b.sent())];
|
|
2163
|
-
case 7: return [5, __values(evaluate
|
|
2294
|
+
case 7: return [5, __values(evaluate(arg, scope))];
|
|
2164
2295
|
case 8: return [2, ~(_b.sent())];
|
|
2165
|
-
case 9: return [5, __values(evaluate
|
|
2296
|
+
case 9: return [5, __values(evaluate(arg, scope))];
|
|
2166
2297
|
case 10: return [2, void (_b.sent())];
|
|
2167
2298
|
case 11:
|
|
2168
2299
|
if (!(arg.type === 'Identifier')) return [3, 13];
|
|
2169
|
-
return [5, __values(Identifier
|
|
2300
|
+
return [5, __values(Identifier(arg, scope, { throwErr: false }))];
|
|
2170
2301
|
case 12: return [2, typeof (_b.sent())];
|
|
2171
|
-
case 13: return [5, __values(evaluate
|
|
2302
|
+
case 13: return [5, __values(evaluate(arg, scope))];
|
|
2172
2303
|
case 14: return [2, typeof (_b.sent())];
|
|
2173
2304
|
case 15:
|
|
2174
2305
|
if (!(arg.type === 'MemberExpression')) return [3, 17];
|
|
2175
|
-
return [5, __values(MemberExpression
|
|
2306
|
+
return [5, __values(MemberExpression(arg, scope, { getVar: true }))];
|
|
2176
2307
|
case 16:
|
|
2177
2308
|
variable = _b.sent();
|
|
2178
2309
|
return [2, variable.del()];
|
|
2179
2310
|
case 17:
|
|
2180
2311
|
if (!(arg.type === 'Identifier')) return [3, 18];
|
|
2181
2312
|
throw new SyntaxError('Delete of an unqualified identifier in strict mode');
|
|
2182
|
-
case 18: return [5, __values(evaluate
|
|
2313
|
+
case 18: return [5, __values(evaluate(arg, scope))];
|
|
2183
2314
|
case 19:
|
|
2184
2315
|
_b.sent();
|
|
2185
2316
|
return [2, true];
|
|
@@ -2187,20 +2318,20 @@
|
|
|
2187
2318
|
}
|
|
2188
2319
|
});
|
|
2189
2320
|
}
|
|
2190
|
-
function UpdateExpression
|
|
2321
|
+
function UpdateExpression(node, scope) {
|
|
2191
2322
|
var arg, variable, value;
|
|
2192
2323
|
return __generator(this, function (_a) {
|
|
2193
2324
|
switch (_a.label) {
|
|
2194
2325
|
case 0:
|
|
2195
2326
|
arg = node.argument;
|
|
2196
2327
|
if (!(arg.type === 'Identifier')) return [3, 2];
|
|
2197
|
-
return [5, __values(Identifier
|
|
2328
|
+
return [5, __values(Identifier(arg, scope, { getVar: true }))];
|
|
2198
2329
|
case 1:
|
|
2199
2330
|
variable = _a.sent();
|
|
2200
2331
|
return [3, 5];
|
|
2201
2332
|
case 2:
|
|
2202
2333
|
if (!(arg.type === 'MemberExpression')) return [3, 4];
|
|
2203
|
-
return [5, __values(MemberExpression
|
|
2334
|
+
return [5, __values(MemberExpression(arg, scope, { getVar: true }))];
|
|
2204
2335
|
case 3:
|
|
2205
2336
|
variable = _a.sent();
|
|
2206
2337
|
return [3, 5];
|
|
@@ -2221,22 +2352,22 @@
|
|
|
2221
2352
|
}
|
|
2222
2353
|
});
|
|
2223
2354
|
}
|
|
2224
|
-
function BinaryExpression
|
|
2355
|
+
function BinaryExpression(node, scope) {
|
|
2225
2356
|
var left, right;
|
|
2226
2357
|
return __generator(this, function (_a) {
|
|
2227
2358
|
switch (_a.label) {
|
|
2228
2359
|
case 0:
|
|
2229
2360
|
if (!(node.left.type === 'PrivateIdentifier')) return [3, 2];
|
|
2230
2361
|
left = node.left.name;
|
|
2231
|
-
return [5, __values(evaluate
|
|
2362
|
+
return [5, __values(evaluate(node.right, scope))];
|
|
2232
2363
|
case 1:
|
|
2233
2364
|
right = _a.sent();
|
|
2234
2365
|
right = right[PRIVATE];
|
|
2235
2366
|
return [3, 5];
|
|
2236
|
-
case 2: return [5, __values(evaluate
|
|
2367
|
+
case 2: return [5, __values(evaluate(node.left, scope))];
|
|
2237
2368
|
case 3:
|
|
2238
2369
|
left = _a.sent();
|
|
2239
|
-
return [5, __values(evaluate
|
|
2370
|
+
return [5, __values(evaluate(node.right, scope))];
|
|
2240
2371
|
case 4:
|
|
2241
2372
|
right = _a.sent();
|
|
2242
2373
|
_a.label = 5;
|
|
@@ -2269,7 +2400,7 @@
|
|
|
2269
2400
|
}
|
|
2270
2401
|
});
|
|
2271
2402
|
}
|
|
2272
|
-
function AssignmentExpression
|
|
2403
|
+
function AssignmentExpression(node, scope) {
|
|
2273
2404
|
var left, variable, win, value_1, value;
|
|
2274
2405
|
var _a;
|
|
2275
2406
|
return __generator(this, function (_b) {
|
|
@@ -2277,7 +2408,7 @@
|
|
|
2277
2408
|
case 0:
|
|
2278
2409
|
left = node.left;
|
|
2279
2410
|
if (!(left.type === 'Identifier')) return [3, 2];
|
|
2280
|
-
return [5, __values(Identifier
|
|
2411
|
+
return [5, __values(Identifier(left, scope, { getVar: true, throwErr: false }))];
|
|
2281
2412
|
case 1:
|
|
2282
2413
|
variable = _b.sent();
|
|
2283
2414
|
if (!variable) {
|
|
@@ -2287,16 +2418,16 @@
|
|
|
2287
2418
|
return [3, 7];
|
|
2288
2419
|
case 2:
|
|
2289
2420
|
if (!(left.type === 'MemberExpression')) return [3, 4];
|
|
2290
|
-
return [5, __values(MemberExpression
|
|
2421
|
+
return [5, __values(MemberExpression(left, scope, { getVar: true }))];
|
|
2291
2422
|
case 3:
|
|
2292
2423
|
variable = _b.sent();
|
|
2293
2424
|
return [3, 7];
|
|
2294
|
-
case 4: return [5, __values(evaluate
|
|
2425
|
+
case 4: return [5, __values(evaluate(node.right, scope))];
|
|
2295
2426
|
case 5:
|
|
2296
2427
|
value_1 = _b.sent();
|
|
2297
|
-
return [5, __values(pattern$
|
|
2428
|
+
return [5, __values(pattern$1(left, scope, { feed: value_1 }))];
|
|
2298
2429
|
case 6: return [2, _b.sent()];
|
|
2299
|
-
case 7: return [5, __values(evaluate
|
|
2430
|
+
case 7: return [5, __values(evaluate(node.right, scope))];
|
|
2300
2431
|
case 8:
|
|
2301
2432
|
value = _b.sent();
|
|
2302
2433
|
switch (node.operator) {
|
|
@@ -2353,7 +2484,7 @@
|
|
|
2353
2484
|
}
|
|
2354
2485
|
});
|
|
2355
2486
|
}
|
|
2356
|
-
function LogicalExpression
|
|
2487
|
+
function LogicalExpression(node, scope) {
|
|
2357
2488
|
var _a, _b, _c, _d;
|
|
2358
2489
|
var _e;
|
|
2359
2490
|
return __generator(this, function (_f) {
|
|
@@ -2366,30 +2497,30 @@
|
|
|
2366
2497
|
case '??': return [3, 9];
|
|
2367
2498
|
}
|
|
2368
2499
|
return [3, 14];
|
|
2369
|
-
case 1: return [5, __values(evaluate
|
|
2500
|
+
case 1: return [5, __values(evaluate(node.left, scope))];
|
|
2370
2501
|
case 2:
|
|
2371
2502
|
_b = (_f.sent());
|
|
2372
2503
|
if (_b) return [3, 4];
|
|
2373
|
-
return [5, __values(evaluate
|
|
2504
|
+
return [5, __values(evaluate(node.right, scope))];
|
|
2374
2505
|
case 3:
|
|
2375
2506
|
_b = (_f.sent());
|
|
2376
2507
|
_f.label = 4;
|
|
2377
2508
|
case 4: return [2, _b];
|
|
2378
|
-
case 5: return [5, __values(evaluate
|
|
2509
|
+
case 5: return [5, __values(evaluate(node.left, scope))];
|
|
2379
2510
|
case 6:
|
|
2380
2511
|
_c = (_f.sent());
|
|
2381
2512
|
if (!_c) return [3, 8];
|
|
2382
|
-
return [5, __values(evaluate
|
|
2513
|
+
return [5, __values(evaluate(node.right, scope))];
|
|
2383
2514
|
case 7:
|
|
2384
2515
|
_c = (_f.sent());
|
|
2385
2516
|
_f.label = 8;
|
|
2386
2517
|
case 8: return [2, _c];
|
|
2387
|
-
case 9: return [5, __values(evaluate
|
|
2518
|
+
case 9: return [5, __values(evaluate(node.left, scope))];
|
|
2388
2519
|
case 10:
|
|
2389
2520
|
if (!((_e = (_f.sent())) !== null && _e !== void 0)) return [3, 11];
|
|
2390
2521
|
_d = _e;
|
|
2391
2522
|
return [3, 13];
|
|
2392
|
-
case 11: return [5, __values(evaluate
|
|
2523
|
+
case 11: return [5, __values(evaluate(node.right, scope))];
|
|
2393
2524
|
case 12:
|
|
2394
2525
|
_d = (_f.sent());
|
|
2395
2526
|
_f.label = 13;
|
|
@@ -2398,7 +2529,7 @@
|
|
|
2398
2529
|
}
|
|
2399
2530
|
});
|
|
2400
2531
|
}
|
|
2401
|
-
function MemberExpression
|
|
2532
|
+
function MemberExpression(node, scope, options) {
|
|
2402
2533
|
var _a, getObj, _b, getVar, object, key, priv, setter, thisObject, privateKey, getter, thisObject;
|
|
2403
2534
|
if (options === void 0) { options = {}; }
|
|
2404
2535
|
return __generator(this, function (_c) {
|
|
@@ -2406,11 +2537,11 @@
|
|
|
2406
2537
|
case 0:
|
|
2407
2538
|
_a = options.getObj, getObj = _a === void 0 ? false : _a, _b = options.getVar, getVar = _b === void 0 ? false : _b;
|
|
2408
2539
|
if (!(node.object.type === 'Super')) return [3, 2];
|
|
2409
|
-
return [5, __values(Super
|
|
2540
|
+
return [5, __values(Super(node.object, scope, { getProto: true }))];
|
|
2410
2541
|
case 1:
|
|
2411
2542
|
object = _c.sent();
|
|
2412
2543
|
return [3, 4];
|
|
2413
|
-
case 2: return [5, __values(evaluate
|
|
2544
|
+
case 2: return [5, __values(evaluate(node.object, scope))];
|
|
2414
2545
|
case 3:
|
|
2415
2546
|
object = _c.sent();
|
|
2416
2547
|
_c.label = 4;
|
|
@@ -2419,7 +2550,7 @@
|
|
|
2419
2550
|
return [2, object];
|
|
2420
2551
|
priv = false;
|
|
2421
2552
|
if (!node.computed) return [3, 6];
|
|
2422
|
-
return [5, __values(evaluate
|
|
2553
|
+
return [5, __values(evaluate(node.property, scope))];
|
|
2423
2554
|
case 5:
|
|
2424
2555
|
key = _c.sent();
|
|
2425
2556
|
return [3, 7];
|
|
@@ -2467,18 +2598,18 @@
|
|
|
2467
2598
|
}
|
|
2468
2599
|
});
|
|
2469
2600
|
}
|
|
2470
|
-
function ConditionalExpression
|
|
2601
|
+
function ConditionalExpression(node, scope) {
|
|
2471
2602
|
var _a;
|
|
2472
2603
|
return __generator(this, function (_b) {
|
|
2473
2604
|
switch (_b.label) {
|
|
2474
|
-
case 0: return [5, __values(evaluate
|
|
2605
|
+
case 0: return [5, __values(evaluate(node.test, scope))];
|
|
2475
2606
|
case 1:
|
|
2476
2607
|
if (!(_b.sent())) return [3, 3];
|
|
2477
|
-
return [5, __values(evaluate
|
|
2608
|
+
return [5, __values(evaluate(node.consequent, scope))];
|
|
2478
2609
|
case 2:
|
|
2479
2610
|
_a = (_b.sent());
|
|
2480
2611
|
return [3, 5];
|
|
2481
|
-
case 3: return [5, __values(evaluate
|
|
2612
|
+
case 3: return [5, __values(evaluate(node.alternate, scope))];
|
|
2482
2613
|
case 4:
|
|
2483
2614
|
_a = (_b.sent());
|
|
2484
2615
|
_b.label = 5;
|
|
@@ -2486,13 +2617,13 @@
|
|
|
2486
2617
|
}
|
|
2487
2618
|
});
|
|
2488
2619
|
}
|
|
2489
|
-
function CallExpression
|
|
2490
|
-
var func, object, key, priv, obj, thisObject, name_1, args, i, arg, _a, _b, _c, _d, superCall;
|
|
2620
|
+
function CallExpression(node, scope) {
|
|
2621
|
+
var func, object, key, priv, obj, thisObject, name_1, args, i, arg, _a, _b, _c, _d, superCall, win;
|
|
2491
2622
|
return __generator(this, function (_e) {
|
|
2492
2623
|
switch (_e.label) {
|
|
2493
2624
|
case 0:
|
|
2494
2625
|
if (!(node.callee.type === 'MemberExpression')) return [3, 5];
|
|
2495
|
-
return [5, __values(MemberExpression
|
|
2626
|
+
return [5, __values(MemberExpression(node.callee, scope, { getObj: true }))];
|
|
2496
2627
|
case 1:
|
|
2497
2628
|
object = _e.sent();
|
|
2498
2629
|
if (node.callee.optional && object == null) {
|
|
@@ -2501,7 +2632,7 @@
|
|
|
2501
2632
|
key = void 0;
|
|
2502
2633
|
priv = false;
|
|
2503
2634
|
if (!node.callee.computed) return [3, 3];
|
|
2504
|
-
return [5, __values(evaluate
|
|
2635
|
+
return [5, __values(evaluate(node.callee.property, scope))];
|
|
2505
2636
|
case 2:
|
|
2506
2637
|
key = _e.sent();
|
|
2507
2638
|
return [3, 4];
|
|
@@ -2538,7 +2669,7 @@
|
|
|
2538
2669
|
return [3, 7];
|
|
2539
2670
|
case 5:
|
|
2540
2671
|
object = scope.find('this').get();
|
|
2541
|
-
return [5, __values(evaluate
|
|
2672
|
+
return [5, __values(evaluate(node.callee, scope))];
|
|
2542
2673
|
case 6:
|
|
2543
2674
|
func = _e.sent();
|
|
2544
2675
|
if (node.optional && func == null) {
|
|
@@ -2573,13 +2704,13 @@
|
|
|
2573
2704
|
arg = node.arguments[i];
|
|
2574
2705
|
if (!(arg.type === 'SpreadElement')) return [3, 10];
|
|
2575
2706
|
_b = (_a = args).concat;
|
|
2576
|
-
return [5, __values(SpreadElement
|
|
2707
|
+
return [5, __values(SpreadElement(arg, scope))];
|
|
2577
2708
|
case 9:
|
|
2578
2709
|
args = _b.apply(_a, [_e.sent()]);
|
|
2579
2710
|
return [3, 12];
|
|
2580
2711
|
case 10:
|
|
2581
2712
|
_d = (_c = args).push;
|
|
2582
|
-
return [5, __values(evaluate
|
|
2713
|
+
return [5, __values(evaluate(arg, scope))];
|
|
2583
2714
|
case 11:
|
|
2584
2715
|
_d.apply(_c, [_e.sent()]);
|
|
2585
2716
|
_e.label = 12;
|
|
@@ -2596,18 +2727,28 @@
|
|
|
2596
2727
|
scope.find(SUPERCALL).set(true);
|
|
2597
2728
|
}
|
|
2598
2729
|
}
|
|
2599
|
-
|
|
2600
|
-
return [2, func.apply(object
|
|
2730
|
+
try {
|
|
2731
|
+
return [2, func.apply(object, args)];
|
|
2601
2732
|
}
|
|
2602
|
-
|
|
2733
|
+
catch (err) {
|
|
2734
|
+
if (err instanceof TypeError && err.message === 'Illegal invocation'
|
|
2735
|
+
&& func.toString().indexOf('[native code]') !== -1) {
|
|
2736
|
+
win = scope.global().find('window').get();
|
|
2737
|
+
if (win && win[WINDOW]) {
|
|
2738
|
+
return [2, func.apply(win[WINDOW], args)];
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
throw err;
|
|
2742
|
+
}
|
|
2743
|
+
return [2];
|
|
2603
2744
|
}
|
|
2604
2745
|
});
|
|
2605
2746
|
}
|
|
2606
|
-
function NewExpression
|
|
2747
|
+
function NewExpression(node, scope) {
|
|
2607
2748
|
var constructor, name_2, args, i, arg, _a, _b, _c, _d;
|
|
2608
2749
|
return __generator(this, function (_e) {
|
|
2609
2750
|
switch (_e.label) {
|
|
2610
|
-
case 0: return [5, __values(evaluate
|
|
2751
|
+
case 0: return [5, __values(evaluate(node.callee, scope))];
|
|
2611
2752
|
case 1:
|
|
2612
2753
|
constructor = _e.sent();
|
|
2613
2754
|
if (typeof constructor !== 'function') {
|
|
@@ -2635,13 +2776,13 @@
|
|
|
2635
2776
|
arg = node.arguments[i];
|
|
2636
2777
|
if (!(arg.type === 'SpreadElement')) return [3, 4];
|
|
2637
2778
|
_b = (_a = args).concat;
|
|
2638
|
-
return [5, __values(SpreadElement
|
|
2779
|
+
return [5, __values(SpreadElement(arg, scope))];
|
|
2639
2780
|
case 3:
|
|
2640
2781
|
args = _b.apply(_a, [_e.sent()]);
|
|
2641
2782
|
return [3, 6];
|
|
2642
2783
|
case 4:
|
|
2643
2784
|
_d = (_c = args).push;
|
|
2644
|
-
return [5, __values(evaluate
|
|
2785
|
+
return [5, __values(evaluate(arg, scope))];
|
|
2645
2786
|
case 5:
|
|
2646
2787
|
_d.apply(_c, [_e.sent()]);
|
|
2647
2788
|
_e.label = 6;
|
|
@@ -2652,7 +2793,7 @@
|
|
|
2652
2793
|
}
|
|
2653
2794
|
});
|
|
2654
2795
|
}
|
|
2655
|
-
function MetaProperty
|
|
2796
|
+
function MetaProperty(node, scope) {
|
|
2656
2797
|
return __generator(this, function (_a) {
|
|
2657
2798
|
if (node.meta.name === 'new' && node.property.name === 'target') {
|
|
2658
2799
|
return [2, scope.find(NEWTARGET).get()];
|
|
@@ -2663,7 +2804,7 @@
|
|
|
2663
2804
|
return [2];
|
|
2664
2805
|
});
|
|
2665
2806
|
}
|
|
2666
|
-
function SequenceExpression
|
|
2807
|
+
function SequenceExpression(node, scope) {
|
|
2667
2808
|
var result, i;
|
|
2668
2809
|
return __generator(this, function (_a) {
|
|
2669
2810
|
switch (_a.label) {
|
|
@@ -2672,7 +2813,7 @@
|
|
|
2672
2813
|
_a.label = 1;
|
|
2673
2814
|
case 1:
|
|
2674
2815
|
if (!(i < node.expressions.length)) return [3, 4];
|
|
2675
|
-
return [5, __values(evaluate
|
|
2816
|
+
return [5, __values(evaluate(node.expressions[i], scope))];
|
|
2676
2817
|
case 2:
|
|
2677
2818
|
result = _a.sent();
|
|
2678
2819
|
_a.label = 3;
|
|
@@ -2683,12 +2824,12 @@
|
|
|
2683
2824
|
}
|
|
2684
2825
|
});
|
|
2685
2826
|
}
|
|
2686
|
-
function ArrowFunctionExpression
|
|
2827
|
+
function ArrowFunctionExpression(node, scope) {
|
|
2687
2828
|
return __generator(this, function (_a) {
|
|
2688
|
-
return [2, createFunc(node, scope)];
|
|
2829
|
+
return [2, createFunc$1(node, scope)];
|
|
2689
2830
|
});
|
|
2690
2831
|
}
|
|
2691
|
-
function TemplateLiteral
|
|
2832
|
+
function TemplateLiteral(node, scope) {
|
|
2692
2833
|
var quasis, expressions, result, temEl, expr, _a, _b;
|
|
2693
2834
|
return __generator(this, function (_c) {
|
|
2694
2835
|
switch (_c.label) {
|
|
@@ -2700,13 +2841,13 @@
|
|
|
2700
2841
|
case 1:
|
|
2701
2842
|
if (!(temEl = quasis.shift())) return [3, 5];
|
|
2702
2843
|
_a = result;
|
|
2703
|
-
return [5, __values(TemplateElement
|
|
2844
|
+
return [5, __values(TemplateElement(temEl))];
|
|
2704
2845
|
case 2:
|
|
2705
2846
|
result = _a + _c.sent();
|
|
2706
2847
|
expr = expressions.shift();
|
|
2707
2848
|
if (!expr) return [3, 4];
|
|
2708
2849
|
_b = result;
|
|
2709
|
-
return [5, __values(evaluate
|
|
2850
|
+
return [5, __values(evaluate(expr, scope))];
|
|
2710
2851
|
case 3:
|
|
2711
2852
|
result = _b + _c.sent();
|
|
2712
2853
|
_c.label = 4;
|
|
@@ -2715,11 +2856,11 @@
|
|
|
2715
2856
|
}
|
|
2716
2857
|
});
|
|
2717
2858
|
}
|
|
2718
|
-
function TaggedTemplateExpression
|
|
2859
|
+
function TaggedTemplateExpression(node, scope) {
|
|
2719
2860
|
var tagFunc, quasis, str, raw, expressions, args, i, _a, _b;
|
|
2720
2861
|
return __generator(this, function (_c) {
|
|
2721
2862
|
switch (_c.label) {
|
|
2722
|
-
case 0: return [5, __values(evaluate
|
|
2863
|
+
case 0: return [5, __values(evaluate(node.tag, scope))];
|
|
2723
2864
|
case 1:
|
|
2724
2865
|
tagFunc = _c.sent();
|
|
2725
2866
|
quasis = node.quasi.quasis;
|
|
@@ -2736,7 +2877,7 @@
|
|
|
2736
2877
|
case 2:
|
|
2737
2878
|
if (!(i < expressions.length)) return [3, 5];
|
|
2738
2879
|
_b = (_a = args).push;
|
|
2739
|
-
return [5, __values(evaluate
|
|
2880
|
+
return [5, __values(evaluate(expressions[i], scope))];
|
|
2740
2881
|
case 3:
|
|
2741
2882
|
_b.apply(_a, [_c.sent()]);
|
|
2742
2883
|
_c.label = 4;
|
|
@@ -2747,29 +2888,29 @@
|
|
|
2747
2888
|
}
|
|
2748
2889
|
});
|
|
2749
2890
|
}
|
|
2750
|
-
function TemplateElement
|
|
2891
|
+
function TemplateElement(node, scope) {
|
|
2751
2892
|
return __generator(this, function (_a) {
|
|
2752
2893
|
return [2, node.value.raw];
|
|
2753
2894
|
});
|
|
2754
2895
|
}
|
|
2755
|
-
function ClassExpression
|
|
2896
|
+
function ClassExpression(node, scope) {
|
|
2756
2897
|
var tmpScope, klass;
|
|
2757
2898
|
return __generator(this, function (_a) {
|
|
2758
2899
|
switch (_a.label) {
|
|
2759
2900
|
case 0:
|
|
2760
2901
|
if (!(node.id && node.id.name)) return [3, 2];
|
|
2761
2902
|
tmpScope = new Scope(scope);
|
|
2762
|
-
return [5, __values(createClass(node, tmpScope))];
|
|
2903
|
+
return [5, __values(createClass$1(node, tmpScope))];
|
|
2763
2904
|
case 1:
|
|
2764
2905
|
klass = _a.sent();
|
|
2765
2906
|
tmpScope.const(node.id.name, klass);
|
|
2766
2907
|
return [2, klass];
|
|
2767
|
-
case 2: return [5, __values(createClass(node, scope))];
|
|
2908
|
+
case 2: return [5, __values(createClass$1(node, scope))];
|
|
2768
2909
|
case 3: return [2, _a.sent()];
|
|
2769
2910
|
}
|
|
2770
2911
|
});
|
|
2771
2912
|
}
|
|
2772
|
-
function Super
|
|
2913
|
+
function Super(node, scope, options) {
|
|
2773
2914
|
var _a, getProto, superClass;
|
|
2774
2915
|
if (options === void 0) { options = {}; }
|
|
2775
2916
|
return __generator(this, function (_b) {
|
|
@@ -2778,32 +2919,32 @@
|
|
|
2778
2919
|
return [2, getProto ? superClass.prototype : superClass];
|
|
2779
2920
|
});
|
|
2780
2921
|
}
|
|
2781
|
-
function SpreadElement
|
|
2922
|
+
function SpreadElement(node, scope) {
|
|
2782
2923
|
var result;
|
|
2783
2924
|
return __generator(this, function (_a) {
|
|
2784
2925
|
switch (_a.label) {
|
|
2785
|
-
case 0: return [5, __values(evaluate
|
|
2926
|
+
case 0: return [5, __values(evaluate(node.argument, scope))];
|
|
2786
2927
|
case 1:
|
|
2787
2928
|
result = _a.sent();
|
|
2788
2929
|
return [2, typeof result === 'string' ? __spread(result) : result];
|
|
2789
2930
|
}
|
|
2790
2931
|
});
|
|
2791
2932
|
}
|
|
2792
|
-
function ChainExpression
|
|
2933
|
+
function ChainExpression(node, scope) {
|
|
2793
2934
|
return __generator(this, function (_a) {
|
|
2794
2935
|
switch (_a.label) {
|
|
2795
|
-
case 0: return [5, __values(evaluate
|
|
2936
|
+
case 0: return [5, __values(evaluate(node.expression, scope))];
|
|
2796
2937
|
case 1: return [2, _a.sent()];
|
|
2797
2938
|
}
|
|
2798
2939
|
});
|
|
2799
2940
|
}
|
|
2800
|
-
function ImportExpression
|
|
2941
|
+
function ImportExpression(node, scope) {
|
|
2801
2942
|
var globalScope, source, module, value, result;
|
|
2802
2943
|
return __generator(this, function (_a) {
|
|
2803
2944
|
switch (_a.label) {
|
|
2804
2945
|
case 0:
|
|
2805
2946
|
globalScope = scope.global();
|
|
2806
|
-
return [5, __values(evaluate
|
|
2947
|
+
return [5, __values(evaluate(node.source, scope))];
|
|
2807
2948
|
case 1:
|
|
2808
2949
|
source = _a.sent();
|
|
2809
2950
|
module = globalScope.find(IMPORT + source);
|
|
@@ -2829,7 +2970,7 @@
|
|
|
2829
2970
|
var res, _a;
|
|
2830
2971
|
return __generator(this, function (_b) {
|
|
2831
2972
|
switch (_b.label) {
|
|
2832
|
-
case 0: return [5, __values(evaluate
|
|
2973
|
+
case 0: return [5, __values(evaluate(node.argument, scope))];
|
|
2833
2974
|
case 1:
|
|
2834
2975
|
res = _b.sent();
|
|
2835
2976
|
if (!node.delegate) return [3, 3];
|
|
@@ -2851,7 +2992,7 @@
|
|
|
2851
2992
|
switch (_b.label) {
|
|
2852
2993
|
case 0:
|
|
2853
2994
|
_a = AWAIT;
|
|
2854
|
-
return [5, __values(evaluate
|
|
2995
|
+
return [5, __values(evaluate(node.argument, scope))];
|
|
2855
2996
|
case 1:
|
|
2856
2997
|
_a.RES = _b.sent();
|
|
2857
2998
|
return [4, AWAIT];
|
|
@@ -2860,37 +3001,37 @@
|
|
|
2860
3001
|
});
|
|
2861
3002
|
}
|
|
2862
3003
|
|
|
2863
|
-
var expression
|
|
3004
|
+
var expression = /*#__PURE__*/Object.freeze({
|
|
2864
3005
|
__proto__: null,
|
|
2865
|
-
ThisExpression: ThisExpression
|
|
2866
|
-
ArrayExpression: ArrayExpression
|
|
2867
|
-
ObjectExpression: ObjectExpression
|
|
2868
|
-
FunctionExpression: FunctionExpression
|
|
2869
|
-
UnaryExpression: UnaryExpression
|
|
2870
|
-
UpdateExpression: UpdateExpression
|
|
2871
|
-
BinaryExpression: BinaryExpression
|
|
2872
|
-
AssignmentExpression: AssignmentExpression
|
|
2873
|
-
LogicalExpression: LogicalExpression
|
|
2874
|
-
MemberExpression: MemberExpression
|
|
2875
|
-
ConditionalExpression: ConditionalExpression
|
|
2876
|
-
CallExpression: CallExpression
|
|
2877
|
-
NewExpression: NewExpression
|
|
2878
|
-
MetaProperty: MetaProperty
|
|
2879
|
-
SequenceExpression: SequenceExpression
|
|
2880
|
-
ArrowFunctionExpression: ArrowFunctionExpression
|
|
2881
|
-
TemplateLiteral: TemplateLiteral
|
|
2882
|
-
TaggedTemplateExpression: TaggedTemplateExpression
|
|
2883
|
-
TemplateElement: TemplateElement
|
|
2884
|
-
ClassExpression: ClassExpression
|
|
2885
|
-
Super: Super
|
|
2886
|
-
SpreadElement: SpreadElement
|
|
2887
|
-
ChainExpression: ChainExpression
|
|
2888
|
-
ImportExpression: ImportExpression
|
|
3006
|
+
ThisExpression: ThisExpression,
|
|
3007
|
+
ArrayExpression: ArrayExpression,
|
|
3008
|
+
ObjectExpression: ObjectExpression,
|
|
3009
|
+
FunctionExpression: FunctionExpression,
|
|
3010
|
+
UnaryExpression: UnaryExpression,
|
|
3011
|
+
UpdateExpression: UpdateExpression,
|
|
3012
|
+
BinaryExpression: BinaryExpression,
|
|
3013
|
+
AssignmentExpression: AssignmentExpression,
|
|
3014
|
+
LogicalExpression: LogicalExpression,
|
|
3015
|
+
MemberExpression: MemberExpression,
|
|
3016
|
+
ConditionalExpression: ConditionalExpression,
|
|
3017
|
+
CallExpression: CallExpression,
|
|
3018
|
+
NewExpression: NewExpression,
|
|
3019
|
+
MetaProperty: MetaProperty,
|
|
3020
|
+
SequenceExpression: SequenceExpression,
|
|
3021
|
+
ArrowFunctionExpression: ArrowFunctionExpression,
|
|
3022
|
+
TemplateLiteral: TemplateLiteral,
|
|
3023
|
+
TaggedTemplateExpression: TaggedTemplateExpression,
|
|
3024
|
+
TemplateElement: TemplateElement,
|
|
3025
|
+
ClassExpression: ClassExpression,
|
|
3026
|
+
Super: Super,
|
|
3027
|
+
SpreadElement: SpreadElement,
|
|
3028
|
+
ChainExpression: ChainExpression,
|
|
3029
|
+
ImportExpression: ImportExpression,
|
|
2889
3030
|
YieldExpression: YieldExpression,
|
|
2890
3031
|
AwaitExpression: AwaitExpression
|
|
2891
3032
|
});
|
|
2892
3033
|
|
|
2893
|
-
function ObjectPattern
|
|
3034
|
+
function ObjectPattern(node, scope, options) {
|
|
2894
3035
|
var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, fedKeys, i, property, value, key, value, rest, i_1;
|
|
2895
3036
|
if (options === void 0) { options = {}; }
|
|
2896
3037
|
return __generator(this, function (_e) {
|
|
@@ -2910,12 +3051,12 @@
|
|
|
2910
3051
|
if (!(value.type === 'Identifier')) return [3, 2];
|
|
2911
3052
|
scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2912
3053
|
return [3, 4];
|
|
2913
|
-
case 2: return [5, __values(pattern$
|
|
3054
|
+
case 2: return [5, __values(pattern$1(value, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
2914
3055
|
case 3:
|
|
2915
3056
|
_e.sent();
|
|
2916
3057
|
_e.label = 4;
|
|
2917
3058
|
case 4: return [3, 7];
|
|
2918
|
-
case 5: return [5, __values(RestElement
|
|
3059
|
+
case 5: return [5, __values(RestElement(property, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
2919
3060
|
case 6:
|
|
2920
3061
|
_e.sent();
|
|
2921
3062
|
_e.label = 7;
|
|
@@ -2924,7 +3065,7 @@
|
|
|
2924
3065
|
if (!(property.type === 'Property')) return [3, 15];
|
|
2925
3066
|
key = void 0;
|
|
2926
3067
|
if (!property.computed) return [3, 10];
|
|
2927
|
-
return [5, __values(evaluate
|
|
3068
|
+
return [5, __values(evaluate(property.key, scope))];
|
|
2928
3069
|
case 9:
|
|
2929
3070
|
key = _e.sent();
|
|
2930
3071
|
return [3, 11];
|
|
@@ -2937,7 +3078,7 @@
|
|
|
2937
3078
|
if (!(value.type === 'Identifier')) return [3, 12];
|
|
2938
3079
|
scope[kind](value.name, feed[key]);
|
|
2939
3080
|
return [3, 14];
|
|
2940
|
-
case 12: return [5, __values(pattern$
|
|
3081
|
+
case 12: return [5, __values(pattern$1(value, scope, { kind: kind, feed: feed[key] }))];
|
|
2941
3082
|
case 13:
|
|
2942
3083
|
_e.sent();
|
|
2943
3084
|
_e.label = 14;
|
|
@@ -2946,7 +3087,7 @@
|
|
|
2946
3087
|
rest = assign({}, feed);
|
|
2947
3088
|
for (i_1 = 0; i_1 < fedKeys.length; i_1++)
|
|
2948
3089
|
delete rest[fedKeys[i_1]];
|
|
2949
|
-
return [5, __values(RestElement
|
|
3090
|
+
return [5, __values(RestElement(property, scope, { kind: kind, feed: rest }))];
|
|
2950
3091
|
case 16:
|
|
2951
3092
|
_e.sent();
|
|
2952
3093
|
_e.label = 17;
|
|
@@ -2957,7 +3098,7 @@
|
|
|
2957
3098
|
}
|
|
2958
3099
|
});
|
|
2959
3100
|
}
|
|
2960
|
-
function ArrayPattern
|
|
3101
|
+
function ArrayPattern(node, scope, options) {
|
|
2961
3102
|
var kind, _a, hoist, _b, onlyBlock, _c, feed, result, i, element, variable;
|
|
2962
3103
|
if (options === void 0) { options = {}; }
|
|
2963
3104
|
return __generator(this, function (_d) {
|
|
@@ -2977,7 +3118,7 @@
|
|
|
2977
3118
|
if (!(element.type === 'Identifier')) return [3, 2];
|
|
2978
3119
|
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2979
3120
|
return [3, 4];
|
|
2980
|
-
case 2: return [5, __values(pattern$
|
|
3121
|
+
case 2: return [5, __values(pattern$1(element, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
2981
3122
|
case 3:
|
|
2982
3123
|
_d.sent();
|
|
2983
3124
|
_d.label = 4;
|
|
@@ -2987,7 +3128,7 @@
|
|
|
2987
3128
|
if (!kind) return [3, 6];
|
|
2988
3129
|
scope[kind](element.name, feed[i]);
|
|
2989
3130
|
return [3, 8];
|
|
2990
|
-
case 6: return [5, __values(Identifier
|
|
3131
|
+
case 6: return [5, __values(Identifier(element, scope, { getVar: true }))];
|
|
2991
3132
|
case 7:
|
|
2992
3133
|
variable = _d.sent();
|
|
2993
3134
|
variable.set(feed[i]);
|
|
@@ -2996,11 +3137,11 @@
|
|
|
2996
3137
|
case 8: return [3, 13];
|
|
2997
3138
|
case 9:
|
|
2998
3139
|
if (!(element.type === 'RestElement')) return [3, 11];
|
|
2999
|
-
return [5, __values(RestElement
|
|
3140
|
+
return [5, __values(RestElement(element, scope, { kind: kind, feed: feed.slice(i) }))];
|
|
3000
3141
|
case 10:
|
|
3001
3142
|
_d.sent();
|
|
3002
3143
|
return [3, 13];
|
|
3003
|
-
case 11: return [5, __values(pattern$
|
|
3144
|
+
case 11: return [5, __values(pattern$1(element, scope, { kind: kind, feed: feed[i] }))];
|
|
3004
3145
|
case 12:
|
|
3005
3146
|
_d.sent();
|
|
3006
3147
|
_d.label = 13;
|
|
@@ -3015,7 +3156,7 @@
|
|
|
3015
3156
|
}
|
|
3016
3157
|
});
|
|
3017
3158
|
}
|
|
3018
|
-
function RestElement
|
|
3159
|
+
function RestElement(node, scope, options) {
|
|
3019
3160
|
var kind, _a, hoist, _b, onlyBlock, _c, feed, arg, variable;
|
|
3020
3161
|
if (options === void 0) { options = {}; }
|
|
3021
3162
|
return __generator(this, function (_d) {
|
|
@@ -3028,7 +3169,7 @@
|
|
|
3028
3169
|
if (!(arg.type === 'Identifier')) return [3, 1];
|
|
3029
3170
|
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3030
3171
|
return [3, 3];
|
|
3031
|
-
case 1: return [5, __values(pattern$
|
|
3172
|
+
case 1: return [5, __values(pattern$1(arg, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3032
3173
|
case 2:
|
|
3033
3174
|
_d.sent();
|
|
3034
3175
|
_d.label = 3;
|
|
@@ -3038,13 +3179,13 @@
|
|
|
3038
3179
|
if (!kind) return [3, 5];
|
|
3039
3180
|
scope[kind](arg.name, feed);
|
|
3040
3181
|
return [3, 7];
|
|
3041
|
-
case 5: return [5, __values(Identifier
|
|
3182
|
+
case 5: return [5, __values(Identifier(arg, scope, { getVar: true }))];
|
|
3042
3183
|
case 6:
|
|
3043
3184
|
variable = _d.sent();
|
|
3044
3185
|
variable.set(feed);
|
|
3045
3186
|
_d.label = 7;
|
|
3046
3187
|
case 7: return [3, 10];
|
|
3047
|
-
case 8: return [5, __values(pattern$
|
|
3188
|
+
case 8: return [5, __values(pattern$1(arg, scope, { kind: kind, feed: feed }))];
|
|
3048
3189
|
case 9:
|
|
3049
3190
|
_d.sent();
|
|
3050
3191
|
_d.label = 10;
|
|
@@ -3052,7 +3193,7 @@
|
|
|
3052
3193
|
}
|
|
3053
3194
|
});
|
|
3054
3195
|
}
|
|
3055
|
-
function AssignmentPattern
|
|
3196
|
+
function AssignmentPattern(node, scope, options) {
|
|
3056
3197
|
var _a, kind, _b, hoist, _c, onlyBlock, _d, feed, _e, left;
|
|
3057
3198
|
if (options === void 0) { options = {}; }
|
|
3058
3199
|
return __generator(this, function (_f) {
|
|
@@ -3060,7 +3201,7 @@
|
|
|
3060
3201
|
case 0:
|
|
3061
3202
|
_a = options.kind, kind = _a === void 0 ? 'var' : _a, _b = options.hoist, hoist = _b === void 0 ? false : _b, _c = options.onlyBlock, onlyBlock = _c === void 0 ? false : _c, _d = options.feed;
|
|
3062
3203
|
if (!(_d === void 0)) return [3, 2];
|
|
3063
|
-
return [5, __values(evaluate
|
|
3204
|
+
return [5, __values(evaluate(node.right, scope))];
|
|
3064
3205
|
case 1:
|
|
3065
3206
|
_e = _f.sent();
|
|
3066
3207
|
return [3, 3];
|
|
@@ -3075,7 +3216,7 @@
|
|
|
3075
3216
|
if (!(left.type === 'Identifier')) return [3, 4];
|
|
3076
3217
|
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3077
3218
|
return [3, 6];
|
|
3078
|
-
case 4: return [5, __values(pattern$
|
|
3219
|
+
case 4: return [5, __values(pattern$1(left, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3079
3220
|
case 5:
|
|
3080
3221
|
_f.sent();
|
|
3081
3222
|
_f.label = 6;
|
|
@@ -3084,7 +3225,7 @@
|
|
|
3084
3225
|
if (!(left.type === 'Identifier')) return [3, 8];
|
|
3085
3226
|
scope[kind](left.name, feed);
|
|
3086
3227
|
return [3, 10];
|
|
3087
|
-
case 8: return [5, __values(pattern$
|
|
3228
|
+
case 8: return [5, __values(pattern$1(left, scope, { kind: kind, feed: feed }))];
|
|
3088
3229
|
case 9:
|
|
3089
3230
|
_f.sent();
|
|
3090
3231
|
_f.label = 10;
|
|
@@ -3093,26 +3234,26 @@
|
|
|
3093
3234
|
});
|
|
3094
3235
|
}
|
|
3095
3236
|
|
|
3096
|
-
var pattern$
|
|
3237
|
+
var pattern$2 = /*#__PURE__*/Object.freeze({
|
|
3097
3238
|
__proto__: null,
|
|
3098
|
-
ObjectPattern: ObjectPattern
|
|
3099
|
-
ArrayPattern: ArrayPattern
|
|
3100
|
-
RestElement: RestElement
|
|
3101
|
-
AssignmentPattern: AssignmentPattern
|
|
3239
|
+
ObjectPattern: ObjectPattern,
|
|
3240
|
+
ArrayPattern: ArrayPattern,
|
|
3241
|
+
RestElement: RestElement,
|
|
3242
|
+
AssignmentPattern: AssignmentPattern
|
|
3102
3243
|
});
|
|
3103
3244
|
|
|
3104
|
-
var evaluateOps
|
|
3105
|
-
function evaluate
|
|
3245
|
+
var evaluateOps;
|
|
3246
|
+
function evaluate(node, scope) {
|
|
3106
3247
|
var handler;
|
|
3107
3248
|
return __generator(this, function (_a) {
|
|
3108
3249
|
switch (_a.label) {
|
|
3109
3250
|
case 0:
|
|
3110
3251
|
if (!node)
|
|
3111
3252
|
return [2];
|
|
3112
|
-
if (!evaluateOps
|
|
3113
|
-
evaluateOps
|
|
3253
|
+
if (!evaluateOps) {
|
|
3254
|
+
evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern$2);
|
|
3114
3255
|
}
|
|
3115
|
-
handler = evaluateOps
|
|
3256
|
+
handler = evaluateOps[node.type];
|
|
3116
3257
|
if (!handler) return [3, 2];
|
|
3117
3258
|
return [5, __values(handler(node, scope))];
|
|
3118
3259
|
case 1: return [2, _a.sent()];
|
|
@@ -3121,17 +3262,17 @@
|
|
|
3121
3262
|
});
|
|
3122
3263
|
}
|
|
3123
3264
|
|
|
3124
|
-
function ExpressionStatement
|
|
3265
|
+
function ExpressionStatement(node, scope) {
|
|
3125
3266
|
return __generator(this, function (_a) {
|
|
3126
3267
|
switch (_a.label) {
|
|
3127
|
-
case 0: return [5, __values(evaluate
|
|
3268
|
+
case 0: return [5, __values(evaluate(node.expression, scope))];
|
|
3128
3269
|
case 1:
|
|
3129
3270
|
_a.sent();
|
|
3130
3271
|
return [2];
|
|
3131
3272
|
}
|
|
3132
3273
|
});
|
|
3133
3274
|
}
|
|
3134
|
-
function BlockStatement
|
|
3275
|
+
function BlockStatement(block, scope, options) {
|
|
3135
3276
|
var _a, invasived, _b, hoisted, subScope, i, result;
|
|
3136
3277
|
if (options === void 0) { options = {}; }
|
|
3137
3278
|
return __generator(this, function (_c) {
|
|
@@ -3140,7 +3281,7 @@
|
|
|
3140
3281
|
_a = options.invasived, invasived = _a === void 0 ? false : _a, _b = options.hoisted, hoisted = _b === void 0 ? false : _b;
|
|
3141
3282
|
subScope = invasived ? scope : new Scope(scope);
|
|
3142
3283
|
if (!!hoisted) return [3, 2];
|
|
3143
|
-
return [5, __values(hoist(block, subScope, { onlyBlock: true }))];
|
|
3284
|
+
return [5, __values(hoist$1(block, subScope, { onlyBlock: true }))];
|
|
3144
3285
|
case 1:
|
|
3145
3286
|
_c.sent();
|
|
3146
3287
|
_c.label = 2;
|
|
@@ -3149,10 +3290,16 @@
|
|
|
3149
3290
|
_c.label = 3;
|
|
3150
3291
|
case 3:
|
|
3151
3292
|
if (!(i < block.body.length)) return [3, 6];
|
|
3152
|
-
return [5, __values(evaluate
|
|
3293
|
+
return [5, __values(evaluate(block.body[i], subScope))];
|
|
3153
3294
|
case 4:
|
|
3154
3295
|
result = _c.sent();
|
|
3155
|
-
if (result === BREAK
|
|
3296
|
+
if (result === BREAK) {
|
|
3297
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3298
|
+
return [3, 6];
|
|
3299
|
+
}
|
|
3300
|
+
return [2, result];
|
|
3301
|
+
}
|
|
3302
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3156
3303
|
return [2, result];
|
|
3157
3304
|
}
|
|
3158
3305
|
_c.label = 5;
|
|
@@ -3163,25 +3310,25 @@
|
|
|
3163
3310
|
}
|
|
3164
3311
|
});
|
|
3165
3312
|
}
|
|
3166
|
-
function EmptyStatement
|
|
3313
|
+
function EmptyStatement() {
|
|
3167
3314
|
return __generator(this, function (_a) {
|
|
3168
3315
|
return [2];
|
|
3169
3316
|
});
|
|
3170
3317
|
}
|
|
3171
|
-
function DebuggerStatement
|
|
3318
|
+
function DebuggerStatement() {
|
|
3172
3319
|
return __generator(this, function (_a) {
|
|
3173
3320
|
debugger;
|
|
3174
3321
|
return [2];
|
|
3175
3322
|
});
|
|
3176
3323
|
}
|
|
3177
|
-
function ReturnStatement
|
|
3324
|
+
function ReturnStatement(node, scope) {
|
|
3178
3325
|
var _a, _b;
|
|
3179
3326
|
return __generator(this, function (_c) {
|
|
3180
3327
|
switch (_c.label) {
|
|
3181
3328
|
case 0:
|
|
3182
3329
|
_a = RETURN;
|
|
3183
3330
|
if (!node.argument) return [3, 2];
|
|
3184
|
-
return [5, __values(evaluate
|
|
3331
|
+
return [5, __values(evaluate(node.argument, scope))];
|
|
3185
3332
|
case 1:
|
|
3186
3333
|
_b = (_c.sent());
|
|
3187
3334
|
return [3, 3];
|
|
@@ -3194,34 +3341,133 @@
|
|
|
3194
3341
|
}
|
|
3195
3342
|
});
|
|
3196
3343
|
}
|
|
3197
|
-
function BreakStatement
|
|
3198
|
-
|
|
3344
|
+
function BreakStatement(node) {
|
|
3345
|
+
var _a;
|
|
3346
|
+
return __generator(this, function (_b) {
|
|
3347
|
+
BREAK.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
3199
3348
|
return [2, BREAK];
|
|
3200
3349
|
});
|
|
3201
3350
|
}
|
|
3202
|
-
function ContinueStatement
|
|
3203
|
-
|
|
3351
|
+
function ContinueStatement(node) {
|
|
3352
|
+
var _a;
|
|
3353
|
+
return __generator(this, function (_b) {
|
|
3354
|
+
CONTINUE.LABEL = (_a = node.label) === null || _a === void 0 ? void 0 : _a.name;
|
|
3204
3355
|
return [2, CONTINUE];
|
|
3205
3356
|
});
|
|
3206
3357
|
}
|
|
3207
|
-
function
|
|
3358
|
+
function LabeledStatement(node, scope) {
|
|
3359
|
+
var label;
|
|
3208
3360
|
return __generator(this, function (_a) {
|
|
3209
3361
|
switch (_a.label) {
|
|
3210
|
-
case 0:
|
|
3362
|
+
case 0:
|
|
3363
|
+
label = node.label.name;
|
|
3364
|
+
if (!(node.body.type === 'WhileStatement')) return [3, 2];
|
|
3365
|
+
return [5, __values(WhileStatement(node.body, scope, { label: label }))];
|
|
3366
|
+
case 1: return [2, _a.sent()];
|
|
3367
|
+
case 2:
|
|
3368
|
+
if (!(node.body.type === 'DoWhileStatement')) return [3, 4];
|
|
3369
|
+
return [5, __values(DoWhileStatement(node.body, scope, { label: label }))];
|
|
3370
|
+
case 3: return [2, _a.sent()];
|
|
3371
|
+
case 4:
|
|
3372
|
+
if (!(node.body.type === 'ForStatement')) return [3, 6];
|
|
3373
|
+
return [5, __values(ForStatement(node.body, scope, { label: label }))];
|
|
3374
|
+
case 5: return [2, _a.sent()];
|
|
3375
|
+
case 6:
|
|
3376
|
+
if (!(node.body.type === 'ForInStatement')) return [3, 8];
|
|
3377
|
+
return [5, __values(ForInStatement(node.body, scope, { label: label }))];
|
|
3378
|
+
case 7: return [2, _a.sent()];
|
|
3379
|
+
case 8:
|
|
3380
|
+
if (!(node.body.type === 'ForOfStatement')) return [3, 10];
|
|
3381
|
+
return [5, __values(ForOfStatement(node.body, scope, { label: label }))];
|
|
3382
|
+
case 9: return [2, _a.sent()];
|
|
3383
|
+
case 10:
|
|
3384
|
+
if (!(node.body.type === 'BlockStatement')) return [3, 12];
|
|
3385
|
+
return [5, __values(BlockStatement(node.body, scope, { label: label }))];
|
|
3386
|
+
case 11: return [2, _a.sent()];
|
|
3387
|
+
case 12:
|
|
3388
|
+
if (!(node.body.type === 'WithStatement')) return [3, 14];
|
|
3389
|
+
return [5, __values(WithStatement(node.body, scope, { label: label }))];
|
|
3390
|
+
case 13: return [2, _a.sent()];
|
|
3391
|
+
case 14:
|
|
3392
|
+
if (!(node.body.type === 'IfStatement')) return [3, 16];
|
|
3393
|
+
return [5, __values(IfStatement(node.body, scope, { label: label }))];
|
|
3394
|
+
case 15: return [2, _a.sent()];
|
|
3395
|
+
case 16:
|
|
3396
|
+
if (!(node.body.type === 'SwitchStatement')) return [3, 18];
|
|
3397
|
+
return [5, __values(SwitchStatement(node.body, scope, { label: label }))];
|
|
3398
|
+
case 17: return [2, _a.sent()];
|
|
3399
|
+
case 18:
|
|
3400
|
+
if (!(node.body.type === 'TryStatement')) return [3, 20];
|
|
3401
|
+
return [5, __values(TryStatement(node.body, scope, { label: label }))];
|
|
3402
|
+
case 19: return [2, _a.sent()];
|
|
3403
|
+
case 20: throw new SyntaxError(node.body.type + " cannot be labeled");
|
|
3404
|
+
}
|
|
3405
|
+
});
|
|
3406
|
+
}
|
|
3407
|
+
function WithStatement(node, scope, options) {
|
|
3408
|
+
var withScope, _a, _b, result;
|
|
3409
|
+
if (options === void 0) { options = {}; }
|
|
3410
|
+
return __generator(this, function (_c) {
|
|
3411
|
+
switch (_c.label) {
|
|
3412
|
+
case 0:
|
|
3413
|
+
withScope = new Scope(scope);
|
|
3414
|
+
_b = (_a = withScope).with;
|
|
3415
|
+
return [5, __values(evaluate(node.object, scope))];
|
|
3211
3416
|
case 1:
|
|
3212
|
-
|
|
3213
|
-
return [5, __values(evaluate
|
|
3214
|
-
case 2:
|
|
3215
|
-
|
|
3216
|
-
|
|
3417
|
+
_b.apply(_a, [_c.sent()]);
|
|
3418
|
+
return [5, __values(evaluate(node.body, withScope))];
|
|
3419
|
+
case 2:
|
|
3420
|
+
result = _c.sent();
|
|
3421
|
+
if (result === BREAK) {
|
|
3422
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3423
|
+
return [2];
|
|
3424
|
+
}
|
|
3425
|
+
return [2, result];
|
|
3426
|
+
}
|
|
3427
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3428
|
+
return [2, result];
|
|
3429
|
+
}
|
|
3430
|
+
return [2];
|
|
3431
|
+
}
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
function IfStatement(node, scope, options) {
|
|
3435
|
+
var result, _a;
|
|
3436
|
+
if (options === void 0) { options = {}; }
|
|
3437
|
+
return __generator(this, function (_b) {
|
|
3438
|
+
switch (_b.label) {
|
|
3439
|
+
case 0:
|
|
3440
|
+
if (!evaluate(node.test, scope)) return [3, 2];
|
|
3441
|
+
return [5, __values(evaluate(node.consequent, scope))];
|
|
3442
|
+
case 1:
|
|
3443
|
+
_a = _b.sent();
|
|
3444
|
+
return [3, 4];
|
|
3445
|
+
case 2: return [5, __values(evaluate(node.alternate, scope))];
|
|
3446
|
+
case 3:
|
|
3447
|
+
_a = _b.sent();
|
|
3448
|
+
_b.label = 4;
|
|
3449
|
+
case 4: return [5, __values(_a)];
|
|
3450
|
+
case 5:
|
|
3451
|
+
result = _b.sent();
|
|
3452
|
+
if (result === BREAK) {
|
|
3453
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3454
|
+
return [2];
|
|
3455
|
+
}
|
|
3456
|
+
return [2, result];
|
|
3457
|
+
}
|
|
3458
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3459
|
+
return [2, result];
|
|
3460
|
+
}
|
|
3461
|
+
return [2];
|
|
3217
3462
|
}
|
|
3218
3463
|
});
|
|
3219
3464
|
}
|
|
3220
|
-
function SwitchStatement
|
|
3465
|
+
function SwitchStatement(node, scope, options) {
|
|
3221
3466
|
var discriminant, matched, i, eachCase, _a, _b, result;
|
|
3467
|
+
if (options === void 0) { options = {}; }
|
|
3222
3468
|
return __generator(this, function (_c) {
|
|
3223
3469
|
switch (_c.label) {
|
|
3224
|
-
case 0: return [5, __values(evaluate
|
|
3470
|
+
case 0: return [5, __values(evaluate(node.discriminant, scope))];
|
|
3225
3471
|
case 1:
|
|
3226
3472
|
discriminant = _c.sent();
|
|
3227
3473
|
matched = false;
|
|
@@ -3234,7 +3480,7 @@
|
|
|
3234
3480
|
if (!_a) return [3, 5];
|
|
3235
3481
|
_b = !eachCase.test;
|
|
3236
3482
|
if (_b) return [3, 4];
|
|
3237
|
-
return [5, __values(evaluate
|
|
3483
|
+
return [5, __values(evaluate(eachCase.test, scope))];
|
|
3238
3484
|
case 3:
|
|
3239
3485
|
_b = (_c.sent()) === discriminant;
|
|
3240
3486
|
_c.label = 4;
|
|
@@ -3246,11 +3492,14 @@
|
|
|
3246
3492
|
matched = true;
|
|
3247
3493
|
}
|
|
3248
3494
|
if (!matched) return [3, 7];
|
|
3249
|
-
return [5, __values(SwitchCase
|
|
3495
|
+
return [5, __values(SwitchCase(eachCase, scope))];
|
|
3250
3496
|
case 6:
|
|
3251
3497
|
result = _c.sent();
|
|
3252
3498
|
if (result === BREAK) {
|
|
3253
|
-
|
|
3499
|
+
if (result.LABEL === options.label) {
|
|
3500
|
+
return [3, 8];
|
|
3501
|
+
}
|
|
3502
|
+
return [2, result];
|
|
3254
3503
|
}
|
|
3255
3504
|
if (result === CONTINUE || result === RETURN) {
|
|
3256
3505
|
return [2, result];
|
|
@@ -3263,7 +3512,7 @@
|
|
|
3263
3512
|
}
|
|
3264
3513
|
});
|
|
3265
3514
|
}
|
|
3266
|
-
function SwitchCase
|
|
3515
|
+
function SwitchCase(node, scope) {
|
|
3267
3516
|
var i, result;
|
|
3268
3517
|
return __generator(this, function (_a) {
|
|
3269
3518
|
switch (_a.label) {
|
|
@@ -3272,7 +3521,7 @@
|
|
|
3272
3521
|
_a.label = 1;
|
|
3273
3522
|
case 1:
|
|
3274
3523
|
if (!(i < node.consequent.length)) return [3, 4];
|
|
3275
|
-
return [5, __values(evaluate
|
|
3524
|
+
return [5, __values(evaluate(node.consequent[i], scope))];
|
|
3276
3525
|
case 2:
|
|
3277
3526
|
result = _a.sent();
|
|
3278
3527
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
@@ -3286,22 +3535,25 @@
|
|
|
3286
3535
|
}
|
|
3287
3536
|
});
|
|
3288
3537
|
}
|
|
3289
|
-
function ThrowStatement
|
|
3538
|
+
function ThrowStatement(node, scope) {
|
|
3290
3539
|
return __generator(this, function (_a) {
|
|
3291
3540
|
switch (_a.label) {
|
|
3292
|
-
case 0: return [5, __values(evaluate
|
|
3541
|
+
case 0: return [5, __values(evaluate(node.argument, scope))];
|
|
3293
3542
|
case 1: throw _a.sent();
|
|
3294
3543
|
}
|
|
3295
3544
|
});
|
|
3296
3545
|
}
|
|
3297
|
-
function TryStatement
|
|
3298
|
-
var err_1, subScope, param, name_1
|
|
3546
|
+
function TryStatement(node, scope, options) {
|
|
3547
|
+
var result, err_1, subScope, param, name_1;
|
|
3548
|
+
if (options === void 0) { options = {}; }
|
|
3299
3549
|
return __generator(this, function (_a) {
|
|
3300
3550
|
switch (_a.label) {
|
|
3301
3551
|
case 0:
|
|
3302
3552
|
_a.trys.push([0, 2, 9, 12]);
|
|
3303
|
-
return [5, __values(BlockStatement
|
|
3304
|
-
case 1:
|
|
3553
|
+
return [5, __values(BlockStatement(node.block, scope))];
|
|
3554
|
+
case 1:
|
|
3555
|
+
result = _a.sent();
|
|
3556
|
+
return [3, 12];
|
|
3305
3557
|
case 2:
|
|
3306
3558
|
err_1 = _a.sent();
|
|
3307
3559
|
if (!node.handler) return [3, 7];
|
|
@@ -3312,51 +3564,67 @@
|
|
|
3312
3564
|
name_1 = param.name;
|
|
3313
3565
|
subScope.var(name_1, err_1);
|
|
3314
3566
|
return [3, 5];
|
|
3315
|
-
case 3: return [5, __values(pattern$
|
|
3567
|
+
case 3: return [5, __values(pattern$1(param, scope, { feed: err_1 }))];
|
|
3316
3568
|
case 4:
|
|
3317
3569
|
_a.sent();
|
|
3318
3570
|
_a.label = 5;
|
|
3319
|
-
case 5: return [5, __values(CatchClause
|
|
3320
|
-
case 6:
|
|
3571
|
+
case 5: return [5, __values(CatchClause(node.handler, subScope))];
|
|
3572
|
+
case 6:
|
|
3573
|
+
result = _a.sent();
|
|
3574
|
+
return [3, 8];
|
|
3321
3575
|
case 7: throw err_1;
|
|
3322
3576
|
case 8: return [3, 12];
|
|
3323
3577
|
case 9:
|
|
3324
3578
|
if (!node.finalizer) return [3, 11];
|
|
3325
|
-
return [5, __values(BlockStatement
|
|
3579
|
+
return [5, __values(BlockStatement(node.finalizer, scope))];
|
|
3326
3580
|
case 10:
|
|
3327
3581
|
result = _a.sent();
|
|
3328
|
-
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
3329
|
-
return [2, result];
|
|
3330
|
-
}
|
|
3331
3582
|
_a.label = 11;
|
|
3332
3583
|
case 11: return [7];
|
|
3333
|
-
case 12:
|
|
3584
|
+
case 12:
|
|
3585
|
+
if (result === BREAK) {
|
|
3586
|
+
if (result.LABEL && result.LABEL === options.label) {
|
|
3587
|
+
return [2];
|
|
3588
|
+
}
|
|
3589
|
+
return [2, result];
|
|
3590
|
+
}
|
|
3591
|
+
if (result === CONTINUE || result === RETURN) {
|
|
3592
|
+
return [2, result];
|
|
3593
|
+
}
|
|
3594
|
+
return [2];
|
|
3334
3595
|
}
|
|
3335
3596
|
});
|
|
3336
3597
|
}
|
|
3337
|
-
function CatchClause
|
|
3598
|
+
function CatchClause(node, scope) {
|
|
3338
3599
|
return __generator(this, function (_a) {
|
|
3339
3600
|
switch (_a.label) {
|
|
3340
|
-
case 0: return [5, __values(BlockStatement
|
|
3601
|
+
case 0: return [5, __values(BlockStatement(node.body, scope, { invasived: true }))];
|
|
3341
3602
|
case 1: return [2, _a.sent()];
|
|
3342
3603
|
}
|
|
3343
3604
|
});
|
|
3344
3605
|
}
|
|
3345
|
-
function WhileStatement
|
|
3606
|
+
function WhileStatement(node, scope, options) {
|
|
3346
3607
|
var result;
|
|
3608
|
+
if (options === void 0) { options = {}; }
|
|
3347
3609
|
return __generator(this, function (_a) {
|
|
3348
3610
|
switch (_a.label) {
|
|
3349
|
-
case 0: return [5, __values(evaluate
|
|
3611
|
+
case 0: return [5, __values(evaluate(node.test, scope))];
|
|
3350
3612
|
case 1:
|
|
3351
3613
|
if (!_a.sent()) return [3, 3];
|
|
3352
|
-
return [5, __values(evaluate
|
|
3614
|
+
return [5, __values(evaluate(node.body, scope))];
|
|
3353
3615
|
case 2:
|
|
3354
3616
|
result = _a.sent();
|
|
3355
3617
|
if (result === BREAK) {
|
|
3356
|
-
|
|
3618
|
+
if (result.LABEL === options.label) {
|
|
3619
|
+
return [3, 3];
|
|
3620
|
+
}
|
|
3621
|
+
return [2, result];
|
|
3357
3622
|
}
|
|
3358
3623
|
else if (result === CONTINUE) {
|
|
3359
|
-
|
|
3624
|
+
if (result.LABEL === options.label) {
|
|
3625
|
+
return [3, 0];
|
|
3626
|
+
}
|
|
3627
|
+
return [2, result];
|
|
3360
3628
|
}
|
|
3361
3629
|
else if (result === RETURN) {
|
|
3362
3630
|
return [2, result];
|
|
@@ -3366,24 +3634,31 @@
|
|
|
3366
3634
|
}
|
|
3367
3635
|
});
|
|
3368
3636
|
}
|
|
3369
|
-
function DoWhileStatement
|
|
3637
|
+
function DoWhileStatement(node, scope, options) {
|
|
3370
3638
|
var result;
|
|
3639
|
+
if (options === void 0) { options = {}; }
|
|
3371
3640
|
return __generator(this, function (_a) {
|
|
3372
3641
|
switch (_a.label) {
|
|
3373
|
-
case 0: return [5, __values(evaluate
|
|
3642
|
+
case 0: return [5, __values(evaluate(node.body, scope))];
|
|
3374
3643
|
case 1:
|
|
3375
3644
|
result = _a.sent();
|
|
3376
3645
|
if (result === BREAK) {
|
|
3377
|
-
|
|
3646
|
+
if (result.LABEL === options.label) {
|
|
3647
|
+
return [3, 4];
|
|
3648
|
+
}
|
|
3649
|
+
return [2, result];
|
|
3378
3650
|
}
|
|
3379
3651
|
else if (result === CONTINUE) {
|
|
3380
|
-
|
|
3652
|
+
if (result.LABEL === options.label) {
|
|
3653
|
+
return [3, 2];
|
|
3654
|
+
}
|
|
3655
|
+
return [2, result];
|
|
3381
3656
|
}
|
|
3382
3657
|
else if (result === RETURN) {
|
|
3383
3658
|
return [2, result];
|
|
3384
3659
|
}
|
|
3385
3660
|
_a.label = 2;
|
|
3386
|
-
case 2: return [5, __values(evaluate
|
|
3661
|
+
case 2: return [5, __values(evaluate(node.test, scope))];
|
|
3387
3662
|
case 3:
|
|
3388
3663
|
if (_a.sent()) return [3, 0];
|
|
3389
3664
|
_a.label = 4;
|
|
@@ -3391,19 +3666,20 @@
|
|
|
3391
3666
|
}
|
|
3392
3667
|
});
|
|
3393
3668
|
}
|
|
3394
|
-
function ForStatement
|
|
3669
|
+
function ForStatement(node, scope, options) {
|
|
3395
3670
|
var forScope, _a, subScope, result;
|
|
3671
|
+
if (options === void 0) { options = {}; }
|
|
3396
3672
|
return __generator(this, function (_b) {
|
|
3397
3673
|
switch (_b.label) {
|
|
3398
3674
|
case 0:
|
|
3399
3675
|
forScope = new Scope(scope);
|
|
3400
|
-
return [5, __values(evaluate
|
|
3676
|
+
return [5, __values(evaluate(node.init, forScope))];
|
|
3401
3677
|
case 1:
|
|
3402
3678
|
_b.sent();
|
|
3403
3679
|
_b.label = 2;
|
|
3404
3680
|
case 2:
|
|
3405
3681
|
if (!node.test) return [3, 4];
|
|
3406
|
-
return [5, __values(evaluate
|
|
3682
|
+
return [5, __values(evaluate(node.test, forScope))];
|
|
3407
3683
|
case 3:
|
|
3408
3684
|
_a = (_b.sent());
|
|
3409
3685
|
return [3, 5];
|
|
@@ -3415,26 +3691,32 @@
|
|
|
3415
3691
|
subScope = new Scope(forScope);
|
|
3416
3692
|
result = void 0;
|
|
3417
3693
|
if (!(node.body.type === 'BlockStatement')) return [3, 7];
|
|
3418
|
-
return [5, __values(BlockStatement
|
|
3694
|
+
return [5, __values(BlockStatement(node.body, subScope, { invasived: true }))];
|
|
3419
3695
|
case 6:
|
|
3420
3696
|
result = _b.sent();
|
|
3421
3697
|
return [3, 9];
|
|
3422
|
-
case 7: return [5, __values(evaluate
|
|
3698
|
+
case 7: return [5, __values(evaluate(node.body, subScope))];
|
|
3423
3699
|
case 8:
|
|
3424
3700
|
result = _b.sent();
|
|
3425
3701
|
_b.label = 9;
|
|
3426
3702
|
case 9:
|
|
3427
3703
|
if (result === BREAK) {
|
|
3428
|
-
|
|
3704
|
+
if (result.LABEL === options.label) {
|
|
3705
|
+
return [3, 12];
|
|
3706
|
+
}
|
|
3707
|
+
return [2, result];
|
|
3429
3708
|
}
|
|
3430
3709
|
else if (result === CONTINUE) {
|
|
3431
|
-
|
|
3710
|
+
if (result.LABEL === options.label) {
|
|
3711
|
+
return [3, 10];
|
|
3712
|
+
}
|
|
3713
|
+
return [2, result];
|
|
3432
3714
|
}
|
|
3433
3715
|
else if (result === RETURN) {
|
|
3434
3716
|
return [2, result];
|
|
3435
3717
|
}
|
|
3436
3718
|
_b.label = 10;
|
|
3437
|
-
case 10: return [5, __values(evaluate
|
|
3719
|
+
case 10: return [5, __values(evaluate(node.update, forScope))];
|
|
3438
3720
|
case 11:
|
|
3439
3721
|
_b.sent();
|
|
3440
3722
|
return [3, 2];
|
|
@@ -3442,13 +3724,14 @@
|
|
|
3442
3724
|
}
|
|
3443
3725
|
});
|
|
3444
3726
|
}
|
|
3445
|
-
function ForInStatement
|
|
3727
|
+
function ForInStatement(node, scope, options) {
|
|
3446
3728
|
var _a, _b, _i, value, result;
|
|
3729
|
+
if (options === void 0) { options = {}; }
|
|
3447
3730
|
return __generator(this, function (_c) {
|
|
3448
3731
|
switch (_c.label) {
|
|
3449
3732
|
case 0:
|
|
3450
3733
|
_a = [];
|
|
3451
|
-
return [5, __values(evaluate
|
|
3734
|
+
return [5, __values(evaluate(node.right, scope))];
|
|
3452
3735
|
case 1:
|
|
3453
3736
|
for (_b in _c.sent())
|
|
3454
3737
|
_a.push(_b);
|
|
@@ -3457,14 +3740,20 @@
|
|
|
3457
3740
|
case 2:
|
|
3458
3741
|
if (!(_i < _a.length)) return [3, 5];
|
|
3459
3742
|
value = _a[_i];
|
|
3460
|
-
return [5, __values(ForXHandler(node, scope, { value: value }))];
|
|
3743
|
+
return [5, __values(ForXHandler$1(node, scope, { value: value }))];
|
|
3461
3744
|
case 3:
|
|
3462
3745
|
result = _c.sent();
|
|
3463
3746
|
if (result === BREAK) {
|
|
3464
|
-
|
|
3747
|
+
if (result.LABEL === options.label) {
|
|
3748
|
+
return [3, 5];
|
|
3749
|
+
}
|
|
3750
|
+
return [2, result];
|
|
3465
3751
|
}
|
|
3466
3752
|
else if (result === CONTINUE) {
|
|
3467
|
-
|
|
3753
|
+
if (result.LABEL === options.label) {
|
|
3754
|
+
return [3, 4];
|
|
3755
|
+
}
|
|
3756
|
+
return [2, result];
|
|
3468
3757
|
}
|
|
3469
3758
|
else if (result === RETURN) {
|
|
3470
3759
|
return [2, result];
|
|
@@ -3477,12 +3766,13 @@
|
|
|
3477
3766
|
}
|
|
3478
3767
|
});
|
|
3479
3768
|
}
|
|
3480
|
-
function ForOfStatement
|
|
3769
|
+
function ForOfStatement(node, scope, options) {
|
|
3481
3770
|
var right, iterator, ret, result, right_1, right_1_1, value, result, e_1_1;
|
|
3482
3771
|
var e_1, _a;
|
|
3772
|
+
if (options === void 0) { options = {}; }
|
|
3483
3773
|
return __generator(this, function (_b) {
|
|
3484
3774
|
switch (_b.label) {
|
|
3485
|
-
case 0: return [5, __values(evaluate
|
|
3775
|
+
case 0: return [5, __values(evaluate(node.right, scope))];
|
|
3486
3776
|
case 1:
|
|
3487
3777
|
right = _b.sent();
|
|
3488
3778
|
if (!node.await) return [3, 8];
|
|
@@ -3495,14 +3785,20 @@
|
|
|
3495
3785
|
_b.label = 3;
|
|
3496
3786
|
case 3:
|
|
3497
3787
|
if (!!ret.done) return [3, 7];
|
|
3498
|
-
return [5, __values(ForXHandler(node, scope, { value: ret.value }))];
|
|
3788
|
+
return [5, __values(ForXHandler$1(node, scope, { value: ret.value }))];
|
|
3499
3789
|
case 4:
|
|
3500
3790
|
result = _b.sent();
|
|
3501
3791
|
if (result === BREAK) {
|
|
3502
|
-
|
|
3792
|
+
if (result.LABEL === options.label) {
|
|
3793
|
+
return [3, 7];
|
|
3794
|
+
}
|
|
3795
|
+
return [2, result];
|
|
3503
3796
|
}
|
|
3504
3797
|
else if (result === CONTINUE) {
|
|
3505
|
-
|
|
3798
|
+
if (result.LABEL === options.label) {
|
|
3799
|
+
return [3, 5];
|
|
3800
|
+
}
|
|
3801
|
+
return [2, result];
|
|
3506
3802
|
}
|
|
3507
3803
|
else if (result === RETURN) {
|
|
3508
3804
|
return [2, result];
|
|
@@ -3522,14 +3818,20 @@
|
|
|
3522
3818
|
case 9:
|
|
3523
3819
|
if (!!right_1_1.done) return [3, 12];
|
|
3524
3820
|
value = right_1_1.value;
|
|
3525
|
-
return [5, __values(ForXHandler(node, scope, { value: value }))];
|
|
3821
|
+
return [5, __values(ForXHandler$1(node, scope, { value: value }))];
|
|
3526
3822
|
case 10:
|
|
3527
3823
|
result = _b.sent();
|
|
3528
3824
|
if (result === BREAK) {
|
|
3529
|
-
|
|
3825
|
+
if (result.LABEL === options.label) {
|
|
3826
|
+
return [3, 12];
|
|
3827
|
+
}
|
|
3828
|
+
return [2, result];
|
|
3530
3829
|
}
|
|
3531
3830
|
else if (result === CONTINUE) {
|
|
3532
|
-
|
|
3831
|
+
if (result.LABEL === options.label) {
|
|
3832
|
+
return [3, 11];
|
|
3833
|
+
}
|
|
3834
|
+
return [2, result];
|
|
3533
3835
|
}
|
|
3534
3836
|
else if (result === RETURN) {
|
|
3535
3837
|
return [2, result];
|
|
@@ -3554,13 +3856,13 @@
|
|
|
3554
3856
|
});
|
|
3555
3857
|
}
|
|
3556
3858
|
|
|
3557
|
-
function FunctionDeclaration
|
|
3859
|
+
function FunctionDeclaration(node, scope) {
|
|
3558
3860
|
return __generator(this, function (_a) {
|
|
3559
|
-
scope.func(node.id.name, createFunc(node, scope));
|
|
3861
|
+
scope.func(node.id.name, createFunc$1(node, scope));
|
|
3560
3862
|
return [2];
|
|
3561
3863
|
});
|
|
3562
3864
|
}
|
|
3563
|
-
function VariableDeclaration
|
|
3865
|
+
function VariableDeclaration(node, scope, options) {
|
|
3564
3866
|
var i;
|
|
3565
3867
|
if (options === void 0) { options = {}; }
|
|
3566
3868
|
return __generator(this, function (_a) {
|
|
@@ -3570,7 +3872,7 @@
|
|
|
3570
3872
|
_a.label = 1;
|
|
3571
3873
|
case 1:
|
|
3572
3874
|
if (!(i < node.declarations.length)) return [3, 4];
|
|
3573
|
-
return [5, __values(VariableDeclarator
|
|
3875
|
+
return [5, __values(VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options)))];
|
|
3574
3876
|
case 2:
|
|
3575
3877
|
_a.sent();
|
|
3576
3878
|
_a.label = 3;
|
|
@@ -3581,7 +3883,7 @@
|
|
|
3581
3883
|
}
|
|
3582
3884
|
});
|
|
3583
3885
|
}
|
|
3584
|
-
function VariableDeclarator
|
|
3886
|
+
function VariableDeclarator(node, scope, options) {
|
|
3585
3887
|
var _a, kind, _b, hoist, _c, onlyBlock, feed, hasFeed, value, _d, name_1;
|
|
3586
3888
|
if (options === void 0) { options = {}; }
|
|
3587
3889
|
return __generator(this, function (_e) {
|
|
@@ -3593,7 +3895,7 @@
|
|
|
3593
3895
|
if (!(node.id.type === 'Identifier')) return [3, 1];
|
|
3594
3896
|
scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
3595
3897
|
return [3, 3];
|
|
3596
|
-
case 1: return [5, __values(pattern$
|
|
3898
|
+
case 1: return [5, __values(pattern$1(node.id, scope, { kind: kind, hoist: hoist, onlyBlock: onlyBlock }))];
|
|
3597
3899
|
case 2:
|
|
3598
3900
|
_e.sent();
|
|
3599
3901
|
_e.label = 3;
|
|
@@ -3603,7 +3905,7 @@
|
|
|
3603
3905
|
if (!hasFeed) return [3, 5];
|
|
3604
3906
|
_d = feed;
|
|
3605
3907
|
return [3, 7];
|
|
3606
|
-
case 5: return [5, __values(evaluate
|
|
3908
|
+
case 5: return [5, __values(evaluate(node.init, scope))];
|
|
3607
3909
|
case 6:
|
|
3608
3910
|
_d = _e.sent();
|
|
3609
3911
|
_e.label = 7;
|
|
@@ -3627,7 +3929,7 @@
|
|
|
3627
3929
|
});
|
|
3628
3930
|
}
|
|
3629
3931
|
return [3, 10];
|
|
3630
|
-
case 8: return [5, __values(pattern$
|
|
3932
|
+
case 8: return [5, __values(pattern$1(node.id, scope, { kind: kind, feed: value }))];
|
|
3631
3933
|
case 9:
|
|
3632
3934
|
_e.sent();
|
|
3633
3935
|
_e.label = 10;
|
|
@@ -3635,21 +3937,21 @@
|
|
|
3635
3937
|
}
|
|
3636
3938
|
});
|
|
3637
3939
|
}
|
|
3638
|
-
function ClassDeclaration
|
|
3940
|
+
function ClassDeclaration(node, scope) {
|
|
3639
3941
|
var _a, _b, _c;
|
|
3640
3942
|
return __generator(this, function (_d) {
|
|
3641
3943
|
switch (_d.label) {
|
|
3642
3944
|
case 0:
|
|
3643
3945
|
_b = (_a = scope).func;
|
|
3644
3946
|
_c = [node.id.name];
|
|
3645
|
-
return [5, __values(createClass(node, scope))];
|
|
3947
|
+
return [5, __values(createClass$1(node, scope))];
|
|
3646
3948
|
case 1:
|
|
3647
3949
|
_b.apply(_a, _c.concat([_d.sent()]));
|
|
3648
3950
|
return [2];
|
|
3649
3951
|
}
|
|
3650
3952
|
});
|
|
3651
3953
|
}
|
|
3652
|
-
function ClassBody
|
|
3954
|
+
function ClassBody(node, scope, options) {
|
|
3653
3955
|
var klass, superClass, i, def;
|
|
3654
3956
|
if (options === void 0) { options = {}; }
|
|
3655
3957
|
return __generator(this, function (_a) {
|
|
@@ -3662,19 +3964,19 @@
|
|
|
3662
3964
|
if (!(i < node.body.length)) return [3, 8];
|
|
3663
3965
|
def = node.body[i];
|
|
3664
3966
|
if (!(def.type === 'MethodDefinition')) return [3, 3];
|
|
3665
|
-
return [5, __values(MethodDefinition
|
|
3967
|
+
return [5, __values(MethodDefinition(def, scope, { klass: klass, superClass: superClass }))];
|
|
3666
3968
|
case 2:
|
|
3667
3969
|
_a.sent();
|
|
3668
3970
|
return [3, 7];
|
|
3669
3971
|
case 3:
|
|
3670
3972
|
if (!(def.type === 'PropertyDefinition' && def.static)) return [3, 5];
|
|
3671
|
-
return [5, __values(PropertyDefinition
|
|
3973
|
+
return [5, __values(PropertyDefinition(def, scope, { klass: klass, superClass: superClass }))];
|
|
3672
3974
|
case 4:
|
|
3673
3975
|
_a.sent();
|
|
3674
3976
|
return [3, 7];
|
|
3675
3977
|
case 5:
|
|
3676
3978
|
if (!(def.type === 'StaticBlock')) return [3, 7];
|
|
3677
|
-
return [5, __values(StaticBlock
|
|
3979
|
+
return [5, __values(StaticBlock(def, scope, { klass: klass, superClass: superClass }))];
|
|
3678
3980
|
case 6:
|
|
3679
3981
|
_a.sent();
|
|
3680
3982
|
_a.label = 7;
|
|
@@ -3685,7 +3987,7 @@
|
|
|
3685
3987
|
}
|
|
3686
3988
|
});
|
|
3687
3989
|
}
|
|
3688
|
-
function MethodDefinition
|
|
3990
|
+
function MethodDefinition(node, scope, options) {
|
|
3689
3991
|
var klass, superClass, key, priv, obj, value, oriDptor, oriDptor;
|
|
3690
3992
|
if (options === void 0) { options = {}; }
|
|
3691
3993
|
return __generator(this, function (_a) {
|
|
@@ -3694,7 +3996,7 @@
|
|
|
3694
3996
|
klass = options.klass, superClass = options.superClass;
|
|
3695
3997
|
priv = false;
|
|
3696
3998
|
if (!node.computed) return [3, 2];
|
|
3697
|
-
return [5, __values(evaluate
|
|
3999
|
+
return [5, __values(evaluate(node.key, scope))];
|
|
3698
4000
|
case 1:
|
|
3699
4001
|
key = _a.sent();
|
|
3700
4002
|
return [3, 3];
|
|
@@ -3718,7 +4020,7 @@
|
|
|
3718
4020
|
}
|
|
3719
4021
|
obj = obj[PRIVATE];
|
|
3720
4022
|
}
|
|
3721
|
-
value = createFunc(node.value, scope, { superClass: superClass });
|
|
4023
|
+
value = createFunc$1(node.value, scope, { superClass: superClass });
|
|
3722
4024
|
switch (node.kind) {
|
|
3723
4025
|
case 'constructor':
|
|
3724
4026
|
break;
|
|
@@ -3754,7 +4056,7 @@
|
|
|
3754
4056
|
}
|
|
3755
4057
|
});
|
|
3756
4058
|
}
|
|
3757
|
-
function PropertyDefinition
|
|
4059
|
+
function PropertyDefinition(node, scope, options) {
|
|
3758
4060
|
var klass, superClass, key, priv, subScope, obj, _a, _b;
|
|
3759
4061
|
if (options === void 0) { options = {}; }
|
|
3760
4062
|
return __generator(this, function (_c) {
|
|
@@ -3763,7 +4065,7 @@
|
|
|
3763
4065
|
klass = options.klass, superClass = options.superClass;
|
|
3764
4066
|
priv = false;
|
|
3765
4067
|
if (!node.computed) return [3, 2];
|
|
3766
|
-
return [5, __values(evaluate
|
|
4068
|
+
return [5, __values(evaluate(node.key, scope))];
|
|
3767
4069
|
case 1:
|
|
3768
4070
|
key = _c.sent();
|
|
3769
4071
|
return [3, 3];
|
|
@@ -3790,12 +4092,12 @@
|
|
|
3790
4092
|
obj = obj[PRIVATE];
|
|
3791
4093
|
}
|
|
3792
4094
|
if (!(node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression')) return [3, 4];
|
|
3793
|
-
obj[key] = createFunc(node.value, subScope, { superClass: superClass });
|
|
4095
|
+
obj[key] = createFunc$1(node.value, subScope, { superClass: superClass });
|
|
3794
4096
|
return [3, 6];
|
|
3795
4097
|
case 4:
|
|
3796
4098
|
_a = obj;
|
|
3797
4099
|
_b = key;
|
|
3798
|
-
return [5, __values(evaluate
|
|
4100
|
+
return [5, __values(evaluate(node.value, subScope))];
|
|
3799
4101
|
case 5:
|
|
3800
4102
|
_a[_b] = _c.sent();
|
|
3801
4103
|
_c.label = 6;
|
|
@@ -3803,7 +4105,7 @@
|
|
|
3803
4105
|
}
|
|
3804
4106
|
});
|
|
3805
4107
|
}
|
|
3806
|
-
function StaticBlock
|
|
4108
|
+
function StaticBlock(node, scope, options) {
|
|
3807
4109
|
var klass, subScope;
|
|
3808
4110
|
if (options === void 0) { options = {}; }
|
|
3809
4111
|
return __generator(this, function (_a) {
|
|
@@ -3812,12 +4114,12 @@
|
|
|
3812
4114
|
klass = options.klass;
|
|
3813
4115
|
subScope = new Scope(scope, true);
|
|
3814
4116
|
subScope.const('this', klass);
|
|
3815
|
-
return [5, __values(BlockStatement
|
|
4117
|
+
return [5, __values(BlockStatement(node, subScope, { invasived: true }))];
|
|
3816
4118
|
case 1: return [2, _a.sent()];
|
|
3817
4119
|
}
|
|
3818
4120
|
});
|
|
3819
4121
|
}
|
|
3820
|
-
function ImportDeclaration
|
|
4122
|
+
function ImportDeclaration(node, scope) {
|
|
3821
4123
|
var globalScope, module, value, result, i, spec, name_2;
|
|
3822
4124
|
return __generator(this, function (_a) {
|
|
3823
4125
|
globalScope = scope.global();
|
|
@@ -3857,24 +4159,24 @@
|
|
|
3857
4159
|
return [2];
|
|
3858
4160
|
});
|
|
3859
4161
|
}
|
|
3860
|
-
function ExportDefaultDeclaration
|
|
4162
|
+
function ExportDefaultDeclaration(node, scope) {
|
|
3861
4163
|
var globalScope, value, variable, exports_1;
|
|
3862
4164
|
return __generator(this, function (_a) {
|
|
3863
4165
|
switch (_a.label) {
|
|
3864
4166
|
case 0:
|
|
3865
4167
|
globalScope = scope.global();
|
|
3866
4168
|
if (!(node.declaration.type === 'FunctionDeclaration')) return [3, 1];
|
|
3867
|
-
value = createFunc(node.declaration, scope);
|
|
4169
|
+
value = createFunc$1(node.declaration, scope);
|
|
3868
4170
|
scope.func(node.declaration.id.name, value);
|
|
3869
4171
|
return [3, 5];
|
|
3870
4172
|
case 1:
|
|
3871
4173
|
if (!(node.declaration.type === 'ClassDeclaration')) return [3, 3];
|
|
3872
|
-
return [5, __values(createClass(node.declaration, scope))];
|
|
4174
|
+
return [5, __values(createClass$1(node.declaration, scope))];
|
|
3873
4175
|
case 2:
|
|
3874
4176
|
value = _a.sent();
|
|
3875
4177
|
scope.func(node.declaration.id.name, value);
|
|
3876
4178
|
return [3, 5];
|
|
3877
|
-
case 3: return [5, __values(evaluate
|
|
4179
|
+
case 3: return [5, __values(evaluate(node.declaration, scope))];
|
|
3878
4180
|
case 4:
|
|
3879
4181
|
value = _a.sent();
|
|
3880
4182
|
_a.label = 5;
|
|
@@ -3890,7 +4192,7 @@
|
|
|
3890
4192
|
}
|
|
3891
4193
|
});
|
|
3892
4194
|
}
|
|
3893
|
-
function ExportNamedDeclaration
|
|
4195
|
+
function ExportNamedDeclaration(node, scope) {
|
|
3894
4196
|
var globalScope, value, variable, exports_2, value, variable, exports_3, variable, exports_4, i, name_3, item, variable, exports_5, i, spec, name_4, item;
|
|
3895
4197
|
return __generator(this, function (_a) {
|
|
3896
4198
|
switch (_a.label) {
|
|
@@ -3898,7 +4200,7 @@
|
|
|
3898
4200
|
globalScope = scope.global();
|
|
3899
4201
|
if (!node.declaration) return [3, 6];
|
|
3900
4202
|
if (!(node.declaration.type === 'FunctionDeclaration')) return [3, 1];
|
|
3901
|
-
value = createFunc(node.declaration, scope);
|
|
4203
|
+
value = createFunc$1(node.declaration, scope);
|
|
3902
4204
|
scope.func(node.declaration.id.name, value);
|
|
3903
4205
|
variable = globalScope.find(EXPORTS);
|
|
3904
4206
|
if (variable) {
|
|
@@ -3910,7 +4212,7 @@
|
|
|
3910
4212
|
return [3, 5];
|
|
3911
4213
|
case 1:
|
|
3912
4214
|
if (!(node.declaration.type === 'ClassDeclaration')) return [3, 3];
|
|
3913
|
-
return [5, __values(createClass(node.declaration, scope))];
|
|
4215
|
+
return [5, __values(createClass$1(node.declaration, scope))];
|
|
3914
4216
|
case 2:
|
|
3915
4217
|
value = _a.sent();
|
|
3916
4218
|
scope.func(node.declaration.id.name, value);
|
|
@@ -3924,7 +4226,7 @@
|
|
|
3924
4226
|
return [3, 5];
|
|
3925
4227
|
case 3:
|
|
3926
4228
|
if (!(node.declaration.type === 'VariableDeclaration')) return [3, 5];
|
|
3927
|
-
return [5, __values(VariableDeclaration
|
|
4229
|
+
return [5, __values(VariableDeclaration(node.declaration, scope))];
|
|
3928
4230
|
case 4:
|
|
3929
4231
|
_a.sent();
|
|
3930
4232
|
variable = globalScope.find(EXPORTS);
|
|
@@ -3966,7 +4268,7 @@
|
|
|
3966
4268
|
}
|
|
3967
4269
|
});
|
|
3968
4270
|
}
|
|
3969
|
-
function ExportAllDeclaration
|
|
4271
|
+
function ExportAllDeclaration(node, scope) {
|
|
3970
4272
|
var globalScope, module, value, result, variable, exports_6;
|
|
3971
4273
|
return __generator(this, function (_a) {
|
|
3972
4274
|
globalScope = scope.global();
|
|
@@ -4043,7 +4345,7 @@
|
|
|
4043
4345
|
});
|
|
4044
4346
|
}
|
|
4045
4347
|
|
|
4046
|
-
function hoist(block, scope, options) {
|
|
4348
|
+
function hoist$1(block, scope, options) {
|
|
4047
4349
|
var _a, onlyBlock, funcDclrList, funcDclrIdxs, i, statement, i;
|
|
4048
4350
|
if (options === void 0) { options = {}; }
|
|
4049
4351
|
return __generator(this, function (_b) {
|
|
@@ -4064,13 +4366,13 @@
|
|
|
4064
4366
|
case 2:
|
|
4065
4367
|
if (!(statement.type === 'VariableDeclaration'
|
|
4066
4368
|
&& ['const', 'let'].indexOf(statement.kind) !== -1)) return [3, 4];
|
|
4067
|
-
return [5, __values(VariableDeclaration
|
|
4369
|
+
return [5, __values(VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true }))];
|
|
4068
4370
|
case 3:
|
|
4069
4371
|
_b.sent();
|
|
4070
4372
|
return [3, 6];
|
|
4071
4373
|
case 4:
|
|
4072
4374
|
if (!!onlyBlock) return [3, 6];
|
|
4073
|
-
return [5, __values(hoistVarRecursion(statement, scope))];
|
|
4375
|
+
return [5, __values(hoistVarRecursion$1(statement, scope))];
|
|
4074
4376
|
case 5:
|
|
4075
4377
|
_b.sent();
|
|
4076
4378
|
_b.label = 6;
|
|
@@ -4088,7 +4390,7 @@
|
|
|
4088
4390
|
}
|
|
4089
4391
|
});
|
|
4090
4392
|
}
|
|
4091
|
-
function hoistVarRecursion(statement, scope) {
|
|
4393
|
+
function hoistVarRecursion$1(statement, scope) {
|
|
4092
4394
|
var _a, i, i, j, tryBlock, i, catchBlock, i, finalBlock, i;
|
|
4093
4395
|
return __generator(this, function (_b) {
|
|
4094
4396
|
switch (_b.label) {
|
|
@@ -4107,31 +4409,31 @@
|
|
|
4107
4409
|
case 'TryStatement': return [3, 25];
|
|
4108
4410
|
}
|
|
4109
4411
|
return [3, 38];
|
|
4110
|
-
case 1: return [5, __values(VariableDeclaration
|
|
4412
|
+
case 1: return [5, __values(VariableDeclaration(statement, scope, { hoist: true }))];
|
|
4111
4413
|
case 2:
|
|
4112
4414
|
_b.sent();
|
|
4113
4415
|
return [3, 38];
|
|
4114
4416
|
case 3:
|
|
4115
4417
|
if (!(statement.left.type === 'VariableDeclaration')) return [3, 5];
|
|
4116
|
-
return [5, __values(VariableDeclaration
|
|
4418
|
+
return [5, __values(VariableDeclaration(statement.left, scope, { hoist: true }))];
|
|
4117
4419
|
case 4:
|
|
4118
4420
|
_b.sent();
|
|
4119
4421
|
_b.label = 5;
|
|
4120
4422
|
case 5:
|
|
4121
4423
|
if (!(statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration')) return [3, 7];
|
|
4122
|
-
return [5, __values(VariableDeclaration
|
|
4424
|
+
return [5, __values(VariableDeclaration(statement.init, scope, { hoist: true }))];
|
|
4123
4425
|
case 6:
|
|
4124
4426
|
_b.sent();
|
|
4125
4427
|
_b.label = 7;
|
|
4126
|
-
case 7: return [5, __values(hoistVarRecursion(statement.body, scope))];
|
|
4428
|
+
case 7: return [5, __values(hoistVarRecursion$1(statement.body, scope))];
|
|
4127
4429
|
case 8:
|
|
4128
4430
|
_b.sent();
|
|
4129
4431
|
return [3, 38];
|
|
4130
|
-
case 9: return [5, __values(hoistVarRecursion(statement.consequent, scope))];
|
|
4432
|
+
case 9: return [5, __values(hoistVarRecursion$1(statement.consequent, scope))];
|
|
4131
4433
|
case 10:
|
|
4132
4434
|
_b.sent();
|
|
4133
4435
|
if (!statement.alternate) return [3, 12];
|
|
4134
|
-
return [5, __values(hoistVarRecursion(statement.alternate, scope))];
|
|
4436
|
+
return [5, __values(hoistVarRecursion$1(statement.alternate, scope))];
|
|
4135
4437
|
case 11:
|
|
4136
4438
|
_b.sent();
|
|
4137
4439
|
_b.label = 12;
|
|
@@ -4141,7 +4443,7 @@
|
|
|
4141
4443
|
_b.label = 14;
|
|
4142
4444
|
case 14:
|
|
4143
4445
|
if (!(i < statement.body.length)) return [3, 17];
|
|
4144
|
-
return [5, __values(hoistVarRecursion(statement.body[i], scope))];
|
|
4446
|
+
return [5, __values(hoistVarRecursion$1(statement.body[i], scope))];
|
|
4145
4447
|
case 15:
|
|
4146
4448
|
_b.sent();
|
|
4147
4449
|
_b.label = 16;
|
|
@@ -4158,7 +4460,7 @@
|
|
|
4158
4460
|
_b.label = 20;
|
|
4159
4461
|
case 20:
|
|
4160
4462
|
if (!(j < statement.cases[i].consequent.length)) return [3, 23];
|
|
4161
|
-
return [5, __values(hoistVarRecursion(statement.cases[i].consequent[j], scope))];
|
|
4463
|
+
return [5, __values(hoistVarRecursion$1(statement.cases[i].consequent[j], scope))];
|
|
4162
4464
|
case 21:
|
|
4163
4465
|
_b.sent();
|
|
4164
4466
|
_b.label = 22;
|
|
@@ -4175,7 +4477,7 @@
|
|
|
4175
4477
|
_b.label = 26;
|
|
4176
4478
|
case 26:
|
|
4177
4479
|
if (!(i < tryBlock.length)) return [3, 29];
|
|
4178
|
-
return [5, __values(hoistVarRecursion(tryBlock[i], scope))];
|
|
4480
|
+
return [5, __values(hoistVarRecursion$1(tryBlock[i], scope))];
|
|
4179
4481
|
case 27:
|
|
4180
4482
|
_b.sent();
|
|
4181
4483
|
_b.label = 28;
|
|
@@ -4189,7 +4491,7 @@
|
|
|
4189
4491
|
_b.label = 30;
|
|
4190
4492
|
case 30:
|
|
4191
4493
|
if (!(i < catchBlock.length)) return [3, 33];
|
|
4192
|
-
return [5, __values(hoistVarRecursion(catchBlock[i], scope))];
|
|
4494
|
+
return [5, __values(hoistVarRecursion$1(catchBlock[i], scope))];
|
|
4193
4495
|
case 31:
|
|
4194
4496
|
_b.sent();
|
|
4195
4497
|
_b.label = 32;
|
|
@@ -4203,7 +4505,7 @@
|
|
|
4203
4505
|
_b.label = 34;
|
|
4204
4506
|
case 34:
|
|
4205
4507
|
if (!(i < finalBlock.length)) return [3, 37];
|
|
4206
|
-
return [5, __values(hoistVarRecursion(finalBlock[i], scope))];
|
|
4508
|
+
return [5, __values(hoistVarRecursion$1(finalBlock[i], scope))];
|
|
4207
4509
|
case 35:
|
|
4208
4510
|
_b.sent();
|
|
4209
4511
|
_b.label = 36;
|
|
@@ -4215,7 +4517,7 @@
|
|
|
4215
4517
|
}
|
|
4216
4518
|
});
|
|
4217
4519
|
}
|
|
4218
|
-
function pattern$
|
|
4520
|
+
function pattern$1(node, scope, options) {
|
|
4219
4521
|
var _a;
|
|
4220
4522
|
if (options === void 0) { options = {}; }
|
|
4221
4523
|
return __generator(this, function (_b) {
|
|
@@ -4229,28 +4531,29 @@
|
|
|
4229
4531
|
case 'AssignmentPattern': return [3, 7];
|
|
4230
4532
|
}
|
|
4231
4533
|
return [3, 9];
|
|
4232
|
-
case 1: return [5, __values(ObjectPattern
|
|
4534
|
+
case 1: return [5, __values(ObjectPattern(node, scope, options))];
|
|
4233
4535
|
case 2: return [2, _b.sent()];
|
|
4234
|
-
case 3: return [5, __values(ArrayPattern
|
|
4536
|
+
case 3: return [5, __values(ArrayPattern(node, scope, options))];
|
|
4235
4537
|
case 4: return [2, _b.sent()];
|
|
4236
|
-
case 5: return [5, __values(RestElement
|
|
4538
|
+
case 5: return [5, __values(RestElement(node, scope, options))];
|
|
4237
4539
|
case 6: return [2, _b.sent()];
|
|
4238
|
-
case 7: return [5, __values(AssignmentPattern
|
|
4540
|
+
case 7: return [5, __values(AssignmentPattern(node, scope, options))];
|
|
4239
4541
|
case 8: return [2, _b.sent()];
|
|
4240
4542
|
case 9: throw new SyntaxError('Unexpected token');
|
|
4241
4543
|
}
|
|
4242
4544
|
});
|
|
4243
4545
|
}
|
|
4244
|
-
function createFunc(node, scope, options) {
|
|
4546
|
+
function createFunc$1(node, scope, options) {
|
|
4547
|
+
var _a;
|
|
4245
4548
|
if (options === void 0) { options = {}; }
|
|
4246
4549
|
if (!node.generator && !node.async) {
|
|
4247
|
-
return createFunc
|
|
4550
|
+
return createFunc(node, scope, options);
|
|
4248
4551
|
}
|
|
4249
4552
|
var superClass = options.superClass, construct = options.construct;
|
|
4250
4553
|
var params = node.params;
|
|
4251
|
-
var tmpFunc = function
|
|
4554
|
+
var tmpFunc = function _b() {
|
|
4252
4555
|
var _i, subScope, i, param, result;
|
|
4253
|
-
var _newTarget = this && this instanceof
|
|
4556
|
+
var _newTarget = this && this instanceof _b ? this.constructor : void 0;
|
|
4254
4557
|
var args = [];
|
|
4255
4558
|
for (_i = 0; _i < arguments.length; _i++) {
|
|
4256
4559
|
args[_i] = arguments[_i];
|
|
@@ -4286,11 +4589,11 @@
|
|
|
4286
4589
|
return [3, 9];
|
|
4287
4590
|
case 5:
|
|
4288
4591
|
if (!(param.type === 'RestElement')) return [3, 7];
|
|
4289
|
-
return [5, __values(RestElement
|
|
4592
|
+
return [5, __values(RestElement(param, subScope, { kind: 'var', feed: args.slice(i) }))];
|
|
4290
4593
|
case 6:
|
|
4291
4594
|
_a.sent();
|
|
4292
4595
|
return [3, 9];
|
|
4293
|
-
case 7: return [5, __values(pattern$
|
|
4596
|
+
case 7: return [5, __values(pattern$1(param, subScope, { kind: 'var', feed: args[i] }))];
|
|
4294
4597
|
case 8:
|
|
4295
4598
|
_a.sent();
|
|
4296
4599
|
_a.label = 9;
|
|
@@ -4299,17 +4602,17 @@
|
|
|
4299
4602
|
return [3, 4];
|
|
4300
4603
|
case 10:
|
|
4301
4604
|
if (!(node.body.type === 'BlockStatement')) return [3, 13];
|
|
4302
|
-
return [5, __values(hoist(node.body, subScope))];
|
|
4605
|
+
return [5, __values(hoist$1(node.body, subScope))];
|
|
4303
4606
|
case 11:
|
|
4304
4607
|
_a.sent();
|
|
4305
|
-
return [5, __values(BlockStatement
|
|
4608
|
+
return [5, __values(BlockStatement(node.body, subScope, {
|
|
4306
4609
|
invasived: true,
|
|
4307
4610
|
hoisted: true
|
|
4308
4611
|
}))];
|
|
4309
4612
|
case 12:
|
|
4310
4613
|
result = _a.sent();
|
|
4311
4614
|
return [3, 15];
|
|
4312
|
-
case 13: return [5, __values(evaluate
|
|
4615
|
+
case 13: return [5, __values(evaluate(node.body, subScope))];
|
|
4313
4616
|
case 14:
|
|
4314
4617
|
result = _a.sent();
|
|
4315
4618
|
if (node.type === 'ArrowFunctionExpression') {
|
|
@@ -4369,13 +4672,20 @@
|
|
|
4369
4672
|
value: params.length,
|
|
4370
4673
|
configurable: true
|
|
4371
4674
|
});
|
|
4675
|
+
var source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
|
|
4676
|
+
if (source) {
|
|
4677
|
+
define(func, 'toString', {
|
|
4678
|
+
value: function () { return source.substring(node.start, node.end); },
|
|
4679
|
+
configurable: true
|
|
4680
|
+
});
|
|
4681
|
+
}
|
|
4372
4682
|
return func;
|
|
4373
4683
|
}
|
|
4374
|
-
function createClass(node, scope) {
|
|
4684
|
+
function createClass$1(node, scope) {
|
|
4375
4685
|
var superClass, methodBody, construct, klass, i, method;
|
|
4376
4686
|
return __generator(this, function (_a) {
|
|
4377
4687
|
switch (_a.label) {
|
|
4378
|
-
case 0: return [5, __values(evaluate
|
|
4688
|
+
case 0: return [5, __values(evaluate(node.superClass, scope))];
|
|
4379
4689
|
case 1:
|
|
4380
4690
|
superClass = _a.sent();
|
|
4381
4691
|
methodBody = node.body.body;
|
|
@@ -4390,7 +4700,7 @@
|
|
|
4390
4700
|
if (!(i < methodBody.length)) return [3, 4];
|
|
4391
4701
|
def = methodBody[i];
|
|
4392
4702
|
if (!(def.type === 'PropertyDefinition' && !def.static)) return [3, 3];
|
|
4393
|
-
return [5, __values(PropertyDefinition
|
|
4703
|
+
return [5, __values(PropertyDefinition(def, scope, { klass: object, superClass: superClass }))];
|
|
4394
4704
|
case 2:
|
|
4395
4705
|
_a.sent();
|
|
4396
4706
|
_a.label = 3;
|
|
@@ -4417,14 +4727,14 @@
|
|
|
4417
4727
|
for (i = 0; i < methodBody.length; i++) {
|
|
4418
4728
|
method = methodBody[i];
|
|
4419
4729
|
if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
|
|
4420
|
-
klass = createFunc(method.value, scope, { superClass: superClass, construct: construct });
|
|
4730
|
+
klass = createFunc$1(method.value, scope, { superClass: superClass, construct: construct });
|
|
4421
4731
|
break;
|
|
4422
4732
|
}
|
|
4423
4733
|
}
|
|
4424
4734
|
if (superClass) {
|
|
4425
4735
|
inherits(klass, superClass);
|
|
4426
4736
|
}
|
|
4427
|
-
return [5, __values(ClassBody
|
|
4737
|
+
return [5, __values(ClassBody(node.body, scope, { klass: klass, superClass: superClass }))];
|
|
4428
4738
|
case 2:
|
|
4429
4739
|
_a.sent();
|
|
4430
4740
|
define(klass, CLSCTOR, { value: true });
|
|
@@ -4436,7 +4746,7 @@
|
|
|
4436
4746
|
}
|
|
4437
4747
|
});
|
|
4438
4748
|
}
|
|
4439
|
-
function ForXHandler(node, scope, options) {
|
|
4749
|
+
function ForXHandler$1(node, scope, options) {
|
|
4440
4750
|
var value, left, subScope, variable, result;
|
|
4441
4751
|
return __generator(this, function (_a) {
|
|
4442
4752
|
switch (_a.label) {
|
|
@@ -4445,28 +4755,28 @@
|
|
|
4445
4755
|
left = node.left;
|
|
4446
4756
|
subScope = new Scope(scope);
|
|
4447
4757
|
if (!(left.type === 'VariableDeclaration')) return [3, 2];
|
|
4448
|
-
return [5, __values(VariableDeclaration
|
|
4758
|
+
return [5, __values(VariableDeclaration(left, subScope, { feed: value }))];
|
|
4449
4759
|
case 1:
|
|
4450
4760
|
_a.sent();
|
|
4451
4761
|
return [3, 6];
|
|
4452
4762
|
case 2:
|
|
4453
4763
|
if (!(left.type === 'Identifier')) return [3, 4];
|
|
4454
|
-
return [5, __values(Identifier(left, scope, { getVar: true }))];
|
|
4764
|
+
return [5, __values(Identifier$1(left, scope, { getVar: true }))];
|
|
4455
4765
|
case 3:
|
|
4456
4766
|
variable = _a.sent();
|
|
4457
4767
|
variable.set(value);
|
|
4458
4768
|
return [3, 6];
|
|
4459
|
-
case 4: return [5, __values(pattern$
|
|
4769
|
+
case 4: return [5, __values(pattern$1(left, scope, { feed: value }))];
|
|
4460
4770
|
case 5:
|
|
4461
4771
|
_a.sent();
|
|
4462
4772
|
_a.label = 6;
|
|
4463
4773
|
case 6:
|
|
4464
4774
|
if (!(node.body.type === 'BlockStatement')) return [3, 8];
|
|
4465
|
-
return [5, __values(BlockStatement
|
|
4775
|
+
return [5, __values(BlockStatement(node.body, subScope, { invasived: true }))];
|
|
4466
4776
|
case 7:
|
|
4467
4777
|
result = _a.sent();
|
|
4468
4778
|
return [3, 10];
|
|
4469
|
-
case 8: return [5, __values(evaluate
|
|
4779
|
+
case 8: return [5, __values(evaluate(node.body, subScope))];
|
|
4470
4780
|
case 9:
|
|
4471
4781
|
result = _a.sent();
|
|
4472
4782
|
_a.label = 10;
|
|
@@ -4475,7 +4785,7 @@
|
|
|
4475
4785
|
});
|
|
4476
4786
|
}
|
|
4477
4787
|
|
|
4478
|
-
function hoist
|
|
4788
|
+
function hoist(block, scope, options) {
|
|
4479
4789
|
if (options === void 0) { options = {}; }
|
|
4480
4790
|
var _a = options.onlyBlock, onlyBlock = _a === void 0 ? false : _a;
|
|
4481
4791
|
var funcDclrList = [];
|
|
@@ -4488,10 +4798,10 @@
|
|
|
4488
4798
|
}
|
|
4489
4799
|
else if (statement.type === 'VariableDeclaration'
|
|
4490
4800
|
&& ['const', 'let'].indexOf(statement.kind) !== -1) {
|
|
4491
|
-
VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
|
|
4801
|
+
VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
|
|
4492
4802
|
}
|
|
4493
4803
|
else if (!onlyBlock) {
|
|
4494
|
-
hoistVarRecursion
|
|
4804
|
+
hoistVarRecursion(statement, scope);
|
|
4495
4805
|
}
|
|
4496
4806
|
}
|
|
4497
4807
|
if (funcDclrIdxs.length) {
|
|
@@ -4501,87 +4811,88 @@
|
|
|
4501
4811
|
block.body = funcDclrList.concat(block.body);
|
|
4502
4812
|
}
|
|
4503
4813
|
}
|
|
4504
|
-
function hoistVarRecursion
|
|
4814
|
+
function hoistVarRecursion(statement, scope) {
|
|
4505
4815
|
switch (statement.type) {
|
|
4506
4816
|
case 'VariableDeclaration':
|
|
4507
|
-
VariableDeclaration(statement, scope, { hoist: true });
|
|
4817
|
+
VariableDeclaration$1(statement, scope, { hoist: true });
|
|
4508
4818
|
break;
|
|
4509
4819
|
case 'ForInStatement':
|
|
4510
4820
|
case 'ForOfStatement':
|
|
4511
4821
|
if (statement.left.type === 'VariableDeclaration') {
|
|
4512
|
-
VariableDeclaration(statement.left, scope, { hoist: true });
|
|
4822
|
+
VariableDeclaration$1(statement.left, scope, { hoist: true });
|
|
4513
4823
|
}
|
|
4514
4824
|
case 'ForStatement':
|
|
4515
4825
|
if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
|
|
4516
|
-
VariableDeclaration(statement.init, scope, { hoist: true });
|
|
4826
|
+
VariableDeclaration$1(statement.init, scope, { hoist: true });
|
|
4517
4827
|
}
|
|
4518
4828
|
case 'WhileStatement':
|
|
4519
4829
|
case 'DoWhileStatement':
|
|
4520
|
-
hoistVarRecursion
|
|
4830
|
+
hoistVarRecursion(statement.body, scope);
|
|
4521
4831
|
break;
|
|
4522
4832
|
case 'IfStatement':
|
|
4523
|
-
hoistVarRecursion
|
|
4833
|
+
hoistVarRecursion(statement.consequent, scope);
|
|
4524
4834
|
if (statement.alternate) {
|
|
4525
|
-
hoistVarRecursion
|
|
4835
|
+
hoistVarRecursion(statement.alternate, scope);
|
|
4526
4836
|
}
|
|
4527
4837
|
break;
|
|
4528
4838
|
case 'BlockStatement':
|
|
4529
4839
|
for (var i = 0; i < statement.body.length; i++) {
|
|
4530
|
-
hoistVarRecursion
|
|
4840
|
+
hoistVarRecursion(statement.body[i], scope);
|
|
4531
4841
|
}
|
|
4532
4842
|
break;
|
|
4533
4843
|
case 'SwitchStatement':
|
|
4534
4844
|
for (var i = 0; i < statement.cases.length; i++) {
|
|
4535
4845
|
for (var j = 0; j < statement.cases[i].consequent.length; j++) {
|
|
4536
|
-
hoistVarRecursion
|
|
4846
|
+
hoistVarRecursion(statement.cases[i].consequent[j], scope);
|
|
4537
4847
|
}
|
|
4538
4848
|
}
|
|
4539
4849
|
break;
|
|
4540
4850
|
case 'TryStatement': {
|
|
4541
4851
|
var tryBlock = statement.block.body;
|
|
4542
4852
|
for (var i = 0; i < tryBlock.length; i++) {
|
|
4543
|
-
hoistVarRecursion
|
|
4853
|
+
hoistVarRecursion(tryBlock[i], scope);
|
|
4544
4854
|
}
|
|
4545
4855
|
var catchBlock = statement.handler && statement.handler.body.body;
|
|
4546
4856
|
if (catchBlock) {
|
|
4547
4857
|
for (var i = 0; i < catchBlock.length; i++) {
|
|
4548
|
-
hoistVarRecursion
|
|
4858
|
+
hoistVarRecursion(catchBlock[i], scope);
|
|
4549
4859
|
}
|
|
4550
4860
|
}
|
|
4551
4861
|
var finalBlock = statement.finalizer && statement.finalizer.body;
|
|
4552
4862
|
if (finalBlock) {
|
|
4553
4863
|
for (var i = 0; i < finalBlock.length; i++) {
|
|
4554
|
-
hoistVarRecursion
|
|
4864
|
+
hoistVarRecursion(finalBlock[i], scope);
|
|
4555
4865
|
}
|
|
4556
4866
|
}
|
|
4557
4867
|
break;
|
|
4558
4868
|
}
|
|
4559
4869
|
}
|
|
4560
4870
|
}
|
|
4561
|
-
function pattern
|
|
4871
|
+
function pattern(node, scope, options) {
|
|
4562
4872
|
if (options === void 0) { options = {}; }
|
|
4563
4873
|
switch (node.type) {
|
|
4564
4874
|
case 'ObjectPattern':
|
|
4565
|
-
return ObjectPattern(node, scope, options);
|
|
4875
|
+
return ObjectPattern$1(node, scope, options);
|
|
4566
4876
|
case 'ArrayPattern':
|
|
4567
|
-
return ArrayPattern(node, scope, options);
|
|
4877
|
+
return ArrayPattern$1(node, scope, options);
|
|
4568
4878
|
case 'RestElement':
|
|
4569
|
-
return RestElement(node, scope, options);
|
|
4879
|
+
return RestElement$1(node, scope, options);
|
|
4570
4880
|
case 'AssignmentPattern':
|
|
4571
|
-
return AssignmentPattern(node, scope, options);
|
|
4881
|
+
return AssignmentPattern$1(node, scope, options);
|
|
4572
4882
|
default:
|
|
4573
4883
|
throw new SyntaxError('Unexpected token');
|
|
4574
4884
|
}
|
|
4575
4885
|
}
|
|
4576
|
-
function createFunc
|
|
4886
|
+
function createFunc(node, scope, options) {
|
|
4887
|
+
var _a;
|
|
4577
4888
|
if (options === void 0) { options = {}; }
|
|
4578
4889
|
if (node.generator || node.async) {
|
|
4579
|
-
return createFunc(node, scope, options);
|
|
4890
|
+
return createFunc$1(node, scope, options);
|
|
4580
4891
|
}
|
|
4581
4892
|
var superClass = options.superClass, construct = options.construct;
|
|
4582
4893
|
var params = node.params;
|
|
4583
|
-
var tmpFunc = function
|
|
4584
|
-
var _newTarget = this && this instanceof
|
|
4894
|
+
var tmpFunc = function _b() {
|
|
4895
|
+
var _newTarget = this && this instanceof _b ? this.constructor : void 0;
|
|
4585
4896
|
var args = [];
|
|
4586
4897
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
4587
4898
|
args[_i] = arguments[_i];
|
|
@@ -4606,22 +4917,22 @@
|
|
|
4606
4917
|
subScope.var(param.name, args[i]);
|
|
4607
4918
|
}
|
|
4608
4919
|
else if (param.type === 'RestElement') {
|
|
4609
|
-
RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
|
|
4920
|
+
RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
|
|
4610
4921
|
}
|
|
4611
4922
|
else {
|
|
4612
|
-
pattern
|
|
4923
|
+
pattern(param, subScope, { kind: 'var', feed: args[i] });
|
|
4613
4924
|
}
|
|
4614
4925
|
}
|
|
4615
4926
|
var result;
|
|
4616
4927
|
if (node.body.type === 'BlockStatement') {
|
|
4617
|
-
hoist
|
|
4618
|
-
result = BlockStatement(node.body, subScope, {
|
|
4928
|
+
hoist(node.body, subScope);
|
|
4929
|
+
result = BlockStatement$1(node.body, subScope, {
|
|
4619
4930
|
invasived: true,
|
|
4620
4931
|
hoisted: true
|
|
4621
4932
|
});
|
|
4622
4933
|
}
|
|
4623
4934
|
else {
|
|
4624
|
-
result = evaluate(node.body, subScope);
|
|
4935
|
+
result = evaluate$1(node.body, subScope);
|
|
4625
4936
|
if (node.type === 'ArrowFunctionExpression') {
|
|
4626
4937
|
RETURN.RES = result;
|
|
4627
4938
|
result = RETURN;
|
|
@@ -4645,16 +4956,23 @@
|
|
|
4645
4956
|
value: params.length,
|
|
4646
4957
|
configurable: true
|
|
4647
4958
|
});
|
|
4959
|
+
var source = (_a = node.loc) === null || _a === void 0 ? void 0 : _a.source;
|
|
4960
|
+
if (source) {
|
|
4961
|
+
define(func, 'toString', {
|
|
4962
|
+
value: function () { return source.substring(node.start, node.end); },
|
|
4963
|
+
configurable: true
|
|
4964
|
+
});
|
|
4965
|
+
}
|
|
4648
4966
|
return func;
|
|
4649
4967
|
}
|
|
4650
|
-
function createClass
|
|
4651
|
-
var superClass = evaluate(node.superClass, scope);
|
|
4968
|
+
function createClass(node, scope) {
|
|
4969
|
+
var superClass = evaluate$1(node.superClass, scope);
|
|
4652
4970
|
var methodBody = node.body.body;
|
|
4653
4971
|
var construct = function (object) {
|
|
4654
4972
|
for (var i = 0; i < methodBody.length; i++) {
|
|
4655
4973
|
var def = methodBody[i];
|
|
4656
4974
|
if (def.type === 'PropertyDefinition' && !def.static) {
|
|
4657
|
-
PropertyDefinition(def, scope, { klass: object, superClass: superClass });
|
|
4975
|
+
PropertyDefinition$1(def, scope, { klass: object, superClass: superClass });
|
|
4658
4976
|
}
|
|
4659
4977
|
}
|
|
4660
4978
|
};
|
|
@@ -4667,14 +4985,14 @@
|
|
|
4667
4985
|
for (var i = 0; i < methodBody.length; i++) {
|
|
4668
4986
|
var method = methodBody[i];
|
|
4669
4987
|
if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
|
|
4670
|
-
klass = createFunc
|
|
4988
|
+
klass = createFunc(method.value, scope, { superClass: superClass, construct: construct });
|
|
4671
4989
|
break;
|
|
4672
4990
|
}
|
|
4673
4991
|
}
|
|
4674
4992
|
if (superClass) {
|
|
4675
4993
|
inherits(klass, superClass);
|
|
4676
4994
|
}
|
|
4677
|
-
ClassBody(node.body, scope, { klass: klass, superClass: superClass });
|
|
4995
|
+
ClassBody$1(node.body, scope, { klass: klass, superClass: superClass });
|
|
4678
4996
|
define(klass, CLSCTOR, { value: true });
|
|
4679
4997
|
define(klass, 'name', {
|
|
4680
4998
|
value: node.id && node.id.name || '',
|
|
@@ -4682,26 +5000,26 @@
|
|
|
4682
5000
|
});
|
|
4683
5001
|
return klass;
|
|
4684
5002
|
}
|
|
4685
|
-
function ForXHandler
|
|
5003
|
+
function ForXHandler(node, scope, options) {
|
|
4686
5004
|
var value = options.value;
|
|
4687
5005
|
var left = node.left;
|
|
4688
5006
|
var subScope = new Scope(scope);
|
|
4689
5007
|
if (left.type === 'VariableDeclaration') {
|
|
4690
|
-
VariableDeclaration(left, subScope, { feed: value });
|
|
5008
|
+
VariableDeclaration$1(left, subScope, { feed: value });
|
|
4691
5009
|
}
|
|
4692
5010
|
else if (left.type === 'Identifier') {
|
|
4693
|
-
var variable = Identifier(left, scope, { getVar: true });
|
|
5011
|
+
var variable = Identifier$1(left, scope, { getVar: true });
|
|
4694
5012
|
variable.set(value);
|
|
4695
5013
|
}
|
|
4696
5014
|
else {
|
|
4697
|
-
pattern
|
|
5015
|
+
pattern(left, scope, { feed: value });
|
|
4698
5016
|
}
|
|
4699
5017
|
var result;
|
|
4700
5018
|
if (node.body.type === 'BlockStatement') {
|
|
4701
|
-
result = BlockStatement(node.body, subScope, { invasived: true });
|
|
5019
|
+
result = BlockStatement$1(node.body, subScope, { invasived: true });
|
|
4702
5020
|
}
|
|
4703
5021
|
else {
|
|
4704
|
-
result = evaluate(node.body, subScope);
|
|
5022
|
+
result = evaluate$1(node.body, subScope);
|
|
4705
5023
|
}
|
|
4706
5024
|
return result;
|
|
4707
5025
|
}
|
|
@@ -4757,8 +5075,8 @@
|
|
|
4757
5075
|
};
|
|
4758
5076
|
Sval.prototype.run = function (code) {
|
|
4759
5077
|
var ast = typeof code === 'string' ? acorn.parse(code, this.options) : code;
|
|
4760
|
-
hoist
|
|
4761
|
-
evaluate(ast, this.scope);
|
|
5078
|
+
hoist(ast, this.scope);
|
|
5079
|
+
evaluate$1(ast, this.scope);
|
|
4762
5080
|
};
|
|
4763
5081
|
Sval.version = version;
|
|
4764
5082
|
return Sval;
|
|
@@ -4766,4 +5084,4 @@
|
|
|
4766
5084
|
|
|
4767
5085
|
return Sval;
|
|
4768
5086
|
|
|
4769
|
-
}))
|
|
5087
|
+
}));
|