Commit Graph

53 Commits

Author SHA1 Message Date
Alex Lam S.L
9199ab5846 minor tweaks (#3502) 2019-10-20 15:19:19 +08:00
Alex Lam S.L
2ea96549c5 unify logging functionality (#3392)
fixes #3253
fixes #3254
2019-04-30 06:32:24 +08:00
Alex Lam S.L
cea685f8d9 fix corner case in ie8 (#3216)
fixes #3215
2018-07-19 14:45:36 +08:00
Alex Lam S.L
bcebacbb9e fix corner cases in preserve_line (#3212) 2018-07-13 01:51:10 +08:00
Alex Lam S.L
766a4147d4 enhance arguments (#3193)
fixes #3192
2018-06-24 04:00:21 +08:00
Alex Lam S.L
9e19e63551 general clean-ups (#3175) 2018-06-06 17:50:56 +08:00
Alex Lam S.L
838f837379 improve general performance (#3104) 2018-04-27 04:30:29 +08:00
Alex Lam S.L
81603ecd15 improve performance through makePredicate() (#3048) 2018-04-03 15:15:01 +08:00
Alex Lam S.L
07e4b64f3a fix AST_Scope.clone() (#2803)
fixes #2799
2018-01-17 21:33:13 +08:00
Alex Lam S.L
edb4e3bd52 make comments output more robust (#2633)
- improve handling of comments right after `return`
- retain comments after `OutputStream`
- preserve trailing comments
- fix handling of new line before comments
- handle comments around parentheses

fixes #88
fixes #112
fixes #218
fixes #372
fixes #2629
2017-12-22 04:59:54 +08:00
Alex Lam S.L
c43118be4f remove unused code (#2579)
fixes #2577
2017-12-11 17:39:08 +08:00
Alex Lam S.L
1743621889 clean up lib/parse.js (#2047)
- remove unused definitions
- replace `array_to_hash()`
2017-06-03 14:00:59 +08:00
Alex Lam S.L
2244743545 convert AST_Seq from binary tree to array (#1460)
- rename `AST_Seq` to `AST_Sequence`
- raise default sequences_limit from 200 to 800
2017-04-12 21:56:27 +08:00
Alex Lam S.L
8223b2e0db fix AST_Node.optimize() (#1602)
Liberal use of `Compressor.transform()` and `AST_Node.optimize()` presents an issue for look-up operations like `TreeWalker.in_boolean_context()` and `TreeWalker.parent()`.

This is an incremental fix such that `AST_Node.optimize()` would now contain the correct stack information when called correctly.
2017-03-15 18:44:13 +08:00
Alex Lam S.L
c2334baa48 fix crash on missing props to string_template() (#1523)
Patched up `make_node()` without `orig`.

There may be other cases where `start` could be missing, so make it print "undefined" instead of crashing.

fixes #1518
2017-03-01 15:25:26 +08:00
Alex Lam S.L
872270b149 improve error messages (#1506)
- better inheritance of `Error` sub-classes
- mark parse error against source in CLI

closes #235
closes #348
closes #524
closes #1356
closes #1405
2017-02-27 03:40:54 +08:00
alexlamsl
f0ff6189be clean up negate_iife
- remove extra tree scanning phase for `negate_iife`
- `negate_iife` now only deals with the narrowest form, i.e. IIFE sitting directly under `AST_SimpleStatement`
- `booleans`, `conditionals` etc. will now take care the rest via more accurate accounting
- `a(); void b();` => `a(); b();`

fixes #1288
closes #1451
2017-02-21 13:29:58 +08:00
Anthony Van de Gejuchte
79b98a9fe8 Do not overwrite options.comments + cleanup 2016-11-29 20:24:08 +01:00
Anthony Van de Gejuchte
a97690fc72 Various LineTerminator changes
* Escaped newlines should also produce SyntaxError
* Fix multiline comment parsing and add tests
* Adapt makePredicate to handle \u2028 and \u2029
* Move up nlb check in regex so it's checked before any escape handling
* Change error messages to conform ecma standard
* Find_eol not recornizing \u2028 and \u2029 as line terminator
* Remove \u180e as it is removed in unicode 6.3.0 from the category zs
2016-06-30 22:12:50 +02:00
kzc
c70d176f35 Simplify member(name, array) implementation. 2016-04-07 09:57:30 -04:00
Mihai Bazon
9317237372 Avoid using inherited hasOwnProperty
Fix #1031
2016-04-07 13:16:22 +03:00
Mihai Bazon
ea3430102c Add property name mangler
We only touch properties that are present in an object literal, or which are
assigned to.  Example:

    x = { foo: 1 };
    x.bar = 2;
    x["baz"] = 3;
    x[cond ? "qwe" : "asd"] = 4;
    console.log(x.stuff);

The names "foo", "bar", "baz", "qwe" and "asd" will be mangled, and the
resulting mangled names will be used for the same properties throughout the
code.  The "stuff" will not be, since it's just referenced but never
assigned to.

This *will* break most of the code out there, but could work on carefully
written code: do not use eval, do not define methods or properties by
walking an array of names, etc.  Also, a comprehensive list of exclusions
needs to be passed, to avoid mangling properties that are standard in
JavaScript, DOM, used in external libraries etc.
2015-03-14 11:22:28 +02:00
Mihai Bazon
bd0886a2c0 semicolons 2013-12-10 20:24:27 +02:00
Mihai Bazon
248f304f02 Merge pull request #245 from ForbesLindesay/patch-1
Make `DefaultsError` a real `Error` object
2013-12-10 10:23:29 -08:00
Mihai Bazon
c16d538ce7 Add --noerr to turn off argument name checking
for now only used for keys passed to `-c` or `-b`.
2013-11-28 13:15:01 +02:00
Forbes Lindesay
dfa395f6ff Make DefaultsError a real Error object 2013-07-22 01:44:03 +01:00
Mihai Bazon
caa8896a8a Only compress code in new Function if all arguments are strings. 2013-05-14 18:36:31 +03:00
Mihai Bazon
320c110b33 When hoisting variables, try to merge in assignments that follow. 2012-12-05 12:30:25 +02:00
Mihai Bazon
a4f6d46118 add option to mangle names even if eval/with is in use
(for more fair comparison to Closure compiler)
2012-11-06 18:19:51 +02:00
Mihai Bazon
8413787efc use a Dictionary object instead of plain object for hashes
to mitigate the `__proto__` issue

related to #30
2012-11-02 10:58:45 +02:00
Mihai Bazon
afb7faa6fa more optimizations for some break/continue cases 2012-10-18 15:14:57 +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
e1098b04a7 "use strict"; 2012-10-02 12:45:58 +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
78be8f5296 compressor successfully moved to TreeTransformer 2012-09-26 14:27:01 +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
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
a132841fb9 more AST_If optimizations 2012-09-12 16:10:03 +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
6b9aeb5325 adaptive base54 digits depending on char frequency (WIP) 2012-09-10 22:29:18 +03:00
Mihai Bazon
a41e6cfabb more progress on the compressor (WIP) 2012-09-10 16:37:05 +03:00
Mihai Bazon
1b5183dd5e checkpoint 2012-09-04 15:36:14 +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
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