Commit Graph

139 Commits

Author SHA1 Message Date
Mihai Bazon
a5b209470c Fix end token for Assign nodes 2013-02-01 13:32:15 +02:00
David Glasser
1529ab965a Fix output for arrays containing undefined values.
1b6bcca7 was a first attempt at this. That commit made Uglify stop replacing
holes with undefined, but instead it started replacing undefined with
holes. This is slightly problematic, because there is a difference between a
hole and an undefined value. More problematically, it changed [1,undefined] to
[1,] which generally doesn't even parse as a hole (just as a trailing comma), so
it didn't even preserve the length of the array!

Instead, parse holes as their own special AST node which prints invisibly.
2013-01-17 11:36:10 +02:00
Mihai Bazon
9916d0e547 Accept string or number as name of an accessor.
[not sure I'm happy about this fix]

Reference mishoo/UglifyJS#478
2012-12-22 01:24:04 +02:00
Mihai Bazon
5276a4a873 add AST_Accessor and AST_SymbolAccessor node types
AST_Accessor will represent the function for a setter or getter.  Since they
are not mangleable, and they should not introduce a name in scope, we have a
new node for their name (AST_SymbolAccessor) which doesn't inherit from
AST_SymbolDeclaration.

fix #37
2012-11-07 12:43:27 +02:00
Mihai Bazon
708abb1ab1 minor 2012-10-13 12:42:01 +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
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
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
075f93ec0d line numbers start at 1 2012-10-02 16:39:53 +03:00
Mihai Bazon
e1098b04a7 "use strict"; 2012-10-02 12:45:58 +03:00
Mihai Bazon
347160c631 add AST_SymbolConst for names defined with const 2012-10-02 12:22:39 +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
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
3da0ac4897 support for directives 2012-09-18 13:21:09 +03:00
Mihai Bazon
924aa58060 more optimizations that v1 does and some cleanups
- a = a + x ==> a+=x
- joining consecutive var statements (hoisting is not always desirable)
- x == false ==> x == 0, x != true ==> x != 1
- x, x ==> x; x = exp(), x ==> x = exp()
- discarding useless break-s
2012-09-14 15:36:38 +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
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
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
24bfd55a22 minor perf. improvements 2012-09-02 11:11:39 +03:00
Mihai Bazon
58a3b5e93f update (c) years 2012-08-27 11:01:41 +03:00
Mihai Bazon
95b18e54a4 added license 2012-08-22 21:28:59 +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
6c35135ace simple visitor API and code to figure out scope and references 2012-08-19 15:57:50 +03:00
Mihai Bazon
13f7b119bb code generator finally seems to work properly 2012-08-17 15:59:42 +03:00
Mihai Bazon
c7c163b82e lots'o'fixes in the output routines; still a looong way to go. 2012-08-16 21:36:16 +03:00
Mihai Bazon
7f273c3b89 codegen and dropped the useless walker 2012-08-16 18:11:04 +03:00
Mihai Bazon
c0ba9e2986 WIP 2012-08-15 14:50:27 +03:00
Mihai Bazon
861e26a666 WIP 2012-06-03 23:10:31 +03:00
Mihai Bazon
46e7507b44 Fixes some gotchas.
DynarchLIB (660K) now passes parsing in 440ms (about 30% slower than the
parser in UglifyJS v1).
2012-05-27 14:36:44 +03:00
Mihai Bazon
562b12f021 init repo 2012-05-27 14:13:26 +03:00