Mihai Bazon
ffccb233e5
convert while into for
2012-11-05 16:01:20 +02:00
Mihai Bazon
fba0c1aafe
minor
2012-11-05 16:01:09 +02:00
Mihai Bazon
774f2ded94
minor optimization
...
for `==` or `!=` against a constant, prefer to display the constant first.
should help a bit after gzip, i.e.:
typeof foo=="undefined"
^^^^^^ ^^^^^^^^^^^^^
vs:
"undefined"==typeof foo
^^^^^^^^^^^^^^^^^^^ (longer sequence that could repeat)
idea stolen from closure.
2012-11-05 13:13:06 +02:00
Mihai Bazon
8413787efc
use a Dictionary object instead of plain object for hashes
...
to mitigate the `__proto__` issue
related to #30
2012-11-02 10:58:45 +02:00
Mihai Bazon
cf409800be
it's safe to negate expression in !EXP only in boolean context
...
#kendo
2012-11-01 15:49:05 +02:00
Mihai Bazon
18270dd9f3
added unsafe_comps for negating <= with >
...
since it has the potential to break code, let's keep it disabled by default
2012-11-01 15:14:56 +02:00
Mihai Bazon
d4c25c571b
fix compressing UnaryPrefix
...
only try negating the expression if the operator is `!`
#kendo
2012-11-01 13:35:08 +02:00
Mihai Bazon
abe0ebbf02
don't move expressions containing the binary in operator into the for initializer
...
(opera can't parse it)
close #25
2012-10-30 14:50:47 +02:00
Mihai Bazon
70fd2b1f33
fix for if (...) return; else return ...;
...
(it was assumed that the first `return` always contains a value)
close #22
2012-10-24 09:33:32 +03:00
Mihai Bazon
30faaf13ed
more sequence optimizations (lift some sequences above binary/unary expressions so that we can avoid parens)
2012-10-22 11:58:06 +03:00
Mihai Bazon
fc8314e810
minor fix for dropping unused definitions.
...
function f(x, y) {
var g = function() { return h() };
var h = function() { return g() };
return x + y;
}
now compresses to `function f(x, y) { return x + y }`
2012-10-19 12:57:29 +03:00
Mihai Bazon
afb7faa6fa
more optimizations for some break/continue cases
2012-10-18 15:14:57 +03:00
Mihai Bazon
253bd8559b
more small optimizations
...
(unlikely to help for hand-written code)
2012-10-17 21:57:08 +03:00
Mihai Bazon
6a099fba66
define aborts on AST_If: true if both branches abort
2012-10-17 16:17:14 +03:00
Mihai Bazon
a21f3c6cdd
employ a better parser for command-line arguments
...
to support passing commas in strings in for example:
uglifyjs2 -cd TEST="'a,b'" <<EOF
console.log(TEST);
EOF
→ console.log("a,b")
close #14
2012-10-17 15:56:45 +03:00
Mihai Bazon
fcc0229087
drop unused function arguments
...
also add test for "drop_unused" (the last one fails for now)
2012-10-13 15:04:44 +03:00
Mihai Bazon
851b48e4a3
fix compressing benchmark.js (it tried to evaluate a statement)
...
the following code in benchmark.js triggered the issue:
support.decompilation = Function(
'return (' + (function(x) { return { 'x': '' + (1 + x) + '', 'y': 0 }; }) + ')'
)()(0).x === '1';
technically that could be resolved into a constant expression, but seems
it's being used here for browser bugs detection :-\
2012-10-13 12:57:10 +03:00
Mihai Bazon
1b6f8d463f
remove the $self hack
...
operations are destructive anyway, so there's no point to clone the nodes in
the transformer. speed++
2012-10-12 11:07:35 +03:00
Mihai Bazon
172aa7a93c
cleanup
...
- use prototype-less objects where feasible (minor speed improvement)
- get rid of HOP
2012-10-11 11:07:42 +03:00
Mihai Bazon
c5ecbfc756
drop unused variable
2012-10-10 11:27:06 +03:00
Mihai Bazon
86182afa7f
minor
2012-10-09 22:56:59 +03:00
Mihai Bazon
a84d07e312
add AST_Infinity node
2012-10-09 18:35:53 +03:00
Mihai Bazon
1b0aab2ce9
added $propdoc to AST nodes and some cleanups
...
hopefully we can make the AST documentation self-generating
2012-10-09 18:20:39 +03:00
Mihai Bazon
9ead49641d
minor AST cleanup (AST_BlockStatement may inherit from AST_Block)
2012-10-09 13:59:17 +03:00
Mihai Bazon
2c025f23db
fix detecting symbols in use
2012-10-09 13:13:55 +03:00
Mihai Bazon
093a9031dc
eliminate redundant directives in the same scope
2012-10-08 12:53:17 +03:00
Mihai Bazon
4a2b91220a
minor
2012-10-05 20:24:56 +03:00
Mihai Bazon
a1e0885930
replace (function(){ ...no side effects ... })() with undefined.
2012-10-05 16:51:16 +03:00
Mihai Bazon
682a58a1f5
removed some unused variables
2012-10-04 08:49:18 +03:00
Mihai Bazon
11863d6f9a
more cleanup (dropped AST_SwitchBlock)
2012-10-03 15:52:31 +03:00
Mihai Bazon
3412498795
AST cleanup (dropped AST_StatementBase)
2012-10-03 15:41:11 +03:00
Mihai Bazon
c11de17e99
added option for side-effect-free statements, fix test
2012-10-03 13:08:03 +03:00
Mihai Bazon
e0f5075e45
fix endless loop in tests
2012-10-03 12:49:47 +03:00
Mihai Bazon
0678ae2076
fix for a = !b && !c && !d && !e → a=!(b||c||d||e)
2012-10-03 11:34:05 +03:00
Mihai Bazon
378ed17809
disable hoist_vars by default and change comparations to comparisons
2012-10-03 11:27:05 +03:00
Mihai Bazon
dde5b22b5e
support defines
2012-10-02 13:20:07 +03:00
Mihai Bazon
e1098b04a7
"use strict";
2012-10-02 12:45:58 +03:00
Mihai Bazon
211792757c
more constant folding (for names defined with const)
2012-10-02 12:45:17 +03:00
Mihai Bazon
ff696cd7bc
drop more unused names
2012-10-02 12:02:33 +03:00
Mihai Bazon
9e5dd81f1e
a shy attempt to obey width in the beautifier; added bracketize option to always print brackets around if/do/while/for statements; export more options via the CLI
2012-10-02 11:22:38 +03:00
Mihai Bazon
13278c6649
removed the "squeeze" method (it's now effectively "transform")
2012-09-26 19:52:32 +03:00
Mihai Bazon
15d58f5917
some speedup and more savings from unused vars that have side effects in initialization
2012-09-26 19:05:49 +03:00
Mihai Bazon
78be8f5296
compressor successfully moved to TreeTransformer
2012-09-26 14:27:01 +03:00
Mihai Bazon
a24e7ee976
checkpoint (refactoring, WIP)
2012-09-26 12:16:16 +03:00
Mihai Bazon
242dd10131
more cleanups
2012-09-25 20:39:15 +03:00
Mihai Bazon
9321d418bc
moving code around (refactoring, WIP)
2012-09-25 15:59:27 +03:00
Mihai Bazon
4201577dd7
started some refactoring (WIP) -- moving squeezer to TreeTransformer
2012-09-25 15:15:47 +03:00
Mihai Bazon
e836e2ae5f
minor
2012-09-25 12:48:36 +03:00
Mihai Bazon
ea6d1ea701
it's not safe to assume that property access is side-effect-free
...
(getters/setters + various browser bugs will trigger side effects; also, an
exception is thrown when the expression is undefined)
2012-09-25 10:32:14 +03:00
Mihai Bazon
368ac8f93c
some boolean cleanup
2012-09-25 10:31:03 +03:00