Mihai Bazon
16b12c6287
fix "file" in the source map
2012-09-10 15:52:53 +03:00
Mihai Bazon
1c8ba35844
minor
2012-09-08 22:51:59 +03:00
Mihai Bazon
5a8e6ce735
fix output for division followed by regexp
...
( v1 report: https://github.com/mishoo/UglifyJS/pull/458 )
2012-09-08 15:38:58 +03:00
Mihai Bazon
43c75c9248
checkpoint
2012-09-07 18:55:13 +03:00
Mihai Bazon
048d6906ae
fix bug (forgot arg name)
2012-09-07 16:02:08 +03:00
Mihai Bazon
919b2733ab
always keep declarations found in unreachable code
...
a few more tests and some cleanups.
2012-09-07 15:18:32 +03:00
Mihai Bazon
b77574ea1c
fixed tests (need to drop the toplevel block in "expected" if it's a single statement)
2012-09-07 11:22:01 +03:00
Mihai Bazon
9bb1a84d6b
don't duplicate argument names
2012-09-05 18:19:30 +03:00
Mihai Bazon
0afafe64fc
declared --stats as boolean
2012-09-05 18:19:24 +03:00
Mihai Bazon
c7b484b64f
fix for variable names like toString
2012-09-05 14:31:05 +03:00
Mihai Bazon
0503513dcc
support for hoisting declarations
...
and finally it seems we beat v1 in terms of compression
2012-09-05 13:43:34 +03:00
Mihai Bazon
8633b0073f
cleaned up usage of AST_BlockStatement
...
The following nodes were instances of AST_BlockStatement: AST_Scope,
AST_SwitchBlock, AST_SwitchBranch. Also, AST_Try, AST_Catch, AST_Finally
were having a body instanceof AST_BlockStatement.
Overloading the meaning of AST_BlockStatement this way turned out to be a
mess; we now have an AST_Block class that is the base class for things
having a block of statements (might or might not be bracketed). The
`this.body` of AST_Scope, AST_Try, AST_Catch, AST_Finally is now an array of
statements (as they inherit from AST_Block).
Avoiding calling superclass's _walk function in walkers (turns out we walked
a node multiple times).
2012-09-05 11:39:43 +03:00
Mihai Bazon
1b5183dd5e
checkpoint
2012-09-04 15:36:14 +03:00
Mihai Bazon
376667a818
more fiddling with boolean expressions, etc.
...
optimize away while(false), and transform while(true) ==> for(;;).
UNSAFE:
some expressions are optimized away when we're in boolean context and can
determine that the value will always be true or false. For example:
x() || true ==> always `true` in boolean context
x() && false ==> always `false` in boolean context
It's not technically correct to drop these expressions since we drop the
function call too (that might have side effects); on the other hand, I can't
see any legitimate use for such expressions and they might simply indicate a
bug (we do warn about it).
2012-09-04 13:20:28 +03:00
Mihai Bazon
3459c40cf9
if present, the else in an if should always be forced statement
2012-09-04 13:17:13 +03:00
Mihai Bazon
86cfb5be86
boolean and if/exit optimizations
2012-09-03 23:49:57 +03:00
Mihai Bazon
e5f1cec6aa
minor
2012-09-03 23:25:30 +03:00
Mihai Bazon
37eecc16a4
more optimizations for ifs/conditionals
...
(XXX: should add tests before anything else)
2012-09-03 19:38:45 +03:00
Mihai Bazon
f03138daa8
resolve constant expressions
2012-09-03 15:47:15 +03:00
Mihai Bazon
f702264617
jumps, try and definitions are statements too
2012-09-03 12:39:02 +03:00
Mihai Bazon
6d0db4ce14
an AST_If is too a StatementWithBody
2012-09-03 12:11:44 +03:00
Mihai Bazon
d7c1dc6c05
a LabeledStatement should be in fact a StatementWithBody
...
This fixes output for:
if (foo) {
moo: if (bar) {
break moo;
}
} else {
baz();
}
(the labeled statement must be outputted inside brackets)
2012-09-03 12:05:10 +03:00
Mihai Bazon
d6efa8b28d
declare boolean options
2012-09-03 12:03:45 +03:00
Mihai Bazon
66c869c8f6
switch branches must be declared required so that the compressor doesn't
...
replace nodes with a single statement.
looks stable for now, though mess begins to sink in. need to review the AST
hierarchy.
2012-09-03 11:05:59 +03:00
Mihai Bazon
1bf5928b54
Reverting "minor perf. improvements"
...
Revert "minor perf. improvements"
This reverts commit 24bfd55a22 .
broke the parser somehow; too early to optimize, let's get the other stuff running.
2012-09-03 10:26:23 +03:00
Mihai Bazon
596af60587
add -b
2012-09-03 10:14:15 +03:00
Mihai Bazon
f2f370cee3
add source mappings for more node types; started CLI utility
2012-09-02 14:32:00 +03:00
Mihai Bazon
24bfd55a22
minor perf. improvements
2012-09-02 11:11:39 +03:00
Mihai Bazon
52bcca288f
started support for generating source maps (WIP)
...
plugged in @fitzgen's source-map library
2012-08-29 19:39:19 +03:00
Mihai Bazon
48440dc250
don't mangle names of setters/getters
2012-08-29 19:26:48 +03:00
Mihai Bazon
6569e66bf8
update with link to discussion about Esprima vs. UglifyJS speed
2012-08-29 11:18:05 +03:00
Mihai Bazon
86cff2029f
docstring for AST_StatementWithBody
2012-08-28 15:39:53 +03:00
Mihai Bazon
1b6bcca717
fix output for arrays containing undefined values
...
[1,,2,] ==> [1,,2] instead of [1,undefined,2]
2012-08-28 15:38:35 +03:00
Mihai Bazon
7fcb6bcb12
fix code generator for this case:
...
if (foo) {
with (bar)
if (baz)
x();
} else y();
(the compressor removes the brackets since the consequent consists of a
single statement, but the codegen must include the brackets because
otherwise the `else` would refer to the inner `if`)
2012-08-28 15:29:58 +03:00
Mihai Bazon
ce8e8d57c0
added README
2012-08-27 12:29:53 +03:00
Mihai Bazon
bf70205b15
minor
2012-08-27 11:48:07 +03:00
Mihai Bazon
58a3b5e93f
update (c) years
2012-08-27 11:01:41 +03:00
Mihai Bazon
8dfa9fe7e5
minor
2012-08-27 11:00:26 +03:00
Mihai Bazon
4437e7af19
fix compressing a,b; return c; into return a,b,c;
2012-08-27 11:00:22 +03:00
Mihai Bazon
a8e49f1536
added print_to_string helper method
2012-08-27 10:59:33 +03:00
Mihai Bazon
8d233c38d4
fix current_col and force a newline every 32K (support options.max_line_len)
2012-08-23 10:39:33 +03:00
Mihai Bazon
95b18e54a4
added license
2012-08-22 21:28:59 +03:00
Mihai Bazon
159a6f048c
wrote more of the compressor and added some tests
2012-08-22 15:21:58 +03:00
Mihai Bazon
f53e139d3c
fix output for certain edge cases
...
the statements if, for, do, while and with might have an AST_EmptyStatement
as body; if that's the case, we need to make sure that the semicolon gets in
the output.
2012-08-22 13:20:05 +03:00
Mihai Bazon
fb8c9e3a48
declare some properties in the node constructor so that they're copied in clone
2012-08-22 00:01:55 +03:00
Mihai Bazon
1b839eb35b
hint that brackets may be required in AST_BlockStatement
2012-08-21 19:16:05 +03:00
Mihai Bazon
ffe58a9961
cleaned up some mess and started the actual compressor
2012-08-21 16:14:43 +03:00
Mihai Bazon
7ae1c600a2
some reorganization
...
(moved pretty much everything that relates to scope in scope.js, added a
module for NodeJS that can be used with require() and exports everything.)
2012-08-21 13:53:16 +03:00
Mihai Bazon
92bd53b513
handle labels properly
...
(they can't be handled the same way as variables in a scope)
2012-08-21 12:45:06 +03:00
Mihai Bazon
159333f4c5
warn about unreferenced symbols
2012-08-21 12:07:34 +03:00