Mihai Bazon
18c63ff3d8
Fix compression of conditionals
...
Don't move the condition on the right side of an assignment when
the left side may have side effects.
Fix #677
2015-04-13 17:29:48 +03:00
Mihai Bazon
276b9a31cd
Fix compressing ![foo()]; as a statement
...
need to check whether the literal has any side effects before replacing that
with `false`.
2015-03-23 23:27:00 +02:00
Mihai Bazon
5801fa39e9
[sequencesize] Actually even better:
...
do create the sequence even if the stat list is bigger than 2000 statements,
but limit the sequence itself to 2000 expressions.
Ref #414
2015-03-22 13:02:45 +02:00
Mihai Bazon
f0ab1b02e6
Avoid sequencesize for more than 2000 statements.
...
It hardly saves any bytes for a sequence so long, and it risks blowing the
stack with the recursive Seq functions.
Ref #414
2015-03-22 12:51:15 +02:00
Mihai Bazon
36c28e02fd
Add start/end nodes for NaN/Infinity transformations
2015-03-22 12:50:36 +02:00
Mihai Bazon
ecfd881ac6
Keep unused function arguments by default
...
Discarding unused function arguments affects function.length, which can lead
to some hard to debug issues. This optimization is now done only in "unsafe
mode".
Fix #121
2015-03-20 10:28:51 +02:00
Richard van Velzen
992b6b9fcc
Fix invalid removal of left side in && and || compression
...
See #637 . This does not produce the optimal result, but it does prevent the removal of non-side-effect-free code.
2015-02-11 21:08:41 +01:00
Richard van Velzen
605362f89d
Drop all console statements properly
...
Because the base reference can be an member expression as well, we have to dig a bit deeper to find the leftmost base reference.
Fixes #451
2015-01-31 13:24:44 +01:00
Tal Ater
a1a4c2ada7
Optimize conditionals where the consequent and alternative are both booleans and not equivalent
2015-01-13 18:27:21 +01:00
Richard van Velzen
42ecd42ac0
Replace the correct node when replacing in void sequences
...
Close #611 .
2015-01-12 17:09:34 +01:00
Mihai Bazon
a10f6a96d7
Merge pull request #482 from arty-name/inline-ng-inject
...
added @ngInject support for inline functions
2015-01-11 12:10:42 +02:00
Mihai Bazon
61c233a08e
Fix make_node_from_constant for Regexp-s
...
Close #588
2015-01-07 11:20:04 +02:00
Mihai Bazon
d2d716483a
aborts(AST_If) returns the if node
...
Previously it returned the abort node from the alternative branch. This is
not much use as it can be different from the one in the body
branch (i.e. return vs. throw) and can trick us into issues like #591 .
Fix #591
2015-01-06 14:01:35 +02:00
Mihai Bazon
e1f0747e4c
Support keep_fnames in compressor, and --keep-fnames. #552
...
Passing `--keep-fnames` will enable it both for compressor/mangler, so that
function names will not be dropped (when unused) nor mangled.
2015-01-05 11:03:13 +02:00
Richard van Velzen
f4d36a58c2
Fix #569
...
When no arguments are given to `new Function()`, it should be treated as
a regular anonymous function (http://es5.github.io/#x15.3.2.1 )
2015-01-04 13:37:59 +01:00
Richard van Velzen
c75f5a1fd8
Fix #597
...
NaN and Infinity were replaced in the output generation, instead of
during compression. This could lead to results where `1/0` was inserted
without parens leading to invalid output.
The nodes are replaced in the compression step now, and the output
generation returns their regular names. This should not be a problem,
since they're already only constructed from the original name.
2014-12-31 12:23:00 +01:00
Mihai Bazon
01d19b4b52
Referencing a global is assumed to have side effects.
...
Close #550
2014-09-28 11:18:25 +03:00
Tal Ater
fb0ec720a4
Compress conditions that have side effects using sequences
2014-09-04 02:57:49 +03:00
Tal Ater
885835a655
Compress conditional assignments where all possible outcomes are equivalant and condition has no side effects
2014-09-02 23:30:25 +03:00
Mihai Bazon
4c64554808
Turn foo.new into foo["new"] when not --screw-ie8. Fix #534
2014-08-26 10:11:01 +03:00
Mihai Bazon
548beeb6b1
Prevent error for Function(""). Close #538
2014-08-20 09:16:34 +03:00
Dan Wolff
8511e80f48
Evaluate "foo".length ==> 3
2014-07-01 11:06:51 +03:00
Artemy Tregubenko
524a8a42a4
added @ngInject support for inline functions
2014-05-11 14:01:08 +02:00
Mihai Bazon
ef2ef07cbd
Add option keep_fargs.
...
By default it's `false`. Pass `true` if you need to keep unused function
arguments.
Close #188 .
2014-02-08 12:33:56 +02:00
Matt Basta
ac0086a745
Simplify nested conditionals if possible
2014-02-06 12:39:13 -08:00
Mihai Bazon
5344b7dab8
Fix if_return dropping the alternative. Close #413
2014-01-31 10:44:13 +02:00
Mihai Bazon
c3087dd179
Better process_for_angular before other statement reductions. #395
2014-01-08 11:39:24 +02:00
Mihai Bazon
2c305af478
Support @ngInject with angular compressor option. Close #395 .
2014-01-08 11:28:32 +02:00
Mihai Bazon
2c88eb6fbe
doh.
2014-01-07 12:54:14 +02:00
Mihai Bazon
27142df4f5
minor: exp["10"] => exp[10]
2014-01-07 12:48:21 +02:00
Mihai Bazon
b521b4b926
Conditional/call optimization
...
foo ? bar(x) : bar(y) ==> bar(foo ? x : y)
2013-12-29 10:31:30 +02:00
Mihai Bazon
5a083a938d
Optimize seq,void 0. Close #377 .
...
(x, void 0) => void x
(x, undefined) => void x
2013-12-22 11:36:45 +02:00
Mihai Bazon
dc5f70eab5
Add drop_console option to the compressor
2013-12-10 19:44:41 +02:00
Mihai Bazon
df8c5623af
minor
2013-12-10 19:39:03 +02:00
Mihai Bazon
d2190c2bf3
Properly scope catch identifier when --screw-ie8
...
Fix #344
2013-11-28 16:43:30 +02:00
Mihai Bazon
50b8d7272c
Fix faulty compression
...
`String(x + 5)` is not always the same as `x + "5"`. Overlooked that. :-(
Close #350
2013-11-20 21:13:16 +02:00
Mihai Bazon
7d11b96f48
Only descend twice after drop_unused if it's the same node type.
...
Fix #345
2013-11-08 11:57:17 +02:00
Mihai Bazon
eab99a1c3d
Better fix for #343
...
We can in fact lift sequences, but only if the operation is assignment and
the left-hand side has no side effects nor property access -- that should
guarantee that whatever we place before it cannot affect the sense of the
assignment.
Dropped contrived test case (too hard to support it now), added a more
meaningful one.
2013-11-06 10:48:48 +02:00
Mihai Bazon
f4919e3a25
Do not lift sequence from right-hand side of binary operation. Fix #343
2013-11-06 10:18:28 +02:00
Mihai Bazon
b70670b69f
Fix regression after e4c5302406
...
`x * (y * z)` ==> `x * y * z` -- the better place to do this is in the
compressor rather than codegen.
2013-10-30 10:45:58 +02:00
Mihai Bazon
9dd97605bc
indentation
2013-10-30 10:44:50 +02:00
Richard van Velzen
785c6064cc
Disallow reversal where lhs has higher or equal precedence
...
Fixes #267
2013-10-29 21:37:36 +01:00
Richard van Velzen
e2daee9a65
Fix RHS concat (raised in #330 )
...
When attempting to concat the left-side of the rhs, make sure the rhs is
a string.
2013-10-26 18:44:52 +02:00
Richard van Velzen
1a5a4bd631
Fix #269
...
Shorten most primitives where possible. Also optimize some edge cases.
2013-10-24 11:08:33 +02:00
Richard van Velzen
7055af8221
Fix #280
...
The `init` of the `ForStatement` is not a `BlockStatement` before it was
descended. The descend has to happen first, and *then* the actual
checks.
2013-10-23 22:26:04 +02:00
Mihai Bazon
63d04fff69
Revert #3a81f60 for now
...
(with it some tests break and it can generate invalid output, see issue #44 )
2013-10-22 21:50:55 +03:00
Mihai Bazon
3fa9265ce4
wrap up
2013-10-09 22:15:43 +03:00
Mihai Bazon
3a81f60982
Don't drop_unused before compression.
...
Fix #280 , #282
2013-10-09 19:15:09 +03:00
Mihai Bazon
f2348dd98b
Rename clean_getters to pure_getters; add pure_funcs.
2013-10-04 13:17:25 +03:00
Mihai Bazon
8cc86fee60
add clean_getters compressor option (default false)
...
allows one to specify if `foo.bar` is considered to have side effects.
2013-10-02 19:38:01 +03:00