a zip code crypto-currency system good for red ONLY

transform.js 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. "use strict";
  34. // Tree transformer helpers.
  35. function TreeTransformer(before, after) {
  36. TreeWalker.call(this);
  37. this.before = before;
  38. this.after = after;
  39. }
  40. TreeTransformer.prototype = new TreeWalker;
  41. (function(undefined){
  42. function _(node, descend) {
  43. node.DEFMETHOD("transform", function(tw, in_list){
  44. var x, y;
  45. tw.push(this);
  46. if (tw.before) x = tw.before(this, descend, in_list);
  47. if (x === undefined) {
  48. if (!tw.after) {
  49. x = this;
  50. descend(x, tw);
  51. } else {
  52. tw.stack[tw.stack.length - 1] = x = this;
  53. descend(x, tw);
  54. y = tw.after(x, in_list);
  55. if (y !== undefined) x = y;
  56. }
  57. }
  58. tw.pop();
  59. return x;
  60. });
  61. };
  62. function do_list(list, tw) {
  63. return MAP(list, function(node){
  64. return node.transform(tw, true);
  65. });
  66. };
  67. _(AST_Node, noop);
  68. _(AST_LabeledStatement, function(self, tw){
  69. self.label = self.label.transform(tw);
  70. self.body = self.body.transform(tw);
  71. });
  72. _(AST_SimpleStatement, function(self, tw){
  73. self.body = self.body.transform(tw);
  74. });
  75. _(AST_Block, function(self, tw){
  76. self.body = do_list(self.body, tw);
  77. });
  78. _(AST_DWLoop, function(self, tw){
  79. self.condition = self.condition.transform(tw);
  80. self.body = self.body.transform(tw);
  81. });
  82. _(AST_For, function(self, tw){
  83. if (self.init) self.init = self.init.transform(tw);
  84. if (self.condition) self.condition = self.condition.transform(tw);
  85. if (self.step) self.step = self.step.transform(tw);
  86. self.body = self.body.transform(tw);
  87. });
  88. _(AST_ForIn, function(self, tw){
  89. self.init = self.init.transform(tw);
  90. self.object = self.object.transform(tw);
  91. self.body = self.body.transform(tw);
  92. });
  93. _(AST_With, function(self, tw){
  94. self.expression = self.expression.transform(tw);
  95. self.body = self.body.transform(tw);
  96. });
  97. _(AST_Exit, function(self, tw){
  98. if (self.value) self.value = self.value.transform(tw);
  99. });
  100. _(AST_LoopControl, function(self, tw){
  101. if (self.label) self.label = self.label.transform(tw);
  102. });
  103. _(AST_If, function(self, tw){
  104. self.condition = self.condition.transform(tw);
  105. self.body = self.body.transform(tw);
  106. if (self.alternative) self.alternative = self.alternative.transform(tw);
  107. });
  108. _(AST_Switch, function(self, tw){
  109. self.expression = self.expression.transform(tw);
  110. self.body = do_list(self.body, tw);
  111. });
  112. _(AST_Case, function(self, tw){
  113. self.expression = self.expression.transform(tw);
  114. self.body = do_list(self.body, tw);
  115. });
  116. _(AST_Try, function(self, tw){
  117. self.body = do_list(self.body, tw);
  118. if (self.bcatch) self.bcatch = self.bcatch.transform(tw);
  119. if (self.bfinally) self.bfinally = self.bfinally.transform(tw);
  120. });
  121. _(AST_Catch, function(self, tw){
  122. self.argname = self.argname.transform(tw);
  123. self.body = do_list(self.body, tw);
  124. });
  125. _(AST_Definitions, function(self, tw){
  126. self.definitions = do_list(self.definitions, tw);
  127. });
  128. _(AST_VarDef, function(self, tw){
  129. self.name = self.name.transform(tw);
  130. if (self.value) self.value = self.value.transform(tw);
  131. });
  132. _(AST_Destructuring, function(self, tw) {
  133. self.names = do_list(self.names, tw);
  134. });
  135. _(AST_Lambda, function(self, tw){
  136. if (self.name) self.name = self.name.transform(tw);
  137. self.argnames = do_list(self.argnames, tw);
  138. if (self.body instanceof AST_Node) {
  139. self.body = self.body.transform(tw);
  140. } else {
  141. self.body = do_list(self.body, tw);
  142. }
  143. });
  144. _(AST_Call, function(self, tw){
  145. self.expression = self.expression.transform(tw);
  146. self.args = do_list(self.args, tw);
  147. });
  148. _(AST_Sequence, function(self, tw){
  149. self.expressions = do_list(self.expressions, tw);
  150. });
  151. _(AST_Dot, function(self, tw){
  152. self.expression = self.expression.transform(tw);
  153. });
  154. _(AST_Sub, function(self, tw){
  155. self.expression = self.expression.transform(tw);
  156. self.property = self.property.transform(tw);
  157. });
  158. _(AST_Yield, function(self, tw){
  159. if (self.expression) self.expression = self.expression.transform(tw);
  160. });
  161. _(AST_Await, function(self, tw){
  162. self.expression = self.expression.transform(tw);
  163. });
  164. _(AST_Unary, function(self, tw){
  165. self.expression = self.expression.transform(tw);
  166. });
  167. _(AST_Binary, function(self, tw){
  168. self.left = self.left.transform(tw);
  169. self.right = self.right.transform(tw);
  170. });
  171. _(AST_Conditional, function(self, tw){
  172. self.condition = self.condition.transform(tw);
  173. self.consequent = self.consequent.transform(tw);
  174. self.alternative = self.alternative.transform(tw);
  175. });
  176. _(AST_Array, function(self, tw){
  177. self.elements = do_list(self.elements, tw);
  178. });
  179. _(AST_Object, function(self, tw){
  180. self.properties = do_list(self.properties, tw);
  181. });
  182. _(AST_ObjectProperty, function(self, tw){
  183. if (self.key instanceof AST_Node) {
  184. self.key = self.key.transform(tw);
  185. }
  186. self.value = self.value.transform(tw);
  187. });
  188. _(AST_Class, function(self, tw){
  189. if (self.name) self.name = self.name.transform(tw);
  190. if (self.extends) self.extends = self.extends.transform(tw);
  191. self.properties = do_list(self.properties, tw);
  192. });
  193. _(AST_Expansion, function(self, tw){
  194. self.expression = self.expression.transform(tw);
  195. });
  196. _(AST_NameMapping, function(self, tw) {
  197. self.foreign_name = self.foreign_name.transform(tw);
  198. self.name = self.name.transform(tw);
  199. });
  200. _(AST_Import, function(self, tw) {
  201. if (self.imported_name) self.imported_name = self.imported_name.transform(tw);
  202. if (self.imported_names) do_list(self.imported_names, tw);
  203. self.module_name = self.module_name.transform(tw);
  204. });
  205. _(AST_Export, function(self, tw) {
  206. if (self.exported_definition) self.exported_definition = self.exported_definition.transform(tw);
  207. if (self.exported_value) self.exported_value = self.exported_value.transform(tw);
  208. if (self.exported_names) do_list(self.exported_names, tw);
  209. if (self.module_name) self.module_name = self.module_name.transform(tw);
  210. });
  211. _(AST_TemplateString, function(self, tw) {
  212. self.segments = do_list(self.segments, tw);
  213. });
  214. _(AST_PrefixedTemplateString, function(self, tw) {
  215. self.template_string = self.template_string.transform(tw);
  216. });
  217. })();