author | mcimadamore |
Fri, 08 Jun 2018 16:33:40 +0100 | |
changeset 50468 | 4a5fd709e286 |
parent 47216 | 71c04702a3d5 |
child 51563 | de411d537aae |
permissions | -rw-r--r-- |
10 | 1 |
/* |
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
2 |
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.tree; |
|
27 |
||
28 |
import com.sun.source.tree.*; |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
29 |
import com.sun.source.tree.Tree.Kind; |
10 | 30 |
import com.sun.tools.javac.tree.JCTree.*; |
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
31 |
import com.sun.tools.javac.util.DefinedBy; |
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
32 |
import com.sun.tools.javac.util.DefinedBy.Api; |
10 | 33 |
import com.sun.tools.javac.util.List; |
34 |
import com.sun.tools.javac.util.ListBuffer; |
|
35 |
||
36 |
/** |
|
37 |
* Creates a copy of a tree, using a given TreeMaker. |
|
38 |
* Names, literal values, etc are shared with the original. |
|
39 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
40 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
41 |
* If you write code that depends on this, you do so at your own risk. |
10 | 42 |
* This code and its internal interfaces are subject to change or |
43 |
* deletion without notice.</b> |
|
44 |
*/ |
|
45 |
public class TreeCopier<P> implements TreeVisitor<JCTree,P> { |
|
46 |
private TreeMaker M; |
|
47 |
||
48 |
/** Creates a new instance of TreeCopier */ |
|
49 |
public TreeCopier(TreeMaker M) { |
|
50 |
this.M = M; |
|
51 |
} |
|
52 |
||
53 |
public <T extends JCTree> T copy(T tree) { |
|
54 |
return copy(tree, null); |
|
55 |
} |
|
56 |
||
57 |
@SuppressWarnings("unchecked") |
|
58 |
public <T extends JCTree> T copy(T tree, P p) { |
|
59 |
if (tree == null) |
|
60 |
return null; |
|
61 |
return (T) (tree.accept(this, p)); |
|
62 |
} |
|
63 |
||
64 |
public <T extends JCTree> List<T> copy(List<T> trees) { |
|
65 |
return copy(trees, null); |
|
66 |
} |
|
67 |
||
68 |
public <T extends JCTree> List<T> copy(List<T> trees, P p) { |
|
69 |
if (trees == null) |
|
70 |
return null; |
|
22163 | 71 |
ListBuffer<T> lb = new ListBuffer<>(); |
10 | 72 |
for (T tree: trees) |
73 |
lb.append(copy(tree, p)); |
|
74 |
return lb.toList(); |
|
75 |
} |
|
76 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
77 |
@DefinedBy(Api.COMPILER_TREE) |
15385 | 78 |
public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) { |
79 |
JCAnnotatedType t = (JCAnnotatedType) node; |
|
80 |
List<JCAnnotation> annotations = copy(t.annotations, p); |
|
81 |
JCExpression underlyingType = copy(t.underlyingType, p); |
|
82 |
return M.at(t.pos).AnnotatedType(annotations, underlyingType); |
|
83 |
} |
|
84 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
85 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 86 |
public JCTree visitAnnotation(AnnotationTree node, P p) { |
87 |
JCAnnotation t = (JCAnnotation) node; |
|
88 |
JCTree annotationType = copy(t.annotationType, p); |
|
89 |
List<JCExpression> args = copy(t.args, p); |
|
15385 | 90 |
if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) { |
91 |
JCAnnotation newTA = M.at(t.pos).TypeAnnotation(annotationType, args); |
|
92 |
newTA.attribute = t.attribute; |
|
93 |
return newTA; |
|
94 |
} else { |
|
95 |
JCAnnotation newT = M.at(t.pos).Annotation(annotationType, args); |
|
96 |
newT.attribute = t.attribute; |
|
97 |
return newT; |
|
98 |
} |
|
10 | 99 |
} |
100 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
101 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 102 |
public JCTree visitAssert(AssertTree node, P p) { |
103 |
JCAssert t = (JCAssert) node; |
|
104 |
JCExpression cond = copy(t.cond, p); |
|
105 |
JCExpression detail = copy(t.detail, p); |
|
106 |
return M.at(t.pos).Assert(cond, detail); |
|
107 |
} |
|
108 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
109 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 110 |
public JCTree visitAssignment(AssignmentTree node, P p) { |
111 |
JCAssign t = (JCAssign) node; |
|
112 |
JCExpression lhs = copy(t.lhs, p); |
|
113 |
JCExpression rhs = copy(t.rhs, p); |
|
114 |
return M.at(t.pos).Assign(lhs, rhs); |
|
115 |
} |
|
116 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
117 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 118 |
public JCTree visitCompoundAssignment(CompoundAssignmentTree node, P p) { |
119 |
JCAssignOp t = (JCAssignOp) node; |
|
120 |
JCTree lhs = copy(t.lhs, p); |
|
121 |
JCTree rhs = copy(t.rhs, p); |
|
122 |
return M.at(t.pos).Assignop(t.getTag(), lhs, rhs); |
|
123 |
} |
|
124 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
125 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 126 |
public JCTree visitBinary(BinaryTree node, P p) { |
127 |
JCBinary t = (JCBinary) node; |
|
128 |
JCExpression lhs = copy(t.lhs, p); |
|
129 |
JCExpression rhs = copy(t.rhs, p); |
|
130 |
return M.at(t.pos).Binary(t.getTag(), lhs, rhs); |
|
131 |
} |
|
132 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
133 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 134 |
public JCTree visitBlock(BlockTree node, P p) { |
135 |
JCBlock t = (JCBlock) node; |
|
136 |
List<JCStatement> stats = copy(t.stats, p); |
|
137 |
return M.at(t.pos).Block(t.flags, stats); |
|
138 |
} |
|
139 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
140 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 141 |
public JCTree visitBreak(BreakTree node, P p) { |
142 |
JCBreak t = (JCBreak) node; |
|
143 |
return M.at(t.pos).Break(t.label); |
|
144 |
} |
|
145 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
146 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 147 |
public JCTree visitCase(CaseTree node, P p) { |
148 |
JCCase t = (JCCase) node; |
|
149 |
JCExpression pat = copy(t.pat, p); |
|
150 |
List<JCStatement> stats = copy(t.stats, p); |
|
151 |
return M.at(t.pos).Case(pat, stats); |
|
152 |
} |
|
153 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
154 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 155 |
public JCTree visitCatch(CatchTree node, P p) { |
156 |
JCCatch t = (JCCatch) node; |
|
157 |
JCVariableDecl param = copy(t.param, p); |
|
158 |
JCBlock body = copy(t.body, p); |
|
159 |
return M.at(t.pos).Catch(param, body); |
|
160 |
} |
|
161 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
162 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 163 |
public JCTree visitClass(ClassTree node, P p) { |
164 |
JCClassDecl t = (JCClassDecl) node; |
|
165 |
JCModifiers mods = copy(t.mods, p); |
|
166 |
List<JCTypeParameter> typarams = copy(t.typarams, p); |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8031
diff
changeset
|
167 |
JCExpression extending = copy(t.extending, p); |
10 | 168 |
List<JCExpression> implementing = copy(t.implementing, p); |
169 |
List<JCTree> defs = copy(t.defs, p); |
|
170 |
return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs); |
|
171 |
} |
|
172 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
173 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 174 |
public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) { |
175 |
JCConditional t = (JCConditional) node; |
|
176 |
JCExpression cond = copy(t.cond, p); |
|
177 |
JCExpression truepart = copy(t.truepart, p); |
|
178 |
JCExpression falsepart = copy(t.falsepart, p); |
|
179 |
return M.at(t.pos).Conditional(cond, truepart, falsepart); |
|
180 |
} |
|
181 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
182 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 183 |
public JCTree visitContinue(ContinueTree node, P p) { |
184 |
JCContinue t = (JCContinue) node; |
|
185 |
return M.at(t.pos).Continue(t.label); |
|
186 |
} |
|
187 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
188 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 189 |
public JCTree visitDoWhileLoop(DoWhileLoopTree node, P p) { |
190 |
JCDoWhileLoop t = (JCDoWhileLoop) node; |
|
191 |
JCStatement body = copy(t.body, p); |
|
192 |
JCExpression cond = copy(t.cond, p); |
|
193 |
return M.at(t.pos).DoLoop(body, cond); |
|
194 |
} |
|
195 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
196 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 197 |
public JCTree visitErroneous(ErroneousTree node, P p) { |
198 |
JCErroneous t = (JCErroneous) node; |
|
199 |
List<? extends JCTree> errs = copy(t.errs, p); |
|
200 |
return M.at(t.pos).Erroneous(errs); |
|
201 |
} |
|
202 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
203 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 204 |
public JCTree visitExpressionStatement(ExpressionStatementTree node, P p) { |
205 |
JCExpressionStatement t = (JCExpressionStatement) node; |
|
206 |
JCExpression expr = copy(t.expr, p); |
|
207 |
return M.at(t.pos).Exec(expr); |
|
208 |
} |
|
209 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
210 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 211 |
public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) { |
212 |
JCEnhancedForLoop t = (JCEnhancedForLoop) node; |
|
213 |
JCVariableDecl var = copy(t.var, p); |
|
214 |
JCExpression expr = copy(t.expr, p); |
|
215 |
JCStatement body = copy(t.body, p); |
|
216 |
return M.at(t.pos).ForeachLoop(var, expr, body); |
|
217 |
} |
|
218 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
219 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 220 |
public JCTree visitForLoop(ForLoopTree node, P p) { |
221 |
JCForLoop t = (JCForLoop) node; |
|
222 |
List<JCStatement> init = copy(t.init, p); |
|
223 |
JCExpression cond = copy(t.cond, p); |
|
224 |
List<JCExpressionStatement> step = copy(t.step, p); |
|
225 |
JCStatement body = copy(t.body, p); |
|
226 |
return M.at(t.pos).ForLoop(init, cond, step, body); |
|
227 |
} |
|
228 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
229 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 230 |
public JCTree visitIdentifier(IdentifierTree node, P p) { |
231 |
JCIdent t = (JCIdent) node; |
|
232 |
return M.at(t.pos).Ident(t.name); |
|
233 |
} |
|
234 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
235 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 236 |
public JCTree visitIf(IfTree node, P p) { |
237 |
JCIf t = (JCIf) node; |
|
238 |
JCExpression cond = copy(t.cond, p); |
|
239 |
JCStatement thenpart = copy(t.thenpart, p); |
|
240 |
JCStatement elsepart = copy(t.elsepart, p); |
|
241 |
return M.at(t.pos).If(cond, thenpart, elsepart); |
|
242 |
} |
|
243 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
244 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 245 |
public JCTree visitImport(ImportTree node, P p) { |
246 |
JCImport t = (JCImport) node; |
|
247 |
JCTree qualid = copy(t.qualid, p); |
|
248 |
return M.at(t.pos).Import(qualid, t.staticImport); |
|
249 |
} |
|
250 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
251 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 252 |
public JCTree visitArrayAccess(ArrayAccessTree node, P p) { |
253 |
JCArrayAccess t = (JCArrayAccess) node; |
|
254 |
JCExpression indexed = copy(t.indexed, p); |
|
255 |
JCExpression index = copy(t.index, p); |
|
256 |
return M.at(t.pos).Indexed(indexed, index); |
|
257 |
} |
|
258 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
259 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 260 |
public JCTree visitLabeledStatement(LabeledStatementTree node, P p) { |
261 |
JCLabeledStatement t = (JCLabeledStatement) node; |
|
262 |
JCStatement body = copy(t.body, p); |
|
20243
21740b37e9aa
8025110: TreeCopier does not correctly copy LabeledStatementTree
jjg
parents:
17807
diff
changeset
|
263 |
return M.at(t.pos).Labelled(t.label, body); |
10 | 264 |
} |
265 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
266 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 267 |
public JCTree visitLiteral(LiteralTree node, P p) { |
268 |
JCLiteral t = (JCLiteral) node; |
|
269 |
return M.at(t.pos).Literal(t.typetag, t.value); |
|
270 |
} |
|
271 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
272 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 273 |
public JCTree visitMethod(MethodTree node, P p) { |
274 |
JCMethodDecl t = (JCMethodDecl) node; |
|
275 |
JCModifiers mods = copy(t.mods, p); |
|
276 |
JCExpression restype = copy(t.restype, p); |
|
277 |
List<JCTypeParameter> typarams = copy(t.typarams, p); |
|
278 |
List<JCVariableDecl> params = copy(t.params, p); |
|
15385 | 279 |
JCVariableDecl recvparam = copy(t.recvparam, p); |
10 | 280 |
List<JCExpression> thrown = copy(t.thrown, p); |
281 |
JCBlock body = copy(t.body, p); |
|
282 |
JCExpression defaultValue = copy(t.defaultValue, p); |
|
15385 | 283 |
return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue); |
10 | 284 |
} |
285 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
286 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 287 |
public JCTree visitMethodInvocation(MethodInvocationTree node, P p) { |
288 |
JCMethodInvocation t = (JCMethodInvocation) node; |
|
289 |
List<JCExpression> typeargs = copy(t.typeargs, p); |
|
290 |
JCExpression meth = copy(t.meth, p); |
|
291 |
List<JCExpression> args = copy(t.args, p); |
|
292 |
return M.at(t.pos).Apply(typeargs, meth, args); |
|
293 |
} |
|
294 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
295 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 296 |
public JCTree visitModifiers(ModifiersTree node, P p) { |
297 |
JCModifiers t = (JCModifiers) node; |
|
298 |
List<JCAnnotation> annotations = copy(t.annotations, p); |
|
299 |
return M.at(t.pos).Modifiers(t.flags, annotations); |
|
300 |
} |
|
301 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
302 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 303 |
public JCTree visitNewArray(NewArrayTree node, P p) { |
304 |
JCNewArray t = (JCNewArray) node; |
|
305 |
JCExpression elemtype = copy(t.elemtype, p); |
|
306 |
List<JCExpression> dims = copy(t.dims, p); |
|
307 |
List<JCExpression> elems = copy(t.elems, p); |
|
308 |
return M.at(t.pos).NewArray(elemtype, dims, elems); |
|
309 |
} |
|
310 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
311 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 312 |
public JCTree visitNewClass(NewClassTree node, P p) { |
313 |
JCNewClass t = (JCNewClass) node; |
|
314 |
JCExpression encl = copy(t.encl, p); |
|
315 |
List<JCExpression> typeargs = copy(t.typeargs, p); |
|
316 |
JCExpression clazz = copy(t.clazz, p); |
|
317 |
List<JCExpression> args = copy(t.args, p); |
|
318 |
JCClassDecl def = copy(t.def, p); |
|
319 |
return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def); |
|
320 |
} |
|
321 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
322 |
@DefinedBy(Api.COMPILER_TREE) |
11141 | 323 |
public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) { |
324 |
JCLambda t = (JCLambda) node; |
|
325 |
List<JCVariableDecl> params = copy(t.params, p); |
|
326 |
JCTree body = copy(t.body, p); |
|
327 |
return M.at(t.pos).Lambda(params, body); |
|
328 |
} |
|
329 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
330 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 331 |
public JCTree visitParenthesized(ParenthesizedTree node, P p) { |
332 |
JCParens t = (JCParens) node; |
|
333 |
JCExpression expr = copy(t.expr, p); |
|
334 |
return M.at(t.pos).Parens(expr); |
|
335 |
} |
|
336 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
337 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 338 |
public JCTree visitReturn(ReturnTree node, P p) { |
339 |
JCReturn t = (JCReturn) node; |
|
340 |
JCExpression expr = copy(t.expr, p); |
|
341 |
return M.at(t.pos).Return(expr); |
|
342 |
} |
|
343 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
344 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 345 |
public JCTree visitMemberSelect(MemberSelectTree node, P p) { |
346 |
JCFieldAccess t = (JCFieldAccess) node; |
|
347 |
JCExpression selected = copy(t.selected, p); |
|
348 |
return M.at(t.pos).Select(selected, t.name); |
|
349 |
} |
|
350 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
351 |
@DefinedBy(Api.COMPILER_TREE) |
11142 | 352 |
public JCTree visitMemberReference(MemberReferenceTree node, P p) { |
353 |
JCMemberReference t = (JCMemberReference) node; |
|
354 |
JCExpression expr = copy(t.expr, p); |
|
355 |
List<JCExpression> typeargs = copy(t.typeargs, p); |
|
356 |
return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs); |
|
357 |
} |
|
358 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
359 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 360 |
public JCTree visitEmptyStatement(EmptyStatementTree node, P p) { |
361 |
JCSkip t = (JCSkip) node; |
|
362 |
return M.at(t.pos).Skip(); |
|
363 |
} |
|
364 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
365 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 366 |
public JCTree visitSwitch(SwitchTree node, P p) { |
367 |
JCSwitch t = (JCSwitch) node; |
|
368 |
JCExpression selector = copy(t.selector, p); |
|
369 |
List<JCCase> cases = copy(t.cases, p); |
|
370 |
return M.at(t.pos).Switch(selector, cases); |
|
371 |
} |
|
372 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
373 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 374 |
public JCTree visitSynchronized(SynchronizedTree node, P p) { |
375 |
JCSynchronized t = (JCSynchronized) node; |
|
376 |
JCExpression lock = copy(t.lock, p); |
|
377 |
JCBlock body = copy(t.body, p); |
|
378 |
return M.at(t.pos).Synchronized(lock, body); |
|
379 |
} |
|
380 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
381 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 382 |
public JCTree visitThrow(ThrowTree node, P p) { |
383 |
JCThrow t = (JCThrow) node; |
|
17807
36cff8c58cdf
7030476: Fix conflicting use of JCTree/JCExpression
vromero
parents:
17578
diff
changeset
|
384 |
JCExpression expr = copy(t.expr, p); |
10 | 385 |
return M.at(t.pos).Throw(expr); |
386 |
} |
|
387 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
388 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 389 |
public JCTree visitCompilationUnit(CompilationUnitTree node, P p) { |
390 |
JCCompilationUnit t = (JCCompilationUnit) node; |
|
24069 | 391 |
List<JCTree> defs = copy(t.defs, p); |
392 |
return M.at(t.pos).TopLevel(defs); |
|
393 |
} |
|
394 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
395 |
@DefinedBy(Api.COMPILER_TREE) |
24069 | 396 |
public JCTree visitPackage(PackageTree node, P p) { |
397 |
JCPackageDecl t = (JCPackageDecl) node; |
|
398 |
List<JCAnnotation> annotations = copy(t.annotations, p); |
|
10 | 399 |
JCExpression pid = copy(t.pid, p); |
24069 | 400 |
return M.at(t.pos).PackageDecl(annotations, pid); |
10 | 401 |
} |
402 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
403 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 404 |
public JCTree visitTry(TryTree node, P p) { |
405 |
JCTry t = (JCTry) node; |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
406 |
List<JCTree> resources = copy(t.resources, p); |
10 | 407 |
JCBlock body = copy(t.body, p); |
408 |
List<JCCatch> catchers = copy(t.catchers, p); |
|
409 |
JCBlock finalizer = copy(t.finalizer, p); |
|
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
410 |
return M.at(t.pos).Try(resources, body, catchers, finalizer); |
10 | 411 |
} |
412 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
413 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 414 |
public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) { |
415 |
JCTypeApply t = (JCTypeApply) node; |
|
416 |
JCExpression clazz = copy(t.clazz, p); |
|
417 |
List<JCExpression> arguments = copy(t.arguments, p); |
|
418 |
return M.at(t.pos).TypeApply(clazz, arguments); |
|
419 |
} |
|
420 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
421 |
@DefinedBy(Api.COMPILER_TREE) |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
422 |
public JCTree visitUnionType(UnionTypeTree node, P p) { |
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
423 |
JCTypeUnion t = (JCTypeUnion) node; |
7074 | 424 |
List<JCExpression> components = copy(t.alternatives, p); |
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
425 |
return M.at(t.pos).TypeUnion(components); |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
426 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
3149
diff
changeset
|
427 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
428 |
@DefinedBy(Api.COMPILER_TREE) |
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
429 |
public JCTree visitIntersectionType(IntersectionTypeTree node, P p) { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
430 |
JCTypeIntersection t = (JCTypeIntersection) node; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
431 |
List<JCExpression> bounds = copy(t.bounds, p); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
432 |
return M.at(t.pos).TypeIntersection(bounds); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
433 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
11142
diff
changeset
|
434 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
435 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 436 |
public JCTree visitArrayType(ArrayTypeTree node, P p) { |
437 |
JCArrayTypeTree t = (JCArrayTypeTree) node; |
|
438 |
JCExpression elemtype = copy(t.elemtype, p); |
|
439 |
return M.at(t.pos).TypeArray(elemtype); |
|
440 |
} |
|
441 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
442 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 443 |
public JCTree visitTypeCast(TypeCastTree node, P p) { |
444 |
JCTypeCast t = (JCTypeCast) node; |
|
445 |
JCTree clazz = copy(t.clazz, p); |
|
446 |
JCExpression expr = copy(t.expr, p); |
|
447 |
return M.at(t.pos).TypeCast(clazz, expr); |
|
448 |
} |
|
449 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
450 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 451 |
public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) { |
452 |
JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node; |
|
453 |
return M.at(t.pos).TypeIdent(t.typetag); |
|
454 |
} |
|
455 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
456 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 457 |
public JCTree visitTypeParameter(TypeParameterTree node, P p) { |
458 |
JCTypeParameter t = (JCTypeParameter) node; |
|
15385 | 459 |
List<JCAnnotation> annos = copy(t.annotations, p); |
10 | 460 |
List<JCExpression> bounds = copy(t.bounds, p); |
15385 | 461 |
return M.at(t.pos).TypeParameter(t.name, bounds, annos); |
10 | 462 |
} |
463 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
464 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 465 |
public JCTree visitInstanceOf(InstanceOfTree node, P p) { |
466 |
JCInstanceOf t = (JCInstanceOf) node; |
|
467 |
JCExpression expr = copy(t.expr, p); |
|
468 |
JCTree clazz = copy(t.clazz, p); |
|
469 |
return M.at(t.pos).TypeTest(expr, clazz); |
|
470 |
} |
|
471 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
472 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 473 |
public JCTree visitUnary(UnaryTree node, P p) { |
474 |
JCUnary t = (JCUnary) node; |
|
475 |
JCExpression arg = copy(t.arg, p); |
|
476 |
return M.at(t.pos).Unary(t.getTag(), arg); |
|
477 |
} |
|
478 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
479 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 480 |
public JCTree visitVariable(VariableTree node, P p) { |
481 |
JCVariableDecl t = (JCVariableDecl) node; |
|
482 |
JCModifiers mods = copy(t.mods, p); |
|
483 |
JCExpression vartype = copy(t.vartype, p); |
|
17578 | 484 |
if (t.nameexpr == null) { |
485 |
JCExpression init = copy(t.init, p); |
|
486 |
return M.at(t.pos).VarDef(mods, t.name, vartype, init); |
|
487 |
} else { |
|
488 |
JCExpression nameexpr = copy(t.nameexpr, p); |
|
489 |
return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype); |
|
490 |
} |
|
10 | 491 |
} |
492 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
493 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 494 |
public JCTree visitWhileLoop(WhileLoopTree node, P p) { |
495 |
JCWhileLoop t = (JCWhileLoop) node; |
|
496 |
JCStatement body = copy(t.body, p); |
|
497 |
JCExpression cond = copy(t.cond, p); |
|
498 |
return M.at(t.pos).WhileLoop(cond, body); |
|
499 |
} |
|
500 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
501 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 502 |
public JCTree visitWildcard(WildcardTree node, P p) { |
503 |
JCWildcard t = (JCWildcard) node; |
|
504 |
TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind); |
|
505 |
JCTree inner = copy(t.inner, p); |
|
506 |
return M.at(t.pos).Wildcard(kind, inner); |
|
507 |
} |
|
508 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
509 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 510 |
public JCTree visitModule(ModuleTree node, P p) { |
511 |
JCModuleDecl t = (JCModuleDecl) node; |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
512 |
JCModifiers mods = copy(t.mods, p); |
36526 | 513 |
JCExpression qualId = copy(t.qualId); |
514 |
List<JCDirective> directives = copy(t.directives); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
515 |
return M.at(t.pos).ModuleDef(mods, t.getModuleType(), qualId, directives); |
36526 | 516 |
} |
517 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
518 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 519 |
public JCExports visitExports(ExportsTree node, P p) { |
520 |
JCExports t = (JCExports) node; |
|
521 |
JCExpression qualId = copy(t.qualid, p); |
|
522 |
List<JCExpression> moduleNames = copy(t.moduleNames, p); |
|
523 |
return M.at(t.pos).Exports(qualId, moduleNames); |
|
524 |
} |
|
525 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
526 |
@Override @DefinedBy(Api.COMPILER_TREE) |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
527 |
public JCOpens visitOpens(OpensTree node, P p) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
528 |
JCOpens t = (JCOpens) node; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
529 |
JCExpression qualId = copy(t.qualid, p); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
530 |
List<JCExpression> moduleNames = copy(t.moduleNames, p); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
531 |
return M.at(t.pos).Opens(qualId, moduleNames); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
532 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
533 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
534 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 535 |
public JCProvides visitProvides(ProvidesTree node, P p) { |
536 |
JCProvides t = (JCProvides) node; |
|
537 |
JCExpression serviceName = copy(t.serviceName, p); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
538 |
List<JCExpression> implNames = copy(t.implNames, p); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
539 |
return M.at(t.pos).Provides(serviceName, implNames); |
36526 | 540 |
} |
541 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
542 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 543 |
public JCRequires visitRequires(RequiresTree node, P p) { |
544 |
JCRequires t = (JCRequires) node; |
|
545 |
JCExpression moduleName = copy(t.moduleName, p); |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
37848
diff
changeset
|
546 |
return M.at(t.pos).Requires(t.isTransitive, t.isStaticPhase, moduleName); |
36526 | 547 |
} |
548 |
||
37848
3c8ff4204d2d
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36526
diff
changeset
|
549 |
@Override @DefinedBy(Api.COMPILER_TREE) |
36526 | 550 |
public JCUses visitUses(UsesTree node, P p) { |
551 |
JCUses t = (JCUses) node; |
|
552 |
JCExpression serviceName = copy(t.qualid, p); |
|
553 |
return M.at(t.pos).Uses(serviceName); |
|
554 |
} |
|
555 |
||
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
556 |
@DefinedBy(Api.COMPILER_TREE) |
10 | 557 |
public JCTree visitOther(Tree node, P p) { |
558 |
JCTree tree = (JCTree) node; |
|
559 |
switch (tree.getTag()) { |
|
10950 | 560 |
case LETEXPR: { |
10 | 561 |
LetExpr t = (LetExpr) node; |
562 |
List<JCVariableDecl> defs = copy(t.defs, p); |
|
33707
d74fef6b01e0
8141639: Signatures in Lower could be made tighter by using JCExpression instead of JCTree
mcimadamore
parents:
26266
diff
changeset
|
563 |
JCExpression expr = copy(t.expr, p); |
10 | 564 |
return M.at(t.pos).LetExpr(defs, expr); |
565 |
} |
|
566 |
default: |
|
567 |
throw new AssertionError("unknown tree tag: " + tree.getTag()); |
|
568 |
} |
|
569 |
} |
|
570 |
||
571 |
} |