Mihai Bazon
6472f9410e
add semicolons option in the code generator (default: true)
...
pass `false` to separate statements with newlines instead of semicolons
2012-10-17 14:52:08 +03:00
Mihai Bazon
8957b3a694
fix small glitches in source map generation
2012-10-16 15:54:12 +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
b071c9d079
add parens to AST_Seq whose parent is AST_Unary
2012-10-13 14:32:08 +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
708abb1ab1
minor
2012-10-13 12:42:01 +03:00
Mihai Bazon
370d3e0917
fix regression from fb5c01c073
...
is_digit takes a char code now, not a string
2012-10-13 12:24:27 +03:00
Mihai Bazon
b51fe0dcc3
fix end tokens in spidermonkey ast import
2012-10-13 11:37:58 +03:00
Mihai Bazon
8149be551e
minor
2012-10-12 14:55:54 +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
72cb5328ee
fix in_boolean_context() (two tests were broken)
2012-10-12 10:49:41 +03:00
Mihai Bazon
fc39553714
use AST_Lambda for object setters/getters
...
so that the optimization that drops the name if unused doesn't apply.
close #12
2012-10-12 10:11:01 +03:00
Mihai Bazon
d9d67317b1
fix pos in syntax error exception
2012-10-11 15:25:38 +03:00
Mihai Bazon
fb5c01c073
stealing more hacks from acorn in the name of speed
2012-10-11 15:17:42 +03:00
Mihai Bazon
f4584af42c
using makeComparator from acorn to generate functions that tests whether a
...
string is keyword, reserved etc.
speeds up the parser a bit, though not spectacular.. still far from acorn.
2012-10-11 11:52:05 +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
5053a29bc0
fix propagation of symbol references
2012-10-11 10:28:48 +03:00
Mihai Bazon
9cdaed9860
fix node name
2012-10-10 23:16:40 +03:00
Mihai Bazon
dacce1b1fa
seems cleaner if AST_Label doesn't inherit from AST_SymbolDeclaration
2012-10-10 11:37:51 +03:00
Mihai Bazon
f26f3b44bc
small improvements in wrap_commonjs:
...
- use MAP.splice instead of a BlockStatement to inject code (avoids some
warnings in the linter)
- use the original symbol in exports, so that we get the proper source mapping
2012-10-10 11:28:05 +03:00
Mihai Bazon
c5ecbfc756
drop unused variable
2012-10-10 11:27:06 +03:00
Mihai Bazon
3799ac8973
add --lint and display {file} in scope_warnings
2012-10-10 11:26:59 +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
88beddfa91
make --comments keep @cc_on too
2012-10-09 18:25:00 +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
e1862cd36f
add --ast-help
...
displays a rather cruel description of the AST classes, derived
directly from the node definitions.
2012-10-09 13:21:21 +03:00
Mihai Bazon
2c025f23db
fix detecting symbols in use
2012-10-09 13:13:55 +03:00
Mihai Bazon
d4970b35ac
should not expose base54.sort() in the API docs, I think
2012-10-08 13:37:27 +03:00
Mihai Bazon
dd8286bce1
added --self to easily get a browser-runnable version of UglifyJS
2012-10-08 12:55:18 +03:00
Mihai Bazon
093a9031dc
eliminate redundant directives in the same scope
2012-10-08 12:53:17 +03:00
Mihai Bazon
80a18fe2fa
for certain nodes that we invent we might not have a original source file to
...
map from, so just use "?". and in any case, don't fail hard when addMapping throws.
2012-10-08 12:52:25 +03:00
Mihai Bazon
455ac5435d
remove unused code
2012-10-05 22:59:05 +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
7ae09120ed
prevent mangling only when eval is *called*, not when it's just referenced
2012-10-05 16:17:31 +03:00
Mihai Bazon
ecd9f21467
fixed import of locations from SpiderMonkey AST
2012-10-05 15:05:06 +03:00
Mihai Bazon
a9b6f9909a
use the appropriate constructor for symbols
2012-10-04 17:28:35 +03:00
Mihai Bazon
708ec0467c
minor
2012-10-04 17:28:09 +03:00
Mihai Bazon
682a58a1f5
removed some unused variables
2012-10-04 08:49:18 +03:00
Mihai Bazon
f20c251882
moving code around
2012-10-03 21:39:47 +03:00
Mihai Bazon
2bd8a118c2
define AST_Node.from_mozilla_ast(ast)
...
returns an UglifyJS2 AST given a Mozilla AST. Still needs some work to do
(need to create specific nodes like AST_SymbolRef, AST_SymbolLambda
etc. instead of base AST_Symbol, in order for the mangler/compressor to work
properly)
2012-10-03 20:03:17 +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
815abcfe18
support for --comments option to keep comments containing @license or @preserve
2012-10-02 16:40:42 +03:00
Mihai Bazon
075f93ec0d
line numbers start at 1
2012-10-02 16:39:53 +03:00
Mihai Bazon
2a5456260e
added option to keep some comments in the output
2012-10-02 14:32:30 +03:00
Mihai Bazon
36be211e99
option to exclude certain names from mangling
2012-10-02 14:02:33 +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
347160c631
add AST_SymbolConst for names defined with const
2012-10-02 12:22:39 +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
896444482a
minor
2012-09-28 11:12:47 +03:00
Mihai Bazon
05e15b1c0c
fix mangling
...
(bug in our code prevented the mangler from using a name that was in use
prior to mangling but not after it)
2012-09-27 00:01:16 +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
10c7f52074
discard all \uFEFF characters ( https://github.com/mishoo/UglifyJS/issues/462 )
2012-09-25 15:30:59 +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
Mihai Bazon
42038fd67f
Support input source map
...
This is useful while compressing generated code; for example compressing JS
compiled by CoffeeScript (assuming you got a source map):
uglifyjs2 --in-source-map generated.js.map \
--source-map uglified.js.map \
-o uglified.js
The above assumes you have a "generated.js.map" file which is the source
mapping between your CoffeeScript and the generated.js (compiled output from
CoffeeScript). The name of the input file is not present in this example;
it will be fetched from the source map (but it can be passed manually too).
The output will be in "uglified.js" and the output map "uglified.js.map"
will actually map to the original CoffeeScript code, rather than to
generated.js.
2012-09-24 17:02:18 +03:00
Mihai Bazon
a83b28503f
properly drop mutually-referring declarations that are not otherwise
...
referenced and have no side effects
2012-09-23 12:47:34 +03:00
Mihai Bazon
76d88b59dc
tree transformer api (WIP)
2012-09-22 19:41:09 +03:00
Mihai Bazon
ec7f895b54
log filename in parse errors / compressor warnings
2012-09-21 14:44:25 +03:00
Mihai Bazon
5491e1d7b1
better support for multiple input files:
...
- use a single AST_Toplevel node for all files
- keep original source filename in the tokens
2012-09-21 14:19:05 +03:00
Mihai Bazon
c4f8c2103f
more on detecting side effects
2012-09-21 11:23:44 +03:00
Mihai Bazon
e8da72d304
drop unused variables
2012-09-19 12:27:38 +03:00
Mihai Bazon
a4d2340c73
fixed label scope/mangling
2012-09-18 19:26:46 +03:00
Mihai Bazon
669874d46b
minor
2012-09-18 14:17:23 +03:00
Mihai Bazon
3da0ac4897
support for directives
2012-09-18 13:21:09 +03:00
Mihai Bazon
21968285e8
added AST_NaN (output as 0/0)
2012-09-18 10:53:46 +03:00
Mihai Bazon
d91613b4a8
only do the typeof x == "undefined" optimization if x is a symbol reference and it's declared in scope, or x is not a symbol reference.
2012-09-17 20:02:57 +03:00
Mihai Bazon
ee669ba878
moved typeof foo == "undefined" ==> foo === undefined under --unsafe
...
because 43fd45154b (commitcomment-1864505)
2012-09-17 18:49:52 +03:00
Mihai Bazon
e370e3b5a4
fix .undeclared (it's now a function)
2012-09-17 15:06:06 +03:00
Mihai Bazon
6ad414ef28
minor
2012-09-17 14:33:36 +03:00
Mihai Bazon
92e22c460d
possible optimization for AST_Undefined
...
if undefined is defined, ;-), we replace AST_Undefined nodes to a reference
to the "undefined" variable; in turn the mangler will compress it to a
single letter; this helps at least on jQuery.
2012-09-17 12:27:32 +03:00
Mihai Bazon
14481de0e9
empty block to empty statement: {} ==> ;
2012-09-17 12:03:02 +03:00
Mihai Bazon
07f1d56f69
more smallish optimizations
2012-09-17 11:50:35 +03:00
Mihai Bazon
5e60a60b3b
try negating AST_Binary
2012-09-17 11:16:44 +03:00
Mihai Bazon
5d781ec6f8
some cleanup
2012-09-16 18:10:54 +03:00
Mihai Bazon
0f418d654e
more sequencesizing (WIP)
2012-09-16 16:29:17 +03:00
Mihai Bazon
21c34a1792
drop unused function
2012-09-16 15:46:47 +03:00
Mihai Bazon
7b6a402916
rewrite handle_if_return
...
optimizations of if/return/continue seem to be even better now
2012-09-16 15:46:20 +03:00
Mihai Bazon
397bf56d25
other small optimization:
...
if (foo) continue;
...body...
==>
if (!foo) { ...body ... }
Only when the parent block is the target loop of the `continue` statement.
2012-09-15 16:10:35 +03:00
Mihai Bazon
4e0262bdfb
figure out label targets
2012-09-15 16:05:17 +03:00
Mihai Bazon
86c14d0988
join_vars:
...
var XXX;
for (var YYY; ...)
==>
for (var XXX,YYY; ...)
2012-09-15 10:54:59 +03:00
Mihai Bazon
43fd45154b
compress typeof x == "undefined" to x === undefined, which further gets
...
shortened to x === void 0 (or x === [][0] in unsafe mode)
2012-09-14 19:56:59 +03:00
Mihai Bazon
50d1670e42
minor
...
when unsafe, compress undefined as [][0]
2012-09-14 19:04:18 +03:00