Mihai Bazon
30faaf13ed
more sequence optimizations (lift some sequences above binary/unary expressions so that we can avoid parens)
2012-10-22 11:58:06 +03:00
Mihai Bazon
afb7faa6fa
more optimizations for some break/continue cases
2012-10-18 15:14:57 +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
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
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
a84d07e312
add AST_Infinity node
2012-10-09 18:35:53 +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
dd8286bce1
added --self to easily get a browser-runnable version of UglifyJS
2012-10-08 12:55:18 +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
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
896444482a
minor
2012-09-28 11:12:47 +03:00
Mihai Bazon
a24e7ee976
checkpoint (refactoring, WIP)
2012-09-26 12:16:16 +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
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
a4d2340c73
fixed label scope/mangling
2012-09-18 19:26:46 +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
4e0262bdfb
figure out label targets
2012-09-15 16:05:17 +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
8e82d8d94c
fixed some mess with symbols/scope
...
- all symbols now have a `thedef` property which is a SymbolDef object,
instead of the `uniq` that we had before (pointing to the first occurrence
of the name as declaration).
- for undeclared symbols we still create a SymbolDef object in the toplevel
scope but mark it "undeclared"
- we can now call figure_out_scope after squeezing, which is useful in order
not to mangle names that were dropped by the squeezer
2012-09-11 15:42:28 +03:00
Mihai Bazon
43c75c9248
checkpoint
2012-09-07 18:55:13 +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
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
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
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
86cff2029f
docstring for AST_StatementWithBody
2012-08-28 15:39:53 +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
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
159a6f048c
wrote more of the compressor and added some tests
2012-08-22 15:21:58 +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
99456c6156
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.
2012-08-21 11:38:49 +03:00
Mihai Bazon
458e251d7e
added mangler and other stuff
2012-08-20 17:32:35 +03:00
Mihai Bazon
1fe0ff9fff
doc (WIP)
2012-08-20 00:35:54 +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
562b12f021
init repo
2012-05-27 14:13:26 +03:00