1 | /***********************************************************************
|
---|
2 |
|
---|
3 | A JavaScript tokenizer / parser / beautifier / compressor.
|
---|
4 | https://github.com/mishoo/UglifyJS2
|
---|
5 |
|
---|
6 | -------------------------------- (C) ---------------------------------
|
---|
7 |
|
---|
8 | Author: Mihai Bazon
|
---|
9 | <mihai.bazon@gmail.com>
|
---|
10 | http://mihai.bazon.net/blog
|
---|
11 |
|
---|
12 | Distributed under the BSD license:
|
---|
13 |
|
---|
14 | Copyright 2012 (c) Mihai Bazon <mihai.bazon@gmail.com>
|
---|
15 |
|
---|
16 | Redistribution and use in source and binary forms, with or without
|
---|
17 | modification, are permitted provided that the following conditions
|
---|
18 | are met:
|
---|
19 |
|
---|
20 | * Redistributions of source code must retain the above
|
---|
21 | copyright notice, this list of conditions and the following
|
---|
22 | disclaimer.
|
---|
23 |
|
---|
24 | * Redistributions in binary form must reproduce the above
|
---|
25 | copyright notice, this list of conditions and the following
|
---|
26 | disclaimer in the documentation and/or other materials
|
---|
27 | provided with the distribution.
|
---|
28 |
|
---|
29 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
|
---|
30 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
31 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
---|
32 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
---|
33 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
---|
34 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
35 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
36 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
37 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
---|
38 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
---|
39 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
40 | SUCH DAMAGE.
|
---|
41 |
|
---|
42 | ***********************************************************************/
|
---|
43 |
|
---|
44 | // bitfield flags to be stored in node.flags.
|
---|
45 | // These are set and unset during compression, and store information in the node without requiring multiple fields.
|
---|
46 | export const UNUSED = 0b00000001;
|
---|
47 | export const TRUTHY = 0b00000010;
|
---|
48 | export const FALSY = 0b00000100;
|
---|
49 | export const UNDEFINED = 0b00001000;
|
---|
50 | export const INLINED = 0b00010000;
|
---|
51 |
|
---|
52 | // Nodes to which values are ever written. Used when keep_assign is part of the unused option string.
|
---|
53 | export const WRITE_ONLY = 0b00100000;
|
---|
54 |
|
---|
55 | // information specific to a single compression pass
|
---|
56 | export const SQUEEZED = 0b0000000100000000;
|
---|
57 | export const OPTIMIZED = 0b0000001000000000;
|
---|
58 | export const TOP = 0b0000010000000000;
|
---|
59 | export const CLEAR_BETWEEN_PASSES = SQUEEZED | OPTIMIZED | TOP;
|
---|
60 |
|
---|
61 | export const has_flag = (node, flag) => node.flags & flag;
|
---|
62 | export const set_flag = (node, flag) => { node.flags |= flag; };
|
---|
63 | export const clear_flag = (node, flag) => { node.flags &= ~flag; };
|
---|