aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-09-16 15:46:47 +0300
committerMihai Bazon <mihai@bazon.net>2012-09-16 15:46:47 +0300
commit21c34a17922f826d3c1d1fa230fb08788393f69b (patch)
treed833c20fff4e892e623d65d2a1a4ab0ca78914cb /lib/compress.js
parent7b6a402916fe697049c38f6ee89c644fcf93c8d4 (diff)
downloadtracifyjs-21c34a17922f826d3c1d1fa230fb08788393f69b.tar.gz
tracifyjs-21c34a17922f826d3c1d1fa230fb08788393f69b.zip
drop unused function
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js118
1 files changed, 0 insertions, 118 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 2f286545..7440a5bd 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -317,124 +317,6 @@ function Compressor(options, false_by_default) {
return ret;
};
- /// XXX: this function is UGLY and kinda wrong.
- /// I think it would be cleaner if it operates backwards.
- function handle_if_return_2(statements, compressor) {
- var self = compressor.self();
- var in_lambda = self instanceof AST_Lambda;
- var last = statements.length - 1;
- return MAP(statements, function(stat, i){
- if (stat instanceof AST_If
- && stat.body instanceof AST_Continue
- && !stat.alternative
- && self === stat.body.target()) {
- CHANGED = true;
- if (i < last) {
- var rest = statements.slice(i + 1);
- var cond = stat.condition;
- while (rest[0] instanceof AST_If
- && rest[0].body instanceof AST_Continue
- && self === rest[0].body.target()
- && !rest[0].alternative) {
- cond = make_node(AST_Binary, rest[0], {
- operator: "||",
- left: cond,
- right: rest[0].condition
- });
- rest.shift();
- }
- return MAP.last(make_node(AST_If, stat, {
- condition: cond.negate(compressor),
- body: make_node(AST_BlockStatement, stat, {
- body: rest
- }).optimize(compressor)
- }).optimize(compressor))
- } else {
- return make_node(AST_SimpleStatement, stat, {
- body: stat.condition
- }).optimize(compressor);
- }
- }
- if (stat instanceof AST_If
- && stat.body instanceof AST_Return
- && !stat.alternative
- && in_lambda) {
- if (!stat.body.value) {
- CHANGED = true;
- if (i < last) {
- var rest = statements.slice(i + 1);
- var cond = stat.condition;
- while (rest[0] instanceof AST_If
- && rest[0].body instanceof AST_Return
- && !rest[0].body.value
- && !rest[0].alternative) {
- cond = make_node(AST_Binary, rest[0], {
- operator: "||",
- left: cond,
- right: rest[0].condition
- });
- rest.shift();
- }
- return MAP.last(make_node(AST_If, stat, {
- condition: cond.negate(compressor),
- body: make_node(AST_BlockStatement, stat, {
- body: rest
- }).optimize(compressor)
- }).optimize(compressor));
- } else {
- return make_node(AST_SimpleStatement, stat, {
- body: stat.condition
- }).optimize(compressor);
- }
- } else if (i == last && last > 0
- && statements[last - 1] instanceof AST_If
- && statements[last - 1].body instanceof AST_Return
- && !statements[last - 1].alternative) {
- CHANGED = true;
- return MAP.splice([ stat, make_node(AST_Return, stat, {
- value: make_node(AST_Undefined, stat).optimize(compressor)
- }).optimize(compressor)]);
- }
- }
- if (stat instanceof AST_If
- && stat.body instanceof AST_Exit
- && stat.body.value
- && !stat.alternative
- && i < last
- && statements[i + 1].TYPE == stat.body.TYPE
- && statements[i + 1].value) {
- CHANGED = true;
- return MAP.last(make_node(AST_If, stat, {
- condition: stat.condition,
- body: stat.body,
- alternative: statements[i + 1]
- }).optimize(compressor));
- }
- if (stat instanceof AST_If
- && stat.alternative instanceof AST_Exit) {
- CHANGED = true;
- return MAP.last(MAP.splice([
- // 1. negate IF and put the exit in the consequent
- make_node(AST_If, stat, {
- condition: stat.condition.negate(compressor),
- body: stat.alternative
- }),
- // 2. the IF body can now go outside the if
- stat.body
- // and 3. add the rest of the statements
- ].concat(statements.slice(i + 1))));
- return MAP.last(make_node(AST_If, stat, {
- condition: stat.condition.negate(compressor),
- body: stat.alternative,
- alternative: make_node(AST_BlockStatement, stat.body, {
- body: [ stat.body ].concat(statements.slice(i + 1))
- })
- }).optimize(compressor));
- }
- return stat;
- });
- };
-
function eliminate_dead_code(statements, compressor) {
var has_quit = false;
return statements.reduce(function(a, stat){