aboutsummaryrefslogtreecommitdiff
path: root/lib/transform.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-09-23 12:47:34 +0300
committerMihai Bazon <mihai@bazon.net>2012-09-23 12:47:34 +0300
commita83b28503f4673aeb744b45306500584a6480e29 (patch)
tree52c34c1e72d32531dd3e1a6c7a1eb935a70c23ec /lib/transform.js
parent76d88b59dcd28b836b2cdaf7908bfd5acaa88ebc (diff)
downloadtracifyjs-a83b28503f4673aeb744b45306500584a6480e29.tar.gz
tracifyjs-a83b28503f4673aeb744b45306500584a6480e29.zip
properly drop mutually-referring declarations that are not otherwise
referenced and have no side effects
Diffstat (limited to 'lib/transform.js')
-rw-r--r--lib/transform.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/transform.js b/lib/transform.js
index 743dd6e7..df51eac3 100644
--- a/lib/transform.js
+++ b/lib/transform.js
@@ -68,14 +68,17 @@ TreeTransformer.prototype = {
node.DEFMETHOD("transform", function(tw, in_list){
var x, y;
tw.push(this);
- x = tw.before(this, function(){
- descend(x, tw);
- }, in_list);
+ x = tw.before(this, descend, in_list);
if (x === undefined) {
- x = this.clone();
- descend(x, tw);
- y = tw.after(this, in_list);
- if (y !== undefined) x = y;
+ if (!tw.after) {
+ x = this;
+ descend(x, tw);
+ } else {
+ x = this.clone();
+ descend(x, tw);
+ y = tw.after(this, in_list);
+ if (y !== undefined) x = y;
+ }
}
tw.pop();
return x;