compressor-flags.js 2.7 KB

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