author | jlahoda |
Wed, 27 Nov 2019 09:00:01 +0100 | |
changeset 59285 | 7799a51dbe30 |
parent 59021 | cfc7bb9a5a92 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
55306 | 2 |
* Copyright (c) 1999, 2019, 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 |
||
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
28 |
import java.util.Iterator; |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
29 |
|
58713
ad69fd32778e
8226585: Improve javac messages for using a preview API
jlahoda
parents:
55306
diff
changeset
|
30 |
import com.sun.source.tree.CaseTree; |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
31 |
import com.sun.source.tree.ModuleTree.ModuleKind; |
10 | 32 |
import com.sun.tools.javac.code.*; |
50400
dcbbc6fb0b69
8200166: Repeating annotations refering to to-be-generated classes don't work.
jlahoda
parents:
47216
diff
changeset
|
33 |
import com.sun.tools.javac.code.Attribute.UnresolvedClass; |
10 | 34 |
import com.sun.tools.javac.code.Symbol.*; |
35 |
import com.sun.tools.javac.code.Type.*; |
|
36 |
import com.sun.tools.javac.util.*; |
|
37 |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
|
38 |
||
39 |
import com.sun.tools.javac.tree.JCTree.*; |
|
40 |
||
41 |
import static com.sun.tools.javac.code.Flags.*; |
|
27224
228abfa87080
8054457: Refactor Symbol kinds from small ints to an enum
emc
parents:
25874
diff
changeset
|
42 |
import static com.sun.tools.javac.code.Kinds.Kind.*; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13845
diff
changeset
|
43 |
import static com.sun.tools.javac.code.TypeTag.*; |
10 | 44 |
|
45 |
/** Factory class for trees. |
|
46 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
47 |
* <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
|
48 |
* If you write code that depends on this, you do so at your own risk. |
10 | 49 |
* This code and its internal interfaces are subject to change or |
50 |
* deletion without notice.</b> |
|
51 |
*/ |
|
52 |
public class TreeMaker implements JCTree.Factory { |
|
53 |
||
54 |
/** The context key for the tree factory. */ |
|
22163 | 55 |
protected static final Context.Key<TreeMaker> treeMakerKey = new Context.Key<>(); |
10 | 56 |
|
57 |
/** Get the TreeMaker instance. */ |
|
58 |
public static TreeMaker instance(Context context) { |
|
59 |
TreeMaker instance = context.get(treeMakerKey); |
|
60 |
if (instance == null) |
|
61 |
instance = new TreeMaker(context); |
|
62 |
return instance; |
|
63 |
} |
|
64 |
||
65 |
/** The position at which subsequent trees will be created. |
|
66 |
*/ |
|
67 |
public int pos = Position.NOPOS; |
|
68 |
||
69 |
/** The toplevel tree to which created trees belong. |
|
70 |
*/ |
|
71 |
public JCCompilationUnit toplevel; |
|
72 |
||
73 |
/** The current name table. */ |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
74 |
Names names; |
10 | 75 |
|
76 |
Types types; |
|
77 |
||
78 |
/** The current symbol table. */ |
|
79 |
Symtab syms; |
|
80 |
||
81 |
/** Create a tree maker with null toplevel and NOPOS as initial position. |
|
82 |
*/ |
|
83 |
protected TreeMaker(Context context) { |
|
84 |
context.put(treeMakerKey, this); |
|
85 |
this.pos = Position.NOPOS; |
|
86 |
this.toplevel = null; |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
10
diff
changeset
|
87 |
this.names = Names.instance(context); |
10 | 88 |
this.syms = Symtab.instance(context); |
89 |
this.types = Types.instance(context); |
|
90 |
} |
|
91 |
||
92 |
/** Create a tree maker with a given toplevel and FIRSTPOS as initial position. |
|
93 |
*/ |
|
13845
bbb35ad7a9c1
7192073: (javac) minor refactoring of tree maker to help IDEs
ksrini
parents:
13689
diff
changeset
|
94 |
protected TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) { |
10 | 95 |
this.pos = Position.FIRSTPOS; |
96 |
this.toplevel = toplevel; |
|
97 |
this.names = names; |
|
98 |
this.types = types; |
|
99 |
this.syms = syms; |
|
100 |
} |
|
101 |
||
102 |
/** Create a new tree maker for a given toplevel. |
|
103 |
*/ |
|
104 |
public TreeMaker forToplevel(JCCompilationUnit toplevel) { |
|
105 |
return new TreeMaker(toplevel, names, types, syms); |
|
106 |
} |
|
107 |
||
108 |
/** Reassign current position. |
|
109 |
*/ |
|
110 |
public TreeMaker at(int pos) { |
|
111 |
this.pos = pos; |
|
112 |
return this; |
|
113 |
} |
|
114 |
||
115 |
/** Reassign current position. |
|
116 |
*/ |
|
117 |
public TreeMaker at(DiagnosticPosition pos) { |
|
118 |
this.pos = (pos == null ? Position.NOPOS : pos.getStartPosition()); |
|
119 |
return this; |
|
120 |
} |
|
121 |
||
122 |
/** |
|
123 |
* Create given tree node at current position. |
|
24069 | 124 |
* @param defs a list of PackageDef, ClassDef, Import, and Skip |
10 | 125 |
*/ |
24069 | 126 |
public JCCompilationUnit TopLevel(List<JCTree> defs) { |
10 | 127 |
for (JCTree node : defs) |
8032 | 128 |
Assert.check(node instanceof JCClassDecl |
24069 | 129 |
|| node instanceof JCPackageDecl |
10 | 130 |
|| node instanceof JCImport |
36526 | 131 |
|| node instanceof JCModuleDecl |
10 | 132 |
|| node instanceof JCSkip |
133 |
|| node instanceof JCErroneous |
|
134 |
|| (node instanceof JCExpressionStatement |
|
8032 | 135 |
&& ((JCExpressionStatement)node).expr instanceof JCErroneous), |
29294
376a915b4ff0
8073645: Add lambda-based lazy eval versions of Assert.check methods
mcimadamore
parents:
27224
diff
changeset
|
136 |
() -> node.getClass().getSimpleName()); |
24069 | 137 |
JCCompilationUnit tree = new JCCompilationUnit(defs); |
138 |
tree.pos = pos; |
|
139 |
return tree; |
|
140 |
} |
|
141 |
||
142 |
public JCPackageDecl PackageDecl(List<JCAnnotation> annotations, |
|
143 |
JCExpression pid) { |
|
144 |
Assert.checkNonNull(annotations); |
|
145 |
Assert.checkNonNull(pid); |
|
146 |
JCPackageDecl tree = new JCPackageDecl(annotations, pid); |
|
10 | 147 |
tree.pos = pos; |
148 |
return tree; |
|
149 |
} |
|
150 |
||
151 |
public JCImport Import(JCTree qualid, boolean importStatic) { |
|
152 |
JCImport tree = new JCImport(qualid, importStatic); |
|
153 |
tree.pos = pos; |
|
154 |
return tree; |
|
155 |
} |
|
156 |
||
157 |
public JCClassDecl ClassDef(JCModifiers mods, |
|
158 |
Name name, |
|
159 |
List<JCTypeParameter> typarams, |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8032
diff
changeset
|
160 |
JCExpression extending, |
10 | 161 |
List<JCExpression> implementing, |
162 |
List<JCTree> defs) |
|
163 |
{ |
|
164 |
JCClassDecl tree = new JCClassDecl(mods, |
|
165 |
name, |
|
166 |
typarams, |
|
167 |
extending, |
|
168 |
implementing, |
|
169 |
defs, |
|
170 |
null); |
|
171 |
tree.pos = pos; |
|
172 |
return tree; |
|
173 |
} |
|
174 |
||
175 |
public JCMethodDecl MethodDef(JCModifiers mods, |
|
176 |
Name name, |
|
177 |
JCExpression restype, |
|
178 |
List<JCTypeParameter> typarams, |
|
179 |
List<JCVariableDecl> params, |
|
180 |
List<JCExpression> thrown, |
|
181 |
JCBlock body, |
|
3149 | 182 |
JCExpression defaultValue) { |
15385 | 183 |
return MethodDef( |
184 |
mods, name, restype, typarams, null, params, |
|
185 |
thrown, body, defaultValue); |
|
186 |
} |
|
187 |
||
188 |
public JCMethodDecl MethodDef(JCModifiers mods, |
|
189 |
Name name, |
|
190 |
JCExpression restype, |
|
191 |
List<JCTypeParameter> typarams, |
|
192 |
JCVariableDecl recvparam, |
|
193 |
List<JCVariableDecl> params, |
|
194 |
List<JCExpression> thrown, |
|
195 |
JCBlock body, |
|
196 |
JCExpression defaultValue) |
|
197 |
{ |
|
10 | 198 |
JCMethodDecl tree = new JCMethodDecl(mods, |
199 |
name, |
|
200 |
restype, |
|
201 |
typarams, |
|
15385 | 202 |
recvparam, |
10 | 203 |
params, |
204 |
thrown, |
|
205 |
body, |
|
206 |
defaultValue, |
|
207 |
null); |
|
208 |
tree.pos = pos; |
|
209 |
return tree; |
|
210 |
} |
|
211 |
||
212 |
public JCVariableDecl VarDef(JCModifiers mods, Name name, JCExpression vartype, JCExpression init) { |
|
213 |
JCVariableDecl tree = new JCVariableDecl(mods, name, vartype, init, null); |
|
214 |
tree.pos = pos; |
|
215 |
return tree; |
|
216 |
} |
|
217 |
||
17578 | 218 |
public JCVariableDecl ReceiverVarDef(JCModifiers mods, JCExpression name, JCExpression vartype) { |
219 |
JCVariableDecl tree = new JCVariableDecl(mods, name, vartype); |
|
220 |
tree.pos = pos; |
|
221 |
return tree; |
|
222 |
} |
|
223 |
||
10 | 224 |
public JCSkip Skip() { |
225 |
JCSkip tree = new JCSkip(); |
|
226 |
tree.pos = pos; |
|
227 |
return tree; |
|
228 |
} |
|
229 |
||
230 |
public JCBlock Block(long flags, List<JCStatement> stats) { |
|
231 |
JCBlock tree = new JCBlock(flags, stats); |
|
232 |
tree.pos = pos; |
|
233 |
return tree; |
|
234 |
} |
|
235 |
||
236 |
public JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond) { |
|
237 |
JCDoWhileLoop tree = new JCDoWhileLoop(body, cond); |
|
238 |
tree.pos = pos; |
|
239 |
return tree; |
|
240 |
} |
|
241 |
||
242 |
public JCWhileLoop WhileLoop(JCExpression cond, JCStatement body) { |
|
243 |
JCWhileLoop tree = new JCWhileLoop(cond, body); |
|
244 |
tree.pos = pos; |
|
245 |
return tree; |
|
246 |
} |
|
247 |
||
248 |
public JCForLoop ForLoop(List<JCStatement> init, |
|
249 |
JCExpression cond, |
|
250 |
List<JCExpressionStatement> step, |
|
251 |
JCStatement body) |
|
252 |
{ |
|
253 |
JCForLoop tree = new JCForLoop(init, cond, step, body); |
|
254 |
tree.pos = pos; |
|
255 |
return tree; |
|
256 |
} |
|
257 |
||
258 |
public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) { |
|
259 |
JCEnhancedForLoop tree = new JCEnhancedForLoop(var, expr, body); |
|
260 |
tree.pos = pos; |
|
261 |
return tree; |
|
262 |
} |
|
263 |
||
264 |
public JCLabeledStatement Labelled(Name label, JCStatement body) { |
|
265 |
JCLabeledStatement tree = new JCLabeledStatement(label, body); |
|
266 |
tree.pos = pos; |
|
267 |
return tree; |
|
268 |
} |
|
269 |
||
270 |
public JCSwitch Switch(JCExpression selector, List<JCCase> cases) { |
|
271 |
JCSwitch tree = new JCSwitch(selector, cases); |
|
272 |
tree.pos = pos; |
|
273 |
return tree; |
|
274 |
} |
|
275 |
||
59021 | 276 |
public JCCase Case(CaseTree.CaseKind caseKind, List<JCExpression> pats, |
51563
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
277 |
List<JCStatement> stats, JCTree body) { |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
278 |
JCCase tree = new JCCase(caseKind, pats, stats, body); |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
279 |
tree.pos = pos; |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
280 |
return tree; |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
281 |
} |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
282 |
|
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
283 |
public JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases) { |
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
284 |
JCSwitchExpression tree = new JCSwitchExpression(selector, cases); |
10 | 285 |
tree.pos = pos; |
286 |
return tree; |
|
287 |
} |
|
288 |
||
289 |
public JCSynchronized Synchronized(JCExpression lock, JCBlock body) { |
|
290 |
JCSynchronized tree = new JCSynchronized(lock, body); |
|
291 |
tree.pos = pos; |
|
292 |
return tree; |
|
293 |
} |
|
294 |
||
295 |
public JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer) { |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
296 |
return Try(List.nil(), body, catchers, finalizer); |
6148
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
297 |
} |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
298 |
|
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
299 |
public JCTry Try(List<JCTree> resources, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
300 |
JCBlock body, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
301 |
List<JCCatch> catchers, |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
302 |
JCBlock finalizer) { |
3a8158299c51
6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents:
5847
diff
changeset
|
303 |
JCTry tree = new JCTry(resources, body, catchers, finalizer); |
10 | 304 |
tree.pos = pos; |
305 |
return tree; |
|
306 |
} |
|
307 |
||
308 |
public JCCatch Catch(JCVariableDecl param, JCBlock body) { |
|
309 |
JCCatch tree = new JCCatch(param, body); |
|
310 |
tree.pos = pos; |
|
311 |
return tree; |
|
312 |
} |
|
313 |
||
314 |
public JCConditional Conditional(JCExpression cond, |
|
315 |
JCExpression thenpart, |
|
316 |
JCExpression elsepart) |
|
317 |
{ |
|
318 |
JCConditional tree = new JCConditional(cond, thenpart, elsepart); |
|
319 |
tree.pos = pos; |
|
320 |
return tree; |
|
321 |
} |
|
322 |
||
323 |
public JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart) { |
|
324 |
JCIf tree = new JCIf(cond, thenpart, elsepart); |
|
325 |
tree.pos = pos; |
|
326 |
return tree; |
|
327 |
} |
|
328 |
||
329 |
public JCExpressionStatement Exec(JCExpression expr) { |
|
330 |
JCExpressionStatement tree = new JCExpressionStatement(expr); |
|
331 |
tree.pos = pos; |
|
332 |
return tree; |
|
333 |
} |
|
334 |
||
55306 | 335 |
public JCBreak Break(Name label) { |
10 | 336 |
JCBreak tree = new JCBreak(label, null); |
337 |
tree.pos = pos; |
|
338 |
return tree; |
|
339 |
} |
|
340 |
||
55306 | 341 |
public JCYield Yield(JCExpression value) { |
342 |
JCYield tree = new JCYield(value, null); |
|
343 |
tree.pos = pos; |
|
344 |
return tree; |
|
345 |
} |
|
346 |
||
10 | 347 |
public JCContinue Continue(Name label) { |
348 |
JCContinue tree = new JCContinue(label, null); |
|
349 |
tree.pos = pos; |
|
350 |
return tree; |
|
351 |
} |
|
352 |
||
353 |
public JCReturn Return(JCExpression expr) { |
|
354 |
JCReturn tree = new JCReturn(expr); |
|
355 |
tree.pos = pos; |
|
356 |
return tree; |
|
357 |
} |
|
358 |
||
17807
36cff8c58cdf
7030476: Fix conflicting use of JCTree/JCExpression
vromero
parents:
17578
diff
changeset
|
359 |
public JCThrow Throw(JCExpression expr) { |
10 | 360 |
JCThrow tree = new JCThrow(expr); |
361 |
tree.pos = pos; |
|
362 |
return tree; |
|
363 |
} |
|
364 |
||
365 |
public JCAssert Assert(JCExpression cond, JCExpression detail) { |
|
366 |
JCAssert tree = new JCAssert(cond, detail); |
|
367 |
tree.pos = pos; |
|
368 |
return tree; |
|
369 |
} |
|
370 |
||
371 |
public JCMethodInvocation Apply(List<JCExpression> typeargs, |
|
372 |
JCExpression fn, |
|
373 |
List<JCExpression> args) |
|
374 |
{ |
|
375 |
JCMethodInvocation tree = new JCMethodInvocation(typeargs, fn, args); |
|
376 |
tree.pos = pos; |
|
377 |
return tree; |
|
378 |
} |
|
379 |
||
380 |
public JCNewClass NewClass(JCExpression encl, |
|
381 |
List<JCExpression> typeargs, |
|
382 |
JCExpression clazz, |
|
383 |
List<JCExpression> args, |
|
384 |
JCClassDecl def) |
|
385 |
{ |
|
52455
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
386 |
return SpeculativeNewClass(encl, typeargs, clazz, args, def, false); |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
387 |
} |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
388 |
|
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
389 |
public JCNewClass SpeculativeNewClass(JCExpression encl, |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
390 |
List<JCExpression> typeargs, |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
391 |
JCExpression clazz, |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
392 |
List<JCExpression> args, |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
393 |
JCClassDecl def, |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
394 |
boolean classDefRemoved) |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
395 |
{ |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
396 |
JCNewClass tree = classDefRemoved ? |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
397 |
new JCNewClass(encl, typeargs, clazz, args, def) { |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
398 |
@Override |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
399 |
public boolean classDeclRemoved() { |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
400 |
return true; |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
401 |
} |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
402 |
} : |
bbbc110cdffe
8210197: javac can't tell during speculative attribution if a diamond expression is creating an anonymous inner class or not
vromero
parents:
51563
diff
changeset
|
403 |
new JCNewClass(encl, typeargs, clazz, args, def); |
10 | 404 |
tree.pos = pos; |
405 |
return tree; |
|
406 |
} |
|
407 |
||
408 |
public JCNewArray NewArray(JCExpression elemtype, |
|
409 |
List<JCExpression> dims, |
|
410 |
List<JCExpression> elems) |
|
411 |
{ |
|
412 |
JCNewArray tree = new JCNewArray(elemtype, dims, elems); |
|
413 |
tree.pos = pos; |
|
414 |
return tree; |
|
415 |
} |
|
416 |
||
11141 | 417 |
public JCLambda Lambda(List<JCVariableDecl> params, |
418 |
JCTree body) |
|
419 |
{ |
|
420 |
JCLambda tree = new JCLambda(params, body); |
|
421 |
tree.pos = pos; |
|
422 |
return tree; |
|
423 |
} |
|
424 |
||
10 | 425 |
public JCParens Parens(JCExpression expr) { |
426 |
JCParens tree = new JCParens(expr); |
|
427 |
tree.pos = pos; |
|
428 |
return tree; |
|
429 |
} |
|
430 |
||
431 |
public JCAssign Assign(JCExpression lhs, JCExpression rhs) { |
|
432 |
JCAssign tree = new JCAssign(lhs, rhs); |
|
433 |
tree.pos = pos; |
|
434 |
return tree; |
|
435 |
} |
|
436 |
||
10950 | 437 |
public JCAssignOp Assignop(JCTree.Tag opcode, JCTree lhs, JCTree rhs) { |
10 | 438 |
JCAssignOp tree = new JCAssignOp(opcode, lhs, rhs, null); |
439 |
tree.pos = pos; |
|
440 |
return tree; |
|
441 |
} |
|
442 |
||
10950 | 443 |
public JCUnary Unary(JCTree.Tag opcode, JCExpression arg) { |
10 | 444 |
JCUnary tree = new JCUnary(opcode, arg); |
445 |
tree.pos = pos; |
|
446 |
return tree; |
|
447 |
} |
|
448 |
||
10950 | 449 |
public JCBinary Binary(JCTree.Tag opcode, JCExpression lhs, JCExpression rhs) { |
10 | 450 |
JCBinary tree = new JCBinary(opcode, lhs, rhs, null); |
451 |
tree.pos = pos; |
|
452 |
return tree; |
|
453 |
} |
|
454 |
||
455 |
public JCTypeCast TypeCast(JCTree clazz, JCExpression expr) { |
|
456 |
JCTypeCast tree = new JCTypeCast(clazz, expr); |
|
457 |
tree.pos = pos; |
|
458 |
return tree; |
|
459 |
} |
|
460 |
||
461 |
public JCInstanceOf TypeTest(JCExpression expr, JCTree clazz) { |
|
462 |
JCInstanceOf tree = new JCInstanceOf(expr, clazz); |
|
463 |
tree.pos = pos; |
|
464 |
return tree; |
|
465 |
} |
|
466 |
||
59285
7799a51dbe30
8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents:
59021
diff
changeset
|
467 |
public JCBindingPattern BindingPattern(Name name, JCTree vartype) { |
7799a51dbe30
8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents:
59021
diff
changeset
|
468 |
JCBindingPattern tree = new JCBindingPattern(name, null, vartype); |
7799a51dbe30
8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents:
59021
diff
changeset
|
469 |
tree.pos = pos; |
7799a51dbe30
8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents:
59021
diff
changeset
|
470 |
return tree; |
7799a51dbe30
8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents:
59021
diff
changeset
|
471 |
} |
7799a51dbe30
8231826: Implement javac changes for pattern matching for instanceof
jlahoda
parents:
59021
diff
changeset
|
472 |
|
10 | 473 |
public JCArrayAccess Indexed(JCExpression indexed, JCExpression index) { |
474 |
JCArrayAccess tree = new JCArrayAccess(indexed, index); |
|
475 |
tree.pos = pos; |
|
476 |
return tree; |
|
477 |
} |
|
478 |
||
479 |
public JCFieldAccess Select(JCExpression selected, Name selector) { |
|
480 |
JCFieldAccess tree = new JCFieldAccess(selected, selector, null); |
|
481 |
tree.pos = pos; |
|
482 |
return tree; |
|
483 |
} |
|
484 |
||
11142 | 485 |
public JCMemberReference Reference(JCMemberReference.ReferenceMode mode, Name name, |
486 |
JCExpression expr, List<JCExpression> typeargs) { |
|
487 |
JCMemberReference tree = new JCMemberReference(mode, name, expr, typeargs); |
|
488 |
tree.pos = pos; |
|
489 |
return tree; |
|
490 |
} |
|
491 |
||
10 | 492 |
public JCIdent Ident(Name name) { |
493 |
JCIdent tree = new JCIdent(name, null); |
|
494 |
tree.pos = pos; |
|
495 |
return tree; |
|
496 |
} |
|
497 |
||
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13845
diff
changeset
|
498 |
public JCLiteral Literal(TypeTag tag, Object value) { |
10 | 499 |
JCLiteral tree = new JCLiteral(tag, value); |
500 |
tree.pos = pos; |
|
501 |
return tree; |
|
502 |
} |
|
503 |
||
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13845
diff
changeset
|
504 |
public JCPrimitiveTypeTree TypeIdent(TypeTag typetag) { |
10 | 505 |
JCPrimitiveTypeTree tree = new JCPrimitiveTypeTree(typetag); |
506 |
tree.pos = pos; |
|
507 |
return tree; |
|
508 |
} |
|
509 |
||
510 |
public JCArrayTypeTree TypeArray(JCExpression elemtype) { |
|
511 |
JCArrayTypeTree tree = new JCArrayTypeTree(elemtype); |
|
512 |
tree.pos = pos; |
|
513 |
return tree; |
|
514 |
} |
|
515 |
||
516 |
public JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments) { |
|
517 |
JCTypeApply tree = new JCTypeApply(clazz, arguments); |
|
518 |
tree.pos = pos; |
|
519 |
return tree; |
|
520 |
} |
|
521 |
||
9300
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
522 |
public JCTypeUnion TypeUnion(List<JCExpression> components) { |
c2de4dd9853b
7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents:
8625
diff
changeset
|
523 |
JCTypeUnion tree = new JCTypeUnion(components); |
5492
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
4870
diff
changeset
|
524 |
tree.pos = pos; |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
4870
diff
changeset
|
525 |
return tree; |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
4870
diff
changeset
|
526 |
} |
515e4b33b335
6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents:
4870
diff
changeset
|
527 |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
528 |
public JCTypeIntersection TypeIntersection(List<JCExpression> components) { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
529 |
JCTypeIntersection tree = new JCTypeIntersection(components); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
530 |
tree.pos = pos; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
531 |
return tree; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
532 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
533 |
|
10 | 534 |
public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds) { |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
535 |
return TypeParameter(name, bounds, List.nil()); |
15385 | 536 |
} |
537 |
||
538 |
public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annos) { |
|
539 |
JCTypeParameter tree = new JCTypeParameter(name, bounds, annos); |
|
10 | 540 |
tree.pos = pos; |
541 |
return tree; |
|
542 |
} |
|
543 |
||
544 |
public JCWildcard Wildcard(TypeBoundKind kind, JCTree type) { |
|
545 |
JCWildcard tree = new JCWildcard(kind, type); |
|
546 |
tree.pos = pos; |
|
547 |
return tree; |
|
548 |
} |
|
549 |
||
550 |
public TypeBoundKind TypeBoundKind(BoundKind kind) { |
|
551 |
TypeBoundKind tree = new TypeBoundKind(kind); |
|
552 |
tree.pos = pos; |
|
553 |
return tree; |
|
554 |
} |
|
555 |
||
556 |
public JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args) { |
|
15385 | 557 |
JCAnnotation tree = new JCAnnotation(Tag.ANNOTATION, annotationType, args); |
558 |
tree.pos = pos; |
|
559 |
return tree; |
|
560 |
} |
|
561 |
||
562 |
public JCAnnotation TypeAnnotation(JCTree annotationType, List<JCExpression> args) { |
|
563 |
JCAnnotation tree = new JCAnnotation(Tag.TYPE_ANNOTATION, annotationType, args); |
|
10 | 564 |
tree.pos = pos; |
565 |
return tree; |
|
566 |
} |
|
567 |
||
568 |
public JCModifiers Modifiers(long flags, List<JCAnnotation> annotations) { |
|
569 |
JCModifiers tree = new JCModifiers(flags, annotations); |
|
6152
111b884a19a7
6972327: JCTree.pos incorrect for annotations without modifiers and package
jjg
parents:
6148
diff
changeset
|
570 |
boolean noFlags = (flags & (Flags.ModifierFlags | Flags.ANNOTATION)) == 0; |
10 | 571 |
tree.pos = (noFlags && annotations.isEmpty()) ? Position.NOPOS : pos; |
572 |
return tree; |
|
573 |
} |
|
574 |
||
575 |
public JCModifiers Modifiers(long flags) { |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
576 |
return Modifiers(flags, List.nil()); |
10 | 577 |
} |
578 |
||
36526 | 579 |
@Override |
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
580 |
public JCModuleDecl ModuleDef(JCModifiers mods, ModuleKind kind, |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
581 |
JCExpression qualid, List<JCDirective> directives) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
582 |
JCModuleDecl tree = new JCModuleDecl(mods, kind, qualid, directives); |
36526 | 583 |
tree.pos = pos; |
584 |
return tree; |
|
585 |
} |
|
586 |
||
587 |
@Override |
|
588 |
public JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames) { |
|
589 |
JCExports tree = new JCExports(qualId, moduleNames); |
|
590 |
tree.pos = pos; |
|
591 |
return tree; |
|
592 |
} |
|
593 |
||
594 |
@Override |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
595 |
public JCOpens Opens(JCExpression qualId, List<JCExpression> moduleNames) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
596 |
JCOpens tree = new JCOpens(qualId, moduleNames); |
36526 | 597 |
tree.pos = pos; |
598 |
return tree; |
|
599 |
} |
|
600 |
||
601 |
@Override |
|
42407
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
602 |
public JCProvides Provides(JCExpression serviceName, List<JCExpression> implNames) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
603 |
JCProvides tree = new JCProvides(serviceName, implNames); |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
604 |
tree.pos = pos; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
605 |
return tree; |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
606 |
} |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
607 |
|
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
608 |
@Override |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
609 |
public JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId) { |
f3702cff2933
8169069: Module system implementation refresh (11/2016)
alanb
parents:
36526
diff
changeset
|
610 |
JCRequires tree = new JCRequires(isTransitive, isStaticPhase, qualId); |
36526 | 611 |
tree.pos = pos; |
612 |
return tree; |
|
613 |
} |
|
614 |
||
615 |
@Override |
|
616 |
public JCUses Uses(JCExpression qualId) { |
|
617 |
JCUses tree = new JCUses(qualId); |
|
618 |
tree.pos = pos; |
|
619 |
return tree; |
|
620 |
} |
|
621 |
||
15385 | 622 |
public JCAnnotatedType AnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) { |
623 |
JCAnnotatedType tree = new JCAnnotatedType(annotations, underlyingType); |
|
624 |
tree.pos = pos; |
|
625 |
return tree; |
|
626 |
} |
|
627 |
||
10 | 628 |
public JCErroneous Erroneous() { |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
629 |
return Erroneous(List.nil()); |
10 | 630 |
} |
631 |
||
632 |
public JCErroneous Erroneous(List<? extends JCTree> errs) { |
|
633 |
JCErroneous tree = new JCErroneous(errs); |
|
634 |
tree.pos = pos; |
|
635 |
return tree; |
|
636 |
} |
|
637 |
||
51563
de411d537aae
8206986: Compiler support for Switch Expressions (Preview)
jlahoda
parents:
50400
diff
changeset
|
638 |
public LetExpr LetExpr(List<JCStatement> defs, JCExpression expr) { |
10 | 639 |
LetExpr tree = new LetExpr(defs, expr); |
640 |
tree.pos = pos; |
|
641 |
return tree; |
|
642 |
} |
|
643 |
||
644 |
/* *************************************************************************** |
|
645 |
* Derived building blocks. |
|
646 |
****************************************************************************/ |
|
647 |
||
648 |
public JCClassDecl AnonymousClassDef(JCModifiers mods, |
|
649 |
List<JCTree> defs) |
|
650 |
{ |
|
651 |
return ClassDef(mods, |
|
652 |
names.empty, |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
653 |
List.nil(), |
10 | 654 |
null, |
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
655 |
List.nil(), |
10 | 656 |
defs); |
657 |
} |
|
658 |
||
33707
d74fef6b01e0
8141639: Signatures in Lower could be made tighter by using JCExpression instead of JCTree
mcimadamore
parents:
33706
diff
changeset
|
659 |
public LetExpr LetExpr(JCVariableDecl def, JCExpression expr) { |
10 | 660 |
LetExpr tree = new LetExpr(List.of(def), expr); |
661 |
tree.pos = pos; |
|
662 |
return tree; |
|
663 |
} |
|
664 |
||
665 |
/** Create an identifier from a symbol. |
|
666 |
*/ |
|
667 |
public JCIdent Ident(Symbol sym) { |
|
668 |
return (JCIdent)new JCIdent((sym.name != names.empty) |
|
669 |
? sym.name |
|
670 |
: sym.flatName(), sym) |
|
671 |
.setPos(pos) |
|
672 |
.setType(sym.type); |
|
673 |
} |
|
674 |
||
675 |
/** Create a selection node from a qualifier tree and a symbol. |
|
676 |
* @param base The qualifier tree. |
|
677 |
*/ |
|
678 |
public JCExpression Select(JCExpression base, Symbol sym) { |
|
679 |
return new JCFieldAccess(base, sym.name, sym).setPos(pos).setType(sym.type); |
|
680 |
} |
|
681 |
||
682 |
/** Create a qualified identifier from a symbol, adding enough qualifications |
|
683 |
* to make the reference unique. |
|
684 |
*/ |
|
685 |
public JCExpression QualIdent(Symbol sym) { |
|
686 |
return isUnqualifiable(sym) |
|
687 |
? Ident(sym) |
|
688 |
: Select(QualIdent(sym.owner), sym); |
|
689 |
} |
|
690 |
||
691 |
/** Create an identifier that refers to the variable declared in given variable |
|
692 |
* declaration. |
|
693 |
*/ |
|
694 |
public JCExpression Ident(JCVariableDecl param) { |
|
695 |
return Ident(param.sym); |
|
696 |
} |
|
697 |
||
698 |
/** Create a list of identifiers referring to the variables declared |
|
699 |
* in given list of variable declarations. |
|
700 |
*/ |
|
701 |
public List<JCExpression> Idents(List<JCVariableDecl> params) { |
|
22163 | 702 |
ListBuffer<JCExpression> ids = new ListBuffer<>(); |
10 | 703 |
for (List<JCVariableDecl> l = params; l.nonEmpty(); l = l.tail) |
704 |
ids.append(Ident(l.head)); |
|
705 |
return ids.toList(); |
|
706 |
} |
|
707 |
||
708 |
/** Create a tree representing `this', given its type. |
|
709 |
*/ |
|
710 |
public JCExpression This(Type t) { |
|
711 |
return Ident(new VarSymbol(FINAL, names._this, t, t.tsym)); |
|
712 |
} |
|
713 |
||
33706
0d21ecb55e6a
8129740: Incorrect class file created when passing lambda in inner class constructor
sadayapalam
parents:
30404
diff
changeset
|
714 |
/** Create a tree representing qualified `this' given its type |
0d21ecb55e6a
8129740: Incorrect class file created when passing lambda in inner class constructor
sadayapalam
parents:
30404
diff
changeset
|
715 |
*/ |
0d21ecb55e6a
8129740: Incorrect class file created when passing lambda in inner class constructor
sadayapalam
parents:
30404
diff
changeset
|
716 |
public JCExpression QualThis(Type t) { |
0d21ecb55e6a
8129740: Incorrect class file created when passing lambda in inner class constructor
sadayapalam
parents:
30404
diff
changeset
|
717 |
return Select(Type(t), new VarSymbol(FINAL, names._this, t, t.tsym)); |
0d21ecb55e6a
8129740: Incorrect class file created when passing lambda in inner class constructor
sadayapalam
parents:
30404
diff
changeset
|
718 |
} |
0d21ecb55e6a
8129740: Incorrect class file created when passing lambda in inner class constructor
sadayapalam
parents:
30404
diff
changeset
|
719 |
|
10 | 720 |
/** Create a tree representing a class literal. |
721 |
*/ |
|
722 |
public JCExpression ClassLiteral(ClassSymbol clazz) { |
|
723 |
return ClassLiteral(clazz.type); |
|
724 |
} |
|
725 |
||
726 |
/** Create a tree representing a class literal. |
|
727 |
*/ |
|
728 |
public JCExpression ClassLiteral(Type t) { |
|
729 |
VarSymbol lit = new VarSymbol(STATIC | PUBLIC | FINAL, |
|
730 |
names._class, |
|
731 |
t, |
|
732 |
t.tsym); |
|
733 |
return Select(Type(t), lit); |
|
734 |
} |
|
735 |
||
736 |
/** Create a tree representing `super', given its type and owner. |
|
737 |
*/ |
|
738 |
public JCIdent Super(Type t, TypeSymbol owner) { |
|
739 |
return Ident(new VarSymbol(FINAL, names._super, t, owner)); |
|
740 |
} |
|
741 |
||
742 |
/** |
|
743 |
* Create a method invocation from a method tree and a list of |
|
744 |
* argument trees. |
|
745 |
*/ |
|
746 |
public JCMethodInvocation App(JCExpression meth, List<JCExpression> args) { |
|
747 |
return Apply(null, meth, args).setType(meth.type.getReturnType()); |
|
748 |
} |
|
749 |
||
750 |
/** |
|
751 |
* Create a no-arg method invocation from a method tree |
|
752 |
*/ |
|
753 |
public JCMethodInvocation App(JCExpression meth) { |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
754 |
return Apply(null, meth, List.nil()).setType(meth.type.getReturnType()); |
10 | 755 |
} |
756 |
||
757 |
/** Create a method invocation from a method tree and a list of argument trees. |
|
758 |
*/ |
|
759 |
public JCExpression Create(Symbol ctor, List<JCExpression> args) { |
|
760 |
Type t = ctor.owner.erasure(types); |
|
761 |
JCNewClass newclass = NewClass(null, null, Type(t), args, null); |
|
762 |
newclass.constructor = ctor; |
|
763 |
newclass.setType(t); |
|
764 |
return newclass; |
|
765 |
} |
|
766 |
||
767 |
/** Create a tree representing given type. |
|
768 |
*/ |
|
769 |
public JCExpression Type(Type t) { |
|
770 |
if (t == null) return null; |
|
771 |
JCExpression tp; |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13845
diff
changeset
|
772 |
switch (t.getTag()) { |
10 | 773 |
case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT: |
774 |
case DOUBLE: case BOOLEAN: case VOID: |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13845
diff
changeset
|
775 |
tp = TypeIdent(t.getTag()); |
10 | 776 |
break; |
777 |
case TYPEVAR: |
|
778 |
tp = Ident(t.tsym); |
|
779 |
break; |
|
780 |
case WILDCARD: { |
|
781 |
WildcardType a = ((WildcardType) t); |
|
30404
952a476681b2
8078473: javac diamond finder crashes when used to build java.base module.
sadayapalam
parents:
29294
diff
changeset
|
782 |
tp = Wildcard(TypeBoundKind(a.kind), a.kind == BoundKind.UNBOUND ? null : Type(a.type)); |
10 | 783 |
break; |
784 |
} |
|
785 |
case CLASS: |
|
25440
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
786 |
switch (t.getKind()) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
787 |
case UNION: { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
788 |
UnionClassType tu = (UnionClassType)t; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
789 |
ListBuffer<JCExpression> la = new ListBuffer<>(); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
790 |
for (Type ta : tu.getAlternativeTypes()) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
791 |
la.add(Type(ta)); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
792 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
793 |
tp = TypeUnion(la.toList()); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
794 |
break; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
795 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
796 |
case INTERSECTION: { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
797 |
IntersectionClassType it = (IntersectionClassType)t; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
798 |
ListBuffer<JCExpression> la = new ListBuffer<>(); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
799 |
for (Type ta : it.getExplicitComponents()) { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
800 |
la.add(Type(ta)); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
801 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
802 |
tp = TypeIntersection(la.toList()); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
803 |
break; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
804 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
805 |
default: { |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
806 |
Type outer = t.getEnclosingType(); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
807 |
JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
808 |
? Select(Type(outer), t.tsym) |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
809 |
: QualIdent(t.tsym); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
810 |
tp = t.getTypeArguments().isEmpty() |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
811 |
? clazz |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
812 |
: TypeApply(clazz, Types(t.getTypeArguments())); |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
813 |
break; |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
814 |
} |
7f9cedf2e88d
8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType
jlahoda
parents:
24069
diff
changeset
|
815 |
} |
10 | 816 |
break; |
817 |
case ARRAY: |
|
818 |
tp = TypeArray(Type(types.elemtype(t))); |
|
819 |
break; |
|
820 |
case ERROR: |
|
821 |
tp = TypeIdent(ERROR); |
|
822 |
break; |
|
823 |
default: |
|
824 |
throw new AssertionError("unexpected type: " + t); |
|
825 |
} |
|
826 |
return tp.setType(t); |
|
827 |
} |
|
828 |
||
829 |
/** Create a list of trees representing given list of types. |
|
830 |
*/ |
|
831 |
public List<JCExpression> Types(List<Type> ts) { |
|
22163 | 832 |
ListBuffer<JCExpression> lb = new ListBuffer<>(); |
10 | 833 |
for (List<Type> l = ts; l.nonEmpty(); l = l.tail) |
8032 | 834 |
lb.append(Type(l.head)); |
835 |
return lb.toList(); |
|
10 | 836 |
} |
837 |
||
838 |
/** Create a variable definition from a variable symbol and an initializer |
|
839 |
* expression. |
|
840 |
*/ |
|
841 |
public JCVariableDecl VarDef(VarSymbol v, JCExpression init) { |
|
842 |
return (JCVariableDecl) |
|
843 |
new JCVariableDecl( |
|
14961
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14725
diff
changeset
|
844 |
Modifiers(v.flags(), Annotations(v.getRawAttributes())), |
10 | 845 |
v.name, |
846 |
Type(v.type), |
|
847 |
init, |
|
848 |
v).setPos(pos).setType(v.type); |
|
849 |
} |
|
850 |
||
851 |
/** Create annotation trees from annotations. |
|
852 |
*/ |
|
853 |
public List<JCAnnotation> Annotations(List<Attribute.Compound> attributes) { |
|
854 |
if (attributes == null) return List.nil(); |
|
22163 | 855 |
ListBuffer<JCAnnotation> result = new ListBuffer<>(); |
10 | 856 |
for (List<Attribute.Compound> i = attributes; i.nonEmpty(); i=i.tail) { |
857 |
Attribute a = i.head; |
|
858 |
result.append(Annotation(a)); |
|
859 |
} |
|
860 |
return result.toList(); |
|
861 |
} |
|
862 |
||
863 |
public JCLiteral Literal(Object value) { |
|
864 |
JCLiteral result = null; |
|
865 |
if (value instanceof String) { |
|
866 |
result = Literal(CLASS, value). |
|
867 |
setType(syms.stringType.constType(value)); |
|
868 |
} else if (value instanceof Integer) { |
|
869 |
result = Literal(INT, value). |
|
870 |
setType(syms.intType.constType(value)); |
|
871 |
} else if (value instanceof Long) { |
|
872 |
result = Literal(LONG, value). |
|
873 |
setType(syms.longType.constType(value)); |
|
874 |
} else if (value instanceof Byte) { |
|
875 |
result = Literal(BYTE, value). |
|
876 |
setType(syms.byteType.constType(value)); |
|
877 |
} else if (value instanceof Character) { |
|
7636
030f141aa32b
6504896: TreeMaker.Literal(Object) does not support Booleans
jjg
parents:
7074
diff
changeset
|
878 |
int v = (int) (((Character) value).toString().charAt(0)); |
22154
3c8d86bf756b
8028415: TreeMaker.Literal(Object) creates invalid JCLiterals when passed a Character.
jlahoda
parents:
20244
diff
changeset
|
879 |
result = Literal(CHAR, v). |
7636
030f141aa32b
6504896: TreeMaker.Literal(Object) does not support Booleans
jjg
parents:
7074
diff
changeset
|
880 |
setType(syms.charType.constType(v)); |
10 | 881 |
} else if (value instanceof Double) { |
882 |
result = Literal(DOUBLE, value). |
|
883 |
setType(syms.doubleType.constType(value)); |
|
884 |
} else if (value instanceof Float) { |
|
885 |
result = Literal(FLOAT, value). |
|
886 |
setType(syms.floatType.constType(value)); |
|
887 |
} else if (value instanceof Short) { |
|
888 |
result = Literal(SHORT, value). |
|
889 |
setType(syms.shortType.constType(value)); |
|
7636
030f141aa32b
6504896: TreeMaker.Literal(Object) does not support Booleans
jjg
parents:
7074
diff
changeset
|
890 |
} else if (value instanceof Boolean) { |
030f141aa32b
6504896: TreeMaker.Literal(Object) does not support Booleans
jjg
parents:
7074
diff
changeset
|
891 |
int v = ((Boolean) value) ? 1 : 0; |
030f141aa32b
6504896: TreeMaker.Literal(Object) does not support Booleans
jjg
parents:
7074
diff
changeset
|
892 |
result = Literal(BOOLEAN, v). |
030f141aa32b
6504896: TreeMaker.Literal(Object) does not support Booleans
jjg
parents:
7074
diff
changeset
|
893 |
setType(syms.booleanType.constType(v)); |
10 | 894 |
} else { |
895 |
throw new AssertionError(value); |
|
896 |
} |
|
897 |
return result; |
|
898 |
} |
|
899 |
||
900 |
class AnnotationBuilder implements Attribute.Visitor { |
|
901 |
JCExpression result = null; |
|
902 |
public void visitConstant(Attribute.Constant v) { |
|
19251
c3b7abd43bc0
8020997: TreeMaker.AnnotationBuilder creates broken element literals with repeating annotations
vromero
parents:
17807
diff
changeset
|
903 |
result = Literal(v.type.getTag(), v.value); |
10 | 904 |
} |
905 |
public void visitClass(Attribute.Class clazz) { |
|
13689
4d519199a6aa
7151010: Add compiler support for repeating annotations
jfranck
parents:
11142
diff
changeset
|
906 |
result = ClassLiteral(clazz.classType).setType(syms.classType); |
10 | 907 |
} |
908 |
public void visitEnum(Attribute.Enum e) { |
|
909 |
result = QualIdent(e.value); |
|
910 |
} |
|
911 |
public void visitError(Attribute.Error e) { |
|
50400
dcbbc6fb0b69
8200166: Repeating annotations refering to to-be-generated classes don't work.
jlahoda
parents:
47216
diff
changeset
|
912 |
if (e instanceof UnresolvedClass) { |
dcbbc6fb0b69
8200166: Repeating annotations refering to to-be-generated classes don't work.
jlahoda
parents:
47216
diff
changeset
|
913 |
result = ClassLiteral(((UnresolvedClass) e).classType).setType(syms.classType); |
dcbbc6fb0b69
8200166: Repeating annotations refering to to-be-generated classes don't work.
jlahoda
parents:
47216
diff
changeset
|
914 |
} else { |
dcbbc6fb0b69
8200166: Repeating annotations refering to to-be-generated classes don't work.
jlahoda
parents:
47216
diff
changeset
|
915 |
result = Erroneous(); |
dcbbc6fb0b69
8200166: Repeating annotations refering to to-be-generated classes don't work.
jlahoda
parents:
47216
diff
changeset
|
916 |
} |
10 | 917 |
} |
918 |
public void visitCompound(Attribute.Compound compound) { |
|
15385 | 919 |
if (compound instanceof Attribute.TypeCompound) { |
920 |
result = visitTypeCompoundInternal((Attribute.TypeCompound) compound); |
|
921 |
} else { |
|
922 |
result = visitCompoundInternal(compound); |
|
923 |
} |
|
10 | 924 |
} |
925 |
public JCAnnotation visitCompoundInternal(Attribute.Compound compound) { |
|
22163 | 926 |
ListBuffer<JCExpression> args = new ListBuffer<>(); |
10 | 927 |
for (List<Pair<Symbol.MethodSymbol,Attribute>> values = compound.values; values.nonEmpty(); values=values.tail) { |
928 |
Pair<MethodSymbol,Attribute> pair = values.head; |
|
929 |
JCExpression valueTree = translate(pair.snd); |
|
930 |
args.append(Assign(Ident(pair.fst), valueTree).setType(valueTree.type)); |
|
931 |
} |
|
932 |
return Annotation(Type(compound.type), args.toList()); |
|
933 |
} |
|
15385 | 934 |
public JCAnnotation visitTypeCompoundInternal(Attribute.TypeCompound compound) { |
22163 | 935 |
ListBuffer<JCExpression> args = new ListBuffer<>(); |
15385 | 936 |
for (List<Pair<Symbol.MethodSymbol,Attribute>> values = compound.values; values.nonEmpty(); values=values.tail) { |
937 |
Pair<MethodSymbol,Attribute> pair = values.head; |
|
938 |
JCExpression valueTree = translate(pair.snd); |
|
939 |
args.append(Assign(Ident(pair.fst), valueTree).setType(valueTree.type)); |
|
940 |
} |
|
941 |
return TypeAnnotation(Type(compound.type), args.toList()); |
|
942 |
} |
|
10 | 943 |
public void visitArray(Attribute.Array array) { |
22163 | 944 |
ListBuffer<JCExpression> elems = new ListBuffer<>(); |
10 | 945 |
for (int i = 0; i < array.values.length; i++) |
946 |
elems.append(translate(array.values[i])); |
|
42828
cce89649f958
8171371: Remove redundant type-arguments from generic method calls
mcimadamore
parents:
42407
diff
changeset
|
947 |
result = NewArray(null, List.nil(), elems.toList()).setType(array.type); |
10 | 948 |
} |
949 |
JCExpression translate(Attribute a) { |
|
950 |
a.accept(this); |
|
951 |
return result; |
|
952 |
} |
|
953 |
JCAnnotation translate(Attribute.Compound a) { |
|
954 |
return visitCompoundInternal(a); |
|
955 |
} |
|
15385 | 956 |
JCAnnotation translate(Attribute.TypeCompound a) { |
957 |
return visitTypeCompoundInternal(a); |
|
958 |
} |
|
10 | 959 |
} |
15385 | 960 |
|
10 | 961 |
AnnotationBuilder annotationBuilder = new AnnotationBuilder(); |
962 |
||
963 |
/** Create an annotation tree from an attribute. |
|
964 |
*/ |
|
965 |
public JCAnnotation Annotation(Attribute a) { |
|
966 |
return annotationBuilder.translate((Attribute.Compound)a); |
|
967 |
} |
|
968 |
||
15385 | 969 |
public JCAnnotation TypeAnnotation(Attribute a) { |
970 |
return annotationBuilder.translate((Attribute.TypeCompound) a); |
|
971 |
} |
|
972 |
||
10 | 973 |
/** Create a method definition from a method symbol and a method body. |
974 |
*/ |
|
975 |
public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) { |
|
976 |
return MethodDef(m, m.type, body); |
|
977 |
} |
|
978 |
||
979 |
/** Create a method definition from a method symbol, method type |
|
980 |
* and a method body. |
|
981 |
*/ |
|
982 |
public JCMethodDecl MethodDef(MethodSymbol m, Type mtype, JCBlock body) { |
|
983 |
return (JCMethodDecl) |
|
984 |
new JCMethodDecl( |
|
14961
e731935052af
8005098: Provide isSynthesized() information on Attribute.Compound
jfranck
parents:
14725
diff
changeset
|
985 |
Modifiers(m.flags(), Annotations(m.getRawAttributes())), |
10 | 986 |
m.name, |
987 |
Type(mtype.getReturnType()), |
|
988 |
TypeParams(mtype.getTypeArguments()), |
|
15385 | 989 |
null, // receiver type |
10 | 990 |
Params(mtype.getParameterTypes(), m), |
991 |
Types(mtype.getThrownTypes()), |
|
992 |
body, |
|
993 |
null, |
|
994 |
m).setPos(pos).setType(mtype); |
|
995 |
} |
|
996 |
||
997 |
/** Create a type parameter tree from its name and type. |
|
998 |
*/ |
|
999 |
public JCTypeParameter TypeParam(Name name, TypeVar tvar) { |
|
1000 |
return (JCTypeParameter) |
|
1001 |
TypeParameter(name, Types(types.getBounds(tvar))).setPos(pos).setType(tvar); |
|
1002 |
} |
|
1003 |
||
1004 |
/** Create a list of type parameter trees from a list of type variables. |
|
1005 |
*/ |
|
1006 |
public List<JCTypeParameter> TypeParams(List<Type> typarams) { |
|
22163 | 1007 |
ListBuffer<JCTypeParameter> tparams = new ListBuffer<>(); |
10 | 1008 |
for (List<Type> l = typarams; l.nonEmpty(); l = l.tail) |
1009 |
tparams.append(TypeParam(l.head.tsym.name, (TypeVar)l.head)); |
|
1010 |
return tparams.toList(); |
|
1011 |
} |
|
1012 |
||
1013 |
/** Create a value parameter tree from its name, type, and owner. |
|
1014 |
*/ |
|
1015 |
public JCVariableDecl Param(Name name, Type argtype, Symbol owner) { |
|
19941
8b91e8eb2d20
7047734: javac, the LVT is not generated correctly in several scenarios
vromero
parents:
19251
diff
changeset
|
1016 |
return VarDef(new VarSymbol(PARAMETER, name, argtype, owner), null); |
10 | 1017 |
} |
1018 |
||
1019 |
/** Create a a list of value parameter trees x0, ..., xn from a list of |
|
1020 |
* their types and an their owner. |
|
1021 |
*/ |
|
1022 |
public List<JCVariableDecl> Params(List<Type> argtypes, Symbol owner) { |
|
22163 | 1023 |
ListBuffer<JCVariableDecl> params = new ListBuffer<>(); |
10 | 1024 |
MethodSymbol mth = (owner.kind == MTH) ? ((MethodSymbol)owner) : null; |
1025 |
if (mth != null && mth.params != null && argtypes.length() == mth.params.length()) { |
|
1026 |
for (VarSymbol param : ((MethodSymbol)owner).params) |
|
1027 |
params.append(VarDef(param, null)); |
|
1028 |
} else { |
|
1029 |
int i = 0; |
|
1030 |
for (List<Type> l = argtypes; l.nonEmpty(); l = l.tail) |
|
1031 |
params.append(Param(paramName(i++), l.head, owner)); |
|
1032 |
} |
|
1033 |
return params.toList(); |
|
1034 |
} |
|
1035 |
||
1036 |
/** Wrap a method invocation in an expression statement or return statement, |
|
1037 |
* depending on whether the method invocation expression's type is void. |
|
1038 |
*/ |
|
1039 |
public JCStatement Call(JCExpression apply) { |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
13845
diff
changeset
|
1040 |
return apply.type.hasTag(VOID) ? Exec(apply) : Return(apply); |
10 | 1041 |
} |
1042 |
||
1043 |
/** Construct an assignment from a variable symbol and a right hand side. |
|
1044 |
*/ |
|
1045 |
public JCStatement Assignment(Symbol v, JCExpression rhs) { |
|
1046 |
return Exec(Assign(Ident(v), rhs).setType(v.type)); |
|
1047 |
} |
|
1048 |
||
1049 |
/** Construct an index expression from a variable and an expression. |
|
1050 |
*/ |
|
1051 |
public JCArrayAccess Indexed(Symbol v, JCExpression index) { |
|
1052 |
JCArrayAccess tree = new JCArrayAccess(QualIdent(v), index); |
|
1053 |
tree.type = ((ArrayType)v.type).elemtype; |
|
1054 |
return tree; |
|
1055 |
} |
|
1056 |
||
1057 |
/** Make an attributed type cast expression. |
|
1058 |
*/ |
|
1059 |
public JCTypeCast TypeCast(Type type, JCExpression expr) { |
|
1060 |
return (JCTypeCast)TypeCast(Type(type), expr).setType(type); |
|
1061 |
} |
|
1062 |
||
1063 |
/* *************************************************************************** |
|
1064 |
* Helper methods. |
|
1065 |
****************************************************************************/ |
|
1066 |
||
1067 |
/** Can given symbol be referred to in unqualified form? |
|
1068 |
*/ |
|
1069 |
boolean isUnqualifiable(Symbol sym) { |
|
1070 |
if (sym.name == names.empty || |
|
1071 |
sym.owner == null || |
|
20244 | 1072 |
sym.owner == syms.rootPackage || |
10 | 1073 |
sym.owner.kind == MTH || sym.owner.kind == VAR) { |
1074 |
return true; |
|
1075 |
} else if (sym.kind == TYP && toplevel != null) { |
|
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1076 |
Iterator<Symbol> it = toplevel.namedImportScope.getSymbolsByName(sym.name).iterator(); |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1077 |
if (it.hasNext()) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1078 |
Symbol s = it.next(); |
10 | 1079 |
return |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1080 |
s == sym && |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1081 |
!it.hasNext(); |
10 | 1082 |
} |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1083 |
it = toplevel.packge.members().getSymbolsByName(sym.name).iterator(); |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1084 |
if (it.hasNext()) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1085 |
Symbol s = it.next(); |
10 | 1086 |
return |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1087 |
s == sym && |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1088 |
!it.hasNext(); |
10 | 1089 |
} |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1090 |
it = toplevel.starImportScope.getSymbolsByName(sym.name).iterator(); |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1091 |
if (it.hasNext()) { |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1092 |
Symbol s = it.next(); |
10 | 1093 |
return |
25443
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1094 |
s == sym && |
9187d77f2c64
8031569: Refactor javac scope implementation to enable lazy imports
jlahoda
parents:
25440
diff
changeset
|
1095 |
!it.hasNext(); |
10 | 1096 |
} |
1097 |
} |
|
1098 |
return false; |
|
1099 |
} |
|
1100 |
||
1101 |
/** The name of synthetic parameter number `i'. |
|
1102 |
*/ |
|
1103 |
public Name paramName(int i) { return names.fromString("x" + i); } |
|
1104 |
||
1105 |
/** The name of synthetic type parameter number `i'. |
|
1106 |
*/ |
|
1107 |
public Name typaramName(int i) { return names.fromString("A" + i); } |
|
1108 |
} |