author | sundar |
Tue, 12 Jul 2016 21:18:13 +0530 | |
changeset 39662 | e2b36a3779b9 |
parent 30984 | 844283fdfa54 |
child 41422 | 97eda72f53b6 |
permissions | -rw-r--r-- |
29407 | 1 |
/* |
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package jdk.nashorn.api.tree; |
|
27 |
||
28 |
/** |
|
29 |
* A simple implementation of the TreeVisitor for ECMAScript edition 5.1. |
|
30 |
* |
|
31 |
* <p>The visit methods corresponding to ES 5.1 language constructs walk the |
|
32 |
* "components" of the given tree by calling accept method passing the |
|
33 |
* current visitor and the additional parameter. |
|
34 |
* |
|
35 |
* <p>For constructs introduced in later versions, {@code visitUnknown} |
|
36 |
* is called instead which throws {@link UnknownTreeException}. |
|
37 |
* |
|
38 |
* <p> Methods in this class may be overridden subject to their |
|
39 |
* general contract. Note that annotating methods in concrete |
|
40 |
* subclasses with {@link java.lang.Override @Override} will help |
|
41 |
* ensure that methods are overridden as intended. |
|
42 |
* |
|
43 |
* @param <R> the return type of this visitor's methods. Use {@link |
|
44 |
* Void} for visitors that do not need to return results. |
|
45 |
* @param <P> the type of the additional parameter to this visitor's |
|
46 |
* methods. Use {@code Void} for visitors that do not need an |
|
47 |
* additional parameter. |
|
48 |
*/ |
|
49 |
public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> { |
|
50 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
51 |
public R visitAssignment(final AssignmentTree node, final P r) { |
29407 | 52 |
node.getVariable().accept(this, r); |
53 |
node.getExpression().accept(this, r); |
|
54 |
return null; |
|
55 |
} |
|
56 |
||
57 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
58 |
public R visitCompoundAssignment(final CompoundAssignmentTree node, final P r) { |
29407 | 59 |
node.getVariable().accept(this, r); |
60 |
node.getExpression().accept(this, r); |
|
61 |
return null; |
|
62 |
} |
|
63 |
||
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
64 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
65 |
* Visits a {@code ModuleTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
66 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
67 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
68 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
69 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
70 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
71 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
72 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
73 |
public R visitModule(ModuleTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
74 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
75 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
76 |
|
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
77 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
78 |
* Visits an {@code ExportEntryTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
79 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
80 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
81 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
82 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
83 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
84 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
85 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
86 |
public R visitExportEntry(ExportEntryTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
87 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
88 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
89 |
|
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
90 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
91 |
* Visits an {@code ImportEntryTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
92 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
93 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
94 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
95 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
96 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
97 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
98 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
99 |
public R visitImportEntry(ImportEntryTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
100 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
101 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
102 |
|
29407 | 103 |
@Override |
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
104 |
public R visitBinary(final BinaryTree node, final P r) { |
29407 | 105 |
node.getLeftOperand().accept(this, r); |
106 |
node.getRightOperand().accept(this, r); |
|
107 |
return null; |
|
108 |
} |
|
109 |
||
110 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
111 |
public R visitBlock(final BlockTree node, final P r) { |
29407 | 112 |
node.getStatements().forEach((tree) -> { |
113 |
tree.accept(this, r); |
|
114 |
}); |
|
115 |
return null; |
|
116 |
} |
|
117 |
||
118 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
119 |
public R visitBreak(final BreakTree node, final P r) { |
29407 | 120 |
return null; |
121 |
} |
|
122 |
||
123 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
124 |
public R visitCase(final CaseTree node, final P r) { |
29407 | 125 |
final Tree caseVal = node.getExpression(); |
126 |
if (caseVal != null) { |
|
127 |
caseVal.accept(this, r); |
|
128 |
} |
|
129 |
||
130 |
node.getStatements().forEach((tree) -> { |
|
131 |
tree.accept(this, r); |
|
132 |
}); |
|
133 |
return null; |
|
134 |
} |
|
135 |
||
136 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
137 |
public R visitCatch(final CatchTree node, final P r) { |
29407 | 138 |
final Tree cond = node.getCondition(); |
139 |
if (cond != null) { |
|
140 |
cond.accept(this, r); |
|
141 |
} |
|
142 |
node.getParameter().accept(this, r); |
|
143 |
node.getBlock().accept(this, r); |
|
144 |
return null; |
|
145 |
} |
|
146 |
||
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
147 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
148 |
* Visits a {@code ClassDeclarationTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
149 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
150 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
151 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
152 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
153 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
154 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
155 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
156 |
public R visitClassDeclaration(ClassDeclarationTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
157 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
158 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
159 |
|
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
160 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
161 |
* Visits a {@code ClassExpressionTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
162 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
163 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
164 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
165 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
166 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
167 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
168 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
169 |
public R visitClassExpression(ClassExpressionTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
170 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
171 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
172 |
|
29407 | 173 |
@Override |
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
174 |
public R visitConditionalExpression(final ConditionalExpressionTree node, final P r) { |
29407 | 175 |
node.getCondition().accept(this, r); |
176 |
node.getTrueExpression().accept(this, r); |
|
177 |
node.getFalseExpression().accept(this, r); |
|
178 |
return null; |
|
179 |
} |
|
180 |
||
181 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
182 |
public R visitContinue(final ContinueTree node, final P r) { |
29407 | 183 |
return null; |
184 |
} |
|
185 |
||
186 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
187 |
public R visitDebugger(final DebuggerTree node, final P r) { |
29407 | 188 |
return null; |
189 |
} |
|
190 |
||
191 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
192 |
public R visitDoWhileLoop(final DoWhileLoopTree node, final P r) { |
29407 | 193 |
node.getStatement().accept(this, r); |
194 |
node.getCondition().accept(this, r); |
|
195 |
return null; |
|
196 |
} |
|
197 |
||
198 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
199 |
public R visitErroneous(final ErroneousTree node, final P r) { |
29407 | 200 |
return null; |
201 |
} |
|
202 |
||
203 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
204 |
public R visitExpressionStatement(final ExpressionStatementTree node, final P r) { |
29407 | 205 |
node.getExpression().accept(this, r); |
206 |
return null; |
|
207 |
} |
|
208 |
||
209 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
210 |
public R visitForLoop(final ForLoopTree node, final P r) { |
29407 | 211 |
final Tree init = node.getInitializer(); |
212 |
if (init != null) { |
|
213 |
init.accept(this, r); |
|
214 |
} |
|
215 |
||
216 |
final Tree cond = node.getCondition(); |
|
217 |
if (cond != null) { |
|
218 |
cond.accept(this, r); |
|
219 |
} |
|
220 |
||
221 |
final Tree update = node.getUpdate(); |
|
222 |
if (update != null) { |
|
223 |
update.accept(this, r); |
|
224 |
} |
|
225 |
||
226 |
node.getStatement().accept(this, r); |
|
227 |
return null; |
|
228 |
} |
|
229 |
||
230 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
231 |
public R visitForInLoop(final ForInLoopTree node, final P r) { |
29407 | 232 |
node.getVariable().accept(this, r); |
233 |
node.getExpression().accept(this, r); |
|
234 |
final StatementTree stat = node.getStatement(); |
|
235 |
if (stat != null) { |
|
236 |
stat.accept(this, r); |
|
237 |
} |
|
238 |
return null; |
|
239 |
} |
|
240 |
||
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
241 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
242 |
* Visits a {@code ForOfLoopTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
243 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
244 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
245 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
246 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
247 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
248 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
249 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
250 |
public R visitForOfLoop(ForOfLoopTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
251 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
252 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
253 |
|
29407 | 254 |
@Override |
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
255 |
public R visitFunctionCall(final FunctionCallTree node, final P r) { |
29407 | 256 |
node.getFunctionSelect().accept(this, r); |
257 |
node.getArguments().forEach((tree) -> { |
|
258 |
tree.accept(this, r); |
|
259 |
}); |
|
260 |
return null; |
|
261 |
} |
|
262 |
||
263 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
264 |
public R visitFunctionDeclaration(final FunctionDeclarationTree node, final P r) { |
29407 | 265 |
node.getParameters().forEach((tree) -> { |
266 |
tree.accept(this, r); |
|
267 |
}); |
|
268 |
node.getBody().accept(this, r); |
|
269 |
return null; |
|
270 |
} |
|
271 |
||
272 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
273 |
public R visitFunctionExpression(final FunctionExpressionTree node, final P r) { |
29407 | 274 |
node.getParameters().forEach((tree) -> { |
275 |
tree.accept(this, r); |
|
276 |
}); |
|
277 |
node.getBody().accept(this, r); |
|
278 |
return null; |
|
279 |
} |
|
280 |
||
281 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
282 |
public R visitIdentifier(final IdentifierTree node, final P r) { |
29407 | 283 |
return null; |
284 |
} |
|
285 |
||
286 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
287 |
public R visitIf(final IfTree node, final P r) { |
29407 | 288 |
node.getCondition().accept(this, r); |
289 |
node.getThenStatement().accept(this, r); |
|
290 |
final Tree elseStat = node.getElseStatement(); |
|
291 |
if (elseStat != null) { |
|
292 |
elseStat.accept(this, r); |
|
293 |
} |
|
294 |
return null; |
|
295 |
} |
|
296 |
||
297 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
298 |
public R visitArrayAccess(final ArrayAccessTree node, final P r) { |
29407 | 299 |
node.getExpression().accept(this, r); |
300 |
node.getIndex().accept(this, r); |
|
301 |
return null; |
|
302 |
} |
|
303 |
||
304 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
305 |
public R visitArrayLiteral(final ArrayLiteralTree node, final P r) { |
29407 | 306 |
node.getElements().stream().filter((tree) -> (tree != null)).forEach((tree) -> { |
307 |
tree.accept(this, r); |
|
308 |
}); |
|
309 |
return null; |
|
310 |
} |
|
311 |
||
312 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
313 |
public R visitLabeledStatement(final LabeledStatementTree node, final P r) { |
29407 | 314 |
node.getStatement().accept(this, r); |
315 |
return null; |
|
316 |
} |
|
317 |
||
318 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
319 |
public R visitLiteral(final LiteralTree node, final P r) { |
29407 | 320 |
return null; |
321 |
} |
|
322 |
||
323 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
324 |
public R visitParenthesized(final ParenthesizedTree node, final P r) { |
29407 | 325 |
node.getExpression().accept(this, r); |
326 |
return null; |
|
327 |
} |
|
328 |
||
329 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
330 |
public R visitReturn(final ReturnTree node, final P r) { |
29407 | 331 |
final Tree retExpr = node.getExpression(); |
332 |
if (retExpr != null) { |
|
333 |
retExpr.accept(this, r); |
|
334 |
} |
|
335 |
return null; |
|
336 |
} |
|
337 |
||
338 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
339 |
public R visitMemberSelect(final MemberSelectTree node, final P r) { |
29407 | 340 |
node.getExpression().accept(this, r); |
341 |
return null; |
|
342 |
} |
|
343 |
||
344 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
345 |
public R visitNew(final NewTree node, final P r) { |
29407 | 346 |
node.getConstructorExpression().accept(this, r); |
347 |
return null; |
|
348 |
} |
|
349 |
||
350 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
351 |
public R visitObjectLiteral(final ObjectLiteralTree node, final P r) { |
29407 | 352 |
node.getProperties().forEach((tree) -> { |
353 |
tree.accept(this, r); |
|
354 |
}); |
|
355 |
return null; |
|
356 |
} |
|
357 |
||
358 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
359 |
public R visitProperty(final PropertyTree node, final P r) { |
29407 | 360 |
FunctionExpressionTree getter = node.getGetter(); |
361 |
if (getter != null) { |
|
362 |
getter.accept(this, r); |
|
363 |
} |
|
364 |
ExpressionTree key = node.getKey(); |
|
365 |
if (key != null) { |
|
366 |
key.accept(this, r); |
|
367 |
} |
|
368 |
||
369 |
FunctionExpressionTree setter = node.getSetter(); |
|
370 |
if (setter != null) { |
|
371 |
setter.accept(this, r); |
|
372 |
} |
|
373 |
||
374 |
ExpressionTree value = node.getValue(); |
|
375 |
if (value != null) { |
|
376 |
value.accept(this, r); |
|
377 |
} |
|
378 |
return null; |
|
379 |
} |
|
380 |
||
381 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
382 |
public R visitRegExpLiteral(final RegExpLiteralTree node, final P r) { |
29407 | 383 |
return null; |
384 |
} |
|
385 |
||
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
386 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
387 |
* Visits a {@code TemplateLiteralTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
388 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
389 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
390 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
391 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
392 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
393 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
394 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
395 |
public R visitTemplateLiteral(TemplateLiteralTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
396 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
397 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
398 |
|
29407 | 399 |
@Override |
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
400 |
public R visitEmptyStatement(final EmptyStatementTree node, final P r) { |
29407 | 401 |
return null; |
402 |
} |
|
403 |
||
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
404 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
405 |
* Visits a {@code SpreadTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
406 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
407 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
408 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
409 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
410 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
411 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
412 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
413 |
public R visitSpread(SpreadTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
414 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
415 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
416 |
|
29407 | 417 |
@Override |
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
418 |
public R visitSwitch(final SwitchTree node, final P r) { |
29407 | 419 |
node.getExpression().accept(this, r); |
420 |
node.getCases().forEach((tree) -> { |
|
421 |
tree.accept(this, r); |
|
422 |
}); |
|
423 |
return null; |
|
424 |
} |
|
425 |
||
426 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
427 |
public R visitThrow(final ThrowTree node, final P r) { |
29407 | 428 |
node.getExpression().accept(this, r); |
429 |
return null; |
|
430 |
} |
|
431 |
||
432 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
433 |
public R visitCompilationUnit(final CompilationUnitTree node, final P r) { |
29407 | 434 |
node.getSourceElements().forEach((tree) -> { |
435 |
tree.accept(this, r); |
|
436 |
}); |
|
437 |
return null; |
|
438 |
} |
|
439 |
||
440 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
441 |
public R visitTry(final TryTree node, final P r) { |
29407 | 442 |
node.getBlock().accept(this, r); |
443 |
node.getCatches().forEach((tree) -> { |
|
444 |
tree.accept(this, r); |
|
445 |
}); |
|
446 |
||
447 |
final Tree finallyBlock = node.getFinallyBlock(); |
|
448 |
if (finallyBlock != null) { |
|
449 |
finallyBlock.accept(this, r); |
|
450 |
} |
|
451 |
return null; |
|
452 |
} |
|
453 |
||
454 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
455 |
public R visitInstanceOf(final InstanceOfTree node, final P r) { |
29407 | 456 |
node.getType().accept(this, r); |
457 |
node.getExpression().accept(this, r); |
|
458 |
return null; |
|
459 |
} |
|
460 |
||
461 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
462 |
public R visitUnary(final UnaryTree node, final P r) { |
29407 | 463 |
node.getExpression().accept(this, r); |
464 |
return null; |
|
465 |
} |
|
466 |
||
467 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
468 |
public R visitVariable(final VariableTree node, final P r) { |
29407 | 469 |
if (node.getInitializer() != null) { |
470 |
node.getInitializer().accept(this, r); |
|
471 |
} |
|
472 |
return null; |
|
473 |
} |
|
474 |
||
475 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
476 |
public R visitWhileLoop(final WhileLoopTree node, final P r) { |
29407 | 477 |
node.getCondition().accept(this, r); |
478 |
node.getStatement().accept(this, r); |
|
479 |
return null; |
|
480 |
} |
|
481 |
||
482 |
@Override |
|
30984
844283fdfa54
8081809: Missing final modifier in method parameters (nashorn code convention)
sundar
parents:
29407
diff
changeset
|
483 |
public R visitWith(final WithTree node, final P r) { |
29407 | 484 |
node.getScope().accept(this, r); |
485 |
node.getStatement().accept(this, r); |
|
486 |
return null; |
|
487 |
} |
|
488 |
||
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
489 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
490 |
* Visits a {@code YieldTree} tree by calling {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
491 |
* visitUnknown}. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
492 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
493 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
494 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
495 |
* @return the result of {@code visitUnknown} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
496 |
*/ |
29407 | 497 |
@Override |
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
498 |
public R visitYield(YieldTree node, P p) { |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
499 |
return visitUnknown(node, p); |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
500 |
} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
501 |
|
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
502 |
/** |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
503 |
* {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
504 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
505 |
* @implSpec The default implementation of this method in {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
506 |
* SimpleTreeVisitorES5_1} will always throw {@code |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
507 |
* UnknownTypeException}. This behavior is not required of a |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
508 |
* subclass. |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
509 |
* |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
510 |
* @param node {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
511 |
* @param p {@inheritDoc} |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
512 |
* @return abnormal return by throwing exception always |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
513 |
* @throws UnknownTreeException |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
514 |
* a visitor implementation may optionally throw this exception |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
515 |
*/ |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
516 |
@Override |
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
517 |
public R visitUnknown(final Tree node, final P p) { |
29407 | 518 |
// unknown in ECMAScript 5.1 edition |
39662
e2b36a3779b9
8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
30984
diff
changeset
|
519 |
throw new UnknownTreeException(node, p); |
29407 | 520 |
} |
521 |
} |