Indirect eval
This commit is contained in:
parent
4b440110a1
commit
e58409b144
@ -7,7 +7,9 @@ export default function({ types: t }) {
|
||||
visitor: {
|
||||
BinaryExpression(path) {
|
||||
const { scope } = path;
|
||||
const { operator, left, right } = path.node;
|
||||
const { node } = path;
|
||||
const { operator, left } = node;
|
||||
let { right } = node;
|
||||
if (operator !== "|>") return;
|
||||
|
||||
let optimizeArrow =
|
||||
@ -21,6 +23,8 @@ export default function({ types: t }) {
|
||||
} else if (params.length > 1) {
|
||||
optimizeArrow = false;
|
||||
}
|
||||
} else if (t.isIdentifier(right, { name: "eval" })) {
|
||||
right = t.sequenceExpression([t.numericLiteral(0), right]);
|
||||
}
|
||||
|
||||
if (optimizeArrow && !param) {
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
var result = '(function() { return this; })()'
|
||||
|> eval;
|
||||
|
||||
assert.notEqual(result, undefined);
|
||||
})();
|
||||
@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
var result = '(function() { return this; })()'
|
||||
|> eval;
|
||||
|
||||
assert.notEqual(result, undefined);
|
||||
})();
|
||||
@ -0,0 +1,8 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var _functionReturn;
|
||||
|
||||
var result = (_functionReturn = '(function() { return this; })()', (0, eval)(_functionReturn));
|
||||
assert.notEqual(result, undefined);
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user