sval 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sval.es6.js +582 -564
- package/dist/sval.js +589 -570
- package/dist/sval.min.js +1 -1
- package/package.json +2 -2
package/dist/sval.es6.js
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('acorn')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['acorn'], factory) :
|
|
4
|
-
(global = global || self, global.Sval = factory(global.acorn));
|
|
5
|
-
}(this, (function (acorn) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Sval = factory(global.acorn));
|
|
5
|
+
})(this, (function (acorn) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var statement = /*#__PURE__*/Object.freeze({
|
|
8
|
-
__proto__: null,
|
|
9
|
-
get ExpressionStatement () { return ExpressionStatement; },
|
|
10
|
-
get BlockStatement () { return BlockStatement; },
|
|
11
|
-
get EmptyStatement () { return EmptyStatement; },
|
|
12
|
-
get DebuggerStatement () { return DebuggerStatement; },
|
|
13
|
-
get ReturnStatement () { return ReturnStatement; },
|
|
14
|
-
get BreakStatement () { return BreakStatement; },
|
|
15
|
-
get ContinueStatement () { return ContinueStatement; },
|
|
16
|
-
get IfStatement () { return IfStatement; },
|
|
17
|
-
get SwitchStatement () { return SwitchStatement; },
|
|
18
|
-
get SwitchCase () { return SwitchCase; },
|
|
19
|
-
get ThrowStatement () { return ThrowStatement; },
|
|
20
|
-
get TryStatement () { return TryStatement; },
|
|
21
|
-
get CatchClause () { return CatchClause; },
|
|
22
|
-
get WhileStatement () { return WhileStatement; },
|
|
23
|
-
get DoWhileStatement () { return DoWhileStatement; },
|
|
24
|
-
get ForStatement () { return ForStatement; },
|
|
25
|
-
get ForInStatement () { return ForInStatement; },
|
|
26
|
-
get ForOfStatement () { return ForOfStatement; }
|
|
27
|
-
});
|
|
28
|
-
var declaration = /*#__PURE__*/Object.freeze({
|
|
29
|
-
__proto__: null,
|
|
30
|
-
get FunctionDeclaration () { return FunctionDeclaration; },
|
|
31
|
-
get VariableDeclaration () { return VariableDeclaration; },
|
|
32
|
-
get VariableDeclarator () { return VariableDeclarator; },
|
|
33
|
-
get ClassDeclaration () { return ClassDeclaration; },
|
|
34
|
-
get ClassBody () { return ClassBody; },
|
|
35
|
-
get MethodDefinition () { return MethodDefinition; },
|
|
36
|
-
get PropertyDefinition () { return PropertyDefinition; },
|
|
37
|
-
get StaticBlock () { return StaticBlock; },
|
|
38
|
-
get ImportDeclaration () { return ImportDeclaration; },
|
|
39
|
-
get ExportDefaultDeclaration () { return ExportDefaultDeclaration; },
|
|
40
|
-
get ExportNamedDeclaration () { return ExportNamedDeclaration; },
|
|
41
|
-
get ExportAllDeclaration () { return ExportAllDeclaration; }
|
|
42
|
-
});
|
|
43
7
|
var statement$1 = /*#__PURE__*/Object.freeze({
|
|
44
8
|
__proto__: null,
|
|
45
9
|
get ExpressionStatement () { return ExpressionStatement$1; },
|
|
@@ -76,6 +40,42 @@
|
|
|
76
40
|
get ExportNamedDeclaration () { return ExportNamedDeclaration$1; },
|
|
77
41
|
get ExportAllDeclaration () { return ExportAllDeclaration$1; }
|
|
78
42
|
});
|
|
43
|
+
var statement = /*#__PURE__*/Object.freeze({
|
|
44
|
+
__proto__: null,
|
|
45
|
+
get ExpressionStatement () { return ExpressionStatement; },
|
|
46
|
+
get BlockStatement () { return BlockStatement; },
|
|
47
|
+
get EmptyStatement () { return EmptyStatement; },
|
|
48
|
+
get DebuggerStatement () { return DebuggerStatement; },
|
|
49
|
+
get ReturnStatement () { return ReturnStatement; },
|
|
50
|
+
get BreakStatement () { return BreakStatement; },
|
|
51
|
+
get ContinueStatement () { return ContinueStatement; },
|
|
52
|
+
get IfStatement () { return IfStatement; },
|
|
53
|
+
get SwitchStatement () { return SwitchStatement; },
|
|
54
|
+
get SwitchCase () { return SwitchCase; },
|
|
55
|
+
get ThrowStatement () { return ThrowStatement; },
|
|
56
|
+
get TryStatement () { return TryStatement; },
|
|
57
|
+
get CatchClause () { return CatchClause; },
|
|
58
|
+
get WhileStatement () { return WhileStatement; },
|
|
59
|
+
get DoWhileStatement () { return DoWhileStatement; },
|
|
60
|
+
get ForStatement () { return ForStatement; },
|
|
61
|
+
get ForInStatement () { return ForInStatement; },
|
|
62
|
+
get ForOfStatement () { return ForOfStatement; }
|
|
63
|
+
});
|
|
64
|
+
var declaration = /*#__PURE__*/Object.freeze({
|
|
65
|
+
__proto__: null,
|
|
66
|
+
get FunctionDeclaration () { return FunctionDeclaration; },
|
|
67
|
+
get VariableDeclaration () { return VariableDeclaration; },
|
|
68
|
+
get VariableDeclarator () { return VariableDeclarator; },
|
|
69
|
+
get ClassDeclaration () { return ClassDeclaration; },
|
|
70
|
+
get ClassBody () { return ClassBody; },
|
|
71
|
+
get MethodDefinition () { return MethodDefinition; },
|
|
72
|
+
get PropertyDefinition () { return PropertyDefinition; },
|
|
73
|
+
get StaticBlock () { return StaticBlock; },
|
|
74
|
+
get ImportDeclaration () { return ImportDeclaration; },
|
|
75
|
+
get ExportDefaultDeclaration () { return ExportDefaultDeclaration; },
|
|
76
|
+
get ExportNamedDeclaration () { return ExportNamedDeclaration; },
|
|
77
|
+
get ExportAllDeclaration () { return ExportAllDeclaration; }
|
|
78
|
+
});
|
|
79
79
|
|
|
80
80
|
const freeze = Object.freeze;
|
|
81
81
|
const define = Object.defineProperty;
|
|
@@ -456,7 +456,7 @@
|
|
|
456
456
|
const IMPORT = createSymbol('import');
|
|
457
457
|
const EXPORTS = createSymbol('exports');
|
|
458
458
|
|
|
459
|
-
var version = "0.5.
|
|
459
|
+
var version = "0.5.3";
|
|
460
460
|
|
|
461
461
|
class Var {
|
|
462
462
|
constructor(kind, value) {
|
|
@@ -585,7 +585,7 @@
|
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
-
function Identifier(node, scope, options = {}) {
|
|
588
|
+
function Identifier$1(node, scope, options = {}) {
|
|
589
589
|
const { getVar = false, throwErr = true } = options;
|
|
590
590
|
if (node.name === 'undefined') {
|
|
591
591
|
return undefined;
|
|
@@ -613,21 +613,21 @@
|
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
-
var identifier = /*#__PURE__*/Object.freeze({
|
|
616
|
+
var identifier$1 = /*#__PURE__*/Object.freeze({
|
|
617
617
|
__proto__: null,
|
|
618
|
-
Identifier: Identifier
|
|
618
|
+
Identifier: Identifier$1
|
|
619
619
|
});
|
|
620
620
|
|
|
621
|
-
function Literal(node, scope) {
|
|
621
|
+
function Literal$1(node, scope) {
|
|
622
622
|
return node.value;
|
|
623
623
|
}
|
|
624
624
|
|
|
625
|
-
var literal = /*#__PURE__*/Object.freeze({
|
|
625
|
+
var literal$1 = /*#__PURE__*/Object.freeze({
|
|
626
626
|
__proto__: null,
|
|
627
|
-
Literal: Literal
|
|
627
|
+
Literal: Literal$1
|
|
628
628
|
});
|
|
629
629
|
|
|
630
|
-
function ThisExpression(node, scope) {
|
|
630
|
+
function ThisExpression$1(node, scope) {
|
|
631
631
|
const superCall = scope.find(SUPERCALL);
|
|
632
632
|
if (superCall && !superCall.get()) {
|
|
633
633
|
throw new ReferenceError('Must call super constructor in derived class '
|
|
@@ -637,41 +637,41 @@
|
|
|
637
637
|
return scope.find('this').get();
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
|
-
function ArrayExpression(node, scope) {
|
|
640
|
+
function ArrayExpression$1(node, scope) {
|
|
641
641
|
let results = [];
|
|
642
642
|
for (let i = 0; i < node.elements.length; i++) {
|
|
643
643
|
const item = node.elements[i];
|
|
644
644
|
if (item.type === 'SpreadElement') {
|
|
645
|
-
results = results.concat(SpreadElement(item, scope));
|
|
645
|
+
results = results.concat(SpreadElement$1(item, scope));
|
|
646
646
|
}
|
|
647
647
|
else {
|
|
648
|
-
results.push(evaluate(item, scope));
|
|
648
|
+
results.push(evaluate$1(item, scope));
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
651
|
return results;
|
|
652
652
|
}
|
|
653
|
-
function ObjectExpression(node, scope) {
|
|
653
|
+
function ObjectExpression$1(node, scope) {
|
|
654
654
|
const object = {};
|
|
655
655
|
for (let i = 0; i < node.properties.length; i++) {
|
|
656
656
|
const property = node.properties[i];
|
|
657
657
|
if (property.type === 'SpreadElement') {
|
|
658
|
-
assign(object, SpreadElement(property, scope));
|
|
658
|
+
assign(object, SpreadElement$1(property, scope));
|
|
659
659
|
}
|
|
660
660
|
else {
|
|
661
661
|
let key;
|
|
662
662
|
const propKey = property.key;
|
|
663
663
|
if (property.computed) {
|
|
664
|
-
key = evaluate(propKey, scope);
|
|
664
|
+
key = evaluate$1(propKey, scope);
|
|
665
665
|
}
|
|
666
666
|
else {
|
|
667
667
|
if (propKey.type === 'Identifier') {
|
|
668
668
|
key = propKey.name;
|
|
669
669
|
}
|
|
670
670
|
else {
|
|
671
|
-
key = '' + (Literal(propKey));
|
|
671
|
+
key = '' + (Literal$1(propKey));
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
|
-
const value = evaluate(property.value, scope);
|
|
674
|
+
const value = evaluate$1(property.value, scope);
|
|
675
675
|
const propKind = property.kind;
|
|
676
676
|
if (propKind === 'init') {
|
|
677
677
|
object[key] = value;
|
|
@@ -698,55 +698,55 @@
|
|
|
698
698
|
}
|
|
699
699
|
return object;
|
|
700
700
|
}
|
|
701
|
-
function FunctionExpression(node, scope) {
|
|
701
|
+
function FunctionExpression$1(node, scope) {
|
|
702
702
|
if (node.id && node.id.name) {
|
|
703
703
|
const tmpScope = new Scope(scope);
|
|
704
|
-
const func = createFunc
|
|
704
|
+
const func = createFunc(node, tmpScope);
|
|
705
705
|
tmpScope.const(node.id.name, func);
|
|
706
706
|
return func;
|
|
707
707
|
}
|
|
708
708
|
else {
|
|
709
|
-
return createFunc
|
|
709
|
+
return createFunc(node, scope);
|
|
710
710
|
}
|
|
711
711
|
}
|
|
712
|
-
function UnaryExpression(node, scope) {
|
|
712
|
+
function UnaryExpression$1(node, scope) {
|
|
713
713
|
const arg = node.argument;
|
|
714
714
|
switch (node.operator) {
|
|
715
|
-
case '+': return +(evaluate(arg, scope));
|
|
716
|
-
case '-': return -(evaluate(arg, scope));
|
|
717
|
-
case '!': return !(evaluate(arg, scope));
|
|
718
|
-
case '~': return ~(evaluate(arg, scope));
|
|
719
|
-
case 'void': return void (evaluate(arg, scope));
|
|
715
|
+
case '+': return +(evaluate$1(arg, scope));
|
|
716
|
+
case '-': return -(evaluate$1(arg, scope));
|
|
717
|
+
case '!': return !(evaluate$1(arg, scope));
|
|
718
|
+
case '~': return ~(evaluate$1(arg, scope));
|
|
719
|
+
case 'void': return void (evaluate$1(arg, scope));
|
|
720
720
|
case 'typeof':
|
|
721
721
|
if (arg.type === 'Identifier') {
|
|
722
|
-
return typeof (Identifier(arg, scope, { throwErr: false }));
|
|
722
|
+
return typeof (Identifier$1(arg, scope, { throwErr: false }));
|
|
723
723
|
}
|
|
724
724
|
else {
|
|
725
|
-
return typeof (evaluate(arg, scope));
|
|
725
|
+
return typeof (evaluate$1(arg, scope));
|
|
726
726
|
}
|
|
727
727
|
case 'delete':
|
|
728
728
|
if (arg.type === 'MemberExpression') {
|
|
729
|
-
const variable = MemberExpression(arg, scope, { getVar: true });
|
|
729
|
+
const variable = MemberExpression$1(arg, scope, { getVar: true });
|
|
730
730
|
return variable.del();
|
|
731
731
|
}
|
|
732
732
|
else if (arg.type === 'Identifier') {
|
|
733
733
|
throw new SyntaxError('Delete of an unqualified identifier in strict mode');
|
|
734
734
|
}
|
|
735
735
|
else {
|
|
736
|
-
evaluate(arg, scope);
|
|
736
|
+
evaluate$1(arg, scope);
|
|
737
737
|
return true;
|
|
738
738
|
}
|
|
739
739
|
default: throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
740
740
|
}
|
|
741
741
|
}
|
|
742
|
-
function UpdateExpression(node, scope) {
|
|
742
|
+
function UpdateExpression$1(node, scope) {
|
|
743
743
|
const arg = node.argument;
|
|
744
744
|
let variable;
|
|
745
745
|
if (arg.type === 'Identifier') {
|
|
746
|
-
variable = Identifier(arg, scope, { getVar: true });
|
|
746
|
+
variable = Identifier$1(arg, scope, { getVar: true });
|
|
747
747
|
}
|
|
748
748
|
else if (arg.type === 'MemberExpression') {
|
|
749
|
-
variable = MemberExpression(arg, scope, { getVar: true });
|
|
749
|
+
variable = MemberExpression$1(arg, scope, { getVar: true });
|
|
750
750
|
}
|
|
751
751
|
else {
|
|
752
752
|
throw new SyntaxError('Unexpected token');
|
|
@@ -764,17 +764,17 @@
|
|
|
764
764
|
throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
|
-
function BinaryExpression(node, scope) {
|
|
767
|
+
function BinaryExpression$1(node, scope) {
|
|
768
768
|
let left;
|
|
769
769
|
let right;
|
|
770
770
|
if (node.left.type === 'PrivateIdentifier') {
|
|
771
771
|
left = node.left.name;
|
|
772
|
-
right = evaluate(node.right, scope);
|
|
772
|
+
right = evaluate$1(node.right, scope);
|
|
773
773
|
right = right[PRIVATE];
|
|
774
774
|
}
|
|
775
775
|
else {
|
|
776
|
-
left = evaluate(node.left, scope);
|
|
777
|
-
right = evaluate(node.right, scope);
|
|
776
|
+
left = evaluate$1(node.left, scope);
|
|
777
|
+
right = evaluate$1(node.right, scope);
|
|
778
778
|
}
|
|
779
779
|
switch (node.operator) {
|
|
780
780
|
case '==': return left == right;
|
|
@@ -802,25 +802,25 @@
|
|
|
802
802
|
default: throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
|
-
function AssignmentExpression(node, scope) {
|
|
805
|
+
function AssignmentExpression$1(node, scope) {
|
|
806
806
|
var _a;
|
|
807
807
|
const left = node.left;
|
|
808
808
|
let variable;
|
|
809
809
|
if (left.type === 'Identifier') {
|
|
810
|
-
variable = Identifier(left, scope, { getVar: true, throwErr: false });
|
|
810
|
+
variable = Identifier$1(left, scope, { getVar: true, throwErr: false });
|
|
811
811
|
if (!variable) {
|
|
812
812
|
const win = scope.global().find('window').get();
|
|
813
813
|
variable = new Prop(win, left.name);
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
816
|
else if (left.type === 'MemberExpression') {
|
|
817
|
-
variable = MemberExpression(left, scope, { getVar: true });
|
|
817
|
+
variable = MemberExpression$1(left, scope, { getVar: true });
|
|
818
818
|
}
|
|
819
819
|
else {
|
|
820
|
-
const value = evaluate(node.right, scope);
|
|
821
|
-
return pattern
|
|
820
|
+
const value = evaluate$1(node.right, scope);
|
|
821
|
+
return pattern(left, scope, { feed: value });
|
|
822
822
|
}
|
|
823
|
-
const value = evaluate(node.right, scope);
|
|
823
|
+
const value = evaluate$1(node.right, scope);
|
|
824
824
|
switch (node.operator) {
|
|
825
825
|
case '=':
|
|
826
826
|
variable.set(value);
|
|
@@ -873,34 +873,34 @@
|
|
|
873
873
|
default: throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
874
874
|
}
|
|
875
875
|
}
|
|
876
|
-
function LogicalExpression(node, scope) {
|
|
876
|
+
function LogicalExpression$1(node, scope) {
|
|
877
877
|
var _a;
|
|
878
878
|
switch (node.operator) {
|
|
879
879
|
case '||':
|
|
880
|
-
return (evaluate(node.left, scope)) || (evaluate(node.right, scope));
|
|
880
|
+
return (evaluate$1(node.left, scope)) || (evaluate$1(node.right, scope));
|
|
881
881
|
case '&&':
|
|
882
|
-
return (evaluate(node.left, scope)) && (evaluate(node.right, scope));
|
|
882
|
+
return (evaluate$1(node.left, scope)) && (evaluate$1(node.right, scope));
|
|
883
883
|
case '??':
|
|
884
|
-
return (_a = (evaluate(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate(node.right, scope));
|
|
884
|
+
return (_a = (evaluate$1(node.left, scope))) !== null && _a !== void 0 ? _a : (evaluate$1(node.right, scope));
|
|
885
885
|
default:
|
|
886
886
|
throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
|
-
function MemberExpression(node, scope, options = {}) {
|
|
889
|
+
function MemberExpression$1(node, scope, options = {}) {
|
|
890
890
|
const { getObj = false, getVar = false } = options;
|
|
891
891
|
let object;
|
|
892
892
|
if (node.object.type === 'Super') {
|
|
893
|
-
object = Super(node.object, scope, { getProto: true });
|
|
893
|
+
object = Super$1(node.object, scope, { getProto: true });
|
|
894
894
|
}
|
|
895
895
|
else {
|
|
896
|
-
object = evaluate(node.object, scope);
|
|
896
|
+
object = evaluate$1(node.object, scope);
|
|
897
897
|
}
|
|
898
898
|
if (getObj)
|
|
899
899
|
return object;
|
|
900
900
|
let key;
|
|
901
901
|
let priv = false;
|
|
902
902
|
if (node.computed) {
|
|
903
|
-
key = evaluate(node.property, scope);
|
|
903
|
+
key = evaluate$1(node.property, scope);
|
|
904
904
|
}
|
|
905
905
|
else if (node.property.type === 'PrivateIdentifier') {
|
|
906
906
|
key = node.property.name;
|
|
@@ -941,23 +941,23 @@
|
|
|
941
941
|
}
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
|
-
function ConditionalExpression(node, scope) {
|
|
945
|
-
return (evaluate(node.test, scope))
|
|
946
|
-
? (evaluate(node.consequent, scope))
|
|
947
|
-
: (evaluate(node.alternate, scope));
|
|
944
|
+
function ConditionalExpression$1(node, scope) {
|
|
945
|
+
return (evaluate$1(node.test, scope))
|
|
946
|
+
? (evaluate$1(node.consequent, scope))
|
|
947
|
+
: (evaluate$1(node.alternate, scope));
|
|
948
948
|
}
|
|
949
|
-
function CallExpression(node, scope) {
|
|
949
|
+
function CallExpression$1(node, scope) {
|
|
950
950
|
let func;
|
|
951
951
|
let object;
|
|
952
952
|
if (node.callee.type === 'MemberExpression') {
|
|
953
|
-
object = MemberExpression(node.callee, scope, { getObj: true });
|
|
953
|
+
object = MemberExpression$1(node.callee, scope, { getObj: true });
|
|
954
954
|
if (node.callee.optional && object == null) {
|
|
955
955
|
return undefined;
|
|
956
956
|
}
|
|
957
957
|
let key;
|
|
958
958
|
let priv = false;
|
|
959
959
|
if (node.callee.computed) {
|
|
960
|
-
key = evaluate(node.callee.property, scope);
|
|
960
|
+
key = evaluate$1(node.callee.property, scope);
|
|
961
961
|
}
|
|
962
962
|
else if (node.callee.property.type === 'PrivateIdentifier') {
|
|
963
963
|
key = node.callee.property.name;
|
|
@@ -989,7 +989,7 @@
|
|
|
989
989
|
}
|
|
990
990
|
else {
|
|
991
991
|
object = scope.find('this').get();
|
|
992
|
-
func = evaluate(node.callee, scope);
|
|
992
|
+
func = evaluate$1(node.callee, scope);
|
|
993
993
|
if (node.optional && func == null) {
|
|
994
994
|
return undefined;
|
|
995
995
|
}
|
|
@@ -1018,10 +1018,10 @@
|
|
|
1018
1018
|
for (let i = 0; i < node.arguments.length; i++) {
|
|
1019
1019
|
const arg = node.arguments[i];
|
|
1020
1020
|
if (arg.type === 'SpreadElement') {
|
|
1021
|
-
args = args.concat(SpreadElement(arg, scope));
|
|
1021
|
+
args = args.concat(SpreadElement$1(arg, scope));
|
|
1022
1022
|
}
|
|
1023
1023
|
else {
|
|
1024
|
-
args.push(evaluate(arg, scope));
|
|
1024
|
+
args.push(evaluate$1(arg, scope));
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
1027
|
if (node.callee.type === 'Super') {
|
|
@@ -1033,13 +1033,22 @@
|
|
|
1033
1033
|
scope.find(SUPERCALL).set(true);
|
|
1034
1034
|
}
|
|
1035
1035
|
}
|
|
1036
|
-
|
|
1037
|
-
return func.apply(object
|
|
1036
|
+
try {
|
|
1037
|
+
return func.apply(object, args);
|
|
1038
|
+
}
|
|
1039
|
+
catch (err) {
|
|
1040
|
+
if (err instanceof TypeError && err.message === 'Illegal invocation'
|
|
1041
|
+
&& func.toString().indexOf('[native code]') !== -1) {
|
|
1042
|
+
const win = scope.global().find('window').get();
|
|
1043
|
+
if (win && win[WINDOW]) {
|
|
1044
|
+
return func.apply(win[WINDOW], args);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
throw err;
|
|
1038
1048
|
}
|
|
1039
|
-
return func.apply(object, args);
|
|
1040
1049
|
}
|
|
1041
|
-
function NewExpression(node, scope) {
|
|
1042
|
-
const constructor = evaluate(node.callee, scope);
|
|
1050
|
+
function NewExpression$1(node, scope) {
|
|
1051
|
+
const constructor = evaluate$1(node.callee, scope);
|
|
1043
1052
|
if (typeof constructor !== 'function') {
|
|
1044
1053
|
let name;
|
|
1045
1054
|
if (node.callee.type === 'Identifier') {
|
|
@@ -1062,15 +1071,15 @@
|
|
|
1062
1071
|
for (let i = 0; i < node.arguments.length; i++) {
|
|
1063
1072
|
const arg = node.arguments[i];
|
|
1064
1073
|
if (arg.type === 'SpreadElement') {
|
|
1065
|
-
args = args.concat(SpreadElement(arg, scope));
|
|
1074
|
+
args = args.concat(SpreadElement$1(arg, scope));
|
|
1066
1075
|
}
|
|
1067
1076
|
else {
|
|
1068
|
-
args.push(evaluate(arg, scope));
|
|
1077
|
+
args.push(evaluate$1(arg, scope));
|
|
1069
1078
|
}
|
|
1070
1079
|
}
|
|
1071
1080
|
return new constructor(...args);
|
|
1072
1081
|
}
|
|
1073
|
-
function MetaProperty(node, scope) {
|
|
1082
|
+
function MetaProperty$1(node, scope) {
|
|
1074
1083
|
if (node.meta.name === 'new' && node.property.name === 'target') {
|
|
1075
1084
|
return scope.find(NEWTARGET).get();
|
|
1076
1085
|
}
|
|
@@ -1078,33 +1087,33 @@
|
|
|
1078
1087
|
return { url: '' };
|
|
1079
1088
|
}
|
|
1080
1089
|
}
|
|
1081
|
-
function SequenceExpression(node, scope) {
|
|
1090
|
+
function SequenceExpression$1(node, scope) {
|
|
1082
1091
|
let result;
|
|
1083
1092
|
for (let i = 0; i < node.expressions.length; i++) {
|
|
1084
|
-
result = evaluate(node.expressions[i], scope);
|
|
1093
|
+
result = evaluate$1(node.expressions[i], scope);
|
|
1085
1094
|
}
|
|
1086
1095
|
return result;
|
|
1087
1096
|
}
|
|
1088
|
-
function ArrowFunctionExpression(node, scope) {
|
|
1089
|
-
return createFunc
|
|
1097
|
+
function ArrowFunctionExpression$1(node, scope) {
|
|
1098
|
+
return createFunc(node, scope);
|
|
1090
1099
|
}
|
|
1091
|
-
function TemplateLiteral(node, scope) {
|
|
1100
|
+
function TemplateLiteral$1(node, scope) {
|
|
1092
1101
|
const quasis = node.quasis.slice();
|
|
1093
1102
|
const expressions = node.expressions.slice();
|
|
1094
1103
|
let result = '';
|
|
1095
1104
|
let temEl;
|
|
1096
1105
|
let expr;
|
|
1097
1106
|
while (temEl = quasis.shift()) {
|
|
1098
|
-
result += TemplateElement(temEl);
|
|
1107
|
+
result += TemplateElement$1(temEl);
|
|
1099
1108
|
expr = expressions.shift();
|
|
1100
1109
|
if (expr) {
|
|
1101
|
-
result += evaluate(expr, scope);
|
|
1110
|
+
result += evaluate$1(expr, scope);
|
|
1102
1111
|
}
|
|
1103
1112
|
}
|
|
1104
1113
|
return result;
|
|
1105
1114
|
}
|
|
1106
|
-
function TaggedTemplateExpression(node, scope) {
|
|
1107
|
-
const tagFunc = evaluate(node.tag, scope);
|
|
1115
|
+
function TaggedTemplateExpression$1(node, scope) {
|
|
1116
|
+
const tagFunc = evaluate$1(node.tag, scope);
|
|
1108
1117
|
const quasis = node.quasi.quasis;
|
|
1109
1118
|
const str = quasis.map(v => v.value.cooked);
|
|
1110
1119
|
const raw = quasis.map(v => v.value.raw);
|
|
@@ -1115,40 +1124,40 @@
|
|
|
1115
1124
|
const args = [];
|
|
1116
1125
|
if (expressions) {
|
|
1117
1126
|
for (let i = 0; i < expressions.length; i++) {
|
|
1118
|
-
args.push(evaluate(expressions[i], scope));
|
|
1127
|
+
args.push(evaluate$1(expressions[i], scope));
|
|
1119
1128
|
}
|
|
1120
1129
|
}
|
|
1121
1130
|
return tagFunc(freeze(str), ...args);
|
|
1122
1131
|
}
|
|
1123
|
-
function TemplateElement(node, scope) {
|
|
1132
|
+
function TemplateElement$1(node, scope) {
|
|
1124
1133
|
return node.value.raw;
|
|
1125
1134
|
}
|
|
1126
|
-
function ClassExpression(node, scope) {
|
|
1135
|
+
function ClassExpression$1(node, scope) {
|
|
1127
1136
|
if (node.id && node.id.name) {
|
|
1128
1137
|
const tmpScope = new Scope(scope);
|
|
1129
|
-
const klass = createClass
|
|
1138
|
+
const klass = createClass(node, tmpScope);
|
|
1130
1139
|
tmpScope.const(node.id.name, klass);
|
|
1131
1140
|
return klass;
|
|
1132
1141
|
}
|
|
1133
1142
|
else {
|
|
1134
|
-
return createClass
|
|
1143
|
+
return createClass(node, scope);
|
|
1135
1144
|
}
|
|
1136
1145
|
}
|
|
1137
|
-
function Super(node, scope, options = {}) {
|
|
1146
|
+
function Super$1(node, scope, options = {}) {
|
|
1138
1147
|
const { getProto = false } = options;
|
|
1139
1148
|
const superClass = scope.find(SUPER).get();
|
|
1140
1149
|
return getProto ? superClass.prototype : superClass;
|
|
1141
1150
|
}
|
|
1142
|
-
function SpreadElement(node, scope) {
|
|
1143
|
-
const result = evaluate(node.argument, scope);
|
|
1151
|
+
function SpreadElement$1(node, scope) {
|
|
1152
|
+
const result = evaluate$1(node.argument, scope);
|
|
1144
1153
|
return typeof result === 'string' ? [...result] : result;
|
|
1145
1154
|
}
|
|
1146
|
-
function ChainExpression(node, scope) {
|
|
1147
|
-
return evaluate(node.expression, scope);
|
|
1155
|
+
function ChainExpression$1(node, scope) {
|
|
1156
|
+
return evaluate$1(node.expression, scope);
|
|
1148
1157
|
}
|
|
1149
|
-
function ImportExpression(node, scope) {
|
|
1158
|
+
function ImportExpression$1(node, scope) {
|
|
1150
1159
|
const globalScope = scope.global();
|
|
1151
|
-
const source = evaluate(node.source, scope);
|
|
1160
|
+
const source = evaluate$1(node.source, scope);
|
|
1152
1161
|
const module = globalScope.find(IMPORT + source);
|
|
1153
1162
|
let value;
|
|
1154
1163
|
if (module) {
|
|
@@ -1168,35 +1177,35 @@
|
|
|
1168
1177
|
return Promise.resolve(value);
|
|
1169
1178
|
}
|
|
1170
1179
|
|
|
1171
|
-
var expression = /*#__PURE__*/Object.freeze({
|
|
1180
|
+
var expression$1 = /*#__PURE__*/Object.freeze({
|
|
1172
1181
|
__proto__: null,
|
|
1173
|
-
ThisExpression: ThisExpression,
|
|
1174
|
-
ArrayExpression: ArrayExpression,
|
|
1175
|
-
ObjectExpression: ObjectExpression,
|
|
1176
|
-
FunctionExpression: FunctionExpression,
|
|
1177
|
-
UnaryExpression: UnaryExpression,
|
|
1178
|
-
UpdateExpression: UpdateExpression,
|
|
1179
|
-
BinaryExpression: BinaryExpression,
|
|
1180
|
-
AssignmentExpression: AssignmentExpression,
|
|
1181
|
-
LogicalExpression: LogicalExpression,
|
|
1182
|
-
MemberExpression: MemberExpression,
|
|
1183
|
-
ConditionalExpression: ConditionalExpression,
|
|
1184
|
-
CallExpression: CallExpression,
|
|
1185
|
-
NewExpression: NewExpression,
|
|
1186
|
-
MetaProperty: MetaProperty,
|
|
1187
|
-
SequenceExpression: SequenceExpression,
|
|
1188
|
-
ArrowFunctionExpression: ArrowFunctionExpression,
|
|
1189
|
-
TemplateLiteral: TemplateLiteral,
|
|
1190
|
-
TaggedTemplateExpression: TaggedTemplateExpression,
|
|
1191
|
-
TemplateElement: TemplateElement,
|
|
1192
|
-
ClassExpression: ClassExpression,
|
|
1193
|
-
Super: Super,
|
|
1194
|
-
SpreadElement: SpreadElement,
|
|
1195
|
-
ChainExpression: ChainExpression,
|
|
1196
|
-
ImportExpression: ImportExpression
|
|
1182
|
+
ThisExpression: ThisExpression$1,
|
|
1183
|
+
ArrayExpression: ArrayExpression$1,
|
|
1184
|
+
ObjectExpression: ObjectExpression$1,
|
|
1185
|
+
FunctionExpression: FunctionExpression$1,
|
|
1186
|
+
UnaryExpression: UnaryExpression$1,
|
|
1187
|
+
UpdateExpression: UpdateExpression$1,
|
|
1188
|
+
BinaryExpression: BinaryExpression$1,
|
|
1189
|
+
AssignmentExpression: AssignmentExpression$1,
|
|
1190
|
+
LogicalExpression: LogicalExpression$1,
|
|
1191
|
+
MemberExpression: MemberExpression$1,
|
|
1192
|
+
ConditionalExpression: ConditionalExpression$1,
|
|
1193
|
+
CallExpression: CallExpression$1,
|
|
1194
|
+
NewExpression: NewExpression$1,
|
|
1195
|
+
MetaProperty: MetaProperty$1,
|
|
1196
|
+
SequenceExpression: SequenceExpression$1,
|
|
1197
|
+
ArrowFunctionExpression: ArrowFunctionExpression$1,
|
|
1198
|
+
TemplateLiteral: TemplateLiteral$1,
|
|
1199
|
+
TaggedTemplateExpression: TaggedTemplateExpression$1,
|
|
1200
|
+
TemplateElement: TemplateElement$1,
|
|
1201
|
+
ClassExpression: ClassExpression$1,
|
|
1202
|
+
Super: Super$1,
|
|
1203
|
+
SpreadElement: SpreadElement$1,
|
|
1204
|
+
ChainExpression: ChainExpression$1,
|
|
1205
|
+
ImportExpression: ImportExpression$1
|
|
1197
1206
|
});
|
|
1198
1207
|
|
|
1199
|
-
function ObjectPattern(node, scope, options = {}) {
|
|
1208
|
+
function ObjectPattern$1(node, scope, options = {}) {
|
|
1200
1209
|
const { kind = 'var', hoist = false, onlyBlock = false, feed = {} } = options;
|
|
1201
1210
|
const fedKeys = [];
|
|
1202
1211
|
for (let i = 0; i < node.properties.length; i++) {
|
|
@@ -1209,18 +1218,18 @@
|
|
|
1209
1218
|
scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1210
1219
|
}
|
|
1211
1220
|
else {
|
|
1212
|
-
pattern
|
|
1221
|
+
pattern(value, scope, { kind, hoist, onlyBlock });
|
|
1213
1222
|
}
|
|
1214
1223
|
}
|
|
1215
1224
|
else {
|
|
1216
|
-
RestElement(property, scope, { kind, hoist, onlyBlock });
|
|
1225
|
+
RestElement$1(property, scope, { kind, hoist, onlyBlock });
|
|
1217
1226
|
}
|
|
1218
1227
|
}
|
|
1219
1228
|
}
|
|
1220
1229
|
else if (property.type === 'Property') {
|
|
1221
1230
|
let key;
|
|
1222
1231
|
if (property.computed) {
|
|
1223
|
-
key = evaluate(property.key, scope);
|
|
1232
|
+
key = evaluate$1(property.key, scope);
|
|
1224
1233
|
}
|
|
1225
1234
|
else {
|
|
1226
1235
|
key = property.key.name;
|
|
@@ -1231,18 +1240,18 @@
|
|
|
1231
1240
|
scope[kind](value.name, feed[key]);
|
|
1232
1241
|
}
|
|
1233
1242
|
else {
|
|
1234
|
-
pattern
|
|
1243
|
+
pattern(value, scope, { kind, feed: feed[key] });
|
|
1235
1244
|
}
|
|
1236
1245
|
}
|
|
1237
1246
|
else {
|
|
1238
1247
|
const rest = assign({}, feed);
|
|
1239
1248
|
for (let i = 0; i < fedKeys.length; i++)
|
|
1240
1249
|
delete rest[fedKeys[i]];
|
|
1241
|
-
RestElement(property, scope, { kind, feed: rest });
|
|
1250
|
+
RestElement$1(property, scope, { kind, feed: rest });
|
|
1242
1251
|
}
|
|
1243
1252
|
}
|
|
1244
1253
|
}
|
|
1245
|
-
function ArrayPattern(node, scope, options = {}) {
|
|
1254
|
+
function ArrayPattern$1(node, scope, options = {}) {
|
|
1246
1255
|
const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
|
|
1247
1256
|
const result = [];
|
|
1248
1257
|
for (let i = 0; i < node.elements.length; i++) {
|
|
@@ -1255,7 +1264,7 @@
|
|
|
1255
1264
|
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1256
1265
|
}
|
|
1257
1266
|
else {
|
|
1258
|
-
pattern
|
|
1267
|
+
pattern(element, scope, { kind, hoist, onlyBlock });
|
|
1259
1268
|
}
|
|
1260
1269
|
}
|
|
1261
1270
|
}
|
|
@@ -1264,23 +1273,23 @@
|
|
|
1264
1273
|
scope[kind](element.name, feed[i]);
|
|
1265
1274
|
}
|
|
1266
1275
|
else {
|
|
1267
|
-
const variable = Identifier(element, scope, { getVar: true });
|
|
1276
|
+
const variable = Identifier$1(element, scope, { getVar: true });
|
|
1268
1277
|
variable.set(feed[i]);
|
|
1269
1278
|
result.push(variable.get());
|
|
1270
1279
|
}
|
|
1271
1280
|
}
|
|
1272
1281
|
else if (element.type === 'RestElement') {
|
|
1273
|
-
RestElement(element, scope, { kind, feed: feed.slice(i) });
|
|
1282
|
+
RestElement$1(element, scope, { kind, feed: feed.slice(i) });
|
|
1274
1283
|
}
|
|
1275
1284
|
else {
|
|
1276
|
-
pattern
|
|
1285
|
+
pattern(element, scope, { kind, feed: feed[i] });
|
|
1277
1286
|
}
|
|
1278
1287
|
}
|
|
1279
1288
|
if (result.length) {
|
|
1280
1289
|
return result;
|
|
1281
1290
|
}
|
|
1282
1291
|
}
|
|
1283
|
-
function RestElement(node, scope, options = {}) {
|
|
1292
|
+
function RestElement$1(node, scope, options = {}) {
|
|
1284
1293
|
const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
|
|
1285
1294
|
const arg = node.argument;
|
|
1286
1295
|
if (hoist) {
|
|
@@ -1289,7 +1298,7 @@
|
|
|
1289
1298
|
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1290
1299
|
}
|
|
1291
1300
|
else {
|
|
1292
|
-
pattern
|
|
1301
|
+
pattern(arg, scope, { kind, hoist, onlyBlock });
|
|
1293
1302
|
}
|
|
1294
1303
|
}
|
|
1295
1304
|
}
|
|
@@ -1298,16 +1307,16 @@
|
|
|
1298
1307
|
scope[kind](arg.name, feed);
|
|
1299
1308
|
}
|
|
1300
1309
|
else {
|
|
1301
|
-
const variable = Identifier(arg, scope, { getVar: true });
|
|
1310
|
+
const variable = Identifier$1(arg, scope, { getVar: true });
|
|
1302
1311
|
variable.set(feed);
|
|
1303
1312
|
}
|
|
1304
1313
|
}
|
|
1305
1314
|
else {
|
|
1306
|
-
pattern
|
|
1315
|
+
pattern(arg, scope, { kind, feed });
|
|
1307
1316
|
}
|
|
1308
1317
|
}
|
|
1309
|
-
function AssignmentPattern(node, scope, options = {}) {
|
|
1310
|
-
const { kind = 'var', hoist = false, onlyBlock = false, feed = evaluate(node.right, scope) } = options;
|
|
1318
|
+
function AssignmentPattern$1(node, scope, options = {}) {
|
|
1319
|
+
const { kind = 'var', hoist = false, onlyBlock = false, feed = evaluate$1(node.right, scope) } = options;
|
|
1311
1320
|
const left = node.left;
|
|
1312
1321
|
if (hoist) {
|
|
1313
1322
|
if (onlyBlock || kind === 'var') {
|
|
@@ -1315,7 +1324,7 @@
|
|
|
1315
1324
|
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1316
1325
|
}
|
|
1317
1326
|
else {
|
|
1318
|
-
pattern
|
|
1327
|
+
pattern(left, scope, { kind, hoist, onlyBlock });
|
|
1319
1328
|
}
|
|
1320
1329
|
}
|
|
1321
1330
|
}
|
|
@@ -1323,21 +1332,21 @@
|
|
|
1323
1332
|
scope[kind](left.name, feed);
|
|
1324
1333
|
}
|
|
1325
1334
|
else {
|
|
1326
|
-
pattern
|
|
1335
|
+
pattern(left, scope, { kind, feed });
|
|
1327
1336
|
}
|
|
1328
1337
|
}
|
|
1329
1338
|
|
|
1330
|
-
var pattern = /*#__PURE__*/Object.freeze({
|
|
1339
|
+
var pattern$3 = /*#__PURE__*/Object.freeze({
|
|
1331
1340
|
__proto__: null,
|
|
1332
|
-
ObjectPattern: ObjectPattern,
|
|
1333
|
-
ArrayPattern: ArrayPattern,
|
|
1334
|
-
RestElement: RestElement,
|
|
1335
|
-
AssignmentPattern: AssignmentPattern
|
|
1341
|
+
ObjectPattern: ObjectPattern$1,
|
|
1342
|
+
ArrayPattern: ArrayPattern$1,
|
|
1343
|
+
RestElement: RestElement$1,
|
|
1344
|
+
AssignmentPattern: AssignmentPattern$1
|
|
1336
1345
|
});
|
|
1337
1346
|
|
|
1338
1347
|
function Program(program, scope) {
|
|
1339
1348
|
for (let i = 0; i < program.body.length; i++) {
|
|
1340
|
-
evaluate(program.body[i], scope);
|
|
1349
|
+
evaluate$1(program.body[i], scope);
|
|
1341
1350
|
}
|
|
1342
1351
|
}
|
|
1343
1352
|
|
|
@@ -1346,14 +1355,14 @@
|
|
|
1346
1355
|
Program: Program
|
|
1347
1356
|
});
|
|
1348
1357
|
|
|
1349
|
-
let evaluateOps;
|
|
1350
|
-
function evaluate(node, scope) {
|
|
1358
|
+
let evaluateOps$1;
|
|
1359
|
+
function evaluate$1(node, scope) {
|
|
1351
1360
|
if (!node)
|
|
1352
1361
|
return;
|
|
1353
|
-
if (!evaluateOps) {
|
|
1354
|
-
evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern, program);
|
|
1362
|
+
if (!evaluateOps$1) {
|
|
1363
|
+
evaluateOps$1 = assign({}, declaration$1, expression$1, identifier$1, statement$1, literal$1, pattern$3, program);
|
|
1355
1364
|
}
|
|
1356
|
-
const handler = evaluateOps[node.type];
|
|
1365
|
+
const handler = evaluateOps$1[node.type];
|
|
1357
1366
|
if (handler) {
|
|
1358
1367
|
return handler(node, scope);
|
|
1359
1368
|
}
|
|
@@ -1362,57 +1371,57 @@
|
|
|
1362
1371
|
}
|
|
1363
1372
|
}
|
|
1364
1373
|
|
|
1365
|
-
function ExpressionStatement(node, scope) {
|
|
1366
|
-
evaluate(node.expression, scope);
|
|
1374
|
+
function ExpressionStatement$1(node, scope) {
|
|
1375
|
+
evaluate$1(node.expression, scope);
|
|
1367
1376
|
}
|
|
1368
|
-
function BlockStatement(block, scope, options = {}) {
|
|
1377
|
+
function BlockStatement$1(block, scope, options = {}) {
|
|
1369
1378
|
const { invasived = false, hoisted = false, } = options;
|
|
1370
1379
|
const subScope = invasived ? scope : new Scope(scope);
|
|
1371
1380
|
if (!hoisted) {
|
|
1372
|
-
hoist
|
|
1381
|
+
hoist(block, subScope, { onlyBlock: true });
|
|
1373
1382
|
}
|
|
1374
1383
|
for (let i = 0; i < block.body.length; i++) {
|
|
1375
|
-
const result = evaluate(block.body[i], subScope);
|
|
1384
|
+
const result = evaluate$1(block.body[i], subScope);
|
|
1376
1385
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
1377
1386
|
return result;
|
|
1378
1387
|
}
|
|
1379
1388
|
}
|
|
1380
1389
|
}
|
|
1381
|
-
function EmptyStatement() {
|
|
1390
|
+
function EmptyStatement$1() {
|
|
1382
1391
|
}
|
|
1383
|
-
function DebuggerStatement() {
|
|
1392
|
+
function DebuggerStatement$1() {
|
|
1384
1393
|
debugger;
|
|
1385
1394
|
}
|
|
1386
|
-
function ReturnStatement(node, scope) {
|
|
1387
|
-
RETURN.RES = node.argument ? (evaluate(node.argument, scope)) : undefined;
|
|
1395
|
+
function ReturnStatement$1(node, scope) {
|
|
1396
|
+
RETURN.RES = node.argument ? (evaluate$1(node.argument, scope)) : undefined;
|
|
1388
1397
|
return RETURN;
|
|
1389
1398
|
}
|
|
1390
|
-
function BreakStatement() {
|
|
1399
|
+
function BreakStatement$1() {
|
|
1391
1400
|
return BREAK;
|
|
1392
1401
|
}
|
|
1393
|
-
function ContinueStatement() {
|
|
1402
|
+
function ContinueStatement$1() {
|
|
1394
1403
|
return CONTINUE;
|
|
1395
1404
|
}
|
|
1396
|
-
function IfStatement(node, scope) {
|
|
1397
|
-
if (evaluate(node.test, scope)) {
|
|
1398
|
-
return evaluate(node.consequent, scope);
|
|
1405
|
+
function IfStatement$1(node, scope) {
|
|
1406
|
+
if (evaluate$1(node.test, scope)) {
|
|
1407
|
+
return evaluate$1(node.consequent, scope);
|
|
1399
1408
|
}
|
|
1400
1409
|
else {
|
|
1401
|
-
return evaluate(node.alternate, scope);
|
|
1410
|
+
return evaluate$1(node.alternate, scope);
|
|
1402
1411
|
}
|
|
1403
1412
|
}
|
|
1404
|
-
function SwitchStatement(node, scope) {
|
|
1405
|
-
const discriminant = evaluate(node.discriminant, scope);
|
|
1413
|
+
function SwitchStatement$1(node, scope) {
|
|
1414
|
+
const discriminant = evaluate$1(node.discriminant, scope);
|
|
1406
1415
|
let matched = false;
|
|
1407
1416
|
for (let i = 0; i < node.cases.length; i++) {
|
|
1408
1417
|
const eachCase = node.cases[i];
|
|
1409
1418
|
if (!matched
|
|
1410
1419
|
&& (!eachCase.test
|
|
1411
|
-
|| (evaluate(eachCase.test, scope)) === discriminant)) {
|
|
1420
|
+
|| (evaluate$1(eachCase.test, scope)) === discriminant)) {
|
|
1412
1421
|
matched = true;
|
|
1413
1422
|
}
|
|
1414
1423
|
if (matched) {
|
|
1415
|
-
const result = SwitchCase(eachCase, scope);
|
|
1424
|
+
const result = SwitchCase$1(eachCase, scope);
|
|
1416
1425
|
if (result === BREAK) {
|
|
1417
1426
|
break;
|
|
1418
1427
|
}
|
|
@@ -1422,20 +1431,20 @@
|
|
|
1422
1431
|
}
|
|
1423
1432
|
}
|
|
1424
1433
|
}
|
|
1425
|
-
function SwitchCase(node, scope) {
|
|
1434
|
+
function SwitchCase$1(node, scope) {
|
|
1426
1435
|
for (let i = 0; i < node.consequent.length; i++) {
|
|
1427
|
-
const result = evaluate(node.consequent[i], scope);
|
|
1436
|
+
const result = evaluate$1(node.consequent[i], scope);
|
|
1428
1437
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
1429
1438
|
return result;
|
|
1430
1439
|
}
|
|
1431
1440
|
}
|
|
1432
1441
|
}
|
|
1433
|
-
function ThrowStatement(node, scope) {
|
|
1434
|
-
throw evaluate(node.argument, scope);
|
|
1442
|
+
function ThrowStatement$1(node, scope) {
|
|
1443
|
+
throw evaluate$1(node.argument, scope);
|
|
1435
1444
|
}
|
|
1436
|
-
function TryStatement(node, scope) {
|
|
1445
|
+
function TryStatement$1(node, scope) {
|
|
1437
1446
|
try {
|
|
1438
|
-
return BlockStatement(node.block, scope);
|
|
1447
|
+
return BlockStatement$1(node.block, scope);
|
|
1439
1448
|
}
|
|
1440
1449
|
catch (err) {
|
|
1441
1450
|
if (node.handler) {
|
|
@@ -1447,10 +1456,10 @@
|
|
|
1447
1456
|
subScope.var(name, err);
|
|
1448
1457
|
}
|
|
1449
1458
|
else {
|
|
1450
|
-
pattern
|
|
1459
|
+
pattern(param, scope, { feed: err });
|
|
1451
1460
|
}
|
|
1452
1461
|
}
|
|
1453
|
-
return CatchClause(node.handler, subScope);
|
|
1462
|
+
return CatchClause$1(node.handler, subScope);
|
|
1454
1463
|
}
|
|
1455
1464
|
else {
|
|
1456
1465
|
throw err;
|
|
@@ -1458,19 +1467,19 @@
|
|
|
1458
1467
|
}
|
|
1459
1468
|
finally {
|
|
1460
1469
|
if (node.finalizer) {
|
|
1461
|
-
const result = BlockStatement(node.finalizer, scope);
|
|
1470
|
+
const result = BlockStatement$1(node.finalizer, scope);
|
|
1462
1471
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
1463
1472
|
return result;
|
|
1464
1473
|
}
|
|
1465
1474
|
}
|
|
1466
1475
|
}
|
|
1467
1476
|
}
|
|
1468
|
-
function CatchClause(node, scope) {
|
|
1469
|
-
return BlockStatement(node.body, scope, { invasived: true });
|
|
1477
|
+
function CatchClause$1(node, scope) {
|
|
1478
|
+
return BlockStatement$1(node.body, scope, { invasived: true });
|
|
1470
1479
|
}
|
|
1471
|
-
function WhileStatement(node, scope) {
|
|
1472
|
-
while (evaluate(node.test, scope)) {
|
|
1473
|
-
const result = evaluate(node.body, scope);
|
|
1480
|
+
function WhileStatement$1(node, scope) {
|
|
1481
|
+
while (evaluate$1(node.test, scope)) {
|
|
1482
|
+
const result = evaluate$1(node.body, scope);
|
|
1474
1483
|
if (result === BREAK) {
|
|
1475
1484
|
break;
|
|
1476
1485
|
}
|
|
@@ -1482,9 +1491,9 @@
|
|
|
1482
1491
|
}
|
|
1483
1492
|
}
|
|
1484
1493
|
}
|
|
1485
|
-
function DoWhileStatement(node, scope) {
|
|
1494
|
+
function DoWhileStatement$1(node, scope) {
|
|
1486
1495
|
do {
|
|
1487
|
-
const result = evaluate(node.body, scope);
|
|
1496
|
+
const result = evaluate$1(node.body, scope);
|
|
1488
1497
|
if (result === BREAK) {
|
|
1489
1498
|
break;
|
|
1490
1499
|
}
|
|
@@ -1494,18 +1503,18 @@
|
|
|
1494
1503
|
else if (result === RETURN) {
|
|
1495
1504
|
return result;
|
|
1496
1505
|
}
|
|
1497
|
-
} while (evaluate(node.test, scope));
|
|
1506
|
+
} while (evaluate$1(node.test, scope));
|
|
1498
1507
|
}
|
|
1499
|
-
function ForStatement(node, scope) {
|
|
1508
|
+
function ForStatement$1(node, scope) {
|
|
1500
1509
|
const forScope = new Scope(scope);
|
|
1501
|
-
for (evaluate(node.init, forScope); node.test ? (evaluate(node.test, forScope)) : true; evaluate(node.update, forScope)) {
|
|
1510
|
+
for (evaluate$1(node.init, forScope); node.test ? (evaluate$1(node.test, forScope)) : true; evaluate$1(node.update, forScope)) {
|
|
1502
1511
|
const subScope = new Scope(forScope);
|
|
1503
1512
|
let result;
|
|
1504
1513
|
if (node.body.type === 'BlockStatement') {
|
|
1505
|
-
result = BlockStatement(node.body, subScope, { invasived: true });
|
|
1514
|
+
result = BlockStatement$1(node.body, subScope, { invasived: true });
|
|
1506
1515
|
}
|
|
1507
1516
|
else {
|
|
1508
|
-
result = evaluate(node.body, subScope);
|
|
1517
|
+
result = evaluate$1(node.body, subScope);
|
|
1509
1518
|
}
|
|
1510
1519
|
if (result === BREAK) {
|
|
1511
1520
|
break;
|
|
@@ -1518,9 +1527,9 @@
|
|
|
1518
1527
|
}
|
|
1519
1528
|
}
|
|
1520
1529
|
}
|
|
1521
|
-
function ForInStatement(node, scope) {
|
|
1522
|
-
for (const value in evaluate(node.right, scope)) {
|
|
1523
|
-
const result = ForXHandler
|
|
1530
|
+
function ForInStatement$1(node, scope) {
|
|
1531
|
+
for (const value in evaluate$1(node.right, scope)) {
|
|
1532
|
+
const result = ForXHandler(node, scope, { value });
|
|
1524
1533
|
if (result === BREAK) {
|
|
1525
1534
|
break;
|
|
1526
1535
|
}
|
|
@@ -1532,10 +1541,10 @@
|
|
|
1532
1541
|
}
|
|
1533
1542
|
}
|
|
1534
1543
|
}
|
|
1535
|
-
function ForOfStatement(node, scope) {
|
|
1536
|
-
const right = evaluate(node.right, scope);
|
|
1544
|
+
function ForOfStatement$1(node, scope) {
|
|
1545
|
+
const right = evaluate$1(node.right, scope);
|
|
1537
1546
|
for (const value of right) {
|
|
1538
|
-
const result = ForXHandler
|
|
1547
|
+
const result = ForXHandler(node, scope, { value });
|
|
1539
1548
|
if (result === BREAK) {
|
|
1540
1549
|
break;
|
|
1541
1550
|
}
|
|
@@ -1548,15 +1557,15 @@
|
|
|
1548
1557
|
}
|
|
1549
1558
|
}
|
|
1550
1559
|
|
|
1551
|
-
function FunctionDeclaration(node, scope) {
|
|
1552
|
-
scope.func(node.id.name, createFunc
|
|
1560
|
+
function FunctionDeclaration$1(node, scope) {
|
|
1561
|
+
scope.func(node.id.name, createFunc(node, scope));
|
|
1553
1562
|
}
|
|
1554
|
-
function VariableDeclaration(node, scope, options = {}) {
|
|
1563
|
+
function VariableDeclaration$1(node, scope, options = {}) {
|
|
1555
1564
|
for (let i = 0; i < node.declarations.length; i++) {
|
|
1556
|
-
VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
|
|
1565
|
+
VariableDeclarator$1(node.declarations[i], scope, assign({ kind: node.kind }, options));
|
|
1557
1566
|
}
|
|
1558
1567
|
}
|
|
1559
|
-
function VariableDeclarator(node, scope, options = {}) {
|
|
1568
|
+
function VariableDeclarator$1(node, scope, options = {}) {
|
|
1560
1569
|
const { kind = 'var', hoist = false, onlyBlock = false, feed } = options;
|
|
1561
1570
|
if (hoist) {
|
|
1562
1571
|
if (onlyBlock || kind === 'var') {
|
|
@@ -1564,13 +1573,13 @@
|
|
|
1564
1573
|
scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
1565
1574
|
}
|
|
1566
1575
|
else {
|
|
1567
|
-
pattern
|
|
1576
|
+
pattern(node.id, scope, { kind, hoist, onlyBlock });
|
|
1568
1577
|
}
|
|
1569
1578
|
}
|
|
1570
1579
|
}
|
|
1571
1580
|
else {
|
|
1572
1581
|
const hasFeed = 'feed' in options;
|
|
1573
|
-
const value = hasFeed ? feed : evaluate(node.init, scope);
|
|
1582
|
+
const value = hasFeed ? feed : evaluate$1(node.init, scope);
|
|
1574
1583
|
if (node.id.type === 'Identifier') {
|
|
1575
1584
|
const name = node.id.name;
|
|
1576
1585
|
if (kind === 'var' && !node.init && !hasFeed) {
|
|
@@ -1590,34 +1599,34 @@
|
|
|
1590
1599
|
}
|
|
1591
1600
|
}
|
|
1592
1601
|
else {
|
|
1593
|
-
pattern
|
|
1602
|
+
pattern(node.id, scope, { kind, feed: value });
|
|
1594
1603
|
}
|
|
1595
1604
|
}
|
|
1596
1605
|
}
|
|
1597
|
-
function ClassDeclaration(node, scope) {
|
|
1598
|
-
scope.func(node.id.name, createClass
|
|
1606
|
+
function ClassDeclaration$1(node, scope) {
|
|
1607
|
+
scope.func(node.id.name, createClass(node, scope));
|
|
1599
1608
|
}
|
|
1600
|
-
function ClassBody(node, scope, options = {}) {
|
|
1609
|
+
function ClassBody$1(node, scope, options = {}) {
|
|
1601
1610
|
const { klass, superClass } = options;
|
|
1602
1611
|
for (let i = 0; i < node.body.length; i++) {
|
|
1603
1612
|
const def = node.body[i];
|
|
1604
1613
|
if (def.type === 'MethodDefinition') {
|
|
1605
|
-
MethodDefinition(def, scope, { klass, superClass });
|
|
1614
|
+
MethodDefinition$1(def, scope, { klass, superClass });
|
|
1606
1615
|
}
|
|
1607
1616
|
else if (def.type === 'PropertyDefinition' && def.static) {
|
|
1608
|
-
PropertyDefinition(def, scope, { klass, superClass });
|
|
1617
|
+
PropertyDefinition$1(def, scope, { klass, superClass });
|
|
1609
1618
|
}
|
|
1610
1619
|
else if (def.type === 'StaticBlock') {
|
|
1611
|
-
StaticBlock(def, scope, { klass, superClass });
|
|
1620
|
+
StaticBlock$1(def, scope, { klass, superClass });
|
|
1612
1621
|
}
|
|
1613
1622
|
}
|
|
1614
1623
|
}
|
|
1615
|
-
function MethodDefinition(node, scope, options = {}) {
|
|
1624
|
+
function MethodDefinition$1(node, scope, options = {}) {
|
|
1616
1625
|
const { klass, superClass } = options;
|
|
1617
1626
|
let key;
|
|
1618
1627
|
let priv = false;
|
|
1619
1628
|
if (node.computed) {
|
|
1620
|
-
key = evaluate(node.key, scope);
|
|
1629
|
+
key = evaluate$1(node.key, scope);
|
|
1621
1630
|
}
|
|
1622
1631
|
else if (node.key.type === 'Identifier') {
|
|
1623
1632
|
key = node.key.name;
|
|
@@ -1636,7 +1645,7 @@
|
|
|
1636
1645
|
}
|
|
1637
1646
|
obj = obj[PRIVATE];
|
|
1638
1647
|
}
|
|
1639
|
-
const value = createFunc
|
|
1648
|
+
const value = createFunc(node.value, scope, { superClass });
|
|
1640
1649
|
switch (node.kind) {
|
|
1641
1650
|
case 'constructor':
|
|
1642
1651
|
break;
|
|
@@ -1669,12 +1678,12 @@
|
|
|
1669
1678
|
throw new SyntaxError('Unexpected token');
|
|
1670
1679
|
}
|
|
1671
1680
|
}
|
|
1672
|
-
function PropertyDefinition(node, scope, options = {}) {
|
|
1681
|
+
function PropertyDefinition$1(node, scope, options = {}) {
|
|
1673
1682
|
const { klass, superClass } = options;
|
|
1674
1683
|
let key;
|
|
1675
1684
|
let priv = false;
|
|
1676
1685
|
if (node.computed) {
|
|
1677
|
-
key = evaluate(node.key, scope);
|
|
1686
|
+
key = evaluate$1(node.key, scope);
|
|
1678
1687
|
}
|
|
1679
1688
|
else if (node.key.type === 'Identifier') {
|
|
1680
1689
|
key = node.key.name;
|
|
@@ -1696,19 +1705,19 @@
|
|
|
1696
1705
|
obj = obj[PRIVATE];
|
|
1697
1706
|
}
|
|
1698
1707
|
if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
|
|
1699
|
-
obj[key] = createFunc
|
|
1708
|
+
obj[key] = createFunc(node.value, subScope, { superClass });
|
|
1700
1709
|
}
|
|
1701
1710
|
else {
|
|
1702
|
-
obj[key] = evaluate(node.value, subScope);
|
|
1711
|
+
obj[key] = evaluate$1(node.value, subScope);
|
|
1703
1712
|
}
|
|
1704
1713
|
}
|
|
1705
|
-
function StaticBlock(node, scope, options = {}) {
|
|
1714
|
+
function StaticBlock$1(node, scope, options = {}) {
|
|
1706
1715
|
const { klass } = options;
|
|
1707
1716
|
const subScope = new Scope(scope, true);
|
|
1708
1717
|
subScope.const('this', klass);
|
|
1709
|
-
return BlockStatement(node, subScope, { invasived: true });
|
|
1718
|
+
return BlockStatement$1(node, subScope, { invasived: true });
|
|
1710
1719
|
}
|
|
1711
|
-
function ImportDeclaration(node, scope) {
|
|
1720
|
+
function ImportDeclaration$1(node, scope) {
|
|
1712
1721
|
const globalScope = scope.global();
|
|
1713
1722
|
const module = globalScope.find(IMPORT + node.source.value);
|
|
1714
1723
|
let value;
|
|
@@ -1745,19 +1754,19 @@
|
|
|
1745
1754
|
scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
|
|
1746
1755
|
}
|
|
1747
1756
|
}
|
|
1748
|
-
function ExportDefaultDeclaration(node, scope) {
|
|
1757
|
+
function ExportDefaultDeclaration$1(node, scope) {
|
|
1749
1758
|
const globalScope = scope.global();
|
|
1750
1759
|
let value;
|
|
1751
1760
|
if (node.declaration.type === 'FunctionDeclaration') {
|
|
1752
|
-
value = createFunc
|
|
1761
|
+
value = createFunc(node.declaration, scope);
|
|
1753
1762
|
scope.func(node.declaration.id.name, value);
|
|
1754
1763
|
}
|
|
1755
1764
|
else if (node.declaration.type === 'ClassDeclaration') {
|
|
1756
|
-
value = createClass
|
|
1765
|
+
value = createClass(node.declaration, scope);
|
|
1757
1766
|
scope.func(node.declaration.id.name, value);
|
|
1758
1767
|
}
|
|
1759
1768
|
else {
|
|
1760
|
-
value = evaluate(node.declaration, scope);
|
|
1769
|
+
value = evaluate$1(node.declaration, scope);
|
|
1761
1770
|
}
|
|
1762
1771
|
const variable = globalScope.find(EXPORTS);
|
|
1763
1772
|
if (variable) {
|
|
@@ -1767,11 +1776,11 @@
|
|
|
1767
1776
|
}
|
|
1768
1777
|
}
|
|
1769
1778
|
}
|
|
1770
|
-
function ExportNamedDeclaration(node, scope) {
|
|
1779
|
+
function ExportNamedDeclaration$1(node, scope) {
|
|
1771
1780
|
const globalScope = scope.global();
|
|
1772
1781
|
if (node.declaration) {
|
|
1773
1782
|
if (node.declaration.type === 'FunctionDeclaration') {
|
|
1774
|
-
const value = createFunc
|
|
1783
|
+
const value = createFunc(node.declaration, scope);
|
|
1775
1784
|
scope.func(node.declaration.id.name, value);
|
|
1776
1785
|
const variable = globalScope.find(EXPORTS);
|
|
1777
1786
|
if (variable) {
|
|
@@ -1782,7 +1791,7 @@
|
|
|
1782
1791
|
}
|
|
1783
1792
|
}
|
|
1784
1793
|
else if (node.declaration.type === 'ClassDeclaration') {
|
|
1785
|
-
const value = createClass
|
|
1794
|
+
const value = createClass(node.declaration, scope);
|
|
1786
1795
|
scope.func(node.declaration.id.name, value);
|
|
1787
1796
|
const variable = globalScope.find(EXPORTS);
|
|
1788
1797
|
if (variable) {
|
|
@@ -1793,7 +1802,7 @@
|
|
|
1793
1802
|
}
|
|
1794
1803
|
}
|
|
1795
1804
|
else if (node.declaration.type === 'VariableDeclaration') {
|
|
1796
|
-
VariableDeclaration(node.declaration, scope);
|
|
1805
|
+
VariableDeclaration$1(node.declaration, scope);
|
|
1797
1806
|
const variable = globalScope.find(EXPORTS);
|
|
1798
1807
|
if (variable) {
|
|
1799
1808
|
const exports = variable.get();
|
|
@@ -1828,7 +1837,7 @@
|
|
|
1828
1837
|
}
|
|
1829
1838
|
}
|
|
1830
1839
|
}
|
|
1831
|
-
function ExportAllDeclaration(node, scope) {
|
|
1840
|
+
function ExportAllDeclaration$1(node, scope) {
|
|
1832
1841
|
const globalScope = scope.global();
|
|
1833
1842
|
const module = globalScope.find(IMPORT + node.source.value);
|
|
1834
1843
|
let value;
|
|
@@ -1855,7 +1864,7 @@
|
|
|
1855
1864
|
}
|
|
1856
1865
|
}
|
|
1857
1866
|
|
|
1858
|
-
function* Identifier
|
|
1867
|
+
function* Identifier(node, scope, options = {}) {
|
|
1859
1868
|
const { getVar = false, throwErr = true } = options;
|
|
1860
1869
|
if (node.name === 'undefined') {
|
|
1861
1870
|
return undefined;
|
|
@@ -1883,21 +1892,21 @@
|
|
|
1883
1892
|
}
|
|
1884
1893
|
}
|
|
1885
1894
|
|
|
1886
|
-
var identifier
|
|
1895
|
+
var identifier = /*#__PURE__*/Object.freeze({
|
|
1887
1896
|
__proto__: null,
|
|
1888
|
-
Identifier: Identifier
|
|
1897
|
+
Identifier: Identifier
|
|
1889
1898
|
});
|
|
1890
1899
|
|
|
1891
|
-
function* Literal
|
|
1900
|
+
function* Literal(node, scope) {
|
|
1892
1901
|
return node.value;
|
|
1893
1902
|
}
|
|
1894
1903
|
|
|
1895
|
-
var literal
|
|
1904
|
+
var literal = /*#__PURE__*/Object.freeze({
|
|
1896
1905
|
__proto__: null,
|
|
1897
|
-
Literal: Literal
|
|
1906
|
+
Literal: Literal
|
|
1898
1907
|
});
|
|
1899
1908
|
|
|
1900
|
-
function* ThisExpression
|
|
1909
|
+
function* ThisExpression(node, scope) {
|
|
1901
1910
|
const superCall = scope.find(SUPERCALL);
|
|
1902
1911
|
if (superCall && !superCall.get()) {
|
|
1903
1912
|
throw new ReferenceError('Must call super constructor in derived class '
|
|
@@ -1907,41 +1916,41 @@
|
|
|
1907
1916
|
return scope.find('this').get();
|
|
1908
1917
|
}
|
|
1909
1918
|
}
|
|
1910
|
-
function* ArrayExpression
|
|
1919
|
+
function* ArrayExpression(node, scope) {
|
|
1911
1920
|
let results = [];
|
|
1912
1921
|
for (let i = 0; i < node.elements.length; i++) {
|
|
1913
1922
|
const item = node.elements[i];
|
|
1914
1923
|
if (item.type === 'SpreadElement') {
|
|
1915
|
-
results = results.concat(yield* SpreadElement
|
|
1924
|
+
results = results.concat(yield* SpreadElement(item, scope));
|
|
1916
1925
|
}
|
|
1917
1926
|
else {
|
|
1918
|
-
results.push(yield* evaluate
|
|
1927
|
+
results.push(yield* evaluate(item, scope));
|
|
1919
1928
|
}
|
|
1920
1929
|
}
|
|
1921
1930
|
return results;
|
|
1922
1931
|
}
|
|
1923
|
-
function* ObjectExpression
|
|
1932
|
+
function* ObjectExpression(node, scope) {
|
|
1924
1933
|
const object = {};
|
|
1925
1934
|
for (let i = 0; i < node.properties.length; i++) {
|
|
1926
1935
|
const property = node.properties[i];
|
|
1927
1936
|
if (property.type === 'SpreadElement') {
|
|
1928
|
-
assign(object, yield* SpreadElement
|
|
1937
|
+
assign(object, yield* SpreadElement(property, scope));
|
|
1929
1938
|
}
|
|
1930
1939
|
else {
|
|
1931
1940
|
let key;
|
|
1932
1941
|
const propKey = property.key;
|
|
1933
1942
|
if (property.computed) {
|
|
1934
|
-
key = yield* evaluate
|
|
1943
|
+
key = yield* evaluate(propKey, scope);
|
|
1935
1944
|
}
|
|
1936
1945
|
else {
|
|
1937
1946
|
if (propKey.type === 'Identifier') {
|
|
1938
1947
|
key = propKey.name;
|
|
1939
1948
|
}
|
|
1940
1949
|
else {
|
|
1941
|
-
key = '' + (yield* Literal
|
|
1950
|
+
key = '' + (yield* Literal(propKey));
|
|
1942
1951
|
}
|
|
1943
1952
|
}
|
|
1944
|
-
const value = yield* evaluate
|
|
1953
|
+
const value = yield* evaluate(property.value, scope);
|
|
1945
1954
|
const propKind = property.kind;
|
|
1946
1955
|
if (propKind === 'init') {
|
|
1947
1956
|
object[key] = value;
|
|
@@ -1968,55 +1977,55 @@
|
|
|
1968
1977
|
}
|
|
1969
1978
|
return object;
|
|
1970
1979
|
}
|
|
1971
|
-
function* FunctionExpression
|
|
1980
|
+
function* FunctionExpression(node, scope) {
|
|
1972
1981
|
if (node.id && node.id.name) {
|
|
1973
1982
|
const tmpScope = new Scope(scope);
|
|
1974
|
-
const func = createFunc(node, tmpScope);
|
|
1983
|
+
const func = createFunc$1(node, tmpScope);
|
|
1975
1984
|
tmpScope.const(node.id.name, func);
|
|
1976
1985
|
return func;
|
|
1977
1986
|
}
|
|
1978
1987
|
else {
|
|
1979
|
-
return createFunc(node, scope);
|
|
1988
|
+
return createFunc$1(node, scope);
|
|
1980
1989
|
}
|
|
1981
1990
|
}
|
|
1982
|
-
function* UnaryExpression
|
|
1991
|
+
function* UnaryExpression(node, scope) {
|
|
1983
1992
|
const arg = node.argument;
|
|
1984
1993
|
switch (node.operator) {
|
|
1985
|
-
case '+': return +(yield* evaluate
|
|
1986
|
-
case '-': return -(yield* evaluate
|
|
1987
|
-
case '!': return !(yield* evaluate
|
|
1988
|
-
case '~': return ~(yield* evaluate
|
|
1989
|
-
case 'void': return void (yield* evaluate
|
|
1994
|
+
case '+': return +(yield* evaluate(arg, scope));
|
|
1995
|
+
case '-': return -(yield* evaluate(arg, scope));
|
|
1996
|
+
case '!': return !(yield* evaluate(arg, scope));
|
|
1997
|
+
case '~': return ~(yield* evaluate(arg, scope));
|
|
1998
|
+
case 'void': return void (yield* evaluate(arg, scope));
|
|
1990
1999
|
case 'typeof':
|
|
1991
2000
|
if (arg.type === 'Identifier') {
|
|
1992
|
-
return typeof (yield* Identifier
|
|
2001
|
+
return typeof (yield* Identifier(arg, scope, { throwErr: false }));
|
|
1993
2002
|
}
|
|
1994
2003
|
else {
|
|
1995
|
-
return typeof (yield* evaluate
|
|
2004
|
+
return typeof (yield* evaluate(arg, scope));
|
|
1996
2005
|
}
|
|
1997
2006
|
case 'delete':
|
|
1998
2007
|
if (arg.type === 'MemberExpression') {
|
|
1999
|
-
const variable = yield* MemberExpression
|
|
2008
|
+
const variable = yield* MemberExpression(arg, scope, { getVar: true });
|
|
2000
2009
|
return variable.del();
|
|
2001
2010
|
}
|
|
2002
2011
|
else if (arg.type === 'Identifier') {
|
|
2003
2012
|
throw new SyntaxError('Delete of an unqualified identifier in strict mode');
|
|
2004
2013
|
}
|
|
2005
2014
|
else {
|
|
2006
|
-
yield* evaluate
|
|
2015
|
+
yield* evaluate(arg, scope);
|
|
2007
2016
|
return true;
|
|
2008
2017
|
}
|
|
2009
2018
|
default: throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
2010
2019
|
}
|
|
2011
2020
|
}
|
|
2012
|
-
function* UpdateExpression
|
|
2021
|
+
function* UpdateExpression(node, scope) {
|
|
2013
2022
|
const arg = node.argument;
|
|
2014
2023
|
let variable;
|
|
2015
2024
|
if (arg.type === 'Identifier') {
|
|
2016
|
-
variable = yield* Identifier
|
|
2025
|
+
variable = yield* Identifier(arg, scope, { getVar: true });
|
|
2017
2026
|
}
|
|
2018
2027
|
else if (arg.type === 'MemberExpression') {
|
|
2019
|
-
variable = yield* MemberExpression
|
|
2028
|
+
variable = yield* MemberExpression(arg, scope, { getVar: true });
|
|
2020
2029
|
}
|
|
2021
2030
|
else {
|
|
2022
2031
|
throw new SyntaxError('Unexpected token');
|
|
@@ -2034,17 +2043,17 @@
|
|
|
2034
2043
|
throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
2035
2044
|
}
|
|
2036
2045
|
}
|
|
2037
|
-
function* BinaryExpression
|
|
2046
|
+
function* BinaryExpression(node, scope) {
|
|
2038
2047
|
let left;
|
|
2039
2048
|
let right;
|
|
2040
2049
|
if (node.left.type === 'PrivateIdentifier') {
|
|
2041
2050
|
left = node.left.name;
|
|
2042
|
-
right = yield* evaluate
|
|
2051
|
+
right = yield* evaluate(node.right, scope);
|
|
2043
2052
|
right = right[PRIVATE];
|
|
2044
2053
|
}
|
|
2045
2054
|
else {
|
|
2046
|
-
left = yield* evaluate
|
|
2047
|
-
right = yield* evaluate
|
|
2055
|
+
left = yield* evaluate(node.left, scope);
|
|
2056
|
+
right = yield* evaluate(node.right, scope);
|
|
2048
2057
|
}
|
|
2049
2058
|
switch (node.operator) {
|
|
2050
2059
|
case '==': return left == right;
|
|
@@ -2072,25 +2081,25 @@
|
|
|
2072
2081
|
default: throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
2073
2082
|
}
|
|
2074
2083
|
}
|
|
2075
|
-
function* AssignmentExpression
|
|
2084
|
+
function* AssignmentExpression(node, scope) {
|
|
2076
2085
|
var _a;
|
|
2077
2086
|
const left = node.left;
|
|
2078
2087
|
let variable;
|
|
2079
2088
|
if (left.type === 'Identifier') {
|
|
2080
|
-
variable = yield* Identifier
|
|
2089
|
+
variable = yield* Identifier(left, scope, { getVar: true, throwErr: false });
|
|
2081
2090
|
if (!variable) {
|
|
2082
2091
|
const win = scope.global().find('window').get();
|
|
2083
2092
|
variable = new Prop(win, left.name);
|
|
2084
2093
|
}
|
|
2085
2094
|
}
|
|
2086
2095
|
else if (left.type === 'MemberExpression') {
|
|
2087
|
-
variable = yield* MemberExpression
|
|
2096
|
+
variable = yield* MemberExpression(left, scope, { getVar: true });
|
|
2088
2097
|
}
|
|
2089
2098
|
else {
|
|
2090
|
-
const value = yield* evaluate
|
|
2091
|
-
return yield* pattern$
|
|
2099
|
+
const value = yield* evaluate(node.right, scope);
|
|
2100
|
+
return yield* pattern$1(left, scope, { feed: value });
|
|
2092
2101
|
}
|
|
2093
|
-
const value = yield* evaluate
|
|
2102
|
+
const value = yield* evaluate(node.right, scope);
|
|
2094
2103
|
switch (node.operator) {
|
|
2095
2104
|
case '=':
|
|
2096
2105
|
variable.set(value);
|
|
@@ -2143,34 +2152,34 @@
|
|
|
2143
2152
|
default: throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
2144
2153
|
}
|
|
2145
2154
|
}
|
|
2146
|
-
function* LogicalExpression
|
|
2155
|
+
function* LogicalExpression(node, scope) {
|
|
2147
2156
|
var _a;
|
|
2148
2157
|
switch (node.operator) {
|
|
2149
2158
|
case '||':
|
|
2150
|
-
return (yield* evaluate
|
|
2159
|
+
return (yield* evaluate(node.left, scope)) || (yield* evaluate(node.right, scope));
|
|
2151
2160
|
case '&&':
|
|
2152
|
-
return (yield* evaluate
|
|
2161
|
+
return (yield* evaluate(node.left, scope)) && (yield* evaluate(node.right, scope));
|
|
2153
2162
|
case '??':
|
|
2154
|
-
return (_a = (yield* evaluate
|
|
2163
|
+
return (_a = (yield* evaluate(node.left, scope))) !== null && _a !== void 0 ? _a : (yield* evaluate(node.right, scope));
|
|
2155
2164
|
default:
|
|
2156
2165
|
throw new SyntaxError(`Unexpected token ${node.operator}`);
|
|
2157
2166
|
}
|
|
2158
2167
|
}
|
|
2159
|
-
function* MemberExpression
|
|
2168
|
+
function* MemberExpression(node, scope, options = {}) {
|
|
2160
2169
|
const { getObj = false, getVar = false } = options;
|
|
2161
2170
|
let object;
|
|
2162
2171
|
if (node.object.type === 'Super') {
|
|
2163
|
-
object = yield* Super
|
|
2172
|
+
object = yield* Super(node.object, scope, { getProto: true });
|
|
2164
2173
|
}
|
|
2165
2174
|
else {
|
|
2166
|
-
object = yield* evaluate
|
|
2175
|
+
object = yield* evaluate(node.object, scope);
|
|
2167
2176
|
}
|
|
2168
2177
|
if (getObj)
|
|
2169
2178
|
return object;
|
|
2170
2179
|
let key;
|
|
2171
2180
|
let priv = false;
|
|
2172
2181
|
if (node.computed) {
|
|
2173
|
-
key = yield* evaluate
|
|
2182
|
+
key = yield* evaluate(node.property, scope);
|
|
2174
2183
|
}
|
|
2175
2184
|
else if (node.property.type === 'PrivateIdentifier') {
|
|
2176
2185
|
key = node.property.name;
|
|
@@ -2211,23 +2220,23 @@
|
|
|
2211
2220
|
}
|
|
2212
2221
|
}
|
|
2213
2222
|
}
|
|
2214
|
-
function* ConditionalExpression
|
|
2215
|
-
return (yield* evaluate
|
|
2216
|
-
? (yield* evaluate
|
|
2217
|
-
: (yield* evaluate
|
|
2223
|
+
function* ConditionalExpression(node, scope) {
|
|
2224
|
+
return (yield* evaluate(node.test, scope))
|
|
2225
|
+
? (yield* evaluate(node.consequent, scope))
|
|
2226
|
+
: (yield* evaluate(node.alternate, scope));
|
|
2218
2227
|
}
|
|
2219
|
-
function* CallExpression
|
|
2228
|
+
function* CallExpression(node, scope) {
|
|
2220
2229
|
let func;
|
|
2221
2230
|
let object;
|
|
2222
2231
|
if (node.callee.type === 'MemberExpression') {
|
|
2223
|
-
object = yield* MemberExpression
|
|
2232
|
+
object = yield* MemberExpression(node.callee, scope, { getObj: true });
|
|
2224
2233
|
if (node.callee.optional && object == null) {
|
|
2225
2234
|
return undefined;
|
|
2226
2235
|
}
|
|
2227
2236
|
let key;
|
|
2228
2237
|
let priv = false;
|
|
2229
2238
|
if (node.callee.computed) {
|
|
2230
|
-
key = yield* evaluate
|
|
2239
|
+
key = yield* evaluate(node.callee.property, scope);
|
|
2231
2240
|
}
|
|
2232
2241
|
else if (node.callee.property.type === 'PrivateIdentifier') {
|
|
2233
2242
|
key = node.callee.property.name;
|
|
@@ -2259,7 +2268,7 @@
|
|
|
2259
2268
|
}
|
|
2260
2269
|
else {
|
|
2261
2270
|
object = scope.find('this').get();
|
|
2262
|
-
func = yield* evaluate
|
|
2271
|
+
func = yield* evaluate(node.callee, scope);
|
|
2263
2272
|
if (node.optional && func == null) {
|
|
2264
2273
|
return undefined;
|
|
2265
2274
|
}
|
|
@@ -2288,10 +2297,10 @@
|
|
|
2288
2297
|
for (let i = 0; i < node.arguments.length; i++) {
|
|
2289
2298
|
const arg = node.arguments[i];
|
|
2290
2299
|
if (arg.type === 'SpreadElement') {
|
|
2291
|
-
args = args.concat(yield* SpreadElement
|
|
2300
|
+
args = args.concat(yield* SpreadElement(arg, scope));
|
|
2292
2301
|
}
|
|
2293
2302
|
else {
|
|
2294
|
-
args.push(yield* evaluate
|
|
2303
|
+
args.push(yield* evaluate(arg, scope));
|
|
2295
2304
|
}
|
|
2296
2305
|
}
|
|
2297
2306
|
if (node.callee.type === 'Super') {
|
|
@@ -2303,13 +2312,22 @@
|
|
|
2303
2312
|
scope.find(SUPERCALL).set(true);
|
|
2304
2313
|
}
|
|
2305
2314
|
}
|
|
2306
|
-
|
|
2307
|
-
return func.apply(object
|
|
2315
|
+
try {
|
|
2316
|
+
return func.apply(object, args);
|
|
2317
|
+
}
|
|
2318
|
+
catch (err) {
|
|
2319
|
+
if (err instanceof TypeError && err.message === 'Illegal invocation'
|
|
2320
|
+
&& func.toString().indexOf('[native code]') !== -1) {
|
|
2321
|
+
const win = scope.global().find('window').get();
|
|
2322
|
+
if (win && win[WINDOW]) {
|
|
2323
|
+
return func.apply(win[WINDOW], args);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
throw err;
|
|
2308
2327
|
}
|
|
2309
|
-
return func.apply(object, args);
|
|
2310
2328
|
}
|
|
2311
|
-
function* NewExpression
|
|
2312
|
-
const constructor = yield* evaluate
|
|
2329
|
+
function* NewExpression(node, scope) {
|
|
2330
|
+
const constructor = yield* evaluate(node.callee, scope);
|
|
2313
2331
|
if (typeof constructor !== 'function') {
|
|
2314
2332
|
let name;
|
|
2315
2333
|
if (node.callee.type === 'Identifier') {
|
|
@@ -2332,15 +2350,15 @@
|
|
|
2332
2350
|
for (let i = 0; i < node.arguments.length; i++) {
|
|
2333
2351
|
const arg = node.arguments[i];
|
|
2334
2352
|
if (arg.type === 'SpreadElement') {
|
|
2335
|
-
args = args.concat(yield* SpreadElement
|
|
2353
|
+
args = args.concat(yield* SpreadElement(arg, scope));
|
|
2336
2354
|
}
|
|
2337
2355
|
else {
|
|
2338
|
-
args.push(yield* evaluate
|
|
2356
|
+
args.push(yield* evaluate(arg, scope));
|
|
2339
2357
|
}
|
|
2340
2358
|
}
|
|
2341
2359
|
return new constructor(...args);
|
|
2342
2360
|
}
|
|
2343
|
-
function* MetaProperty
|
|
2361
|
+
function* MetaProperty(node, scope) {
|
|
2344
2362
|
if (node.meta.name === 'new' && node.property.name === 'target') {
|
|
2345
2363
|
return scope.find(NEWTARGET).get();
|
|
2346
2364
|
}
|
|
@@ -2348,33 +2366,33 @@
|
|
|
2348
2366
|
return { url: '' };
|
|
2349
2367
|
}
|
|
2350
2368
|
}
|
|
2351
|
-
function* SequenceExpression
|
|
2369
|
+
function* SequenceExpression(node, scope) {
|
|
2352
2370
|
let result;
|
|
2353
2371
|
for (let i = 0; i < node.expressions.length; i++) {
|
|
2354
|
-
result = yield* evaluate
|
|
2372
|
+
result = yield* evaluate(node.expressions[i], scope);
|
|
2355
2373
|
}
|
|
2356
2374
|
return result;
|
|
2357
2375
|
}
|
|
2358
|
-
function* ArrowFunctionExpression
|
|
2359
|
-
return createFunc(node, scope);
|
|
2376
|
+
function* ArrowFunctionExpression(node, scope) {
|
|
2377
|
+
return createFunc$1(node, scope);
|
|
2360
2378
|
}
|
|
2361
|
-
function* TemplateLiteral
|
|
2379
|
+
function* TemplateLiteral(node, scope) {
|
|
2362
2380
|
const quasis = node.quasis.slice();
|
|
2363
2381
|
const expressions = node.expressions.slice();
|
|
2364
2382
|
let result = '';
|
|
2365
2383
|
let temEl;
|
|
2366
2384
|
let expr;
|
|
2367
2385
|
while (temEl = quasis.shift()) {
|
|
2368
|
-
result += yield* TemplateElement
|
|
2386
|
+
result += yield* TemplateElement(temEl);
|
|
2369
2387
|
expr = expressions.shift();
|
|
2370
2388
|
if (expr) {
|
|
2371
|
-
result += yield* evaluate
|
|
2389
|
+
result += yield* evaluate(expr, scope);
|
|
2372
2390
|
}
|
|
2373
2391
|
}
|
|
2374
2392
|
return result;
|
|
2375
2393
|
}
|
|
2376
|
-
function* TaggedTemplateExpression
|
|
2377
|
-
const tagFunc = yield* evaluate
|
|
2394
|
+
function* TaggedTemplateExpression(node, scope) {
|
|
2395
|
+
const tagFunc = yield* evaluate(node.tag, scope);
|
|
2378
2396
|
const quasis = node.quasi.quasis;
|
|
2379
2397
|
const str = quasis.map(v => v.value.cooked);
|
|
2380
2398
|
const raw = quasis.map(v => v.value.raw);
|
|
@@ -2385,40 +2403,40 @@
|
|
|
2385
2403
|
const args = [];
|
|
2386
2404
|
if (expressions) {
|
|
2387
2405
|
for (let i = 0; i < expressions.length; i++) {
|
|
2388
|
-
args.push(yield* evaluate
|
|
2406
|
+
args.push(yield* evaluate(expressions[i], scope));
|
|
2389
2407
|
}
|
|
2390
2408
|
}
|
|
2391
2409
|
return tagFunc(freeze(str), ...args);
|
|
2392
2410
|
}
|
|
2393
|
-
function* TemplateElement
|
|
2411
|
+
function* TemplateElement(node, scope) {
|
|
2394
2412
|
return node.value.raw;
|
|
2395
2413
|
}
|
|
2396
|
-
function* ClassExpression
|
|
2414
|
+
function* ClassExpression(node, scope) {
|
|
2397
2415
|
if (node.id && node.id.name) {
|
|
2398
2416
|
const tmpScope = new Scope(scope);
|
|
2399
|
-
const klass = yield* createClass(node, tmpScope);
|
|
2417
|
+
const klass = yield* createClass$1(node, tmpScope);
|
|
2400
2418
|
tmpScope.const(node.id.name, klass);
|
|
2401
2419
|
return klass;
|
|
2402
2420
|
}
|
|
2403
2421
|
else {
|
|
2404
|
-
return yield* createClass(node, scope);
|
|
2422
|
+
return yield* createClass$1(node, scope);
|
|
2405
2423
|
}
|
|
2406
2424
|
}
|
|
2407
|
-
function* Super
|
|
2425
|
+
function* Super(node, scope, options = {}) {
|
|
2408
2426
|
const { getProto = false } = options;
|
|
2409
2427
|
const superClass = scope.find(SUPER).get();
|
|
2410
2428
|
return getProto ? superClass.prototype : superClass;
|
|
2411
2429
|
}
|
|
2412
|
-
function* SpreadElement
|
|
2413
|
-
const result = yield* evaluate
|
|
2430
|
+
function* SpreadElement(node, scope) {
|
|
2431
|
+
const result = yield* evaluate(node.argument, scope);
|
|
2414
2432
|
return typeof result === 'string' ? [...result] : result;
|
|
2415
2433
|
}
|
|
2416
|
-
function* ChainExpression
|
|
2417
|
-
return yield* evaluate
|
|
2434
|
+
function* ChainExpression(node, scope) {
|
|
2435
|
+
return yield* evaluate(node.expression, scope);
|
|
2418
2436
|
}
|
|
2419
|
-
function* ImportExpression
|
|
2437
|
+
function* ImportExpression(node, scope) {
|
|
2420
2438
|
const globalScope = scope.global();
|
|
2421
|
-
const source = yield* evaluate
|
|
2439
|
+
const source = yield* evaluate(node.source, scope);
|
|
2422
2440
|
const module = globalScope.find(IMPORT + source);
|
|
2423
2441
|
let value;
|
|
2424
2442
|
if (module) {
|
|
@@ -2438,45 +2456,45 @@
|
|
|
2438
2456
|
return Promise.resolve(value);
|
|
2439
2457
|
}
|
|
2440
2458
|
function* YieldExpression(node, scope) {
|
|
2441
|
-
const res = yield* evaluate
|
|
2459
|
+
const res = yield* evaluate(node.argument, scope);
|
|
2442
2460
|
return node.delegate ? yield* res : yield res;
|
|
2443
2461
|
}
|
|
2444
2462
|
function* AwaitExpression(node, scope) {
|
|
2445
|
-
AWAIT.RES = yield* evaluate
|
|
2463
|
+
AWAIT.RES = yield* evaluate(node.argument, scope);
|
|
2446
2464
|
return yield AWAIT;
|
|
2447
2465
|
}
|
|
2448
2466
|
|
|
2449
|
-
var expression
|
|
2467
|
+
var expression = /*#__PURE__*/Object.freeze({
|
|
2450
2468
|
__proto__: null,
|
|
2451
|
-
ThisExpression: ThisExpression
|
|
2452
|
-
ArrayExpression: ArrayExpression
|
|
2453
|
-
ObjectExpression: ObjectExpression
|
|
2454
|
-
FunctionExpression: FunctionExpression
|
|
2455
|
-
UnaryExpression: UnaryExpression
|
|
2456
|
-
UpdateExpression: UpdateExpression
|
|
2457
|
-
BinaryExpression: BinaryExpression
|
|
2458
|
-
AssignmentExpression: AssignmentExpression
|
|
2459
|
-
LogicalExpression: LogicalExpression
|
|
2460
|
-
MemberExpression: MemberExpression
|
|
2461
|
-
ConditionalExpression: ConditionalExpression
|
|
2462
|
-
CallExpression: CallExpression
|
|
2463
|
-
NewExpression: NewExpression
|
|
2464
|
-
MetaProperty: MetaProperty
|
|
2465
|
-
SequenceExpression: SequenceExpression
|
|
2466
|
-
ArrowFunctionExpression: ArrowFunctionExpression
|
|
2467
|
-
TemplateLiteral: TemplateLiteral
|
|
2468
|
-
TaggedTemplateExpression: TaggedTemplateExpression
|
|
2469
|
-
TemplateElement: TemplateElement
|
|
2470
|
-
ClassExpression: ClassExpression
|
|
2471
|
-
Super: Super
|
|
2472
|
-
SpreadElement: SpreadElement
|
|
2473
|
-
ChainExpression: ChainExpression
|
|
2474
|
-
ImportExpression: ImportExpression
|
|
2469
|
+
ThisExpression: ThisExpression,
|
|
2470
|
+
ArrayExpression: ArrayExpression,
|
|
2471
|
+
ObjectExpression: ObjectExpression,
|
|
2472
|
+
FunctionExpression: FunctionExpression,
|
|
2473
|
+
UnaryExpression: UnaryExpression,
|
|
2474
|
+
UpdateExpression: UpdateExpression,
|
|
2475
|
+
BinaryExpression: BinaryExpression,
|
|
2476
|
+
AssignmentExpression: AssignmentExpression,
|
|
2477
|
+
LogicalExpression: LogicalExpression,
|
|
2478
|
+
MemberExpression: MemberExpression,
|
|
2479
|
+
ConditionalExpression: ConditionalExpression,
|
|
2480
|
+
CallExpression: CallExpression,
|
|
2481
|
+
NewExpression: NewExpression,
|
|
2482
|
+
MetaProperty: MetaProperty,
|
|
2483
|
+
SequenceExpression: SequenceExpression,
|
|
2484
|
+
ArrowFunctionExpression: ArrowFunctionExpression,
|
|
2485
|
+
TemplateLiteral: TemplateLiteral,
|
|
2486
|
+
TaggedTemplateExpression: TaggedTemplateExpression,
|
|
2487
|
+
TemplateElement: TemplateElement,
|
|
2488
|
+
ClassExpression: ClassExpression,
|
|
2489
|
+
Super: Super,
|
|
2490
|
+
SpreadElement: SpreadElement,
|
|
2491
|
+
ChainExpression: ChainExpression,
|
|
2492
|
+
ImportExpression: ImportExpression,
|
|
2475
2493
|
YieldExpression: YieldExpression,
|
|
2476
2494
|
AwaitExpression: AwaitExpression
|
|
2477
2495
|
});
|
|
2478
2496
|
|
|
2479
|
-
function* ObjectPattern
|
|
2497
|
+
function* ObjectPattern(node, scope, options = {}) {
|
|
2480
2498
|
const { kind = 'var', hoist = false, onlyBlock = false, feed = {} } = options;
|
|
2481
2499
|
const fedKeys = [];
|
|
2482
2500
|
for (let i = 0; i < node.properties.length; i++) {
|
|
@@ -2489,18 +2507,18 @@
|
|
|
2489
2507
|
scope[kind](value.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2490
2508
|
}
|
|
2491
2509
|
else {
|
|
2492
|
-
yield* pattern$
|
|
2510
|
+
yield* pattern$1(value, scope, { kind, hoist, onlyBlock });
|
|
2493
2511
|
}
|
|
2494
2512
|
}
|
|
2495
2513
|
else {
|
|
2496
|
-
yield* RestElement
|
|
2514
|
+
yield* RestElement(property, scope, { kind, hoist, onlyBlock });
|
|
2497
2515
|
}
|
|
2498
2516
|
}
|
|
2499
2517
|
}
|
|
2500
2518
|
else if (property.type === 'Property') {
|
|
2501
2519
|
let key;
|
|
2502
2520
|
if (property.computed) {
|
|
2503
|
-
key = yield* evaluate
|
|
2521
|
+
key = yield* evaluate(property.key, scope);
|
|
2504
2522
|
}
|
|
2505
2523
|
else {
|
|
2506
2524
|
key = property.key.name;
|
|
@@ -2511,18 +2529,18 @@
|
|
|
2511
2529
|
scope[kind](value.name, feed[key]);
|
|
2512
2530
|
}
|
|
2513
2531
|
else {
|
|
2514
|
-
yield* pattern$
|
|
2532
|
+
yield* pattern$1(value, scope, { kind, feed: feed[key] });
|
|
2515
2533
|
}
|
|
2516
2534
|
}
|
|
2517
2535
|
else {
|
|
2518
2536
|
const rest = assign({}, feed);
|
|
2519
2537
|
for (let i = 0; i < fedKeys.length; i++)
|
|
2520
2538
|
delete rest[fedKeys[i]];
|
|
2521
|
-
yield* RestElement
|
|
2539
|
+
yield* RestElement(property, scope, { kind, feed: rest });
|
|
2522
2540
|
}
|
|
2523
2541
|
}
|
|
2524
2542
|
}
|
|
2525
|
-
function* ArrayPattern
|
|
2543
|
+
function* ArrayPattern(node, scope, options = {}) {
|
|
2526
2544
|
const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
|
|
2527
2545
|
const result = [];
|
|
2528
2546
|
for (let i = 0; i < node.elements.length; i++) {
|
|
@@ -2535,7 +2553,7 @@
|
|
|
2535
2553
|
scope[kind](element.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2536
2554
|
}
|
|
2537
2555
|
else {
|
|
2538
|
-
yield* pattern$
|
|
2556
|
+
yield* pattern$1(element, scope, { kind, hoist, onlyBlock });
|
|
2539
2557
|
}
|
|
2540
2558
|
}
|
|
2541
2559
|
}
|
|
@@ -2544,23 +2562,23 @@
|
|
|
2544
2562
|
scope[kind](element.name, feed[i]);
|
|
2545
2563
|
}
|
|
2546
2564
|
else {
|
|
2547
|
-
const variable = yield* Identifier
|
|
2565
|
+
const variable = yield* Identifier(element, scope, { getVar: true });
|
|
2548
2566
|
variable.set(feed[i]);
|
|
2549
2567
|
result.push(variable.get());
|
|
2550
2568
|
}
|
|
2551
2569
|
}
|
|
2552
2570
|
else if (element.type === 'RestElement') {
|
|
2553
|
-
yield* RestElement
|
|
2571
|
+
yield* RestElement(element, scope, { kind, feed: feed.slice(i) });
|
|
2554
2572
|
}
|
|
2555
2573
|
else {
|
|
2556
|
-
yield* pattern$
|
|
2574
|
+
yield* pattern$1(element, scope, { kind, feed: feed[i] });
|
|
2557
2575
|
}
|
|
2558
2576
|
}
|
|
2559
2577
|
if (result.length) {
|
|
2560
2578
|
return result;
|
|
2561
2579
|
}
|
|
2562
2580
|
}
|
|
2563
|
-
function* RestElement
|
|
2581
|
+
function* RestElement(node, scope, options = {}) {
|
|
2564
2582
|
const { kind, hoist = false, onlyBlock = false, feed = [] } = options;
|
|
2565
2583
|
const arg = node.argument;
|
|
2566
2584
|
if (hoist) {
|
|
@@ -2569,7 +2587,7 @@
|
|
|
2569
2587
|
scope[kind](arg.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2570
2588
|
}
|
|
2571
2589
|
else {
|
|
2572
|
-
yield* pattern$
|
|
2590
|
+
yield* pattern$1(arg, scope, { kind, hoist, onlyBlock });
|
|
2573
2591
|
}
|
|
2574
2592
|
}
|
|
2575
2593
|
}
|
|
@@ -2578,16 +2596,16 @@
|
|
|
2578
2596
|
scope[kind](arg.name, feed);
|
|
2579
2597
|
}
|
|
2580
2598
|
else {
|
|
2581
|
-
const variable = yield* Identifier
|
|
2599
|
+
const variable = yield* Identifier(arg, scope, { getVar: true });
|
|
2582
2600
|
variable.set(feed);
|
|
2583
2601
|
}
|
|
2584
2602
|
}
|
|
2585
2603
|
else {
|
|
2586
|
-
yield* pattern$
|
|
2604
|
+
yield* pattern$1(arg, scope, { kind, feed });
|
|
2587
2605
|
}
|
|
2588
2606
|
}
|
|
2589
|
-
function* AssignmentPattern
|
|
2590
|
-
const { kind = 'var', hoist = false, onlyBlock = false, feed = yield* evaluate
|
|
2607
|
+
function* AssignmentPattern(node, scope, options = {}) {
|
|
2608
|
+
const { kind = 'var', hoist = false, onlyBlock = false, feed = yield* evaluate(node.right, scope) } = options;
|
|
2591
2609
|
const left = node.left;
|
|
2592
2610
|
if (hoist) {
|
|
2593
2611
|
if (onlyBlock || kind === 'var') {
|
|
@@ -2595,7 +2613,7 @@
|
|
|
2595
2613
|
scope[kind](left.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2596
2614
|
}
|
|
2597
2615
|
else {
|
|
2598
|
-
yield* pattern$
|
|
2616
|
+
yield* pattern$1(left, scope, { kind, hoist, onlyBlock });
|
|
2599
2617
|
}
|
|
2600
2618
|
}
|
|
2601
2619
|
}
|
|
@@ -2603,26 +2621,26 @@
|
|
|
2603
2621
|
scope[kind](left.name, feed);
|
|
2604
2622
|
}
|
|
2605
2623
|
else {
|
|
2606
|
-
yield* pattern$
|
|
2624
|
+
yield* pattern$1(left, scope, { kind, feed });
|
|
2607
2625
|
}
|
|
2608
2626
|
}
|
|
2609
2627
|
|
|
2610
|
-
var pattern$
|
|
2628
|
+
var pattern$2 = /*#__PURE__*/Object.freeze({
|
|
2611
2629
|
__proto__: null,
|
|
2612
|
-
ObjectPattern: ObjectPattern
|
|
2613
|
-
ArrayPattern: ArrayPattern
|
|
2614
|
-
RestElement: RestElement
|
|
2615
|
-
AssignmentPattern: AssignmentPattern
|
|
2630
|
+
ObjectPattern: ObjectPattern,
|
|
2631
|
+
ArrayPattern: ArrayPattern,
|
|
2632
|
+
RestElement: RestElement,
|
|
2633
|
+
AssignmentPattern: AssignmentPattern
|
|
2616
2634
|
});
|
|
2617
2635
|
|
|
2618
|
-
let evaluateOps
|
|
2619
|
-
function* evaluate
|
|
2636
|
+
let evaluateOps;
|
|
2637
|
+
function* evaluate(node, scope) {
|
|
2620
2638
|
if (!node)
|
|
2621
2639
|
return;
|
|
2622
|
-
if (!evaluateOps
|
|
2623
|
-
evaluateOps
|
|
2640
|
+
if (!evaluateOps) {
|
|
2641
|
+
evaluateOps = assign({}, declaration, expression, identifier, statement, literal, pattern$2);
|
|
2624
2642
|
}
|
|
2625
|
-
const handler = evaluateOps
|
|
2643
|
+
const handler = evaluateOps[node.type];
|
|
2626
2644
|
if (handler) {
|
|
2627
2645
|
return yield* handler(node, scope);
|
|
2628
2646
|
}
|
|
@@ -2631,57 +2649,57 @@
|
|
|
2631
2649
|
}
|
|
2632
2650
|
}
|
|
2633
2651
|
|
|
2634
|
-
function* ExpressionStatement
|
|
2635
|
-
yield* evaluate
|
|
2652
|
+
function* ExpressionStatement(node, scope) {
|
|
2653
|
+
yield* evaluate(node.expression, scope);
|
|
2636
2654
|
}
|
|
2637
|
-
function* BlockStatement
|
|
2655
|
+
function* BlockStatement(block, scope, options = {}) {
|
|
2638
2656
|
const { invasived = false, hoisted = false, } = options;
|
|
2639
2657
|
const subScope = invasived ? scope : new Scope(scope);
|
|
2640
2658
|
if (!hoisted) {
|
|
2641
|
-
yield* hoist(block, subScope, { onlyBlock: true });
|
|
2659
|
+
yield* hoist$1(block, subScope, { onlyBlock: true });
|
|
2642
2660
|
}
|
|
2643
2661
|
for (let i = 0; i < block.body.length; i++) {
|
|
2644
|
-
const result = yield* evaluate
|
|
2662
|
+
const result = yield* evaluate(block.body[i], subScope);
|
|
2645
2663
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
2646
2664
|
return result;
|
|
2647
2665
|
}
|
|
2648
2666
|
}
|
|
2649
2667
|
}
|
|
2650
|
-
function* EmptyStatement
|
|
2668
|
+
function* EmptyStatement() {
|
|
2651
2669
|
}
|
|
2652
|
-
function* DebuggerStatement
|
|
2670
|
+
function* DebuggerStatement() {
|
|
2653
2671
|
debugger;
|
|
2654
2672
|
}
|
|
2655
|
-
function* ReturnStatement
|
|
2656
|
-
RETURN.RES = node.argument ? (yield* evaluate
|
|
2673
|
+
function* ReturnStatement(node, scope) {
|
|
2674
|
+
RETURN.RES = node.argument ? (yield* evaluate(node.argument, scope)) : undefined;
|
|
2657
2675
|
return RETURN;
|
|
2658
2676
|
}
|
|
2659
|
-
function* BreakStatement
|
|
2677
|
+
function* BreakStatement() {
|
|
2660
2678
|
return BREAK;
|
|
2661
2679
|
}
|
|
2662
|
-
function* ContinueStatement
|
|
2680
|
+
function* ContinueStatement() {
|
|
2663
2681
|
return CONTINUE;
|
|
2664
2682
|
}
|
|
2665
|
-
function* IfStatement
|
|
2666
|
-
if (yield* evaluate
|
|
2667
|
-
return yield* evaluate
|
|
2683
|
+
function* IfStatement(node, scope) {
|
|
2684
|
+
if (yield* evaluate(node.test, scope)) {
|
|
2685
|
+
return yield* evaluate(node.consequent, scope);
|
|
2668
2686
|
}
|
|
2669
2687
|
else {
|
|
2670
|
-
return yield* evaluate
|
|
2688
|
+
return yield* evaluate(node.alternate, scope);
|
|
2671
2689
|
}
|
|
2672
2690
|
}
|
|
2673
|
-
function* SwitchStatement
|
|
2674
|
-
const discriminant = yield* evaluate
|
|
2691
|
+
function* SwitchStatement(node, scope) {
|
|
2692
|
+
const discriminant = yield* evaluate(node.discriminant, scope);
|
|
2675
2693
|
let matched = false;
|
|
2676
2694
|
for (let i = 0; i < node.cases.length; i++) {
|
|
2677
2695
|
const eachCase = node.cases[i];
|
|
2678
2696
|
if (!matched
|
|
2679
2697
|
&& (!eachCase.test
|
|
2680
|
-
|| (yield* evaluate
|
|
2698
|
+
|| (yield* evaluate(eachCase.test, scope)) === discriminant)) {
|
|
2681
2699
|
matched = true;
|
|
2682
2700
|
}
|
|
2683
2701
|
if (matched) {
|
|
2684
|
-
const result = yield* SwitchCase
|
|
2702
|
+
const result = yield* SwitchCase(eachCase, scope);
|
|
2685
2703
|
if (result === BREAK) {
|
|
2686
2704
|
break;
|
|
2687
2705
|
}
|
|
@@ -2691,20 +2709,20 @@
|
|
|
2691
2709
|
}
|
|
2692
2710
|
}
|
|
2693
2711
|
}
|
|
2694
|
-
function* SwitchCase
|
|
2712
|
+
function* SwitchCase(node, scope) {
|
|
2695
2713
|
for (let i = 0; i < node.consequent.length; i++) {
|
|
2696
|
-
const result = yield* evaluate
|
|
2714
|
+
const result = yield* evaluate(node.consequent[i], scope);
|
|
2697
2715
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
2698
2716
|
return result;
|
|
2699
2717
|
}
|
|
2700
2718
|
}
|
|
2701
2719
|
}
|
|
2702
|
-
function* ThrowStatement
|
|
2703
|
-
throw yield* evaluate
|
|
2720
|
+
function* ThrowStatement(node, scope) {
|
|
2721
|
+
throw yield* evaluate(node.argument, scope);
|
|
2704
2722
|
}
|
|
2705
|
-
function* TryStatement
|
|
2723
|
+
function* TryStatement(node, scope) {
|
|
2706
2724
|
try {
|
|
2707
|
-
return yield* BlockStatement
|
|
2725
|
+
return yield* BlockStatement(node.block, scope);
|
|
2708
2726
|
}
|
|
2709
2727
|
catch (err) {
|
|
2710
2728
|
if (node.handler) {
|
|
@@ -2716,10 +2734,10 @@
|
|
|
2716
2734
|
subScope.var(name, err);
|
|
2717
2735
|
}
|
|
2718
2736
|
else {
|
|
2719
|
-
yield* pattern$
|
|
2737
|
+
yield* pattern$1(param, scope, { feed: err });
|
|
2720
2738
|
}
|
|
2721
2739
|
}
|
|
2722
|
-
return yield* CatchClause
|
|
2740
|
+
return yield* CatchClause(node.handler, subScope);
|
|
2723
2741
|
}
|
|
2724
2742
|
else {
|
|
2725
2743
|
throw err;
|
|
@@ -2727,19 +2745,19 @@
|
|
|
2727
2745
|
}
|
|
2728
2746
|
finally {
|
|
2729
2747
|
if (node.finalizer) {
|
|
2730
|
-
const result = yield* BlockStatement
|
|
2748
|
+
const result = yield* BlockStatement(node.finalizer, scope);
|
|
2731
2749
|
if (result === BREAK || result === CONTINUE || result === RETURN) {
|
|
2732
2750
|
return result;
|
|
2733
2751
|
}
|
|
2734
2752
|
}
|
|
2735
2753
|
}
|
|
2736
2754
|
}
|
|
2737
|
-
function* CatchClause
|
|
2738
|
-
return yield* BlockStatement
|
|
2755
|
+
function* CatchClause(node, scope) {
|
|
2756
|
+
return yield* BlockStatement(node.body, scope, { invasived: true });
|
|
2739
2757
|
}
|
|
2740
|
-
function* WhileStatement
|
|
2741
|
-
while (yield* evaluate
|
|
2742
|
-
const result = yield* evaluate
|
|
2758
|
+
function* WhileStatement(node, scope) {
|
|
2759
|
+
while (yield* evaluate(node.test, scope)) {
|
|
2760
|
+
const result = yield* evaluate(node.body, scope);
|
|
2743
2761
|
if (result === BREAK) {
|
|
2744
2762
|
break;
|
|
2745
2763
|
}
|
|
@@ -2751,9 +2769,9 @@
|
|
|
2751
2769
|
}
|
|
2752
2770
|
}
|
|
2753
2771
|
}
|
|
2754
|
-
function* DoWhileStatement
|
|
2772
|
+
function* DoWhileStatement(node, scope) {
|
|
2755
2773
|
do {
|
|
2756
|
-
const result = yield* evaluate
|
|
2774
|
+
const result = yield* evaluate(node.body, scope);
|
|
2757
2775
|
if (result === BREAK) {
|
|
2758
2776
|
break;
|
|
2759
2777
|
}
|
|
@@ -2763,18 +2781,18 @@
|
|
|
2763
2781
|
else if (result === RETURN) {
|
|
2764
2782
|
return result;
|
|
2765
2783
|
}
|
|
2766
|
-
} while (yield* evaluate
|
|
2784
|
+
} while (yield* evaluate(node.test, scope));
|
|
2767
2785
|
}
|
|
2768
|
-
function* ForStatement
|
|
2786
|
+
function* ForStatement(node, scope) {
|
|
2769
2787
|
const forScope = new Scope(scope);
|
|
2770
|
-
for (yield* evaluate
|
|
2788
|
+
for (yield* evaluate(node.init, forScope); node.test ? (yield* evaluate(node.test, forScope)) : true; yield* evaluate(node.update, forScope)) {
|
|
2771
2789
|
const subScope = new Scope(forScope);
|
|
2772
2790
|
let result;
|
|
2773
2791
|
if (node.body.type === 'BlockStatement') {
|
|
2774
|
-
result = yield* BlockStatement
|
|
2792
|
+
result = yield* BlockStatement(node.body, subScope, { invasived: true });
|
|
2775
2793
|
}
|
|
2776
2794
|
else {
|
|
2777
|
-
result = yield* evaluate
|
|
2795
|
+
result = yield* evaluate(node.body, subScope);
|
|
2778
2796
|
}
|
|
2779
2797
|
if (result === BREAK) {
|
|
2780
2798
|
break;
|
|
@@ -2787,9 +2805,9 @@
|
|
|
2787
2805
|
}
|
|
2788
2806
|
}
|
|
2789
2807
|
}
|
|
2790
|
-
function* ForInStatement
|
|
2791
|
-
for (const value in yield* evaluate
|
|
2792
|
-
const result = yield* ForXHandler(node, scope, { value });
|
|
2808
|
+
function* ForInStatement(node, scope) {
|
|
2809
|
+
for (const value in yield* evaluate(node.right, scope)) {
|
|
2810
|
+
const result = yield* ForXHandler$1(node, scope, { value });
|
|
2793
2811
|
if (result === BREAK) {
|
|
2794
2812
|
break;
|
|
2795
2813
|
}
|
|
@@ -2801,13 +2819,13 @@
|
|
|
2801
2819
|
}
|
|
2802
2820
|
}
|
|
2803
2821
|
}
|
|
2804
|
-
function* ForOfStatement
|
|
2805
|
-
const right = yield* evaluate
|
|
2822
|
+
function* ForOfStatement(node, scope) {
|
|
2823
|
+
const right = yield* evaluate(node.right, scope);
|
|
2806
2824
|
if (node.await) {
|
|
2807
2825
|
const iterator = getAsyncIterator(right);
|
|
2808
2826
|
let ret;
|
|
2809
2827
|
for (AWAIT.RES = iterator.next(), ret = yield AWAIT; !ret.done; AWAIT.RES = iterator.next(), ret = yield AWAIT) {
|
|
2810
|
-
const result = yield* ForXHandler(node, scope, { value: ret.value });
|
|
2828
|
+
const result = yield* ForXHandler$1(node, scope, { value: ret.value });
|
|
2811
2829
|
if (result === BREAK) {
|
|
2812
2830
|
break;
|
|
2813
2831
|
}
|
|
@@ -2821,7 +2839,7 @@
|
|
|
2821
2839
|
}
|
|
2822
2840
|
else {
|
|
2823
2841
|
for (const value of right) {
|
|
2824
|
-
const result = yield* ForXHandler(node, scope, { value });
|
|
2842
|
+
const result = yield* ForXHandler$1(node, scope, { value });
|
|
2825
2843
|
if (result === BREAK) {
|
|
2826
2844
|
break;
|
|
2827
2845
|
}
|
|
@@ -2835,15 +2853,15 @@
|
|
|
2835
2853
|
}
|
|
2836
2854
|
}
|
|
2837
2855
|
|
|
2838
|
-
function* FunctionDeclaration
|
|
2839
|
-
scope.func(node.id.name, createFunc(node, scope));
|
|
2856
|
+
function* FunctionDeclaration(node, scope) {
|
|
2857
|
+
scope.func(node.id.name, createFunc$1(node, scope));
|
|
2840
2858
|
}
|
|
2841
|
-
function* VariableDeclaration
|
|
2859
|
+
function* VariableDeclaration(node, scope, options = {}) {
|
|
2842
2860
|
for (let i = 0; i < node.declarations.length; i++) {
|
|
2843
|
-
yield* VariableDeclarator
|
|
2861
|
+
yield* VariableDeclarator(node.declarations[i], scope, assign({ kind: node.kind }, options));
|
|
2844
2862
|
}
|
|
2845
2863
|
}
|
|
2846
|
-
function* VariableDeclarator
|
|
2864
|
+
function* VariableDeclarator(node, scope, options = {}) {
|
|
2847
2865
|
const { kind = 'var', hoist = false, onlyBlock = false, feed } = options;
|
|
2848
2866
|
if (hoist) {
|
|
2849
2867
|
if (onlyBlock || kind === 'var') {
|
|
@@ -2851,13 +2869,13 @@
|
|
|
2851
2869
|
scope[kind](node.id.name, onlyBlock ? DEADZONE : kind === 'var' ? NOINIT : undefined);
|
|
2852
2870
|
}
|
|
2853
2871
|
else {
|
|
2854
|
-
yield* pattern$
|
|
2872
|
+
yield* pattern$1(node.id, scope, { kind, hoist, onlyBlock });
|
|
2855
2873
|
}
|
|
2856
2874
|
}
|
|
2857
2875
|
}
|
|
2858
2876
|
else {
|
|
2859
2877
|
const hasFeed = 'feed' in options;
|
|
2860
|
-
const value = hasFeed ? feed : yield* evaluate
|
|
2878
|
+
const value = hasFeed ? feed : yield* evaluate(node.init, scope);
|
|
2861
2879
|
if (node.id.type === 'Identifier') {
|
|
2862
2880
|
const name = node.id.name;
|
|
2863
2881
|
if (kind === 'var' && !node.init && !hasFeed) {
|
|
@@ -2877,34 +2895,34 @@
|
|
|
2877
2895
|
}
|
|
2878
2896
|
}
|
|
2879
2897
|
else {
|
|
2880
|
-
yield* pattern$
|
|
2898
|
+
yield* pattern$1(node.id, scope, { kind, feed: value });
|
|
2881
2899
|
}
|
|
2882
2900
|
}
|
|
2883
2901
|
}
|
|
2884
|
-
function* ClassDeclaration
|
|
2885
|
-
scope.func(node.id.name, yield* createClass(node, scope));
|
|
2902
|
+
function* ClassDeclaration(node, scope) {
|
|
2903
|
+
scope.func(node.id.name, yield* createClass$1(node, scope));
|
|
2886
2904
|
}
|
|
2887
|
-
function* ClassBody
|
|
2905
|
+
function* ClassBody(node, scope, options = {}) {
|
|
2888
2906
|
const { klass, superClass } = options;
|
|
2889
2907
|
for (let i = 0; i < node.body.length; i++) {
|
|
2890
2908
|
const def = node.body[i];
|
|
2891
2909
|
if (def.type === 'MethodDefinition') {
|
|
2892
|
-
yield* MethodDefinition
|
|
2910
|
+
yield* MethodDefinition(def, scope, { klass, superClass });
|
|
2893
2911
|
}
|
|
2894
2912
|
else if (def.type === 'PropertyDefinition' && def.static) {
|
|
2895
|
-
yield* PropertyDefinition
|
|
2913
|
+
yield* PropertyDefinition(def, scope, { klass, superClass });
|
|
2896
2914
|
}
|
|
2897
2915
|
else if (def.type === 'StaticBlock') {
|
|
2898
|
-
yield* StaticBlock
|
|
2916
|
+
yield* StaticBlock(def, scope, { klass, superClass });
|
|
2899
2917
|
}
|
|
2900
2918
|
}
|
|
2901
2919
|
}
|
|
2902
|
-
function* MethodDefinition
|
|
2920
|
+
function* MethodDefinition(node, scope, options = {}) {
|
|
2903
2921
|
const { klass, superClass } = options;
|
|
2904
2922
|
let key;
|
|
2905
2923
|
let priv = false;
|
|
2906
2924
|
if (node.computed) {
|
|
2907
|
-
key = yield* evaluate
|
|
2925
|
+
key = yield* evaluate(node.key, scope);
|
|
2908
2926
|
}
|
|
2909
2927
|
else if (node.key.type === 'Identifier') {
|
|
2910
2928
|
key = node.key.name;
|
|
@@ -2923,7 +2941,7 @@
|
|
|
2923
2941
|
}
|
|
2924
2942
|
obj = obj[PRIVATE];
|
|
2925
2943
|
}
|
|
2926
|
-
const value = createFunc(node.value, scope, { superClass });
|
|
2944
|
+
const value = createFunc$1(node.value, scope, { superClass });
|
|
2927
2945
|
switch (node.kind) {
|
|
2928
2946
|
case 'constructor':
|
|
2929
2947
|
break;
|
|
@@ -2956,12 +2974,12 @@
|
|
|
2956
2974
|
throw new SyntaxError('Unexpected token');
|
|
2957
2975
|
}
|
|
2958
2976
|
}
|
|
2959
|
-
function* PropertyDefinition
|
|
2977
|
+
function* PropertyDefinition(node, scope, options = {}) {
|
|
2960
2978
|
const { klass, superClass } = options;
|
|
2961
2979
|
let key;
|
|
2962
2980
|
let priv = false;
|
|
2963
2981
|
if (node.computed) {
|
|
2964
|
-
key = yield* evaluate
|
|
2982
|
+
key = yield* evaluate(node.key, scope);
|
|
2965
2983
|
}
|
|
2966
2984
|
else if (node.key.type === 'Identifier') {
|
|
2967
2985
|
key = node.key.name;
|
|
@@ -2983,19 +3001,19 @@
|
|
|
2983
3001
|
obj = obj[PRIVATE];
|
|
2984
3002
|
}
|
|
2985
3003
|
if (node.value.type === 'FunctionExpression' || node.value.type === 'ArrowFunctionExpression') {
|
|
2986
|
-
obj[key] = createFunc(node.value, subScope, { superClass });
|
|
3004
|
+
obj[key] = createFunc$1(node.value, subScope, { superClass });
|
|
2987
3005
|
}
|
|
2988
3006
|
else {
|
|
2989
|
-
obj[key] = yield* evaluate
|
|
3007
|
+
obj[key] = yield* evaluate(node.value, subScope);
|
|
2990
3008
|
}
|
|
2991
3009
|
}
|
|
2992
|
-
function* StaticBlock
|
|
3010
|
+
function* StaticBlock(node, scope, options = {}) {
|
|
2993
3011
|
const { klass } = options;
|
|
2994
3012
|
const subScope = new Scope(scope, true);
|
|
2995
3013
|
subScope.const('this', klass);
|
|
2996
|
-
return yield* BlockStatement
|
|
3014
|
+
return yield* BlockStatement(node, subScope, { invasived: true });
|
|
2997
3015
|
}
|
|
2998
|
-
function* ImportDeclaration
|
|
3016
|
+
function* ImportDeclaration(node, scope) {
|
|
2999
3017
|
const globalScope = scope.global();
|
|
3000
3018
|
const module = globalScope.find(IMPORT + node.source.value);
|
|
3001
3019
|
let value;
|
|
@@ -3032,19 +3050,19 @@
|
|
|
3032
3050
|
scope.var(spec.local.name, name === '*' ? assign({}, value) : value[name]);
|
|
3033
3051
|
}
|
|
3034
3052
|
}
|
|
3035
|
-
function* ExportDefaultDeclaration
|
|
3053
|
+
function* ExportDefaultDeclaration(node, scope) {
|
|
3036
3054
|
const globalScope = scope.global();
|
|
3037
3055
|
let value;
|
|
3038
3056
|
if (node.declaration.type === 'FunctionDeclaration') {
|
|
3039
|
-
value = createFunc(node.declaration, scope);
|
|
3057
|
+
value = createFunc$1(node.declaration, scope);
|
|
3040
3058
|
scope.func(node.declaration.id.name, value);
|
|
3041
3059
|
}
|
|
3042
3060
|
else if (node.declaration.type === 'ClassDeclaration') {
|
|
3043
|
-
value = yield* createClass(node.declaration, scope);
|
|
3061
|
+
value = yield* createClass$1(node.declaration, scope);
|
|
3044
3062
|
scope.func(node.declaration.id.name, value);
|
|
3045
3063
|
}
|
|
3046
3064
|
else {
|
|
3047
|
-
value = yield* evaluate
|
|
3065
|
+
value = yield* evaluate(node.declaration, scope);
|
|
3048
3066
|
}
|
|
3049
3067
|
const variable = globalScope.find(EXPORTS);
|
|
3050
3068
|
if (variable) {
|
|
@@ -3054,11 +3072,11 @@
|
|
|
3054
3072
|
}
|
|
3055
3073
|
}
|
|
3056
3074
|
}
|
|
3057
|
-
function* ExportNamedDeclaration
|
|
3075
|
+
function* ExportNamedDeclaration(node, scope) {
|
|
3058
3076
|
const globalScope = scope.global();
|
|
3059
3077
|
if (node.declaration) {
|
|
3060
3078
|
if (node.declaration.type === 'FunctionDeclaration') {
|
|
3061
|
-
const value = createFunc(node.declaration, scope);
|
|
3079
|
+
const value = createFunc$1(node.declaration, scope);
|
|
3062
3080
|
scope.func(node.declaration.id.name, value);
|
|
3063
3081
|
const variable = globalScope.find(EXPORTS);
|
|
3064
3082
|
if (variable) {
|
|
@@ -3069,7 +3087,7 @@
|
|
|
3069
3087
|
}
|
|
3070
3088
|
}
|
|
3071
3089
|
else if (node.declaration.type === 'ClassDeclaration') {
|
|
3072
|
-
const value = yield* createClass(node.declaration, scope);
|
|
3090
|
+
const value = yield* createClass$1(node.declaration, scope);
|
|
3073
3091
|
scope.func(node.declaration.id.name, value);
|
|
3074
3092
|
const variable = globalScope.find(EXPORTS);
|
|
3075
3093
|
if (variable) {
|
|
@@ -3080,7 +3098,7 @@
|
|
|
3080
3098
|
}
|
|
3081
3099
|
}
|
|
3082
3100
|
else if (node.declaration.type === 'VariableDeclaration') {
|
|
3083
|
-
yield* VariableDeclaration
|
|
3101
|
+
yield* VariableDeclaration(node.declaration, scope);
|
|
3084
3102
|
const variable = globalScope.find(EXPORTS);
|
|
3085
3103
|
if (variable) {
|
|
3086
3104
|
const exports = variable.get();
|
|
@@ -3115,7 +3133,7 @@
|
|
|
3115
3133
|
}
|
|
3116
3134
|
}
|
|
3117
3135
|
}
|
|
3118
|
-
function* ExportAllDeclaration
|
|
3136
|
+
function* ExportAllDeclaration(node, scope) {
|
|
3119
3137
|
const globalScope = scope.global();
|
|
3120
3138
|
const module = globalScope.find(IMPORT + node.source.value);
|
|
3121
3139
|
let value;
|
|
@@ -3188,7 +3206,7 @@
|
|
|
3188
3206
|
});
|
|
3189
3207
|
}
|
|
3190
3208
|
|
|
3191
|
-
function* hoist(block, scope, options = {}) {
|
|
3209
|
+
function* hoist$1(block, scope, options = {}) {
|
|
3192
3210
|
const { onlyBlock = false } = options;
|
|
3193
3211
|
const funcDclrList = [];
|
|
3194
3212
|
const funcDclrIdxs = [];
|
|
@@ -3200,10 +3218,10 @@
|
|
|
3200
3218
|
}
|
|
3201
3219
|
else if (statement.type === 'VariableDeclaration'
|
|
3202
3220
|
&& ['const', 'let'].indexOf(statement.kind) !== -1) {
|
|
3203
|
-
yield* VariableDeclaration
|
|
3221
|
+
yield* VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
|
|
3204
3222
|
}
|
|
3205
3223
|
else if (!onlyBlock) {
|
|
3206
|
-
yield* hoistVarRecursion(statement, scope);
|
|
3224
|
+
yield* hoistVarRecursion$1(statement, scope);
|
|
3207
3225
|
}
|
|
3208
3226
|
}
|
|
3209
3227
|
if (funcDclrIdxs.length) {
|
|
@@ -3213,80 +3231,80 @@
|
|
|
3213
3231
|
block.body = funcDclrList.concat(block.body);
|
|
3214
3232
|
}
|
|
3215
3233
|
}
|
|
3216
|
-
function* hoistVarRecursion(statement, scope) {
|
|
3234
|
+
function* hoistVarRecursion$1(statement, scope) {
|
|
3217
3235
|
switch (statement.type) {
|
|
3218
3236
|
case 'VariableDeclaration':
|
|
3219
|
-
yield* VariableDeclaration
|
|
3237
|
+
yield* VariableDeclaration(statement, scope, { hoist: true });
|
|
3220
3238
|
break;
|
|
3221
3239
|
case 'ForInStatement':
|
|
3222
3240
|
case 'ForOfStatement':
|
|
3223
3241
|
if (statement.left.type === 'VariableDeclaration') {
|
|
3224
|
-
yield* VariableDeclaration
|
|
3242
|
+
yield* VariableDeclaration(statement.left, scope, { hoist: true });
|
|
3225
3243
|
}
|
|
3226
3244
|
case 'ForStatement':
|
|
3227
3245
|
if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
|
|
3228
|
-
yield* VariableDeclaration
|
|
3246
|
+
yield* VariableDeclaration(statement.init, scope, { hoist: true });
|
|
3229
3247
|
}
|
|
3230
3248
|
case 'WhileStatement':
|
|
3231
3249
|
case 'DoWhileStatement':
|
|
3232
|
-
yield* hoistVarRecursion(statement.body, scope);
|
|
3250
|
+
yield* hoistVarRecursion$1(statement.body, scope);
|
|
3233
3251
|
break;
|
|
3234
3252
|
case 'IfStatement':
|
|
3235
|
-
yield* hoistVarRecursion(statement.consequent, scope);
|
|
3253
|
+
yield* hoistVarRecursion$1(statement.consequent, scope);
|
|
3236
3254
|
if (statement.alternate) {
|
|
3237
|
-
yield* hoistVarRecursion(statement.alternate, scope);
|
|
3255
|
+
yield* hoistVarRecursion$1(statement.alternate, scope);
|
|
3238
3256
|
}
|
|
3239
3257
|
break;
|
|
3240
3258
|
case 'BlockStatement':
|
|
3241
3259
|
for (let i = 0; i < statement.body.length; i++) {
|
|
3242
|
-
yield* hoistVarRecursion(statement.body[i], scope);
|
|
3260
|
+
yield* hoistVarRecursion$1(statement.body[i], scope);
|
|
3243
3261
|
}
|
|
3244
3262
|
break;
|
|
3245
3263
|
case 'SwitchStatement':
|
|
3246
3264
|
for (let i = 0; i < statement.cases.length; i++) {
|
|
3247
3265
|
for (let j = 0; j < statement.cases[i].consequent.length; j++) {
|
|
3248
|
-
yield* hoistVarRecursion(statement.cases[i].consequent[j], scope);
|
|
3266
|
+
yield* hoistVarRecursion$1(statement.cases[i].consequent[j], scope);
|
|
3249
3267
|
}
|
|
3250
3268
|
}
|
|
3251
3269
|
break;
|
|
3252
3270
|
case 'TryStatement': {
|
|
3253
3271
|
const tryBlock = statement.block.body;
|
|
3254
3272
|
for (let i = 0; i < tryBlock.length; i++) {
|
|
3255
|
-
yield* hoistVarRecursion(tryBlock[i], scope);
|
|
3273
|
+
yield* hoistVarRecursion$1(tryBlock[i], scope);
|
|
3256
3274
|
}
|
|
3257
3275
|
const catchBlock = statement.handler && statement.handler.body.body;
|
|
3258
3276
|
if (catchBlock) {
|
|
3259
3277
|
for (let i = 0; i < catchBlock.length; i++) {
|
|
3260
|
-
yield* hoistVarRecursion(catchBlock[i], scope);
|
|
3278
|
+
yield* hoistVarRecursion$1(catchBlock[i], scope);
|
|
3261
3279
|
}
|
|
3262
3280
|
}
|
|
3263
3281
|
const finalBlock = statement.finalizer && statement.finalizer.body;
|
|
3264
3282
|
if (finalBlock) {
|
|
3265
3283
|
for (let i = 0; i < finalBlock.length; i++) {
|
|
3266
|
-
yield* hoistVarRecursion(finalBlock[i], scope);
|
|
3284
|
+
yield* hoistVarRecursion$1(finalBlock[i], scope);
|
|
3267
3285
|
}
|
|
3268
3286
|
}
|
|
3269
3287
|
break;
|
|
3270
3288
|
}
|
|
3271
3289
|
}
|
|
3272
3290
|
}
|
|
3273
|
-
function* pattern$
|
|
3291
|
+
function* pattern$1(node, scope, options = {}) {
|
|
3274
3292
|
switch (node.type) {
|
|
3275
3293
|
case 'ObjectPattern':
|
|
3276
|
-
return yield* ObjectPattern
|
|
3294
|
+
return yield* ObjectPattern(node, scope, options);
|
|
3277
3295
|
case 'ArrayPattern':
|
|
3278
|
-
return yield* ArrayPattern
|
|
3296
|
+
return yield* ArrayPattern(node, scope, options);
|
|
3279
3297
|
case 'RestElement':
|
|
3280
|
-
return yield* RestElement
|
|
3298
|
+
return yield* RestElement(node, scope, options);
|
|
3281
3299
|
case 'AssignmentPattern':
|
|
3282
|
-
return yield* AssignmentPattern
|
|
3300
|
+
return yield* AssignmentPattern(node, scope, options);
|
|
3283
3301
|
default:
|
|
3284
3302
|
throw new SyntaxError('Unexpected token');
|
|
3285
3303
|
}
|
|
3286
3304
|
}
|
|
3287
|
-
function createFunc(node, scope, options = {}) {
|
|
3305
|
+
function createFunc$1(node, scope, options = {}) {
|
|
3288
3306
|
if (!node.generator && !node.async) {
|
|
3289
|
-
return createFunc
|
|
3307
|
+
return createFunc(node, scope, options);
|
|
3290
3308
|
}
|
|
3291
3309
|
const { superClass, construct } = options;
|
|
3292
3310
|
const params = node.params;
|
|
@@ -3311,22 +3329,22 @@
|
|
|
3311
3329
|
subScope.var(param.name, args[i]);
|
|
3312
3330
|
}
|
|
3313
3331
|
else if (param.type === 'RestElement') {
|
|
3314
|
-
yield* RestElement
|
|
3332
|
+
yield* RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
|
|
3315
3333
|
}
|
|
3316
3334
|
else {
|
|
3317
|
-
yield* pattern$
|
|
3335
|
+
yield* pattern$1(param, subScope, { kind: 'var', feed: args[i] });
|
|
3318
3336
|
}
|
|
3319
3337
|
}
|
|
3320
3338
|
let result;
|
|
3321
3339
|
if (node.body.type === 'BlockStatement') {
|
|
3322
|
-
yield* hoist(node.body, subScope);
|
|
3323
|
-
result = yield* BlockStatement
|
|
3340
|
+
yield* hoist$1(node.body, subScope);
|
|
3341
|
+
result = yield* BlockStatement(node.body, subScope, {
|
|
3324
3342
|
invasived: true,
|
|
3325
3343
|
hoisted: true
|
|
3326
3344
|
});
|
|
3327
3345
|
}
|
|
3328
3346
|
else {
|
|
3329
|
-
result = yield* evaluate
|
|
3347
|
+
result = yield* evaluate(node.body, subScope);
|
|
3330
3348
|
if (node.type === 'ArrowFunctionExpression') {
|
|
3331
3349
|
RETURN.RES = result;
|
|
3332
3350
|
result = RETURN;
|
|
@@ -3380,14 +3398,14 @@
|
|
|
3380
3398
|
});
|
|
3381
3399
|
return func;
|
|
3382
3400
|
}
|
|
3383
|
-
function* createClass(node, scope) {
|
|
3384
|
-
const superClass = yield* evaluate
|
|
3401
|
+
function* createClass$1(node, scope) {
|
|
3402
|
+
const superClass = yield* evaluate(node.superClass, scope);
|
|
3385
3403
|
const methodBody = node.body.body;
|
|
3386
3404
|
const construct = function* (object) {
|
|
3387
3405
|
for (let i = 0; i < methodBody.length; i++) {
|
|
3388
3406
|
const def = methodBody[i];
|
|
3389
3407
|
if (def.type === 'PropertyDefinition' && !def.static) {
|
|
3390
|
-
yield* PropertyDefinition
|
|
3408
|
+
yield* PropertyDefinition(def, scope, { klass: object, superClass });
|
|
3391
3409
|
}
|
|
3392
3410
|
}
|
|
3393
3411
|
};
|
|
@@ -3400,14 +3418,14 @@
|
|
|
3400
3418
|
for (let i = 0; i < methodBody.length; i++) {
|
|
3401
3419
|
const method = methodBody[i];
|
|
3402
3420
|
if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
|
|
3403
|
-
klass = createFunc(method.value, scope, { superClass, construct });
|
|
3421
|
+
klass = createFunc$1(method.value, scope, { superClass, construct });
|
|
3404
3422
|
break;
|
|
3405
3423
|
}
|
|
3406
3424
|
}
|
|
3407
3425
|
if (superClass) {
|
|
3408
3426
|
inherits(klass, superClass);
|
|
3409
3427
|
}
|
|
3410
|
-
yield* ClassBody
|
|
3428
|
+
yield* ClassBody(node.body, scope, { klass, superClass });
|
|
3411
3429
|
define(klass, CLSCTOR, { value: true });
|
|
3412
3430
|
define(klass, 'name', {
|
|
3413
3431
|
value: node.id && node.id.name || '',
|
|
@@ -3415,31 +3433,31 @@
|
|
|
3415
3433
|
});
|
|
3416
3434
|
return klass;
|
|
3417
3435
|
}
|
|
3418
|
-
function* ForXHandler(node, scope, options) {
|
|
3436
|
+
function* ForXHandler$1(node, scope, options) {
|
|
3419
3437
|
const { value } = options;
|
|
3420
3438
|
const left = node.left;
|
|
3421
3439
|
const subScope = new Scope(scope);
|
|
3422
3440
|
if (left.type === 'VariableDeclaration') {
|
|
3423
|
-
yield* VariableDeclaration
|
|
3441
|
+
yield* VariableDeclaration(left, subScope, { feed: value });
|
|
3424
3442
|
}
|
|
3425
3443
|
else if (left.type === 'Identifier') {
|
|
3426
|
-
const variable = yield* Identifier(left, scope, { getVar: true });
|
|
3444
|
+
const variable = yield* Identifier$1(left, scope, { getVar: true });
|
|
3427
3445
|
variable.set(value);
|
|
3428
3446
|
}
|
|
3429
3447
|
else {
|
|
3430
|
-
yield* pattern$
|
|
3448
|
+
yield* pattern$1(left, scope, { feed: value });
|
|
3431
3449
|
}
|
|
3432
3450
|
let result;
|
|
3433
3451
|
if (node.body.type === 'BlockStatement') {
|
|
3434
|
-
result = yield* BlockStatement
|
|
3452
|
+
result = yield* BlockStatement(node.body, subScope, { invasived: true });
|
|
3435
3453
|
}
|
|
3436
3454
|
else {
|
|
3437
|
-
result = yield* evaluate
|
|
3455
|
+
result = yield* evaluate(node.body, subScope);
|
|
3438
3456
|
}
|
|
3439
3457
|
return result;
|
|
3440
3458
|
}
|
|
3441
3459
|
|
|
3442
|
-
function hoist
|
|
3460
|
+
function hoist(block, scope, options = {}) {
|
|
3443
3461
|
const { onlyBlock = false } = options;
|
|
3444
3462
|
const funcDclrList = [];
|
|
3445
3463
|
const funcDclrIdxs = [];
|
|
@@ -3451,10 +3469,10 @@
|
|
|
3451
3469
|
}
|
|
3452
3470
|
else if (statement.type === 'VariableDeclaration'
|
|
3453
3471
|
&& ['const', 'let'].indexOf(statement.kind) !== -1) {
|
|
3454
|
-
VariableDeclaration(statement, scope, { hoist: true, onlyBlock: true });
|
|
3472
|
+
VariableDeclaration$1(statement, scope, { hoist: true, onlyBlock: true });
|
|
3455
3473
|
}
|
|
3456
3474
|
else if (!onlyBlock) {
|
|
3457
|
-
hoistVarRecursion
|
|
3475
|
+
hoistVarRecursion(statement, scope);
|
|
3458
3476
|
}
|
|
3459
3477
|
}
|
|
3460
3478
|
if (funcDclrIdxs.length) {
|
|
@@ -3464,80 +3482,80 @@
|
|
|
3464
3482
|
block.body = funcDclrList.concat(block.body);
|
|
3465
3483
|
}
|
|
3466
3484
|
}
|
|
3467
|
-
function hoistVarRecursion
|
|
3485
|
+
function hoistVarRecursion(statement, scope) {
|
|
3468
3486
|
switch (statement.type) {
|
|
3469
3487
|
case 'VariableDeclaration':
|
|
3470
|
-
VariableDeclaration(statement, scope, { hoist: true });
|
|
3488
|
+
VariableDeclaration$1(statement, scope, { hoist: true });
|
|
3471
3489
|
break;
|
|
3472
3490
|
case 'ForInStatement':
|
|
3473
3491
|
case 'ForOfStatement':
|
|
3474
3492
|
if (statement.left.type === 'VariableDeclaration') {
|
|
3475
|
-
VariableDeclaration(statement.left, scope, { hoist: true });
|
|
3493
|
+
VariableDeclaration$1(statement.left, scope, { hoist: true });
|
|
3476
3494
|
}
|
|
3477
3495
|
case 'ForStatement':
|
|
3478
3496
|
if (statement.type === 'ForStatement' && statement.init.type === 'VariableDeclaration') {
|
|
3479
|
-
VariableDeclaration(statement.init, scope, { hoist: true });
|
|
3497
|
+
VariableDeclaration$1(statement.init, scope, { hoist: true });
|
|
3480
3498
|
}
|
|
3481
3499
|
case 'WhileStatement':
|
|
3482
3500
|
case 'DoWhileStatement':
|
|
3483
|
-
hoistVarRecursion
|
|
3501
|
+
hoistVarRecursion(statement.body, scope);
|
|
3484
3502
|
break;
|
|
3485
3503
|
case 'IfStatement':
|
|
3486
|
-
hoistVarRecursion
|
|
3504
|
+
hoistVarRecursion(statement.consequent, scope);
|
|
3487
3505
|
if (statement.alternate) {
|
|
3488
|
-
hoistVarRecursion
|
|
3506
|
+
hoistVarRecursion(statement.alternate, scope);
|
|
3489
3507
|
}
|
|
3490
3508
|
break;
|
|
3491
3509
|
case 'BlockStatement':
|
|
3492
3510
|
for (let i = 0; i < statement.body.length; i++) {
|
|
3493
|
-
hoistVarRecursion
|
|
3511
|
+
hoistVarRecursion(statement.body[i], scope);
|
|
3494
3512
|
}
|
|
3495
3513
|
break;
|
|
3496
3514
|
case 'SwitchStatement':
|
|
3497
3515
|
for (let i = 0; i < statement.cases.length; i++) {
|
|
3498
3516
|
for (let j = 0; j < statement.cases[i].consequent.length; j++) {
|
|
3499
|
-
hoistVarRecursion
|
|
3517
|
+
hoistVarRecursion(statement.cases[i].consequent[j], scope);
|
|
3500
3518
|
}
|
|
3501
3519
|
}
|
|
3502
3520
|
break;
|
|
3503
3521
|
case 'TryStatement': {
|
|
3504
3522
|
const tryBlock = statement.block.body;
|
|
3505
3523
|
for (let i = 0; i < tryBlock.length; i++) {
|
|
3506
|
-
hoistVarRecursion
|
|
3524
|
+
hoistVarRecursion(tryBlock[i], scope);
|
|
3507
3525
|
}
|
|
3508
3526
|
const catchBlock = statement.handler && statement.handler.body.body;
|
|
3509
3527
|
if (catchBlock) {
|
|
3510
3528
|
for (let i = 0; i < catchBlock.length; i++) {
|
|
3511
|
-
hoistVarRecursion
|
|
3529
|
+
hoistVarRecursion(catchBlock[i], scope);
|
|
3512
3530
|
}
|
|
3513
3531
|
}
|
|
3514
3532
|
const finalBlock = statement.finalizer && statement.finalizer.body;
|
|
3515
3533
|
if (finalBlock) {
|
|
3516
3534
|
for (let i = 0; i < finalBlock.length; i++) {
|
|
3517
|
-
hoistVarRecursion
|
|
3535
|
+
hoistVarRecursion(finalBlock[i], scope);
|
|
3518
3536
|
}
|
|
3519
3537
|
}
|
|
3520
3538
|
break;
|
|
3521
3539
|
}
|
|
3522
3540
|
}
|
|
3523
3541
|
}
|
|
3524
|
-
function pattern
|
|
3542
|
+
function pattern(node, scope, options = {}) {
|
|
3525
3543
|
switch (node.type) {
|
|
3526
3544
|
case 'ObjectPattern':
|
|
3527
|
-
return ObjectPattern(node, scope, options);
|
|
3545
|
+
return ObjectPattern$1(node, scope, options);
|
|
3528
3546
|
case 'ArrayPattern':
|
|
3529
|
-
return ArrayPattern(node, scope, options);
|
|
3547
|
+
return ArrayPattern$1(node, scope, options);
|
|
3530
3548
|
case 'RestElement':
|
|
3531
|
-
return RestElement(node, scope, options);
|
|
3549
|
+
return RestElement$1(node, scope, options);
|
|
3532
3550
|
case 'AssignmentPattern':
|
|
3533
|
-
return AssignmentPattern(node, scope, options);
|
|
3551
|
+
return AssignmentPattern$1(node, scope, options);
|
|
3534
3552
|
default:
|
|
3535
3553
|
throw new SyntaxError('Unexpected token');
|
|
3536
3554
|
}
|
|
3537
3555
|
}
|
|
3538
|
-
function createFunc
|
|
3556
|
+
function createFunc(node, scope, options = {}) {
|
|
3539
3557
|
if (node.generator || node.async) {
|
|
3540
|
-
return createFunc(node, scope, options);
|
|
3558
|
+
return createFunc$1(node, scope, options);
|
|
3541
3559
|
}
|
|
3542
3560
|
const { superClass, construct } = options;
|
|
3543
3561
|
const params = node.params;
|
|
@@ -3562,22 +3580,22 @@
|
|
|
3562
3580
|
subScope.var(param.name, args[i]);
|
|
3563
3581
|
}
|
|
3564
3582
|
else if (param.type === 'RestElement') {
|
|
3565
|
-
RestElement(param, subScope, { kind: 'var', feed: args.slice(i) });
|
|
3583
|
+
RestElement$1(param, subScope, { kind: 'var', feed: args.slice(i) });
|
|
3566
3584
|
}
|
|
3567
3585
|
else {
|
|
3568
|
-
pattern
|
|
3586
|
+
pattern(param, subScope, { kind: 'var', feed: args[i] });
|
|
3569
3587
|
}
|
|
3570
3588
|
}
|
|
3571
3589
|
let result;
|
|
3572
3590
|
if (node.body.type === 'BlockStatement') {
|
|
3573
|
-
hoist
|
|
3574
|
-
result = BlockStatement(node.body, subScope, {
|
|
3591
|
+
hoist(node.body, subScope);
|
|
3592
|
+
result = BlockStatement$1(node.body, subScope, {
|
|
3575
3593
|
invasived: true,
|
|
3576
3594
|
hoisted: true
|
|
3577
3595
|
});
|
|
3578
3596
|
}
|
|
3579
3597
|
else {
|
|
3580
|
-
result = evaluate(node.body, subScope);
|
|
3598
|
+
result = evaluate$1(node.body, subScope);
|
|
3581
3599
|
if (node.type === 'ArrowFunctionExpression') {
|
|
3582
3600
|
RETURN.RES = result;
|
|
3583
3601
|
result = RETURN;
|
|
@@ -3603,14 +3621,14 @@
|
|
|
3603
3621
|
});
|
|
3604
3622
|
return func;
|
|
3605
3623
|
}
|
|
3606
|
-
function createClass
|
|
3607
|
-
const superClass = evaluate(node.superClass, scope);
|
|
3624
|
+
function createClass(node, scope) {
|
|
3625
|
+
const superClass = evaluate$1(node.superClass, scope);
|
|
3608
3626
|
const methodBody = node.body.body;
|
|
3609
3627
|
const construct = function (object) {
|
|
3610
3628
|
for (let i = 0; i < methodBody.length; i++) {
|
|
3611
3629
|
const def = methodBody[i];
|
|
3612
3630
|
if (def.type === 'PropertyDefinition' && !def.static) {
|
|
3613
|
-
PropertyDefinition(def, scope, { klass: object, superClass });
|
|
3631
|
+
PropertyDefinition$1(def, scope, { klass: object, superClass });
|
|
3614
3632
|
}
|
|
3615
3633
|
}
|
|
3616
3634
|
};
|
|
@@ -3623,14 +3641,14 @@
|
|
|
3623
3641
|
for (let i = 0; i < methodBody.length; i++) {
|
|
3624
3642
|
const method = methodBody[i];
|
|
3625
3643
|
if (method.type === 'MethodDefinition' && method.kind === 'constructor') {
|
|
3626
|
-
klass = createFunc
|
|
3644
|
+
klass = createFunc(method.value, scope, { superClass, construct });
|
|
3627
3645
|
break;
|
|
3628
3646
|
}
|
|
3629
3647
|
}
|
|
3630
3648
|
if (superClass) {
|
|
3631
3649
|
inherits(klass, superClass);
|
|
3632
3650
|
}
|
|
3633
|
-
ClassBody(node.body, scope, { klass, superClass });
|
|
3651
|
+
ClassBody$1(node.body, scope, { klass, superClass });
|
|
3634
3652
|
define(klass, CLSCTOR, { value: true });
|
|
3635
3653
|
define(klass, 'name', {
|
|
3636
3654
|
value: node.id && node.id.name || '',
|
|
@@ -3638,26 +3656,26 @@
|
|
|
3638
3656
|
});
|
|
3639
3657
|
return klass;
|
|
3640
3658
|
}
|
|
3641
|
-
function ForXHandler
|
|
3659
|
+
function ForXHandler(node, scope, options) {
|
|
3642
3660
|
const { value } = options;
|
|
3643
3661
|
const left = node.left;
|
|
3644
3662
|
const subScope = new Scope(scope);
|
|
3645
3663
|
if (left.type === 'VariableDeclaration') {
|
|
3646
|
-
VariableDeclaration(left, subScope, { feed: value });
|
|
3664
|
+
VariableDeclaration$1(left, subScope, { feed: value });
|
|
3647
3665
|
}
|
|
3648
3666
|
else if (left.type === 'Identifier') {
|
|
3649
|
-
const variable = Identifier(left, scope, { getVar: true });
|
|
3667
|
+
const variable = Identifier$1(left, scope, { getVar: true });
|
|
3650
3668
|
variable.set(value);
|
|
3651
3669
|
}
|
|
3652
3670
|
else {
|
|
3653
|
-
pattern
|
|
3671
|
+
pattern(left, scope, { feed: value });
|
|
3654
3672
|
}
|
|
3655
3673
|
let result;
|
|
3656
3674
|
if (node.body.type === 'BlockStatement') {
|
|
3657
|
-
result = BlockStatement(node.body, subScope, { invasived: true });
|
|
3675
|
+
result = BlockStatement$1(node.body, subScope, { invasived: true });
|
|
3658
3676
|
}
|
|
3659
3677
|
else {
|
|
3660
|
-
result = evaluate(node.body, subScope);
|
|
3678
|
+
result = evaluate$1(node.body, subScope);
|
|
3661
3679
|
}
|
|
3662
3680
|
return result;
|
|
3663
3681
|
}
|
|
@@ -3711,12 +3729,12 @@
|
|
|
3711
3729
|
}
|
|
3712
3730
|
run(code) {
|
|
3713
3731
|
const ast = typeof code === 'string' ? acorn.parse(code, this.options) : code;
|
|
3714
|
-
hoist
|
|
3715
|
-
evaluate(ast, this.scope);
|
|
3732
|
+
hoist(ast, this.scope);
|
|
3733
|
+
evaluate$1(ast, this.scope);
|
|
3716
3734
|
}
|
|
3717
3735
|
}
|
|
3718
3736
|
Sval.version = version;
|
|
3719
3737
|
|
|
3720
3738
|
return Sval;
|
|
3721
3739
|
|
|
3722
|
-
}))
|
|
3740
|
+
}));
|