kzc
73d6438773
fix \\n and \\r in template strings ( #1857 )
...
fixes #1856
2017-04-30 17:05:32 +08:00
kzc
5c6316a37d
fix class method formatting ( #1853 )
...
fixes #1852
2017-04-29 18:13:25 +08:00
alexlamsl
0d8597e904
Merge branch 'master' into harmony-v2.8.22
2017-04-09 15:50:38 +08:00
Alex Lam S.L
d6fbc365e2
fix LHS cases for NaN & friends ( #1804 )
...
`Infinity = beyond` should not become `1/0 = beyond`
2017-04-09 03:18:14 +08:00
Alex Lam S.L
0479ff0c54
fix a couple of bugs in global_defs ( #1802 )
...
- `optimize()` substituted expression
- compute nested property string correctly
fixes #1801
Miscellaneous
- reset optimisation flags on all node types
2017-04-08 16:46:25 +08:00
Alex Lam S.L
cf72fe552f
fix delete corner cases ( #1799 )
...
- assignment
- boolean
- conditional
- sequence
2017-04-08 14:25:28 +08:00
Alex Lam S.L
c2a1bceb77
fix pure_getters for chained property access ( #1798 )
2017-04-07 17:06:01 +08:00
Alex Lam S.L
e3c9c22c75
fix corner cases with delete ( #1796 )
...
`delete Infinity` returns `false` where as `delete (1/0)` returns `true`
2017-04-07 15:39:59 +08:00
Alex Lam S.L
0f4cd73dcc
introduce "strict" to pure_getters ( #1795 )
2017-04-07 13:31:58 +08:00
Alex Lam S.L
281e882d27
fix reduce_vars on catch variable ( #1794 )
...
Improved catch handling in `figure_out_scope()` means special case treatment of IE8 is no longer valid in `reset_opt_flags()`.
Also fixed recursive assignment in variable definition.
2017-04-07 12:32:56 +08:00
Alex Lam S.L
cc6aa3e5ac
fix incorrect context in variable substitution ( #1791 )
...
`AST_Node.optimize()` is context-aware, so don't cache its results to be used elsewhere.
Also fixed a few cases of AST corruption and beef up safety of `pure_getters`.
2017-04-07 03:42:17 +08:00
Alex Lam S.L
e869779a98
enable inline_script by default ( #1793 )
2017-04-07 00:45:51 +08:00
Alex Lam S.L
06cdb74279
improve pure_getters ( #1786 )
...
- property access to `null` & `undefined` always has side effects
- utilise `reduce_vars` to determine safe property access
- may-be cases treated as side effects unless `unsafe`
2017-04-06 11:18:59 +08:00
Alex Lam S.L
ff289b90a9
implement delayed resolution for reduce_vars ( #1788 )
...
Although it would be nice to enforce `AST_Node` cloning during transformation, that ship has sailed a long time ago.
We now get the assigned value when resolving `AST_SymbolRef` instead of `reset_opt_flags()`, which has the added advantage of improved compressor efficiency.
fixes #1787
2017-04-05 21:06:42 +08:00
Alex Lam S.L
9b6bc67c33
optimise do{...}while(false) ( #1785 )
...
- better heuristics to avoid issues like #1532
- fix `TreeWalker.loopcontrol_target()`
- `continue` cannot refer to `switch` blocks
2017-04-04 23:48:22 +08:00
Anthony Van de Gejuchte
c20bb99a62
Put expression after extend between parentheses if necessary ( #1780 )
2017-04-04 12:38:13 +08:00
Alex Lam S.L
951770fc68
exclude mangling of special property names ( #1779 )
...
- `null`
- `true`
- `false`
- numeric literals
2017-04-04 03:50:19 +08:00
Anthony Van de Gejuchte
2377171200
Fix walker not able to handle destr pattern in spread when compressing ( #1438 )
2017-04-04 01:23:22 +08:00
Anthony Van de Gejuchte
603d92effc
Allow AST_DefaultAssign as parameter ( #1778 )
...
This may be the case for parsing arrow functions,
as left side expressions are converted to destructuring patterns
before being converted to parameters.
2017-04-04 00:46:05 +08:00
Alex Lam S.L
48b3fe9952
fix mangleProperties on identifiers ( #1776 )
...
- fix handling of "-Infinity"
- add test case for "-0"
reverts #1481
2017-04-03 23:17:47 +08:00
Anthony Van de Gejuchte
17f0cc359f
Allow empty destructuring ( #1773 )
2017-04-03 17:21:27 +08:00
Alex Lam S.L
59a4e56bc8
fix mangleProperties of undefined & Infinity ( #1772 )
...
`NaN` already works by the happy accident of `Number.NaN`
fixes #1770
2017-04-03 12:31:05 +08:00
alexlamsl
4614b5b46e
Merge branch 'master' into harmony-v2.8.21
2017-04-02 17:25:20 +08:00
Alex Lam S.L
9469c03ac9
fix corner case in switch ( #1765 )
2017-04-02 17:07:20 +08:00
Alex Lam S.L
d57527697f
avoid confusion of NaN & Infinity with catch symbol of the same name ( #1763 )
...
fixes #1760
fixes #1761
2017-04-02 16:14:09 +08:00
Alex Lam S.L
f7ca4f2297
fix corner cases in switch and undefined ( #1762 )
...
- fix side effects in switch condition for singular blocks
- fix `undefined` confusion with local variable
- gate `OPT(AST_Switch)` with `switches`
fixes #1758
fixes #1759
2017-04-02 14:52:25 +08:00
Alex Lam S.L
ee3fe0f4cd
fix switch branch elimination ( #1752 )
...
Merge unreachable case body with previous fallthrough case
fixes #1750
2017-04-01 17:19:57 +08:00
Alex Lam S.L
257ddc3bdb
improve compression of undefined, NaN & Infinitiy ( #1748 )
...
- migrate transformation logic from `OutputStream` to `Compressor`
- always turn `undefined` into `void 0` (unless `unsafe`)
- always keep `NaN` except when avoiding local variable redefinition
- introduce `keep_infinity` to suppress `1/0` transform, except when avoiding local variable redefinition
supersedes #1723
fixes #1730
2017-04-01 03:02:14 +08:00
Alex Lam S.L
1ddc05725d
combine rules for binary boolean operations ( #1744 )
2017-03-31 18:47:44 +08:00
Ondřej Španěl
2f93058c6e
More variants of import added ( #1738 )
...
- `import * from "x.js"`
- `import * as Name from "x.js"`
2017-03-31 17:52:56 +08:00
Ondřej Španěl
a729c43e87
Another variant of export added - export {Name}. ( #1737 )
2017-03-31 17:51:27 +08:00
Alex Lam S.L
a0c3836ba0
sort options in alphabetical order ( #1743 )
...
They started off as functional groups I guess, but given the sheer number of options this is becoming too difficult to read.
2017-03-31 16:41:04 +08:00
Alex Lam S.L
11e9bdc427
fix missing preamble when shebang is absent ( #1742 )
2017-03-31 15:26:57 +08:00
alexlamsl
d717bf9ce8
Merge branch 'master' into harmony
2017-03-31 12:54:03 +08:00
Alex Lam S.L
c595b84032
fix catch symbol mangling ( #1734 )
...
Only need to look up the immediate non-block/catch scope for the same-name special case.
fixes #1733
2017-03-31 02:57:47 +08:00
Ondřej Španěl
5dea52266b
[ES6] Implemented parse for export Name from Module variants. ( #1701 )
...
- add `AST_Export` new variants output
- add tests to `test/compress/`
- update `$propdoc` of `AST_Export` ("exported_names" & "module_name")
- add tests for `export ... as ...` variants
2017-03-30 17:07:50 +08:00
Alex Lam S.L
7cb1adf455
remove paranthesis for -(x*y) ( #1732 )
2017-03-30 16:09:00 +08:00
Alex Lam S.L
7bea38a05d
optimize try-catch-finally ( #1731 )
...
- eliminate empty blocks
- flatten out if try-block does not throw
2017-03-30 12:16:58 +08:00
Alex Lam S.L
beb9659778
speed up IIFE elimination ( #1728 )
...
- `side_effects` will clean up inner statements, so checking for an empty function body should suffice
- drop side effects when dropping `return` from statement
2017-03-29 23:27:35 +08:00
Alex Lam S.L
f1a833a7aa
speed up equivalent_to() and AST_Switch ( #1727 )
2017-03-29 22:08:26 +08:00
Alex Lam S.L
2e41cd6394
fix missing parentheses around NaN/Infinity shorthands ( #1726 )
...
fixes #1724
fixes #1725
2017-03-29 20:53:03 +08:00
Alex Lam S.L
09f77c7d4d
output optimal representations of NaN & Infinity ( #1723 )
...
- move these optimisations out from `Compressor` to `OutputStream`
- fixes behaviour inconsistency when running uglified code from global or module levels due to redefinition
2017-03-29 18:31:55 +08:00
Alex Lam S.L
fef0bf9ee0
improve beautified output of switch blocks ( #1721 )
2017-03-29 04:40:05 +08:00
Alex Lam S.L
eb48a035e7
fix corner case in unused ( #1718 )
...
When fixing catch-related issue in #1715 , it tries to optimise for duplicate definitions but did not take anonymous functions into account.
Remove such optimisation for now and we can cover this as a more general rule later.
2017-03-29 01:00:21 +08:00
alexlamsl
1e2b0aaa04
Merge branch 'master' into harmony-v2.8.17
2017-03-28 22:03:46 +08:00
Alex Lam S.L
c909ffb715
fix unused on var of the same name within catch ( #1716 )
...
fixes #1715
2017-03-28 21:25:49 +08:00
Alex Lam S.L
f71f4905b0
fix is_number() on += ( #1714 )
...
fixes #1710
2017-03-28 17:08:16 +08:00
Alex Lam S.L
fb177a6312
drop anonymous function name when overshadowed by other declarations ( #1712 )
...
fixes #1709
2017-03-28 17:02:20 +08:00
Alex Lam S.L
65da9acce6
handle var within catch of the same name ( #1711 )
...
The following code prints `1`:
var a = 1;
!function(){
a = 4;
try{
throw 2;
} catch (a) {
var a = 3;
}
}();
console.log(a);
fixes #1708
2017-03-28 16:42:39 +08:00
Alex Lam S.L
67d0237f73
fix tail trimming of switch blocks ( #1707 )
...
now guarded under `dead_code`
fixes #1705
2017-03-28 03:59:13 +08:00