UglifyJS.git
12 years agofix output for division followed by regexp
Mihai Bazon [Sat, 8 Sep 2012 12:38:58 +0000 (15:38 +0300)]
fix output for division followed by regexp

( v1 report: https://github.com/mishoo/UglifyJS/pull/458 )

12 years agocheckpoint
Mihai Bazon [Fri, 7 Sep 2012 15:55:13 +0000 (18:55 +0300)]
checkpoint

12 years agofix bug (forgot arg name)
Mihai Bazon [Fri, 7 Sep 2012 13:02:08 +0000 (16:02 +0300)]
fix bug (forgot arg name)

12 years agoalways keep declarations found in unreachable code
Mihai Bazon [Fri, 7 Sep 2012 12:18:32 +0000 (15:18 +0300)]
always keep declarations found in unreachable code

a few more tests and some cleanups.

12 years agofixed tests (need to drop the toplevel block in "expected" if it's a single statement)
Mihai Bazon [Fri, 7 Sep 2012 08:22:01 +0000 (11:22 +0300)]
fixed tests (need to drop the toplevel block in "expected" if it's a single statement)

12 years agodon't duplicate argument names
Mihai Bazon [Wed, 5 Sep 2012 15:19:30 +0000 (18:19 +0300)]
don't duplicate argument names

12 years agodeclared `--stats` as boolean
Mihai Bazon [Wed, 5 Sep 2012 15:19:24 +0000 (18:19 +0300)]
declared `--stats` as boolean

12 years agofix for variable names like `toString`
Mihai Bazon [Wed, 5 Sep 2012 11:31:05 +0000 (14:31 +0300)]
fix for variable names like `toString`

12 years agosupport for hoisting declarations
Mihai Bazon [Wed, 5 Sep 2012 10:43:34 +0000 (13:43 +0300)]
support for hoisting declarations

and finally it seems we beat v1 in terms of compression

12 years agocleaned up usage of AST_BlockStatement
Mihai Bazon [Wed, 5 Sep 2012 08:31:02 +0000 (11:31 +0300)]
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).

12 years agocheckpoint
Mihai Bazon [Tue, 4 Sep 2012 12:36:14 +0000 (15:36 +0300)]
checkpoint

12 years agomore fiddling with boolean expressions, etc.
Mihai Bazon [Tue, 4 Sep 2012 10:20:28 +0000 (13:20 +0300)]
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).

12 years agoif present, the `else` in an `if` should always be forced statement
Mihai Bazon [Tue, 4 Sep 2012 10:17:13 +0000 (13:17 +0300)]
if present, the `else` in an `if` should always be forced statement

12 years agoboolean and if/exit optimizations
Mihai Bazon [Mon, 3 Sep 2012 20:49:57 +0000 (23:49 +0300)]
boolean and if/exit optimizations

12 years agominor
Mihai Bazon [Mon, 3 Sep 2012 16:43:46 +0000 (19:43 +0300)]
minor

12 years agomore optimizations for ifs/conditionals
Mihai Bazon [Mon, 3 Sep 2012 16:38:45 +0000 (19:38 +0300)]
more optimizations for ifs/conditionals

(XXX: should add tests before anything else)

12 years agoresolve constant expressions
Mihai Bazon [Mon, 3 Sep 2012 12:47:15 +0000 (15:47 +0300)]
resolve constant expressions

12 years agojumps, try and definitions are statements too
Mihai Bazon [Mon, 3 Sep 2012 09:39:02 +0000 (12:39 +0300)]
jumps, try and definitions are statements too

12 years agoan AST_If is too a StatementWithBody
Mihai Bazon [Mon, 3 Sep 2012 09:11:44 +0000 (12:11 +0300)]
an AST_If is too a StatementWithBody

12 years agoa LabeledStatement should be in fact a StatementWithBody
Mihai Bazon [Mon, 3 Sep 2012 09:05:10 +0000 (12:05 +0300)]
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)

12 years agodeclare boolean options
Mihai Bazon [Mon, 3 Sep 2012 09:03:45 +0000 (12:03 +0300)]
declare boolean options

12 years agoswitch branches must be declared `required` so that the compressor doesn't
Mihai Bazon [Mon, 3 Sep 2012 08:05:59 +0000 (11:05 +0300)]
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.

12 years agoReverting "minor perf. improvements"
Mihai Bazon [Mon, 3 Sep 2012 07:26:23 +0000 (10:26 +0300)]
Reverting "minor perf. improvements"
Revert "minor perf. improvements"

This reverts commit 24bfd55a22afd791d4a97694641831cfbd27fb14.

broke the parser somehow; too early to optimize, let's get the other stuff running.

12 years agoadd -b
Mihai Bazon [Mon, 3 Sep 2012 07:14:15 +0000 (10:14 +0300)]
add -b

12 years agoadd source mappings for more node types; started CLI utility
Mihai Bazon [Sun, 2 Sep 2012 11:32:00 +0000 (14:32 +0300)]
add source mappings for more node types; started CLI utility

12 years agominor perf. improvements
Mihai Bazon [Sun, 2 Sep 2012 08:11:39 +0000 (11:11 +0300)]
minor perf. improvements

12 years agostarted support for generating source maps (WIP)
Mihai Bazon [Wed, 29 Aug 2012 16:39:19 +0000 (19:39 +0300)]
started support for generating source maps (WIP)

plugged in @fitzgen's source-map library

12 years agodon't mangle names of setters/getters
Mihai Bazon [Wed, 29 Aug 2012 16:26:48 +0000 (19:26 +0300)]
don't mangle names of setters/getters

12 years agoupdate with link to discussion about Esprima vs. UglifyJS speed
Mihai Bazon [Wed, 29 Aug 2012 08:18:05 +0000 (11:18 +0300)]
update with link to discussion about Esprima vs. UglifyJS speed

12 years agodocstring for AST_StatementWithBody
Mihai Bazon [Tue, 28 Aug 2012 12:39:53 +0000 (15:39 +0300)]
docstring for AST_StatementWithBody

12 years agofix output for arrays containing undefined values
Mihai Bazon [Tue, 28 Aug 2012 12:38:35 +0000 (15:38 +0300)]
fix output for arrays containing undefined values

[1,,2,] ==> [1,,2] instead of [1,undefined,2]

12 years agofix code generator for this case:
Mihai Bazon [Tue, 28 Aug 2012 12:29:58 +0000 (15:29 +0300)]
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`)

12 years agoadded README
Mihai Bazon [Mon, 27 Aug 2012 09:29:53 +0000 (12:29 +0300)]
added README

12 years agominor
Mihai Bazon [Mon, 27 Aug 2012 08:48:07 +0000 (11:48 +0300)]
minor

12 years agoupdate (c) years
Mihai Bazon [Mon, 27 Aug 2012 08:01:27 +0000 (11:01 +0300)]
update (c) years

12 years agominor
Mihai Bazon [Mon, 27 Aug 2012 08:00:26 +0000 (11:00 +0300)]
minor

12 years agofix compressing `a,b; return c;` into `return a,b,c;`
Mihai Bazon [Mon, 27 Aug 2012 08:00:22 +0000 (11:00 +0300)]
fix compressing `a,b; return c;` into `return a,b,c;`

12 years agoadded print_to_string helper method
Mihai Bazon [Mon, 27 Aug 2012 07:59:33 +0000 (10:59 +0300)]
added print_to_string helper method

12 years agofix current_col and force a newline every 32K (support options.max_line_len)
Mihai Bazon [Thu, 23 Aug 2012 07:39:33 +0000 (10:39 +0300)]
fix current_col and force a newline every 32K (support options.max_line_len)

12 years agoadded license
Mihai Bazon [Wed, 22 Aug 2012 18:28:59 +0000 (21:28 +0300)]
added license

12 years agowrote more of the compressor and added some tests
Mihai Bazon [Wed, 22 Aug 2012 12:21:58 +0000 (15:21 +0300)]
wrote more of the compressor and added some tests

12 years agofix output for certain edge cases
Mihai Bazon [Wed, 22 Aug 2012 10:20:05 +0000 (13:20 +0300)]
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.

12 years agodeclare some properties in the node constructor so that they're copied in clone
Mihai Bazon [Tue, 21 Aug 2012 17:06:57 +0000 (20:06 +0300)]
declare some properties in the node constructor so that they're copied in clone

12 years agohint that brackets may be required in AST_BlockStatement
Mihai Bazon [Tue, 21 Aug 2012 13:27:57 +0000 (16:27 +0300)]
hint that brackets may be required in AST_BlockStatement

12 years agocleaned up some mess and started the actual compressor
Mihai Bazon [Tue, 21 Aug 2012 12:45:05 +0000 (15:45 +0300)]
cleaned up some mess and started the actual compressor

12 years agosome reorganization
Mihai Bazon [Tue, 21 Aug 2012 09:55:56 +0000 (12:55 +0300)]
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.)

12 years agohandle labels properly
Mihai Bazon [Tue, 21 Aug 2012 09:37:05 +0000 (12:37 +0300)]
handle labels properly

(they can't be handled the same way as variables in a scope)

12 years agowarn about unreferenced symbols
Mihai Bazon [Tue, 21 Aug 2012 08:53:19 +0000 (11:53 +0300)]
warn about unreferenced symbols

12 years agomore fixes:
Mihai Bazon [Tue, 21 Aug 2012 08:38:49 +0000 (11:38 +0300)]
more fixes:

- added walker for AST_ObjectProperty
- handle redefinitions properly (only mangle one symbol, make them all point
  to a single definition)

DynarchLIB seems to run fine after mangling + compressed output.

12 years agoadded mangler and other stuff
Mihai Bazon [Mon, 20 Aug 2012 14:19:30 +0000 (17:19 +0300)]
added mangler and other stuff

12 years agodoc (WIP)
Mihai Bazon [Sun, 19 Aug 2012 19:46:00 +0000 (22:46 +0300)]
doc (WIP)

12 years agosimple visitor API and code to figure out scope and references
Mihai Bazon [Sun, 19 Aug 2012 12:57:50 +0000 (15:57 +0300)]
simple visitor API and code to figure out scope and references

12 years agosome fixes (need testing) in AST_If codegen
Mihai Bazon [Sat, 18 Aug 2012 09:29:57 +0000 (12:29 +0300)]
some fixes (need testing) in AST_If codegen

12 years agominor whitespace issues
Mihai Bazon [Fri, 17 Aug 2012 20:08:09 +0000 (23:08 +0300)]
minor whitespace issues

12 years agobig speed improvement (observable when beautify = false)
Mihai Bazon [Fri, 17 Aug 2012 16:04:23 +0000 (19:04 +0300)]
big speed improvement (observable when beautify = false)

who would have thought that str.charAt(str.length - 1) is not a constant,
instant operation?  seems to get slower and slower as the string grows.

0.6s vs. 3s

12 years agodon't output both space and semicolon when beautify=false
Mihai Bazon [Fri, 17 Aug 2012 15:33:26 +0000 (18:33 +0300)]
don't output both space and semicolon when beautify=false

12 years agoadded some comments about the rules governing parens
Mihai Bazon [Fri, 17 Aug 2012 14:56:16 +0000 (17:56 +0300)]
added some comments about the rules governing parens

12 years agofix one more glitch
Mihai Bazon [Fri, 17 Aug 2012 13:27:43 +0000 (16:27 +0300)]
fix one more glitch

12 years agocode generator finally seems to work properly
Mihai Bazon [Fri, 17 Aug 2012 12:59:42 +0000 (15:59 +0300)]
code generator finally seems to work properly

12 years agolots'o'fixes in the output routines; still a looong way to go.
Mihai Bazon [Thu, 16 Aug 2012 16:54:37 +0000 (19:54 +0300)]
lots'o'fixes in the output routines; still a looong way to go.

12 years agocodegen and dropped the useless walker
Mihai Bazon [Thu, 16 Aug 2012 15:11:04 +0000 (18:11 +0300)]
codegen and dropped the useless walker

12 years agoWIP
Mihai Bazon [Wed, 15 Aug 2012 10:32:37 +0000 (13:32 +0300)]
WIP

12 years agoWIP
Mihai Bazon [Sun, 27 May 2012 14:25:31 +0000 (17:25 +0300)]
WIP

12 years agoadded small node test script
Mihai Bazon [Sun, 27 May 2012 11:36:51 +0000 (14:36 +0300)]
added small node test script

12 years agoFixes some gotchas.
Mihai Bazon [Sun, 27 May 2012 11:36:44 +0000 (14:36 +0300)]
Fixes some gotchas.

DynarchLIB (660K) now passes parsing in 440ms (about 30% slower than the
parser in UglifyJS v1).

12 years agoinit repo
Mihai Bazon [Sun, 27 May 2012 11:09:01 +0000 (14:09 +0300)]
init repo