@babel/traverse 7.0.0-beta.40 → 7.0.0-beta.44
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.
Potentially problematic release.
This version of @babel/traverse might be problematic. Click here for more details.
- package/lib/cache.js +3 -1
- package/lib/context.js +27 -18
- package/lib/hub.js +3 -1
- package/lib/index.js +48 -18
- package/lib/path/ancestry.js +13 -3
- package/lib/path/comments.js +14 -4
- package/lib/path/context.js +9 -9
- package/lib/path/conversion.js +56 -38
- package/lib/path/evaluation.js +18 -18
- package/lib/path/family.js +15 -5
- package/lib/path/index.js +51 -19
- package/lib/path/inference/index.js +29 -19
- package/lib/path/inference/inferer-reference.js +19 -9
- package/lib/path/inference/inferers.js +54 -41
- package/lib/path/introspection.js +34 -16
- package/lib/path/lib/hoister.js +21 -7
- package/lib/path/lib/removal-hooks.js +3 -1
- package/lib/path/lib/virtual-types.js +31 -21
- package/lib/path/modification.js +18 -9
- package/lib/path/removal.js +3 -1
- package/lib/path/replacement.js +53 -28
- package/lib/scope/binding.js +3 -1
- package/lib/scope/index.js +120 -85
- package/lib/scope/lib/renamer.js +34 -30
- package/lib/visitors.js +53 -33
- package/package.json +9 -8
package/lib/cache.js
CHANGED
package/lib/context.js
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
4
6
|
exports.default = void 0;
|
5
7
|
|
6
|
-
var
|
8
|
+
var _path2 = _interopRequireDefault(require("./path"));
|
7
9
|
|
8
|
-
|
10
|
+
function t() {
|
11
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
12
|
+
|
13
|
+
t = function t() {
|
14
|
+
return data;
|
15
|
+
};
|
16
|
+
|
17
|
+
return data;
|
18
|
+
}
|
9
19
|
|
10
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
11
21
|
|
@@ -28,7 +38,7 @@ var TraversalContext = function () {
|
|
28
38
|
var opts = this.opts;
|
29
39
|
if (opts.enter || opts.exit) return true;
|
30
40
|
if (opts[node.type]) return true;
|
31
|
-
var keys = t.VISITOR_KEYS[node.type];
|
41
|
+
var keys = t().VISITOR_KEYS[node.type];
|
32
42
|
if (!keys || !keys.length) return false;
|
33
43
|
|
34
44
|
for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
@@ -43,15 +53,15 @@ var TraversalContext = function () {
|
|
43
53
|
_ref = _i.value;
|
44
54
|
}
|
45
55
|
|
46
|
-
var
|
47
|
-
if (node[
|
56
|
+
var key = _ref;
|
57
|
+
if (node[key]) return true;
|
48
58
|
}
|
49
59
|
|
50
60
|
return false;
|
51
61
|
};
|
52
62
|
|
53
63
|
_proto.create = function create(node, obj, key, listKey) {
|
54
|
-
return
|
64
|
+
return _path2.default.get({
|
55
65
|
parentPath: this.parentPath,
|
56
66
|
parent: node,
|
57
67
|
container: obj,
|
@@ -115,24 +125,23 @@ var TraversalContext = function () {
|
|
115
125
|
_ref2 = _i2.value;
|
116
126
|
}
|
117
127
|
|
118
|
-
var
|
119
|
-
|
120
|
-
_path2.resync();
|
128
|
+
var path = _ref2;
|
129
|
+
path.resync();
|
121
130
|
|
122
|
-
if (
|
123
|
-
|
131
|
+
if (path.contexts.length === 0 || path.contexts[path.contexts.length - 1] !== this) {
|
132
|
+
path.pushContext(this);
|
124
133
|
}
|
125
134
|
|
126
|
-
if (
|
135
|
+
if (path.key === null) continue;
|
127
136
|
|
128
137
|
if (testing && queue.length >= 10000) {
|
129
138
|
this.trap = true;
|
130
139
|
}
|
131
140
|
|
132
|
-
if (visited.indexOf(
|
133
|
-
visited.push(
|
141
|
+
if (visited.indexOf(path.node) >= 0) continue;
|
142
|
+
visited.push(path.node);
|
134
143
|
|
135
|
-
if (
|
144
|
+
if (path.visit()) {
|
136
145
|
stop = true;
|
137
146
|
break;
|
138
147
|
}
|
@@ -157,9 +166,9 @@ var TraversalContext = function () {
|
|
157
166
|
_ref3 = _i3.value;
|
158
167
|
}
|
159
168
|
|
160
|
-
var
|
169
|
+
var _path = _ref3;
|
161
170
|
|
162
|
-
|
171
|
+
_path.popContext();
|
163
172
|
}
|
164
173
|
|
165
174
|
this.queue = null;
|
package/lib/hub.js
CHANGED
package/lib/index.js
CHANGED
@@ -1,8 +1,28 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
4
6
|
exports.default = traverse;
|
5
|
-
|
7
|
+
Object.defineProperty(exports, "NodePath", {
|
8
|
+
enumerable: true,
|
9
|
+
get: function get() {
|
10
|
+
return _path.default;
|
11
|
+
}
|
12
|
+
});
|
13
|
+
Object.defineProperty(exports, "Scope", {
|
14
|
+
enumerable: true,
|
15
|
+
get: function get() {
|
16
|
+
return _scope.default;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports, "Hub", {
|
20
|
+
enumerable: true,
|
21
|
+
get: function get() {
|
22
|
+
return _hub.default;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
exports.visitors = void 0;
|
6
26
|
|
7
27
|
var _context = _interopRequireDefault(require("./context"));
|
8
28
|
|
@@ -10,24 +30,34 @@ var visitors = _interopRequireWildcard(require("./visitors"));
|
|
10
30
|
|
11
31
|
exports.visitors = visitors;
|
12
32
|
|
13
|
-
|
33
|
+
function _includes() {
|
34
|
+
var data = _interopRequireDefault(require("lodash/includes"));
|
35
|
+
|
36
|
+
_includes = function _includes() {
|
37
|
+
return data;
|
38
|
+
};
|
39
|
+
|
40
|
+
return data;
|
41
|
+
}
|
42
|
+
|
43
|
+
function t() {
|
44
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
45
|
+
|
46
|
+
t = function t() {
|
47
|
+
return data;
|
48
|
+
};
|
14
49
|
|
15
|
-
|
50
|
+
return data;
|
51
|
+
}
|
16
52
|
|
17
53
|
var cache = _interopRequireWildcard(require("./cache"));
|
18
54
|
|
19
55
|
var _path = _interopRequireDefault(require("./path"));
|
20
56
|
|
21
|
-
exports.NodePath = _path.default;
|
22
|
-
|
23
57
|
var _scope = _interopRequireDefault(require("./scope"));
|
24
58
|
|
25
|
-
exports.Scope = _scope.default;
|
26
|
-
|
27
59
|
var _hub = _interopRequireDefault(require("./hub"));
|
28
60
|
|
29
|
-
exports.Hub = _hub.default;
|
30
|
-
|
31
61
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
32
62
|
|
33
63
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -51,11 +81,11 @@ traverse.verify = visitors.verify;
|
|
51
81
|
traverse.explode = visitors.explode;
|
52
82
|
|
53
83
|
traverse.cheap = function (node, enter) {
|
54
|
-
return t.traverseFast(node, enter);
|
84
|
+
return t().traverseFast(node, enter);
|
55
85
|
};
|
56
86
|
|
57
87
|
traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
|
58
|
-
var keys = t.VISITOR_KEYS[node.type];
|
88
|
+
var keys = t().VISITOR_KEYS[node.type];
|
59
89
|
if (!keys) return;
|
60
90
|
var context = new _context.default(scope, opts, state, parentPath);
|
61
91
|
|
@@ -71,19 +101,19 @@ traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
|
|
71
101
|
_ref = _i.value;
|
72
102
|
}
|
73
103
|
|
74
|
-
var
|
75
|
-
if (skipKeys && skipKeys[
|
76
|
-
if (context.visit(node,
|
104
|
+
var key = _ref;
|
105
|
+
if (skipKeys && skipKeys[key]) continue;
|
106
|
+
if (context.visit(node, key)) return;
|
77
107
|
}
|
78
108
|
};
|
79
109
|
|
80
110
|
traverse.clearNode = function (node, opts) {
|
81
|
-
t.removeProperties(node, opts);
|
111
|
+
t().removeProperties(node, opts);
|
82
112
|
cache.path.delete(node);
|
83
113
|
};
|
84
114
|
|
85
115
|
traverse.removeProperties = function (tree, opts) {
|
86
|
-
t.traverseFast(tree, traverse.clearNode, opts);
|
116
|
+
t().traverseFast(tree, traverse.clearNode, opts);
|
87
117
|
return tree;
|
88
118
|
};
|
89
119
|
|
@@ -95,7 +125,7 @@ function hasBlacklistedType(path, state) {
|
|
95
125
|
}
|
96
126
|
|
97
127
|
traverse.hasType = function (tree, type, blacklistTypes) {
|
98
|
-
if ((0, _includes.default)(blacklistTypes, tree.type)) return false;
|
128
|
+
if ((0, _includes().default)(blacklistTypes, tree.type)) return false;
|
99
129
|
if (tree.type === type) return true;
|
100
130
|
var state = {
|
101
131
|
has: false,
|
package/lib/path/ancestry.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
4
6
|
exports.findParent = findParent;
|
5
7
|
exports.find = find;
|
6
8
|
exports.getFunctionParent = getFunctionParent;
|
@@ -12,7 +14,15 @@ exports.isAncestor = isAncestor;
|
|
12
14
|
exports.isDescendant = isDescendant;
|
13
15
|
exports.inType = inType;
|
14
16
|
|
15
|
-
|
17
|
+
function t() {
|
18
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
19
|
+
|
20
|
+
t = function t() {
|
21
|
+
return data;
|
22
|
+
};
|
23
|
+
|
24
|
+
return data;
|
25
|
+
}
|
16
26
|
|
17
27
|
var _index = _interopRequireDefault(require("./index"));
|
18
28
|
|
@@ -67,7 +77,7 @@ function getStatementParent() {
|
|
67
77
|
function getEarliestCommonAncestorFrom(paths) {
|
68
78
|
return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
|
69
79
|
var earliest;
|
70
|
-
var keys = t.VISITOR_KEYS[deepest.type];
|
80
|
+
var keys = t().VISITOR_KEYS[deepest.type];
|
71
81
|
var _arr = ancestries;
|
72
82
|
|
73
83
|
for (var _i = 0; _i < _arr.length; _i++) {
|
package/lib/path/comments.js
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
4
6
|
exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
|
5
7
|
exports.addComment = addComment;
|
6
8
|
exports.addComments = addComments;
|
7
9
|
|
8
|
-
|
10
|
+
function t() {
|
11
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
12
|
+
|
13
|
+
t = function t() {
|
14
|
+
return data;
|
15
|
+
};
|
16
|
+
|
17
|
+
return data;
|
18
|
+
}
|
9
19
|
|
10
20
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
11
21
|
|
@@ -29,9 +39,9 @@ function shareCommentsWithSiblings() {
|
|
29
39
|
}
|
30
40
|
|
31
41
|
function addComment(type, content, line) {
|
32
|
-
t.addComment(this.node, type, content, line);
|
42
|
+
t().addComment(this.node, type, content, line);
|
33
43
|
}
|
34
44
|
|
35
45
|
function addComments(type, comments) {
|
36
|
-
t.addComments(this.node, type, comments);
|
46
|
+
t().addComments(this.node, type, comments);
|
37
47
|
}
|
package/lib/path/context.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
4
6
|
exports.call = call;
|
5
7
|
exports._call = _call;
|
6
8
|
exports.isBlacklisted = isBlacklisted;
|
@@ -56,19 +58,18 @@ function _call(fns) {
|
|
56
58
|
_ref = _i.value;
|
57
59
|
}
|
58
60
|
|
59
|
-
var
|
60
|
-
if (!
|
61
|
+
var fn = _ref;
|
62
|
+
if (!fn) continue;
|
61
63
|
var node = this.node;
|
62
64
|
if (!node) return true;
|
63
|
-
|
64
|
-
var ret = _fn.call(this.state, this, this.state);
|
65
|
+
var ret = fn.call(this.state, this, this.state);
|
65
66
|
|
66
67
|
if (ret && typeof ret === "object" && typeof ret.then === "function") {
|
67
68
|
throw new Error("You appear to be using a plugin with an async traversal visitor, " + "which your current version of Babel does not support." + "If you're using a published plugin, you may need to upgrade " + "your @babel/core version.");
|
68
69
|
}
|
69
70
|
|
70
71
|
if (ret) {
|
71
|
-
throw new Error("Unexpected return value from visitor method " +
|
72
|
+
throw new Error("Unexpected return value from visitor method " + fn);
|
72
73
|
}
|
73
74
|
|
74
75
|
if (this.node !== node) return true;
|
@@ -253,9 +254,8 @@ function requeue(pathToQueue) {
|
|
253
254
|
_ref2 = _i2.value;
|
254
255
|
}
|
255
256
|
|
256
|
-
var
|
257
|
-
|
258
|
-
_context.maybeQueue(pathToQueue);
|
257
|
+
var context = _ref2;
|
258
|
+
context.maybeQueue(pathToQueue);
|
259
259
|
}
|
260
260
|
}
|
261
261
|
|
package/lib/path/conversion.js
CHANGED
@@ -1,15 +1,33 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
4
6
|
exports.toComputedKey = toComputedKey;
|
5
7
|
exports.ensureBlock = ensureBlock;
|
6
8
|
exports.arrowFunctionToShadowed = arrowFunctionToShadowed;
|
7
9
|
exports.unwrapFunctionEnvironment = unwrapFunctionEnvironment;
|
8
10
|
exports.arrowFunctionToExpression = arrowFunctionToExpression;
|
9
11
|
|
10
|
-
|
12
|
+
function t() {
|
13
|
+
var data = _interopRequireWildcard(require("@babel/types"));
|
11
14
|
|
12
|
-
|
15
|
+
t = function t() {
|
16
|
+
return data;
|
17
|
+
};
|
18
|
+
|
19
|
+
return data;
|
20
|
+
}
|
21
|
+
|
22
|
+
function _helperFunctionName() {
|
23
|
+
var data = _interopRequireDefault(require("@babel/helper-function-name"));
|
24
|
+
|
25
|
+
_helperFunctionName = function _helperFunctionName() {
|
26
|
+
return data;
|
27
|
+
};
|
28
|
+
|
29
|
+
return data;
|
30
|
+
}
|
13
31
|
|
14
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
33
|
|
@@ -28,7 +46,7 @@ function toComputedKey() {
|
|
28
46
|
}
|
29
47
|
|
30
48
|
if (!node.computed) {
|
31
|
-
if (t.isIdentifier(key)) key = t.stringLiteral(key.name);
|
49
|
+
if (t().isIdentifier(key)) key = t().stringLiteral(key.name);
|
32
50
|
}
|
33
51
|
|
34
52
|
return key;
|
@@ -64,14 +82,14 @@ function ensureBlock() {
|
|
64
82
|
|
65
83
|
if (this.isFunction()) {
|
66
84
|
key = "argument";
|
67
|
-
statements.push(t.returnStatement(body.node));
|
85
|
+
statements.push(t().returnStatement(body.node));
|
68
86
|
} else {
|
69
87
|
key = "expression";
|
70
|
-
statements.push(t.expressionStatement(body.node));
|
88
|
+
statements.push(t().expressionStatement(body.node));
|
71
89
|
}
|
72
90
|
}
|
73
91
|
|
74
|
-
this.node.body = t.blockStatement(statements);
|
92
|
+
this.node.body = t().blockStatement(statements);
|
75
93
|
var parentPath = this.get(stringPath);
|
76
94
|
body.setup(parentPath, listKey ? parentPath.node[listKey] : parentPath.node, listKey, key);
|
77
95
|
return this.node;
|
@@ -111,12 +129,12 @@ function arrowFunctionToExpression(_temp) {
|
|
111
129
|
if (checkBinding) {
|
112
130
|
this.parentPath.scope.push({
|
113
131
|
id: checkBinding,
|
114
|
-
init: t.objectExpression([])
|
132
|
+
init: t().objectExpression([])
|
115
133
|
});
|
116
134
|
}
|
117
135
|
|
118
|
-
this.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(this.hub.file.addHelper("newArrowCheck"), [t.thisExpression(), checkBinding ? t.identifier(checkBinding.name) : t.identifier(thisBinding)])));
|
119
|
-
this.replaceWith(t.callExpression(t.memberExpression((0, _helperFunctionName.default)(this, true) || this.node, t.identifier("bind")), [checkBinding ? t.identifier(checkBinding.name) : t.thisExpression()]));
|
136
|
+
this.get("body").unshiftContainer("body", t().expressionStatement(t().callExpression(this.hub.file.addHelper("newArrowCheck"), [t().thisExpression(), checkBinding ? t().identifier(checkBinding.name) : t().identifier(thisBinding)])));
|
137
|
+
this.replaceWith(t().callExpression(t().memberExpression((0, _helperFunctionName().default)(this, true) || this.node, t().identifier("bind")), [checkBinding ? t().identifier(checkBinding.name) : t().thisExpression()]));
|
120
138
|
}
|
121
139
|
}
|
122
140
|
|
@@ -169,7 +187,7 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
169
187
|
});
|
170
188
|
var superBinding = getSuperBinding(thisEnvFn);
|
171
189
|
allSuperCalls.forEach(function (superCall) {
|
172
|
-
var callee = t.identifier(superBinding);
|
190
|
+
var callee = t().identifier(superBinding);
|
173
191
|
callee.loc = superCall.node.callee.loc;
|
174
192
|
superCall.get("callee").replaceWith(callee);
|
175
193
|
});
|
@@ -182,7 +200,7 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
182
200
|
|
183
201
|
if (!specCompliant || inConstructor && hasSuperClass(thisEnvFn)) {
|
184
202
|
thisPaths.forEach(function (thisChild) {
|
185
|
-
var thisRef = thisChild.isJSX() ? t.jsxIdentifier(thisBinding) : t.identifier(thisBinding);
|
203
|
+
var thisRef = thisChild.isJSX() ? t().jsxIdentifier(thisBinding) : t().identifier(thisBinding);
|
186
204
|
thisRef.loc = thisChild.node.loc;
|
187
205
|
thisChild.replaceWith(thisRef);
|
188
206
|
});
|
@@ -192,10 +210,10 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
192
210
|
|
193
211
|
if (argumentsPaths.length > 0) {
|
194
212
|
var argumentsBinding = getBinding(thisEnvFn, "arguments", function () {
|
195
|
-
return t.identifier("arguments");
|
213
|
+
return t().identifier("arguments");
|
196
214
|
});
|
197
215
|
argumentsPaths.forEach(function (argumentsChild) {
|
198
|
-
var argsRef = t.identifier(argumentsBinding);
|
216
|
+
var argsRef = t().identifier(argumentsBinding);
|
199
217
|
argsRef.loc = argumentsChild.node.loc;
|
200
218
|
argumentsChild.replaceWith(argsRef);
|
201
219
|
});
|
@@ -203,10 +221,10 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
203
221
|
|
204
222
|
if (newTargetPaths.length > 0) {
|
205
223
|
var newTargetBinding = getBinding(thisEnvFn, "newtarget", function () {
|
206
|
-
return t.metaProperty(t.identifier("new"), t.identifier("target"));
|
224
|
+
return t().metaProperty(t().identifier("new"), t().identifier("target"));
|
207
225
|
});
|
208
226
|
newTargetPaths.forEach(function (targetChild) {
|
209
|
-
var targetRef = t.identifier(newTargetBinding);
|
227
|
+
var targetRef = t().identifier(newTargetBinding);
|
210
228
|
targetRef.loc = targetChild.node.loc;
|
211
229
|
targetChild.replaceWith(targetRef);
|
212
230
|
});
|
@@ -230,10 +248,10 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
230
248
|
|
231
249
|
if (superProp.node.computed) {
|
232
250
|
var prop = superProp.get("property").node;
|
233
|
-
superProp.replaceWith(t.identifier(_superBinding));
|
251
|
+
superProp.replaceWith(t().identifier(_superBinding));
|
234
252
|
superProp.parentPath.node.arguments.unshift(prop);
|
235
253
|
} else {
|
236
|
-
superProp.replaceWith(t.identifier(_superBinding));
|
254
|
+
superProp.replaceWith(t().identifier(_superBinding));
|
237
255
|
}
|
238
256
|
} else {
|
239
257
|
var isAssignment = superProp.parentPath.isAssignmentExpression({
|
@@ -251,9 +269,9 @@ function hoistFunctionEnvironment(fnPath, specCompliant, allowInsertArrow) {
|
|
251
269
|
if (isAssignment) {
|
252
270
|
var value = superProp.parentPath.node.right;
|
253
271
|
args.push(value);
|
254
|
-
superProp.parentPath.replaceWith(t.callExpression(t.identifier(_superBinding2), args));
|
272
|
+
superProp.parentPath.replaceWith(t().callExpression(t().identifier(_superBinding2), args));
|
255
273
|
} else {
|
256
|
-
superProp.replaceWith(t.callExpression(t.identifier(_superBinding2), args));
|
274
|
+
superProp.replaceWith(t().callExpression(t().identifier(_superBinding2), args));
|
257
275
|
}
|
258
276
|
}
|
259
277
|
});
|
@@ -271,11 +289,11 @@ function standardizeSuperProperty(superProp) {
|
|
271
289
|
|
272
290
|
if (superProp.node.computed) {
|
273
291
|
var tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
|
274
|
-
assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, t.assignmentExpression("=", tmp, superProp.node.property), true));
|
275
|
-
assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(tmp.name), true), value));
|
292
|
+
assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, t().assignmentExpression("=", tmp, superProp.node.property), true));
|
293
|
+
assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(tmp.name), true), value));
|
276
294
|
} else {
|
277
|
-
assignmentPath.get("left").replaceWith(t.memberExpression(superProp.node.object, superProp.node.property));
|
278
|
-
assignmentPath.get("right").replaceWith(t.binaryExpression(op, t.memberExpression(superProp.node.object, t.identifier(superProp.node.property.name)), value));
|
295
|
+
assignmentPath.get("left").replaceWith(t().memberExpression(superProp.node.object, superProp.node.property));
|
296
|
+
assignmentPath.get("right").replaceWith(t().binaryExpression(op, t().memberExpression(superProp.node.object, t().identifier(superProp.node.property.name)), value));
|
279
297
|
}
|
280
298
|
|
281
299
|
return [assignmentPath.get("left"), assignmentPath.get("right").get("left")];
|
@@ -285,13 +303,13 @@ function standardizeSuperProperty(superProp) {
|
|
285
303
|
var _tmp = superProp.scope.generateDeclaredUidIdentifier("tmp");
|
286
304
|
|
287
305
|
var computedKey = superProp.node.computed ? superProp.scope.generateDeclaredUidIdentifier("prop") : null;
|
288
|
-
var parts = [t.assignmentExpression("=", _tmp, t.memberExpression(superProp.node.object, computedKey ? t.assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t.assignmentExpression("=", t.memberExpression(superProp.node.object, computedKey ? t.identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t.binaryExpression("+", t.identifier(_tmp.name), t.numericLiteral(1)))];
|
306
|
+
var parts = [t().assignmentExpression("=", _tmp, t().memberExpression(superProp.node.object, computedKey ? t().assignmentExpression("=", computedKey, superProp.node.property) : superProp.node.property, superProp.node.computed)), t().assignmentExpression("=", t().memberExpression(superProp.node.object, computedKey ? t().identifier(computedKey.name) : superProp.node.property, superProp.node.computed), t().binaryExpression("+", t().identifier(_tmp.name), t().numericLiteral(1)))];
|
289
307
|
|
290
308
|
if (!superProp.parentPath.node.prefix) {
|
291
|
-
parts.push(t.identifier(_tmp.name));
|
309
|
+
parts.push(t().identifier(_tmp.name));
|
292
310
|
}
|
293
311
|
|
294
|
-
updateExpr.replaceWith(t.sequenceExpression(parts));
|
312
|
+
updateExpr.replaceWith(t().sequenceExpression(parts));
|
295
313
|
var left = updateExpr.get("expressions.0.right");
|
296
314
|
var right = updateExpr.get("expressions.1.left");
|
297
315
|
return [left, right];
|
@@ -306,7 +324,7 @@ function hasSuperClass(thisEnvFn) {
|
|
306
324
|
|
307
325
|
function getThisBinding(thisEnvFn, inConstructor) {
|
308
326
|
return getBinding(thisEnvFn, "this", function (thisBinding) {
|
309
|
-
if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();
|
327
|
+
if (!inConstructor || !hasSuperClass(thisEnvFn)) return t().thisExpression();
|
310
328
|
var supers = new WeakSet();
|
311
329
|
thisEnvFn.traverse({
|
312
330
|
Function: function Function(child) {
|
@@ -321,7 +339,7 @@ function getThisBinding(thisEnvFn, inConstructor) {
|
|
321
339
|
if (!child.get("callee").isSuper()) return;
|
322
340
|
if (supers.has(child.node)) return;
|
323
341
|
supers.add(child.node);
|
324
|
-
child.replaceWith(t.assignmentExpression("=", t.identifier(thisBinding), child.node));
|
342
|
+
child.replaceWith(t().assignmentExpression("=", t().identifier(thisBinding), child.node));
|
325
343
|
}
|
326
344
|
});
|
327
345
|
});
|
@@ -330,25 +348,25 @@ function getThisBinding(thisEnvFn, inConstructor) {
|
|
330
348
|
function getSuperBinding(thisEnvFn) {
|
331
349
|
return getBinding(thisEnvFn, "supercall", function () {
|
332
350
|
var argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
|
333
|
-
return t.arrowFunctionExpression([t.restElement(argsBinding)], t.callExpression(t.super(), [t.spreadElement(t.identifier(argsBinding.name))]));
|
351
|
+
return t().arrowFunctionExpression([t().restElement(argsBinding)], t().callExpression(t().super(), [t().spreadElement(t().identifier(argsBinding.name))]));
|
334
352
|
});
|
335
353
|
}
|
336
354
|
|
337
355
|
function getSuperPropCallBinding(thisEnvFn, propName) {
|
338
356
|
return getBinding(thisEnvFn, "superprop_call:" + (propName || ""), function () {
|
339
357
|
var argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
|
340
|
-
var argsList = [t.restElement(argsBinding)];
|
358
|
+
var argsList = [t().restElement(argsBinding)];
|
341
359
|
var fnBody;
|
342
360
|
|
343
361
|
if (propName) {
|
344
|
-
fnBody = t.callExpression(t.memberExpression(t.super(), t.identifier(propName)), [t.spreadElement(t.identifier(argsBinding.name))]);
|
362
|
+
fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(propName)), [t().spreadElement(t().identifier(argsBinding.name))]);
|
345
363
|
} else {
|
346
364
|
var method = thisEnvFn.scope.generateUidIdentifier("prop");
|
347
365
|
argsList.unshift(method);
|
348
|
-
fnBody = t.callExpression(t.memberExpression(t.super(), t.identifier(method.name), true), [t.spreadElement(t.identifier(argsBinding.name))]);
|
366
|
+
fnBody = t().callExpression(t().memberExpression(t().super(), t().identifier(method.name), true), [t().spreadElement(t().identifier(argsBinding.name))]);
|
349
367
|
}
|
350
368
|
|
351
|
-
return t.arrowFunctionExpression(argsList, fnBody);
|
369
|
+
return t().arrowFunctionExpression(argsList, fnBody);
|
352
370
|
});
|
353
371
|
}
|
354
372
|
|
@@ -359,20 +377,20 @@ function getSuperPropBinding(thisEnvFn, isAssignment, propName) {
|
|
359
377
|
var fnBody;
|
360
378
|
|
361
379
|
if (propName) {
|
362
|
-
fnBody = t.memberExpression(t.super(), t.identifier(propName));
|
380
|
+
fnBody = t().memberExpression(t().super(), t().identifier(propName));
|
363
381
|
} else {
|
364
382
|
var method = thisEnvFn.scope.generateUidIdentifier("prop");
|
365
383
|
argsList.unshift(method);
|
366
|
-
fnBody = t.memberExpression(t.super(), t.identifier(method.name), true);
|
384
|
+
fnBody = t().memberExpression(t().super(), t().identifier(method.name), true);
|
367
385
|
}
|
368
386
|
|
369
387
|
if (isAssignment) {
|
370
388
|
var valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
|
371
389
|
argsList.push(valueIdent);
|
372
|
-
fnBody = t.assignmentExpression("=", fnBody, t.identifier(valueIdent.name));
|
390
|
+
fnBody = t().assignmentExpression("=", fnBody, t().identifier(valueIdent.name));
|
373
391
|
}
|
374
392
|
|
375
|
-
return t.arrowFunctionExpression(argsList, fnBody);
|
393
|
+
return t().arrowFunctionExpression(argsList, fnBody);
|
376
394
|
});
|
377
395
|
}
|
378
396
|
|