@@ -530,12 +530,11 @@ merge(Compressor.prototype, {
|
|||||||
tw.safe_ids = save_ids;
|
tw.safe_ids = save_ids;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
def(AST_Do, function(tw) {
|
def(AST_DWLoop, function(tw, descend) {
|
||||||
var saved_loop = tw.in_loop;
|
var saved_loop = tw.in_loop;
|
||||||
tw.in_loop = this;
|
tw.in_loop = this;
|
||||||
push(tw);
|
push(tw);
|
||||||
this.body.walk(tw);
|
descend();
|
||||||
this.condition.walk(tw);
|
|
||||||
pop(tw);
|
pop(tw);
|
||||||
tw.in_loop = saved_loop;
|
tw.in_loop = saved_loop;
|
||||||
return true;
|
return true;
|
||||||
@@ -714,16 +713,6 @@ merge(Compressor.prototype, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
def(AST_While, function(tw) {
|
|
||||||
var saved_loop = tw.in_loop;
|
|
||||||
tw.in_loop = this;
|
|
||||||
push(tw);
|
|
||||||
this.condition.walk(tw);
|
|
||||||
this.body.walk(tw);
|
|
||||||
pop(tw);
|
|
||||||
tw.in_loop = saved_loop;
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
})(function(node, func){
|
})(function(node, func){
|
||||||
node.DEFMETHOD("reduce_vars", func);
|
node.DEFMETHOD("reduce_vars", func);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -93,7 +93,12 @@ TreeTransformer.prototype = new TreeWalker;
|
|||||||
self.body = do_list(self.body, tw);
|
self.body = do_list(self.body, tw);
|
||||||
});
|
});
|
||||||
|
|
||||||
_(AST_DWLoop, function(self, tw){
|
_(AST_Do, function(self, tw){
|
||||||
|
self.body = self.body.transform(tw);
|
||||||
|
self.condition = self.condition.transform(tw);
|
||||||
|
});
|
||||||
|
|
||||||
|
_(AST_While, function(self, tw){
|
||||||
self.condition = self.condition.transform(tw);
|
self.condition = self.condition.transform(tw);
|
||||||
self.body = self.body.transform(tw);
|
self.body = self.body.transform(tw);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -716,3 +716,29 @@ issue_3021: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "2 2"
|
expect_stdout: "2 2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3046: {
|
||||||
|
options = {
|
||||||
|
hoist_props: true,
|
||||||
|
reduce_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function(a) {
|
||||||
|
do {
|
||||||
|
var b = {
|
||||||
|
c: a++
|
||||||
|
};
|
||||||
|
} while (b.c && a);
|
||||||
|
return a;
|
||||||
|
}(0));
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function(a) {
|
||||||
|
do {
|
||||||
|
var b_c = a++;
|
||||||
|
} while (b_c && a);
|
||||||
|
return a;
|
||||||
|
}(0));
|
||||||
|
}
|
||||||
|
expect_stdout: "1"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user