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