diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js index e4479ca8..c6e27e06 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -4468,6 +4468,35 @@ merge(Compressor.prototype, { }); return true; } + if (node instanceof AST_Continue) { + var target = tw.loopcontrol_target(node); + if (!(target instanceof AST_Do)) return true; + var stack = []; + while (!HOP(segment, "block") || segment.block !== target) { + stack.push(segment); + pop(); + } + segment.loop = "c"; + push(); + while (stack.length) { + var seg = stack.pop(); + push(); + if (HOP(seg, "block")) segment.block = seg.block; + if (HOP(seg, "loop")) segment.loop = seg.loop; + } + return true; + } + if (node instanceof AST_Do) { + push(); + segment.block = node; + segment.loop = true; + var save = segment; + node.body.walk(tw); + if (segment.loop == "c") segment = save; + node.condition.walk(tw); + pop(); + return true; + } if (node instanceof AST_For) { if (node.init) node.init.walk(tw); push(); @@ -4501,14 +4530,6 @@ merge(Compressor.prototype, { } return true; } - if (node instanceof AST_IterationStatement) { - push(); - segment.block = node; - segment.loop = true; - descend(); - pop(); - return true; - } if (node instanceof AST_LabeledStatement) { push(); segment.block = node; @@ -4601,6 +4622,14 @@ merge(Compressor.prototype, { } return true; } + if (node instanceof AST_While) { + push(); + segment.block = node; + segment.loop = true; + descend(); + pop(); + return true; + } }); tw.directives = Object.create(compressor.directives); self.walk(tw); |