Skip to content

Commit 37353d1

Browse files
committed
bugfix
1 parent 8e3b5d8 commit 37353d1

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

build/transformations/evalOutlining.js

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/transformations/evalOutlining.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class EvalOutlining extends BaseTransformation {
1818
estraverse.replace(this.ast, {
1919
enter: (node: estree.Node, parent: estree.Node | null): estree.Node | void => {
2020
if (parent !== null && parent.type === 'BlockStatement') {
21-
if (this.forbiddenStatements.includes(node.type)) {
21+
if (!this.isSuitable(node)) {
2222
return;
2323
}
2424
if (Math.random() <= this.settings.threshold) {
@@ -47,6 +47,26 @@ class EvalOutlining extends BaseTransformation {
4747
Verbose.log(`${count} expressions outlined to eval`.yellow);
4848
return this.ast;
4949
}
50+
51+
/**
52+
* @protected
53+
* @param {estree.Node} expression
54+
* @returns {boolean}
55+
* @memberof EvalOutlining
56+
*/
57+
protected isSuitable(expression: estree.Node): boolean {
58+
let suitable: boolean = true;
59+
60+
estraverse.traverse(expression, {
61+
enter: (node: estree.Node): void => {
62+
if (this.forbiddenStatements.includes(node.type)) {
63+
suitable = false;
64+
}
65+
}
66+
});
67+
68+
return suitable;
69+
}
5070
}
5171

5272
export = EvalOutlining;

0 commit comments

Comments
 (0)