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