Produced by Araxis Merge on 9/25/2018 2:13:08 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\tools\javac\tree | JCTree.java | Mon Jan 22 14:47:06 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\tools\javac\tree | JCTree.java | Wed Sep 12 16:50:19 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 3 | 5178 |
Changed | 2 | 4 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | /* | |
2 | * Copyrig ht (c) 199 9, 2013, O racle and/ or its aff iliates. A ll rights reserved. | |
3 | * DO NOT ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER. | |
4 | * | |
5 | * This co de is free software; you can r edistribut e it and/o r modify i t | |
6 | * under t he terms o f the GNU General Pu blic Licen se version 2 only, a s | |
7 | * publish ed by the Free Softw are Founda tion. Ora cle design ates this | |
8 | * particu lar file a s subject to the "Cl asspath" e xception a s provided | |
9 | * by Orac le in the LICENSE fi le that ac companied this code. | |
10 | * | |
11 | * This co de is dist ributed in the hope that it wi ll be usef ul, but WI THOUT | |
12 | * ANY WAR RANTY; wit hout even the implie d warranty of MERCHA NTABILITY or | |
13 | * FITNESS FOR A PAR TICULAR PU RPOSE. Se e the GNU General Pu blic Licen se | |
14 | * version 2 for mor e details (a copy is included in the LIC ENSE file that | |
15 | * accompa nied this code). | |
16 | * | |
17 | * You sho uld have r eceived a copy of th e GNU Gene ral Public License v ersion | |
18 | * 2 along with this work; if not, write to the Fr ee Softwar e Foundati on, | |
19 | * Inc., 5 1 Franklin St, Fifth Floor, Bo ston, MA 0 2110-1301 USA. | |
20 | * | |
21 | * Please contact Or acle, 500 Oracle Par kway, Redw ood Shores , CA 94065 USA | |
22 | * or visi t www.orac le.com if you need a dditional informatio n or have any | |
23 | * questio ns. | |
24 | */ | |
25 | ||
26 | package co m.sun.tool s.javac.tr ee; | |
27 | ||
28 | import jav a.io.IOExc eption; | |
29 | import jav a.io.Strin gWriter; | |
30 | import jav a.util.*; | |
31 | ||
32 | import jav ax.lang.mo del.elemen t.Modifier ; | |
33 | import jav ax.lang.mo del.type.T ypeKind; | |
34 | import jav ax.tools.J avaFileObj ect; | |
35 | ||
36 | import com .sun.sourc e.tree.*; | |
37 | import com .sun.sourc e.tree.Lam bdaExpress ionTree.Bo dyKind; | |
38 | import com .sun.sourc e.tree.Mem berReferen ceTree.Ref erenceMode ; | |
39 | import com .sun.tools .javac.cod e.*; | |
40 | import com .sun.tools .javac.cod e.Scope.*; | |
41 | import com .sun.tools .javac.cod e.Symbol.* ; | |
42 | import com .sun.tools .javac.uti l.*; | |
43 | import com .sun.tools .javac.uti l.JCDiagno stic.Diagn osticPosit ion; | |
44 | import com .sun.tools .javac.uti l.List; | |
45 | import sta tic com.su n.tools.ja vac.tree.J CTree.Tag. *; | |
46 | ||
47 | /** | |
48 | * Root cl ass for ab stract syn tax tree n odes. It p rovides de finitions | |
49 | * for spe cific tree nodes as subclasses nested in side. | |
50 | * | |
51 | * <p>Each subclass is highly standardiz ed. It ge nerally co ntains | |
52 | * only tr ee fields for the sy ntactic su bcomponent s of the n ode. Some | |
53 | * classes that repr esent iden tifier use s or defin itions als o define a | |
54 | * Symbol field that denotes t he represe nted ident ifier. Cl asses for | |
55 | * non-loc al jumps a lso carry the jump t arget as a field. T he root | |
56 | * class T ree itself defines f ields for the tree's type and position. | |
57 | * No othe r fields a re kept in a tree no de; instea d paramete rs are | |
58 | * passed to methods accessing the node. | |
59 | * | |
60 | * <p>Exce pt for the methods d efined by com.sun.so urce, the only | |
61 | * method defined in subclasse s is `visi t' which a pplies a g iven | |
62 | * visitor to the tr ee. The ac tual tree processing is done b y visitor | |
63 | * classes in other packages. The abstra ct class V isitor, as well as | |
64 | * an Fact ory interf ace for tr ees, are d efined as inner clas ses in | |
65 | * Tree. | |
66 | * | |
67 | * <p>To a void ambig uities wit h the Tree API in co m.sun.sour ce all sub | |
68 | * classes should, b y conventi on, start with JC (j avac). | |
69 | * | |
70 | * <p><b>T his is NOT part of a ny support ed API. | |
71 | * If you write code that depe nds on thi s, you do so at your own risk. | |
72 | * This co de and its internal interfaces are subje ct to chan ge or | |
73 | * deletio n without notice.</b > | |
74 | * | |
75 | * @see Tr eeMaker | |
76 | * @see Tr eeInfo | |
77 | * @see Tr eeTranslat or | |
78 | * @see Pr etty | |
79 | */ | |
80 | public abs tract clas s JCTree i mplements Tree, Clon eable, Dia gnosticPos ition { | |
81 | ||
82 | /* Tre e tag valu es, identi fying kind s of trees */ | |
83 | public enum Tag { | |
84 | /* * For meth ods that r eturn an i nvalid tag if a give n conditio n is not m et | |
85 | * / | |
86 | NO _TAG, | |
87 | ||
88 | /* * Toplevel nodes, of type TopL evel, repr esenting e ntire sour ce files. | |
89 | */ | |
90 | TO PLEVEL, | |
91 | ||
92 | /* * Import c lauses, of type Impo rt. | |
93 | * / | |
94 | IM PORT, | |
95 | ||
96 | /* * Class de finitions, of type C lassDef. | |
97 | * / | |
98 | CL ASSDEF, | |
99 | ||
100 | /* * Method d efinitions , of type MethodDef. | |
101 | * / | |
102 | ME THODDEF, | |
103 | ||
104 | /* * Variable definitio ns, of typ e VarDef. | |
105 | * / | |
106 |
|
|
107 | ||
108 | /* * The no-o p statemen t ";", of type Skip | |
109 | * / | |
110 | SK IP, | |
111 | ||
112 | /* * Blocks, of type Bl ock. | |
113 | * / | |
114 | BL OCK, | |
115 | ||
116 | /* * Do-while loops, of type DoLo op. | |
117 | * / | |
118 | DO LOOP, | |
119 | ||
120 | /* * While-lo ops, of ty pe WhileLo op. | |
121 | * / | |
122 | WH ILELOOP, | |
123 | ||
124 | /* * For-loop s, of type ForLoop. | |
125 | * / | |
126 | FO RLOOP, | |
127 | ||
128 | /* * Foreach- loops, of type Forea chLoop. | |
129 | * / | |
130 | FO REACHLOOP, | |
131 | ||
132 | /* * Labelled statement s, of type Labelled. | |
133 | * / | |
134 | LA BELLED, | |
135 | ||
136 | /* * Switch s tatements, of type S witch. | |
137 | * / | |
138 | SW ITCH, | |
139 | ||
140 | /* * Case par ts in swit ch stateme nts, of ty pe Case. | |
141 | * / | |
142 | CA SE, | |
143 | ||
144 | /* * Synchron ized state ments, of type Synch onized. | |
145 | * / | |
146 | SY NCHRONIZED , | |
147 | ||
148 | /* * Try stat ements, of type Try. | |
149 | * / | |
150 | TR Y, | |
151 | ||
152 | /* * Catch cl auses in t ry stateme nts, of ty pe Catch. | |
153 | * / | |
154 | CA TCH, | |
155 | ||
156 | /* * Conditio nal expres sions, of type Condi tional. | |
157 | * / | |
158 | CO NDEXPR, | |
159 | ||
160 | /* * Conditio nal statem ents, of t ype If. | |
161 | * / | |
162 | IF , | |
163 | ||
164 | /* * Expressi on stateme nts, of ty pe Exec. | |
165 | * / | |
166 | EX EC, | |
167 | ||
168 | /* * Break st atements, of type Br eak. | |
169 | * / | |
170 | BR EAK, | |
171 | ||
172 | /* * Continue statement s, of type Continue. | |
173 | * / | |
174 | CO NTINUE, | |
175 | ||
176 | /* * Return s tatements, of type R eturn. | |
177 | * / | |
178 | RE TURN, | |
179 | ||
180 | /* * Throw st atements, of type Th row. | |
181 | * / | |
182 | TH ROW, | |
183 | ||
184 | /* * Assert s tatements, of type A ssert. | |
185 | * / | |
186 | AS SERT, | |
187 | ||
188 | /* * Method i nvocation expression s, of type Apply. | |
189 | * / | |
190 | AP PLY, | |
191 | ||
192 | /* * Class in stance cre ation expr essions, o f type New Class. | |
193 | * / | |
194 | NE WCLASS, | |
195 | ||
196 | /* * Array cr eation exp ressions, of type Ne wArray. | |
197 | * / | |
198 | NE WARRAY, | |
199 | ||
200 | /* * Lambda e xpression, of type L ambda. | |
201 | * / | |
202 | LA MBDA, | |
203 | ||
204 | /* * Parenthe sized sube xpressions , of type Parens. | |
205 | * / | |
206 | PA RENS, | |
207 | ||
208 | /* * Assignme nt express ions, of t ype Assign . | |
209 | * / | |
210 | AS SIGN, | |
211 | ||
212 | /* * Type cas t expressi ons, of ty pe TypeCas t. | |
213 | * / | |
214 | TY PECAST, | |
215 | ||
216 | /* * Type tes t expressi ons, of ty pe TypeTes t. | |
217 | * / | |
218 | TY PETEST, | |
219 | ||
220 | /* * Indexed array expr essions, o f type Ind exed. | |
221 | * / | |
222 | IN DEXED, | |
223 | ||
224 | /* * Selectio ns, of typ e Select. | |
225 | * / | |
226 | SE LECT, | |
227 | ||
228 | /* * Member r eferences, of type R eference. | |
229 | * / | |
230 | RE FERENCE, | |
231 | ||
232 | /* * Simple i dentifiers , of type Ident. | |
233 | * / | |
234 | ID ENT, | |
235 | ||
236 | /* * Literals , of type Literal. | |
237 | * / | |
238 | LI TERAL, | |
239 | ||
240 | /* * Basic ty pe identif iers, of t ype TypeId ent. | |
241 | * / | |
242 | TY PEIDENT, | |
243 | ||
244 | /* * Array ty pes, of ty pe TypeArr ay. | |
245 | * / | |
246 | TY PEARRAY, | |
247 | ||
248 | /* * Paramete rized type s, of type TypeApply . | |
249 | * / | |
250 | TY PEAPPLY, | |
251 | ||
252 | /* * Union ty pes, of ty pe TypeUni on. | |
253 | * / | |
254 | TY PEUNION, | |
255 | ||
256 | /* * Intersec tion types , of type TypeInters ection. | |
257 | * / | |
258 | TY PEINTERSEC TION, | |
259 | ||
260 | /* * Formal t ype parame ters, of t ype TypePa rameter. | |
261 | * / | |
262 | TY PEPARAMETE R, | |
263 | ||
264 | /* * Type arg ument. | |
265 | * / | |
266 | WI LDCARD, | |
267 | ||
268 | /* * Bound ki nd: extend s, super, exact, or unbound | |
269 | * / | |
270 | TY PEBOUNDKIN D, | |
271 | ||
272 | /* * metadata : Annotati on. | |
273 | * / | |
274 | AN NOTATION, | |
275 | ||
276 | /* * metadata : Type ann otation. | |
277 | * / | |
278 | TY PE_ANNOTAT ION, | |
279 | ||
280 | /* * metadata : Modifier s | |
281 | * / | |
282 | MO DIFIERS, | |
283 | ||
284 | /* * An annot ated type tree. | |
285 | * / | |
286 | AN NOTATED_TY PE, | |
287 | ||
288 | /* * Error tr ees, of ty pe Erroneo us. | |
289 | * / | |
290 | ER RONEOUS, | |
291 | ||
292 | /* * Unary op erators, o f type Una ry. | |
293 | * / | |
294 | PO S, // + | |
295 | NE G, // - | |
296 | NO T, // ! | |
297 | CO MPL, // ~ | |
298 | PR EINC, // ++ _ | |
299 | PR EDEC, // -- _ | |
300 | PO STINC, // _ ++ | |
301 | PO STDEC, // _ -- | |
302 | ||
303 | /* * unary op erator for null refe rence chec ks, only u sed intern ally. | |
304 | * / | |
305 | NU LLCHK, | |
306 | ||
307 | /* * Binary o perators, of type Bi nary. | |
308 | * / | |
309 | OR , // || | |
310 | AN D, // && | |
311 | BI TOR, // | | |
312 | BI TXOR, // ^ | |
313 | BI TAND, // & | |
314 | EQ , // == | |
315 | NE , // != | |
316 | LT , // < | |
317 | GT , // > | |
318 | LE , // <= | |
319 | GE , // >= | |
320 | SL , // << | |
321 | SR , // >> | |
322 | US R, // >>> | |
323 | PL US, // + | |
324 | MI NUS, // - | |
325 | MU L, // * | |
326 | DI V, // / | |
327 | MO D, // % | |
328 | ||
329 | /* * Assignme nt operato rs, of typ e Assignop . | |
330 | * / | |
331 | BI TOR_ASG(BI TOR), // |= | |
332 | BI TXOR_ASG(B ITXOR), // ^= | |
333 | BI TAND_ASG(B ITAND), // &= | |
334 | ||
335 | SL _ASG(SL), // <<= | |
336 | SR _ASG(SR), // >>= | |
337 | US R_ASG(USR) , // >>>= | |
338 | PL US_ASG(PLU S), // += | |
339 | MI NUS_ASG(MI NUS), // -= | |
340 | MU L_ASG(MUL) , // *= | |
341 | DI V_ASG(DIV) , // /= | |
342 | MO D_ASG(MOD) , // %= | |
343 | ||
344 | /* * A synthe tic let ex pression, of type Le tExpr. | |
345 | * / | |
346 | LE TEXPR; // ala sc heme | |
347 | ||
348 | pr ivate fina l Tag noAs signTag; | |
349 | ||
350 | pr ivate stat ic final i nt numberO fOperators = MOD.ord inal() - P OS.ordinal () + 1; | |
351 | ||
352 | pr ivate Tag( Tag noAssi gnTag) { | |
353 | this.noA ssignTag = noAssignT ag; | |
354 | } | |
355 | ||
356 | pr ivate Tag( ) { | |
357 | this(nul l); | |
358 | } | |
359 | ||
360 | pu blic stati c int getN umberOfOpe rators() { | |
361 | return n umberOfOpe rators; | |
362 | } | |
363 | ||
364 | pu blic Tag n oAssignOp( ) { | |
365 | if (noAs signTag != null) | |
366 | retu rn noAssig nTag; | |
367 | throw ne w Assertio nError("no AssignOp() method is not avail able for n on assignm ent tags") ; | |
368 | } | |
369 | ||
370 | pu blic boole an isPostU naryOp() { | |
371 | return ( this == PO STINC || t his == POS TDEC); | |
372 | } | |
373 | ||
374 | pu blic boole an isIncOr DecUnaryOp () { | |
375 | return ( this == PR EINC || th is == PRED EC || this == POSTIN C || this == POSTDEC ); | |
376 | } | |
377 | ||
378 | pu blic boole an isAssig nop() { | |
379 | return n oAssignTag != null; | |
380 | } | |
381 | ||
382 | pu blic int o peratorInd ex() { | |
383 | return ( this.ordin al() - POS .ordinal() ); | |
384 | } | |
385 | } | |
386 | ||
387 | /* The (encoded) position in the sou rce file. @see util. Position. | |
388 | */ | |
389 | public int pos; | |
390 | ||
391 | /* The type of t his node. | |
392 | */ | |
393 | public Type type ; | |
394 | ||
395 | /* The tag of th is node -- one of th e constant s declared above. | |
396 | */ | |
397 | public abstract Tag getTag (); | |
398 | ||
399 | /* Ret urns true if the tag of this n ode is equ als to tag . | |
400 | */ | |
401 | public boolean h asTag(Tag tag) { | |
402 | re turn tag = = getTag() ; | |
403 | } | |
404 | ||
405 | /** Co nvert a tr ee to a pr etty-print ed string. */ | |
406 | @Overr ide | |
407 | public String to String() { | |
408 | St ringWriter s = new S tringWrite r(); | |
409 | tr y { | |
410 | new Pret ty(s, fals e).printEx pr(this); | |
411 | } | |
412 | ca tch (IOExc eption e) { | |
413 | // shoul d never ha ppen, beca use String Writer is defined | |
414 | // never to throw any IOExce ptions | |
415 | throw ne w Assertio nError(e); | |
416 | } | |
417 | re turn s.toS tring(); | |
418 | } | |
419 | ||
420 | /** Se t position field and return th is tree. | |
421 | */ | |
422 | public JCTree se tPos(int p os) { | |
423 | th is.pos = p os; | |
424 | re turn this; | |
425 | } | |
426 | ||
427 | /** Se t type fie ld and ret urn this t ree. | |
428 | */ | |
429 | public JCTree se tType(Type type) { | |
430 | th is.type = type; | |
431 | re turn this; | |
432 | } | |
433 | ||
434 | /** Vi sit this t ree with a given vis itor. | |
435 | */ | |
436 | public abstract void accep t(Visitor v); | |
437 | ||
438 | public abstract <R,D> R ac cept(TreeV isitor<R,D > v, D d); | |
439 | ||
440 | /** Re turn a sha llow copy of this tr ee. | |
441 | */ | |
442 | @Overr ide | |
443 | public Object cl one() { | |
444 | tr y { | |
445 | return s uper.clone (); | |
446 | } catch(Clon eNotSuppor tedExcepti on e) { | |
447 | throw ne w RuntimeE xception(e ); | |
448 | } | |
449 | } | |
450 | ||
451 | /** Ge t a defaul t position for this tree node. | |
452 | */ | |
453 | public Diagnosti cPosition pos() { | |
454 | re turn this; | |
455 | } | |
456 | ||
457 | // for default D iagnosticP osition | |
458 | public JCTree ge tTree() { | |
459 | re turn this; | |
460 | } | |
461 | ||
462 | // for default D iagnosticP osition | |
463 | public int getSt artPositio n() { | |
464 | re turn TreeI nfo.getSta rtPos(this ); | |
465 | } | |
466 | ||
467 | // for default D iagnosticP osition | |
468 | public int getPr eferredPos ition() { | |
469 | re turn pos; | |
470 | } | |
471 | ||
472 | // for default D iagnosticP osition | |
473 | public int getEn dPosition( EndPosTabl e endPosTa ble) { | |
474 | re turn TreeI nfo.getEnd Pos(this, endPosTabl e); | |
475 | } | |
476 | ||
477 | /** | |
478 | * Eve rything in one sourc e file is kept in a {@linkplai n JCCompil ationUnit} structure . | |
479 | */ | |
480 | public static cl ass JCComp ilationUni t extends JCTree imp lements Co mpilationU nitTree { | |
481 | pu blic List< JCAnnotati on> packag eAnnotatio ns; | |
482 | /* * The tree represent ing the pa ckage clau se. */ | |
483 | pu blic JCExp ression pi d; | |
484 | /* * All defi nitions in this file (ClassDef , Import, and Skip) */ | |
485 | pu blic List< JCTree> de fs; | |
486 | /* The sourc e file nam e. */ | |
487 | pu blic JavaF ileObject sourcefile ; | |
488 | /* * The pack age to whi ch this co mpilation unit belon gs. */ | |
489 | pu blic Packa geSymbol p ackge; | |
490 | /* * A scope for all na med import s. */ | |
491 | pu blic Impor tScope nam edImportSc ope; | |
492 | /* * A scope for all im port-on-de mands. */ | |
493 | pu blic StarI mportScope starImpor tScope; | |
494 | /* * Line sta rting posi tions, def ined only if option -g is set. */ | |
495 | pu blic Posit ion.LineMa p lineMap = null; | |
496 | /* * A table that store s all docu mentation comments i ndexed by the tree | |
497 | * nodes the y refer to . defined only if op tion -s is set. */ | |
498 | pu blic DocCo mmentTable docCommen ts = null; | |
499 | /* An object encapsula ting endin g position s of sourc e ranges i ndexed by | |
500 | * the tree nodes they belong to . Defined only if op tion -Xjco v is set. */ | |
501 | pu blic EndPo sTable end Positions = null; | |
502 | pr otected JC Compilatio nUnit(List <JCAnnotat ion> packa geAnnotati ons, | |
503 | JCExpr ession pid , | |
504 | List<J CTree> def s, | |
505 | JavaFi leObject s ourcefile, | |
506 | Packag eSymbol pa ckge, | |
507 | Import Scope name dImportSco pe, | |
508 | StarIm portScope starImport Scope) { | |
509 | this.pac kageAnnota tions = pa ckageAnnot ations; | |
510 | this.pid = pid; | |
511 | this.def s = defs; | |
512 | this.sou rcefile = sourcefile ; | |
513 | this.pac kge = pack ge; | |
514 | this.nam edImportSc ope = name dImportSco pe; | |
515 | this.sta rImportSco pe = starI mportScope ; | |
516 | } | |
517 | @O verride | |
518 | pu blic void accept(Vis itor v) { v.visitTop Level(this ); } | |
519 | ||
520 | pu blic Kind getKind() { return K ind.COMPIL ATION_UNIT ; } | |
521 | pu blic List< JCAnnotati on> getPac kageAnnota tions() { | |
522 | return p ackageAnno tations; | |
523 | } | |
524 | pu blic List< JCImport> getImports () { | |
525 | ListBuff er<JCImpor t> imports = new Lis tBuffer<JC Import>(); | |
526 | for (JCT ree tree : defs) { | |
527 | if ( tree.hasTa g(IMPORT)) | |
528 | imports.ap pend((JCIm port)tree) ; | |
529 | else if (!tree .hasTag(SK IP)) | |
530 | break; | |
531 | } | |
532 | return i mports.toL ist(); | |
533 | } | |
534 | pu blic JCExp ression ge tPackageNa me() { ret urn pid; } | |
535 | pu blic JavaF ileObject getSourceF ile() { | |
536 | return s ourcefile; | |
537 | } | |
538 | pu blic Posit ion.LineMa p getLineM ap() { | |
539 | return l ineMap; | |
540 | } | |
541 | pu blic List< JCTree> ge tTypeDecls () { | |
542 | List<JCT ree> typeD efs; | |
543 | for (typ eDefs = de fs; !typeD efs.isEmpt y(); typeD efs = type Defs.tail) | |
544 | if ( !typeDefs. head.hasTa g(IMPORT)) | |
545 | break; | |
546 | return t ypeDefs; | |
547 | } | |
548 | @O verride | |
549 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
550 | return v .visitComp ilationUni t(this, d) ; | |
551 | } | |
552 | ||
553 | @O verride | |
554 | pu blic Tag g etTag() { | |
555 | return T OPLEVEL; | |
556 | } | |
557 | } | |
558 | ||
559 | /** | |
560 | * An import cla use. | |
561 | */ | |
562 | public static cl ass JCImpo rt extends JCTree im plements I mportTree { | |
563 | pu blic boole an staticI mport; | |
564 | /* * The impo rted class (es). */ | |
565 | pu blic JCTre e qualid; | |
566 | pr otected JC Import(JCT ree qualid , boolean importStat ic) { | |
567 | this.qua lid = qual id; | |
568 | this.sta ticImport = importSt atic; | |
569 | } | |
570 | @O verride | |
571 | pu blic void accept(Vis itor v) { v.visitImp ort(this); } | |
572 | ||
573 | pu blic boole an isStati c() { retu rn staticI mport; } | |
574 | pu blic JCTre e getQuali fiedIdenti fier() { r eturn qual id; } | |
575 | ||
576 | pu blic Kind getKind() { return K ind.IMPORT ; } | |
577 | @O verride | |
578 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
579 | return v .visitImpo rt(this, d ); | |
580 | } | |
581 | ||
582 | @O verride | |
583 | pu blic Tag g etTag() { | |
584 | return I MPORT; | |
585 | } | |
586 | } | |
587 | ||
588 | public static ab stract cla ss JCState ment exten ds JCTree implements Statement Tree { | |
589 | @O verride | |
590 | pu blic JCSta tement set Type(Type type) { | |
591 | super.se tType(type ); | |
592 | return t his; | |
593 | } | |
594 | @O verride | |
595 | pu blic JCSta tement set Pos(int po s) { | |
596 | super.se tPos(pos); | |
597 | return t his; | |
598 | } | |
599 | } | |
600 | ||
601 | public static ab stract cla ss JCExpre ssion exte nds JCTree implement s Expressi onTree { | |
602 | @O verride | |
603 | pu blic JCExp ression se tType(Type type) { | |
604 | super.se tType(type ); | |
605 | return t his; | |
606 | } | |
607 | @O verride | |
608 | pu blic JCExp ression se tPos(int p os) { | |
609 | super.se tPos(pos); | |
610 | return t his; | |
611 | } | |
612 | ||
613 | pu blic boole an isPoly( ) { return false; } | |
614 | pu blic boole an isStand alone() { return tru e; } | |
615 | } | |
616 | ||
617 | /** | |
618 | * Com mon supert ype for al l poly exp ression tr ees (lambd a, method references , | |
619 | * con ditionals, method an d construc tor calls) | |
620 | */ | |
621 | public static ab stract cla ss JCPolyE xpression extends JC Expression { | |
622 | ||
623 | /* * | |
624 | * A poly ex pression c an only be truly 'po ly' in cer tain conte xts | |
625 | * / | |
626 | pu blic enum PolyKind { | |
627 | /** poly expressio n to be tr eated as a standalon e expressi on */ | |
628 | STANDALO NE, | |
629 | /** true poly expr ession */ | |
630 | POLY; | |
631 | } | |
632 | ||
633 | /* * is this poly expre ssion a 't rue' poly expression ? */ | |
634 | pu blic PolyK ind polyKi nd; | |
635 | ||
636 | @O verride pu blic boole an isPoly( ) { return polyKind == PolyKin d.POLY; } | |
637 | @O verride pu blic boole an isStand alone() { return pol yKind == P olyKind.ST ANDALONE; } | |
638 | } | |
639 | ||
640 | /** | |
641 | * Com mon supert ype for al l function al express ion trees (lambda an d method r eferences) | |
642 | */ | |
643 | public static ab stract cla ss JCFunct ionalExpre ssion exte nds JCPoly Expression { | |
644 | ||
645 | pu blic JCFun ctionalExp ression() { | |
646 | //a func tional exp ression is always a 'true' pol y | |
647 | polyKind = PolyKin d.POLY; | |
648 | } | |
649 | ||
650 | /* * list of target typ es inferre d for this functiona l expressi on. */ | |
651 | pu blic List< Type> targ ets; | |
652 | ||
653 | pu blic Type getDescrip torType(Ty pes types) { | |
654 | return t argets.non Empty() ? types.find Descriptor Type(targe ts.head) : types.cre ateErrorTy pe(null); | |
655 | } | |
656 | } | |
657 | ||
658 | /** | |
659 | * A c lass defin ition. | |
660 | */ | |
661 | public static cl ass JCClas sDecl exte nds JCStat ement impl ements Cla ssTree { | |
662 | /* * the modi fiers */ | |
663 | pu blic JCMod ifiers mod s; | |
664 | /* * the name of the cl ass */ | |
665 | pu blic Name name; | |
666 | /* * formal c lass param eters */ | |
667 | pu blic List< JCTypePara meter> typ arams; | |
668 | /* * the clas ses this c lass exten ds */ | |
669 | pu blic JCExp ression ex tending; | |
670 | /* * the inte rfaces imp lemented b y this cla ss */ | |
671 | pu blic List< JCExpressi on> implem enting; | |
672 | /* * all vari ables and methods de fined in t his class */ | |
673 | pu blic List< JCTree> de fs; | |
674 | /* * the symb ol */ | |
675 | pu blic Class Symbol sym ; | |
676 | pr otected JC ClassDecl( JCModifier s mods, | |
677 | Nam e name, | |
678 | Lis t<JCTypePa rameter> t yparams, | |
679 | JCE xpression extending, | |
680 | Lis t<JCExpres sion> impl ementing, | |
681 | Lis t<JCTree> defs, | |
682 | Cla ssSymbol s ym) | |
683 | { | |
684 | this.mod s = mods; | |
685 | this.nam e = name; | |
686 | this.typ arams = ty params; | |
687 | this.ext ending = e xtending; | |
688 | this.imp lementing = implemen ting; | |
689 | this.def s = defs; | |
690 | this.sym = sym; | |
691 | } | |
692 | @O verride | |
693 | pu blic void accept(Vis itor v) { v.visitCla ssDef(this ); } | |
694 | ||
695 | pu blic Kind getKind() { | |
696 | if ((mod s.flags & Flags.ANNO TATION) != 0) | |
697 | retu rn Kind.AN NOTATION_T YPE; | |
698 | else if ((mods.fla gs & Flags .INTERFACE ) != 0) | |
699 | retu rn Kind.IN TERFACE; | |
700 | else if ((mods.fla gs & Flags .ENUM) != 0) | |
701 | retu rn Kind.EN UM; | |
702 | else | |
703 | retu rn Kind.CL ASS; | |
704 | } | |
705 | ||
706 | pu blic JCMod ifiers get Modifiers( ) { return mods; } | |
707 | pu blic Name getSimpleN ame() { re turn name; } | |
708 | pu blic List< JCTypePara meter> get TypeParame ters() { | |
709 | return t yparams; | |
710 | } | |
711 | pu blic JCExp ression ge tExtendsCl ause() { r eturn exte nding; } | |
712 | pu blic List< JCExpressi on> getImp lementsCla use() { | |
713 | return i mplementin g; | |
714 | } | |
715 | pu blic List< JCTree> ge tMembers() { | |
716 | return d efs; | |
717 | } | |
718 | @O verride | |
719 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
720 | return v .visitClas s(this, d) ; | |
721 | } | |
722 | ||
723 | @O verride | |
724 | pu blic Tag g etTag() { | |
725 | return C LASSDEF; | |
726 | } | |
727 | } | |
728 | ||
729 | /** | |
730 | * A m ethod defi nition. | |
731 | */ | |
732 | public static cl ass JCMeth odDecl ext ends JCTre e implemen ts MethodT ree { | |
733 | /* * method m odifiers * / | |
734 | pu blic JCMod ifiers mod s; | |
735 | /* * method n ame */ | |
736 | pu blic Name name; | |
737 | /* * type of method ret urn value */ | |
738 | pu blic JCExp ression re stype; | |
739 | /* * type par ameters */ | |
740 | pu blic List< JCTypePara meter> typ arams; | |
741 | /* * receiver parameter */ | |
742 | pu blic JCVar iableDecl recvparam; | |
743 | /* * value pa rameters * / | |
744 | pu blic List< JCVariable Decl> para ms; | |
745 | /* * exceptio ns thrown by this me thod */ | |
746 | pu blic List< JCExpressi on> thrown ; | |
747 | /* * statemen ts in the method */ | |
748 | pu blic JCBlo ck body; | |
749 | /* * default value, for annotatio n types */ | |
750 | pu blic JCExp ression de faultValue ; | |
751 | /* * method s ymbol */ | |
752 | pu blic Metho dSymbol sy m; | |
753 | pr otected JC MethodDecl (JCModifie rs mods, | |
754 | Na me name, | |
755 | JC Expression restype, | |
756 | Li st<JCTypeP arameter> typarams, | |
757 | JC VariableDe cl recvpar am, | |
758 | Li st<JCVaria bleDecl> p arams, | |
759 | Li st<JCExpre ssion> thr own, | |
760 | JC Block body , | |
761 | JC Expression defaultVa lue, | |
762 | Me thodSymbol sym) | |
763 | { | |
764 | this.mod s = mods; | |
765 | this.nam e = name; | |
766 | this.res type = res type; | |
767 | this.typ arams = ty params; | |
768 | this.par ams = para ms; | |
769 | this.rec vparam = r ecvparam; | |
770 | // TODO: do someth ing specia l if the g iven type is null? | |
771 | // recei ver != nul l ? receiv er : List. <JCTypeAnn otation>ni l()); | |
772 | this.thr own = thro wn; | |
773 | this.bod y = body; | |
774 | this.def aultValue = defaultV alue; | |
775 | this.sym = sym; | |
776 | } | |
777 | @O verride | |
778 | pu blic void accept(Vis itor v) { v.visitMet hodDef(thi s); } | |
779 | ||
780 | pu blic Kind getKind() { return K ind.METHOD ; } | |
781 | pu blic JCMod ifiers get Modifiers( ) { return mods; } | |
782 | pu blic Name getName() { return n ame; } | |
783 | pu blic JCTre e getRetur nType() { return res type; } | |
784 | pu blic List< JCTypePara meter> get TypeParame ters() { | |
785 | return t yparams; | |
786 | } | |
787 | pu blic List< JCVariable Decl> getP arameters( ) { | |
788 | return p arams; | |
789 | } | |
790 | pu blic JCVar iableDecl getReceive rParameter () { retur n recvpara m; } | |
791 | pu blic List< JCExpressi on> getThr ows() { | |
792 | return t hrown; | |
793 | } | |
794 | pu blic JCBlo ck getBody () { retur n body; } | |
795 | pu blic JCTre e getDefau ltValue() { // for a nnotation types | |
796 | return d efaultValu e; | |
797 | } | |
798 | @O verride | |
799 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
800 | return v .visitMeth od(this, d ); | |
801 | } | |
802 | ||
803 | @O verride | |
804 | pu blic Tag g etTag() { | |
805 | return M ETHODDEF; | |
806 | } | |
807 | } | |
808 | ||
809 | /** | |
810 | * A v ariable de finition. | |
811 | */ | |
812 | public static cl ass JCVari ableDecl e xtends JCS tatement i mplements VariableTr ee { | |
813 | /* * variable modifiers */ | |
814 | pu blic JCMod ifiers mod s; | |
815 | /* * variable name */ | |
816 | pu blic Name name; | |
817 | /* * variable name expr ession */ | |
818 | pu blic JCExp ression na meexpr; | |
819 | /* * type of the variab le */ | |
820 | pu blic JCExp ression va rtype; | |
821 | /* * variable 's initial value */ | |
822 | pu blic JCExp ression in it; | |
823 | /* * symbol * / | |
824 | pu blic VarSy mbol sym; | |
825 | ||
826 | pr otected JC VariableDe cl(JCModif iers mods, | |
827 | Name name, | |
828 | JCExp ression va rtype, | |
829 | JCExp ression in it, | |
830 | VarSy mbol sym) { | |
831 | this.mod s = mods; | |
832 | this.nam e = name; | |
833 | this.var type = var type; | |
834 | this.ini t = init; | |
835 | this.sym = sym; | |
836 | } | |
837 | ||
838 | pr otected JC VariableDe cl(JCModif iers mods, | |
839 | JCExp ression na meexpr, | |
840 | JCExp ression va rtype) { | |
841 | this(mod s, null, v artype, nu ll, null); | |
842 | this.nam eexpr = na meexpr; | |
843 | if (name expr.hasTa g(Tag.IDEN T)) { | |
844 | this .name = (( JCIdent)na meexpr).na me; | |
845 | } else { | |
846 | // O nly other option is qualified name x.y.t his; | |
847 | this .name = (( JCFieldAcc ess)nameex pr).name; | |
848 | } | |
849 | } | |
850 | ||
851 | @O verride | |
852 | pu blic void accept(Vis itor v) { v.visitVar Def(this); } | |
853 | ||
854 | pu blic Kind getKind() { return K ind.VARIAB LE; } | |
855 | pu blic JCMod ifiers get Modifiers( ) { return mods; } | |
856 | pu blic Name getName() { return n ame; } | |
857 | pu blic JCExp ression ge tNameExpre ssion() { return nam eexpr; } | |
858 | pu blic JCTre e getType( ) { return vartype; } | |
859 | pu blic JCExp ression ge tInitializ er() { | |
860 | return i nit; | |
861 | } | |
862 | @O verride | |
863 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
864 | return v .visitVari able(this, d); | |
865 | } | |
866 | ||
867 | @O verride | |
868 | pu blic Tag g etTag() { | |
869 | return
|
|
870 | } | |
871 | } | |
872 | ||
873 | /** | |
874 | * A n o-op state ment ";". | |
875 | */ | |
876 | public static cl ass JCSkip extends J CStatement implement s EmptySta tementTree { | |
877 | pr otected JC Skip() { | |
878 | } | |
879 | @O verride | |
880 | pu blic void accept(Vis itor v) { v.visitSki p(this); } | |
881 | ||
882 | pu blic Kind getKind() { return K ind.EMPTY_ STATEMENT; } | |
883 | @O verride | |
884 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
885 | return v .visitEmpt yStatement (this, d); | |
886 | } | |
887 | ||
888 | @O verride | |
889 | pu blic Tag g etTag() { | |
890 | return S KIP; | |
891 | } | |
892 | } | |
893 | ||
894 | /** | |
895 | * A s tatement b lock. | |
896 | */ | |
897 | public static cl ass JCBloc k extends JCStatemen t implemen ts BlockTr ee { | |
898 | /* * flags */ | |
899 | pu blic long flags; | |
900 | /* * statemen ts */ | |
901 | pu blic List< JCStatemen t> stats; | |
902 | /* * Position of closin g brace, o ptional. * / | |
903 | pu blic int e ndpos = Po sition.NOP OS; | |
904 | pr otected JC Block(long flags, Li st<JCState ment> stat s) { | |
905 | this.sta ts = stats ; | |
906 | this.fla gs = flags ; | |
907 | } | |
908 | @O verride | |
909 | pu blic void accept(Vis itor v) { v.visitBlo ck(this); } | |
910 | ||
911 | pu blic Kind getKind() { return K ind.BLOCK; } | |
912 | pu blic List< JCStatemen t> getStat ements() { | |
913 | return s tats; | |
914 | } | |
915 | pu blic boole an isStati c() { retu rn (flags & Flags.ST ATIC) != 0 ; } | |
916 | @O verride | |
917 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
918 | return v .visitBloc k(this, d) ; | |
919 | } | |
920 | ||
921 | @O verride | |
922 | pu blic Tag g etTag() { | |
923 | return B LOCK; | |
924 | } | |
925 | } | |
926 | ||
927 | /** | |
928 | * A d o loop | |
929 | */ | |
930 | public static cl ass JCDoWh ileLoop ex tends JCSt atement im plements D oWhileLoop Tree { | |
931 | pu blic JCSta tement bod y; | |
932 | pu blic JCExp ression co nd; | |
933 | pr otected JC DoWhileLoo p(JCStatem ent body, JCExpressi on cond) { | |
934 | this.bod y = body; | |
935 | this.con d = cond; | |
936 | } | |
937 | @O verride | |
938 | pu blic void accept(Vis itor v) { v.visitDoL oop(this); } | |
939 | ||
940 | pu blic Kind getKind() { return K ind.DO_WHI LE_LOOP; } | |
941 | pu blic JCExp ression ge tCondition () { retur n cond; } | |
942 | pu blic JCSta tement get Statement( ) { return body; } | |
943 | @O verride | |
944 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
945 | return v .visitDoWh ileLoop(th is, d); | |
946 | } | |
947 | ||
948 | @O verride | |
949 | pu blic Tag g etTag() { | |
950 | return D OLOOP; | |
951 | } | |
952 | } | |
953 | ||
954 | /** | |
955 | * A w hile loop | |
956 | */ | |
957 | public static cl ass JCWhil eLoop exte nds JCStat ement impl ements Whi leLoopTree { | |
958 | pu blic JCExp ression co nd; | |
959 | pu blic JCSta tement bod y; | |
960 | pr otected JC WhileLoop( JCExpressi on cond, J CStatement body) { | |
961 | this.con d = cond; | |
962 | this.bod y = body; | |
963 | } | |
964 | @O verride | |
965 | pu blic void accept(Vis itor v) { v.visitWhi leLoop(thi s); } | |
966 | ||
967 | pu blic Kind getKind() { return K ind.WHILE_ LOOP; } | |
968 | pu blic JCExp ression ge tCondition () { retur n cond; } | |
969 | pu blic JCSta tement get Statement( ) { return body; } | |
970 | @O verride | |
971 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
972 | return v .visitWhil eLoop(this , d); | |
973 | } | |
974 | ||
975 | @O verride | |
976 | pu blic Tag g etTag() { | |
977 | return W HILELOOP; | |
978 | } | |
979 | } | |
980 | ||
981 | /** | |
982 | * A f or loop. | |
983 | */ | |
984 | public static cl ass JCForL oop extend s JCStatem ent implem ents ForLo opTree { | |
985 | pu blic List< JCStatemen t> init; | |
986 | pu blic JCExp ression co nd; | |
987 | pu blic List< JCExpressi onStatemen t> step; | |
988 | pu blic JCSta tement bod y; | |
989 | pr otected JC ForLoop(Li st<JCState ment> init , | |
990 | JCEx pression c ond, | |
991 | List <JCExpress ionStateme nt> update , | |
992 | JCSt atement bo dy) | |
993 | { | |
994 | this.ini t = init; | |
995 | this.con d = cond; | |
996 | this.ste p = update ; | |
997 | this.bod y = body; | |
998 | } | |
999 | @O verride | |
1000 | pu blic void accept(Vis itor v) { v.visitFor Loop(this) ; } | |
1001 | ||
1002 | pu blic Kind getKind() { return K ind.FOR_LO OP; } | |
1003 | pu blic JCExp ression ge tCondition () { retur n cond; } | |
1004 | pu blic JCSta tement get Statement( ) { return body; } | |
1005 | pu blic List< JCStatemen t> getInit ializer() { | |
1006 | return i nit; | |
1007 | } | |
1008 | pu blic List< JCExpressi onStatemen t> getUpda te() { | |
1009 | return s tep; | |
1010 | } | |
1011 | @O verride | |
1012 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1013 | return v .visitForL oop(this, d); | |
1014 | } | |
1015 | ||
1016 | @O verride | |
1017 | pu blic Tag g etTag() { | |
1018 | return F ORLOOP; | |
1019 | } | |
1020 | } | |
1021 | ||
1022 | /** | |
1023 | * The enhanced for loop. | |
1024 | */ | |
1025 | public static cl ass JCEnha ncedForLoo p extends JCStatemen t implemen ts Enhance dForLoopTr ee { | |
1026 | pu blic JCVar iableDecl var; | |
1027 | pu blic JCExp ression ex pr; | |
1028 | pu blic JCSta tement bod y; | |
1029 | pr otected JC EnhancedFo rLoop(JCVa riableDecl var, JCEx pression e xpr, JCSta tement bod y) { | |
1030 | this.var = var; | |
1031 | this.exp r = expr; | |
1032 | this.bod y = body; | |
1033 | } | |
1034 | @O verride | |
1035 | pu blic void accept(Vis itor v) { v.visitFor eachLoop(t his); } | |
1036 | ||
1037 | pu blic Kind getKind() { return K ind.ENHANC ED_FOR_LOO P; } | |
1038 | pu blic JCVar iableDecl getVariabl e() { retu rn var; } | |
1039 | pu blic JCExp ression ge tExpressio n() { retu rn expr; } | |
1040 | pu blic JCSta tement get Statement( ) { return body; } | |
1041 | @O verride | |
1042 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1043 | return v .visitEnha ncedForLoo p(this, d) ; | |
1044 | } | |
1045 | @O verride | |
1046 | pu blic Tag g etTag() { | |
1047 | return F OREACHLOOP ; | |
1048 | } | |
1049 | } | |
1050 | ||
1051 | /** | |
1052 | * A l abelled ex pression o r statemen t. | |
1053 | */ | |
1054 | public static cl ass JCLabe ledStateme nt extends JCStateme nt impleme nts Labele dStatement Tree { | |
1055 | pu blic Name label; | |
1056 | pu blic JCSta tement bod y; | |
1057 | pr otected JC LabeledSta tement(Nam e label, J CStatement body) { | |
1058 | this.lab el = label ; | |
1059 | this.bod y = body; | |
1060 | } | |
1061 | @O verride | |
1062 | pu blic void accept(Vis itor v) { v.visitLab elled(this ); } | |
1063 | pu blic Kind getKind() { return K ind.LABELE D_STATEMEN T; } | |
1064 | pu blic Name getLabel() { return label; } | |
1065 | pu blic JCSta tement get Statement( ) { return body; } | |
1066 | @O verride | |
1067 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1068 | return v .visitLabe ledStateme nt(this, d ); | |
1069 | } | |
1070 | @O verride | |
1071 | pu blic Tag g etTag() { | |
1072 | return L ABELLED; | |
1073 | } | |
1074 | } | |
1075 | ||
1076 | /** | |
1077 | * A " switch ( ) { }" cons truction. | |
1078 | */ | |
1079 | public static cl ass JCSwit ch extends JCStateme nt impleme nts Switch Tree { | |
1080 | pu blic JCExp ression se lector; | |
1081 | pu blic List< JCCase> ca ses; | |
1082 | pr otected JC Switch(JCE xpression selector, List<JCCas e> cases) { | |
1083 | this.sel ector = se lector; | |
1084 | this.cas es = cases ; | |
1085 | } | |
1086 | @O verride | |
1087 | pu blic void accept(Vis itor v) { v.visitSwi tch(this); } | |
1088 | ||
1089 | pu blic Kind getKind() { return K ind.SWITCH ; } | |
1090 | pu blic JCExp ression ge tExpressio n() { retu rn selecto r; } | |
1091 | pu blic List< JCCase> ge tCases() { return ca ses; } | |
1092 | @O verride | |
1093 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1094 | return v .visitSwit ch(this, d ); | |
1095 | } | |
1096 | @O verride | |
1097 | pu blic Tag g etTag() { | |
1098 | return S WITCH; | |
1099 | } | |
1100 | } | |
1101 | ||
1102 | /** | |
1103 | * A " case :" o f a switch . | |
1104 | */ | |
1105 | public static cl ass JCCase extends J CStatement implement s CaseTree { | |
1106 | pu blic JCExp ression pa t; | |
1107 | pu blic List< JCStatemen t> stats; | |
1108 | pr otected JC Case(JCExp ression pa t, List<JC Statement> stats) { | |
1109 | this.pat = pat; | |
1110 | this.sta ts = stats ; | |
1111 | } | |
1112 | @O verride | |
1113 | pu blic void accept(Vis itor v) { v.visitCas e(this); } | |
1114 | ||
1115 | pu blic Kind getKind() { return K ind.CASE; } | |
1116 | pu blic JCExp ression ge tExpressio n() { retu rn pat; } | |
1117 | pu blic List< JCStatemen t> getStat ements() { return st ats; } | |
1118 | @O verride | |
1119 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1120 | return v .visitCase (this, d); | |
1121 | } | |
1122 | @O verride | |
1123 | pu blic Tag g etTag() { | |
1124 | return C ASE; | |
1125 | } | |
1126 | } | |
1127 | ||
1128 | /** | |
1129 | * A s ynchronize d block. | |
1130 | */ | |
1131 | public static cl ass JCSync hronized e xtends JCS tatement i mplements Synchroniz edTree { | |
1132 | pu blic JCExp ression lo ck; | |
1133 | pu blic JCBlo ck body; | |
1134 | pr otected JC Synchroniz ed(JCExpre ssion lock , JCBlock body) { | |
1135 | this.loc k = lock; | |
1136 | this.bod y = body; | |
1137 | } | |
1138 | @O verride | |
1139 | pu blic void accept(Vis itor v) { v.visitSyn chronized( this); } | |
1140 | ||
1141 | pu blic Kind getKind() { return K ind.SYNCHR ONIZED; } | |
1142 | pu blic JCExp ression ge tExpressio n() { retu rn lock; } | |
1143 | pu blic JCBlo ck getBloc k() { retu rn body; } | |
1144 | @O verride | |
1145 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1146 | return v .visitSync hronized(t his, d); | |
1147 | } | |
1148 | @O verride | |
1149 | pu blic Tag g etTag() { | |
1150 | return S YNCHRONIZE D; | |
1151 | } | |
1152 | } | |
1153 | ||
1154 | /** | |
1155 | * A " try { } ca tch ( ) { } finally { }" block . | |
1156 | */ | |
1157 | public static cl ass JCTry extends JC Statement implements TryTree { | |
1158 | pu blic JCBlo ck body; | |
1159 | pu blic List< JCCatch> c atchers; | |
1160 | pu blic JCBlo ck finaliz er; | |
1161 | pu blic List< JCTree> re sources; | |
1162 | pu blic boole an finally CanComplet eNormally; | |
1163 | pr otected JC Try(List<J CTree> res ources, | |
1164 | JCBloc k body, | |
1165 | List<J CCatch> ca tchers, | |
1166 | JCBloc k finalize r) { | |
1167 | this.bod y = body; | |
1168 | this.cat chers = ca tchers; | |
1169 | this.fin alizer = f inalizer; | |
1170 | this.res ources = r esources; | |
1171 | } | |
1172 | @O verride | |
1173 | pu blic void accept(Vis itor v) { v.visitTry (this); } | |
1174 | ||
1175 | pu blic Kind getKind() { return K ind.TRY; } | |
1176 | pu blic JCBlo ck getBloc k() { retu rn body; } | |
1177 | pu blic List< JCCatch> g etCatches( ) { | |
1178 | return c atchers; | |
1179 | } | |
1180 | pu blic JCBlo ck getFina llyBlock() { return finalizer; } | |
1181 | @O verride | |
1182 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1183 | return v .visitTry( this, d); | |
1184 | } | |
1185 | @O verride | |
1186 | pu blic List< JCTree> ge tResources () { | |
1187 | return r esources; | |
1188 | } | |
1189 | @O verride | |
1190 | pu blic Tag g etTag() { | |
1191 | return T RY; | |
1192 | } | |
1193 | } | |
1194 | ||
1195 | /** | |
1196 | * A c atch block . | |
1197 | */ | |
1198 | public static cl ass JCCatc h extends JCTree imp lements Ca tchTree { | |
1199 | pu blic JCVar iableDecl param; | |
1200 | pu blic JCBlo ck body; | |
1201 | pr otected JC Catch(JCVa riableDecl param, JC Block body ) { | |
1202 | this.par am = param ; | |
1203 | this.bod y = body; | |
1204 | } | |
1205 | @O verride | |
1206 | pu blic void accept(Vis itor v) { v.visitCat ch(this); } | |
1207 | ||
1208 | pu blic Kind getKind() { return K ind.CATCH; } | |
1209 | pu blic JCVar iableDecl getParamet er() { ret urn param; } | |
1210 | pu blic JCBlo ck getBloc k() { retu rn body; } | |
1211 | @O verride | |
1212 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1213 | return v .visitCatc h(this, d) ; | |
1214 | } | |
1215 | @O verride | |
1216 | pu blic Tag g etTag() { | |
1217 | return C ATCH; | |
1218 | } | |
1219 | } | |
1220 | ||
1221 | /** | |
1222 | * A ( ) ? ( ) : ( ) condi tional exp ression | |
1223 | */ | |
1224 | public static cl ass JCCond itional ex tends JCPo lyExpressi on impleme nts Condit ionalExpre ssionTree { | |
1225 | pu blic JCExp ression co nd; | |
1226 | pu blic JCExp ression tr uepart; | |
1227 | pu blic JCExp ression fa lsepart; | |
1228 | pr otected JC Conditiona l(JCExpres sion cond, | |
1229 | JCExpressi on truepar t, | |
1230 | JCExpressi on falsepa rt) | |
1231 | { | |
1232 | this.con d = cond; | |
1233 | this.tru epart = tr uepart; | |
1234 | this.fal separt = f alsepart; | |
1235 | } | |
1236 | @O verride | |
1237 | pu blic void accept(Vis itor v) { v.visitCon ditional(t his); } | |
1238 | ||
1239 | pu blic Kind getKind() { return K ind.CONDIT IONAL_EXPR ESSION; } | |
1240 | pu blic JCExp ression ge tCondition () { retur n cond; } | |
1241 | pu blic JCExp ression ge tTrueExpre ssion() { return tru epart; } | |
1242 | pu blic JCExp ression ge tFalseExpr ession() { return fa lsepart; } | |
1243 | @O verride | |
1244 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1245 | return v .visitCond itionalExp ression(th is, d); | |
1246 | } | |
1247 | @O verride | |
1248 | pu blic Tag g etTag() { | |
1249 | return C ONDEXPR; | |
1250 | } | |
1251 | } | |
1252 | ||
1253 | /** | |
1254 | * An "if ( ) { } else { } " block | |
1255 | */ | |
1256 | public static cl ass JCIf e xtends JCS tatement i mplements IfTree { | |
1257 | pu blic JCExp ression co nd; | |
1258 | pu blic JCSta tement the npart; | |
1259 | pu blic JCSta tement els epart; | |
1260 | pr otected JC If(JCExpre ssion cond , | |
1261 | JCStateme nt thenpar t, | |
1262 | JCStateme nt elsepar t) | |
1263 | { | |
1264 | this.con d = cond; | |
1265 | this.the npart = th enpart; | |
1266 | this.els epart = el separt; | |
1267 | } | |
1268 | @O verride | |
1269 | pu blic void accept(Vis itor v) { v.visitIf( this); } | |
1270 | ||
1271 | pu blic Kind getKind() { return K ind.IF; } | |
1272 | pu blic JCExp ression ge tCondition () { retur n cond; } | |
1273 | pu blic JCSta tement get ThenStatem ent() { re turn thenp art; } | |
1274 | pu blic JCSta tement get ElseStatem ent() { re turn elsep art; } | |
1275 | @O verride | |
1276 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1277 | return v .visitIf(t his, d); | |
1278 | } | |
1279 | @O verride | |
1280 | pu blic Tag g etTag() { | |
1281 | return I F; | |
1282 | } | |
1283 | } | |
1284 | ||
1285 | /** | |
1286 | * an expression statement | |
1287 | */ | |
1288 | public static cl ass JCExpr essionStat ement exte nds JCStat ement impl ements Exp ressionSta tementTree { | |
1289 | /* * expressi on structu re */ | |
1290 | pu blic JCExp ression ex pr; | |
1291 | pr otected JC Expression Statement( JCExpressi on expr) | |
1292 | { | |
1293 | this.exp r = expr; | |
1294 | } | |
1295 | @O verride | |
1296 | pu blic void accept(Vis itor v) { v.visitExe c(this); } | |
1297 | ||
1298 | pu blic Kind getKind() { return K ind.EXPRES SION_STATE MENT; } | |
1299 | pu blic JCExp ression ge tExpressio n() { retu rn expr; } | |
1300 | @O verride | |
1301 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1302 | return v .visitExpr essionStat ement(this , d); | |
1303 | } | |
1304 | @O verride | |
1305 | pu blic Tag g etTag() { | |
1306 | return E XEC; | |
1307 | } | |
1308 | ||
1309 | /* * Convert a expressi on-stateme nt tree to a pretty- printed st ring. */ | |
1310 | @O verride | |
1311 | pu blic Strin g toString () { | |
1312 | StringWr iter s = n ew StringW riter(); | |
1313 | try { | |
1314 | new Pretty(s, false).pri ntStat(thi s); | |
1315 | } | |
1316 | catch (I OException e) { | |
1317 | // s hould neve r happen, because St ringWriter is define d | |
1318 | // n ever to th row any IO Exceptions | |
1319 | thro w new Asse rtionError (e); | |
1320 | } | |
1321 | return s .toString( ); | |
1322 | } | |
1323 | } | |
1324 | ||
1325 | /** | |
1326 | * A b reak from a loop or switch. | |
1327 | */ | |
1328 | public static cl ass JCBrea k extends JCStatemen t implemen ts BreakTr ee { | |
1329 | pu blic Name label; | |
1330 | pu blic JCTre e target; | |
1331 | pr otected JC Break(Name label, JC Tree targe t) { | |
1332 | this.lab el = label ; | |
1333 | this.tar get = targ et; | |
1334 | } | |
1335 | @O verride | |
1336 | pu blic void accept(Vis itor v) { v.visitBre ak(this); } | |
1337 | ||
1338 | pu blic Kind getKind() { return K ind.BREAK; } | |
1339 | pu blic Name getLabel() { return label; } | |
1340 | @O verride | |
1341 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1342 | return v .visitBrea k(this, d) ; | |
1343 | } | |
1344 | @O verride | |
1345 | pu blic Tag g etTag() { | |
1346 | return B REAK; | |
1347 | } | |
1348 | } | |
1349 | ||
1350 | /** | |
1351 | * A c ontinue of a loop. | |
1352 | */ | |
1353 | public static cl ass JCCont inue exten ds JCState ment imple ments Cont inueTree { | |
1354 | pu blic Name label; | |
1355 | pu blic JCTre e target; | |
1356 | pr otected JC Continue(N ame label, JCTree ta rget) { | |
1357 | this.lab el = label ; | |
1358 | this.tar get = targ et; | |
1359 | } | |
1360 | @O verride | |
1361 | pu blic void accept(Vis itor v) { v.visitCon tinue(this ); } | |
1362 | ||
1363 | pu blic Kind getKind() { return K ind.CONTIN UE; } | |
1364 | pu blic Name getLabel() { return label; } | |
1365 | @O verride | |
1366 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1367 | return v .visitCont inue(this, d); | |
1368 | } | |
1369 | @O verride | |
1370 | pu blic Tag g etTag() { | |
1371 | return C ONTINUE; | |
1372 | } | |
1373 | } | |
1374 | ||
1375 | /** | |
1376 | * A r eturn stat ement. | |
1377 | */ | |
1378 | public static cl ass JCRetu rn extends JCStateme nt impleme nts Return Tree { | |
1379 | pu blic JCExp ression ex pr; | |
1380 | pr otected JC Return(JCE xpression expr) { | |
1381 | this.exp r = expr; | |
1382 | } | |
1383 | @O verride | |
1384 | pu blic void accept(Vis itor v) { v.visitRet urn(this); } | |
1385 | ||
1386 | pu blic Kind getKind() { return K ind.RETURN ; } | |
1387 | pu blic JCExp ression ge tExpressio n() { retu rn expr; } | |
1388 | @O verride | |
1389 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1390 | return v .visitRetu rn(this, d ); | |
1391 | } | |
1392 | @O verride | |
1393 | pu blic Tag g etTag() { | |
1394 | return R ETURN; | |
1395 | } | |
1396 | } | |
1397 | ||
1398 | /** | |
1399 | * A t hrow state ment. | |
1400 | */ | |
1401 | public static cl ass JCThro w extends JCStatemen t implemen ts ThrowTr ee { | |
1402 | pu blic JCExp ression ex pr; | |
1403 | pr otected JC Throw(JCEx pression e xpr) { | |
1404 | this.exp r = expr; | |
1405 | } | |
1406 | @O verride | |
1407 | pu blic void accept(Vis itor v) { v.visitThr ow(this); } | |
1408 | ||
1409 | pu blic Kind getKind() { return K ind.THROW; } | |
1410 | pu blic JCExp ression ge tExpressio n() { retu rn expr; } | |
1411 | @O verride | |
1412 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1413 | return v .visitThro w(this, d) ; | |
1414 | } | |
1415 | @O verride | |
1416 | pu blic Tag g etTag() { | |
1417 | return T HROW; | |
1418 | } | |
1419 | } | |
1420 | ||
1421 | /** | |
1422 | * An assert sta tement. | |
1423 | */ | |
1424 | public static cl ass JCAsse rt extends JCStateme nt impleme nts Assert Tree { | |
1425 | pu blic JCExp ression co nd; | |
1426 | pu blic JCExp ression de tail; | |
1427 | pr otected JC Assert(JCE xpression cond, JCEx pression d etail) { | |
1428 | this.con d = cond; | |
1429 | this.det ail = deta il; | |
1430 | } | |
1431 | @O verride | |
1432 | pu blic void accept(Vis itor v) { v.visitAss ert(this); } | |
1433 | ||
1434 | pu blic Kind getKind() { return K ind.ASSERT ; } | |
1435 | pu blic JCExp ression ge tCondition () { retur n cond; } | |
1436 | pu blic JCExp ression ge tDetail() { return d etail; } | |
1437 | @O verride | |
1438 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1439 | return v .visitAsse rt(this, d ); | |
1440 | } | |
1441 | @O verride | |
1442 | pu blic Tag g etTag() { | |
1443 | return A SSERT; | |
1444 | } | |
1445 | } | |
1446 | ||
1447 | /** | |
1448 | * A m ethod invo cation | |
1449 | */ | |
1450 | public static cl ass JCMeth odInvocati on extends JCPolyExp ression im plements M ethodInvoc ationTree { | |
1451 | pu blic List< JCExpressi on> typear gs; | |
1452 | pu blic JCExp ression me th; | |
1453 | pu blic List< JCExpressi on> args; | |
1454 | pu blic Type varargsEle ment; | |
1455 | pr otected JC MethodInvo cation(Lis t<JCExpres sion> type args, | |
1456 | JCExpr ession met h, | |
1457 | List<J CExpressio n> args) | |
1458 | { | |
1459 | this.typ eargs = (t ypeargs == null) ? L ist.<JCExp ression>ni l() | |
1460 | : t ypeargs; | |
1461 | this.met h = meth; | |
1462 | this.arg s = args; | |
1463 | } | |
1464 | @O verride | |
1465 | pu blic void accept(Vis itor v) { v.visitApp ly(this); } | |
1466 | ||
1467 | pu blic Kind getKind() { return K ind.METHOD _INVOCATIO N; } | |
1468 | pu blic List< JCExpressi on> getTyp eArguments () { | |
1469 | return t ypeargs; | |
1470 | } | |
1471 | pu blic JCExp ression ge tMethodSel ect() { re turn meth; } | |
1472 | pu blic List< JCExpressi on> getArg uments() { | |
1473 | return a rgs; | |
1474 | } | |
1475 | @O verride | |
1476 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1477 | return v .visitMeth odInvocati on(this, d ); | |
1478 | } | |
1479 | @O verride | |
1480 | pu blic JCMet hodInvocat ion setTyp e(Type typ e) { | |
1481 | super.se tType(type ); | |
1482 | return t his; | |
1483 | } | |
1484 | @O verride | |
1485 | pu blic Tag g etTag() { | |
1486 | return(A PPLY); | |
1487 | } | |
1488 | } | |
1489 | ||
1490 | /** | |
1491 | * A n ew(...) op eration. | |
1492 | */ | |
1493 | public static cl ass JCNewC lass exten ds JCPolyE xpression implements NewClassT ree { | |
1494 | pu blic JCExp ression en cl; | |
1495 | pu blic List< JCExpressi on> typear gs; | |
1496 | pu blic JCExp ression cl azz; | |
1497 | pu blic List< JCExpressi on> args; | |
1498 | pu blic JCCla ssDecl def ; | |
1499 | pu blic Symbo l construc tor; | |
1500 | pu blic Type varargsEle ment; | |
1501 | pu blic Type constructo rType; | |
1502 | pr otected JC NewClass(J CExpressio n encl, | |
1503 | Lis t<JCExpres sion> type args, | |
1504 | JCE xpression clazz, | |
1505 | Lis t<JCExpres sion> args , | |
1506 | JCC lassDecl d ef) | |
1507 | { | |
1508 | this.enc l = encl; | |
1509 | this.typ eargs = (t ypeargs == null) ? L ist.<JCExp ression>ni l() | |
1510 | : t ypeargs; | |
1511 | this.cla zz = clazz ; | |
1512 | this.arg s = args; | |
1513 | this.def = def; | |
1514 | } | |
1515 | @O verride | |
1516 | pu blic void accept(Vis itor v) { v.visitNew Class(this ); } | |
1517 | ||
1518 | pu blic Kind getKind() { return K ind.NEW_CL ASS; } | |
1519 | pu blic JCExp ression ge tEnclosing Expression () { // ex pr.new C< ... > ( .. . ) | |
1520 | return e ncl; | |
1521 | } | |
1522 | pu blic List< JCExpressi on> getTyp eArguments () { | |
1523 | return t ypeargs; | |
1524 | } | |
1525 | pu blic JCExp ression ge tIdentifie r() { retu rn clazz; } | |
1526 | pu blic List< JCExpressi on> getArg uments() { | |
1527 | return a rgs; | |
1528 | } | |
1529 | pu blic JCCla ssDecl get ClassBody( ) { return def; } | |
1530 | @O verride | |
1531 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1532 | return v .visitNewC lass(this, d); | |
1533 | } | |
1534 | @O verride | |
1535 | pu blic Tag g etTag() { | |
1536 | return N EWCLASS; | |
1537 | } | |
1538 | } | |
1539 | ||
1540 | /** | |
1541 | * A n ew[...] op eration. | |
1542 | */ | |
1543 | public static cl ass JCNewA rray exten ds JCExpre ssion impl ements New ArrayTree { | |
1544 | pu blic JCExp ression el emtype; | |
1545 | pu blic List< JCExpressi on> dims; | |
1546 | // type anno tations on inner-mos t componen t | |
1547 | pu blic List< JCAnnotati on> annota tions; | |
1548 | // type anno tations on dimension s | |
1549 | pu blic List< List<JCAnn otation>> dimAnnotat ions; | |
1550 | pu blic List< JCExpressi on> elems; | |
1551 | pr otected JC NewArray(J CExpressio n elemtype , | |
1552 | Lis t<JCExpres sion> dims , | |
1553 | Lis t<JCExpres sion> elem s) | |
1554 | { | |
1555 | this.ele mtype = el emtype; | |
1556 | this.dim s = dims; | |
1557 | this.ann otations = List.nil( ); | |
1558 | this.dim Annotation s = List.n il(); | |
1559 | this.ele ms = elems ; | |
1560 | } | |
1561 | @O verride | |
1562 | pu blic void accept(Vis itor v) { v.visitNew Array(this ); } | |
1563 | ||
1564 | pu blic Kind getKind() { return K ind.NEW_AR RAY; } | |
1565 | pu blic JCExp ression ge tType() { return ele mtype; } | |
1566 | pu blic List< JCExpressi on> getDim ensions() { | |
1567 | return d ims; | |
1568 | } | |
1569 | pu blic List< JCExpressi on> getIni tializers( ) { | |
1570 | return e lems; | |
1571 | } | |
1572 | @O verride | |
1573 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1574 | return v .visitNewA rray(this, d); | |
1575 | } | |
1576 | @O verride | |
1577 | pu blic Tag g etTag() { | |
1578 | return N EWARRAY; | |
1579 | } | |
1580 | ||
1581 | @O verride | |
1582 | pu blic List< JCAnnotati on> getAnn otations() { | |
1583 | return a nnotations ; | |
1584 | } | |
1585 | ||
1586 | @O verride | |
1587 | pu blic List< List<JCAnn otation>> getDimAnno tations() { | |
1588 | return d imAnnotati ons; | |
1589 | } | |
1590 | } | |
1591 | ||
1592 | /** | |
1593 | * A l ambda expr ession. | |
1594 | */ | |
1595 | public static cl ass JCLamb da extends JCFunctio nalExpress ion implem ents Lambd aExpressio nTree { | |
1596 | ||
1597 | pu blic enum ParameterK ind { | |
1598 | IMPLICIT , | |
1599 | EXPLICIT ; | |
1600 | } | |
1601 | ||
1602 | pu blic List< JCVariable Decl> para ms; | |
1603 | pu blic JCTre e body; | |
1604 | pu blic boole an canComp leteNormal ly = true; | |
1605 | pu blic Param eterKind p aramKind; | |
1606 | ||
1607 | pu blic JCLam bda(List<J CVariableD ecl> param s, | |
1608 | JCTree body) { | |
1609 | this.par ams = para ms; | |
1610 | this.bod y = body; | |
1611 | if (para ms.isEmpty () || | |
1612 | para ms.head.va rtype != n ull) { | |
1613 | para mKind = Pa rameterKin d.EXPLICIT ; | |
1614 | } else { | |
1615 | para mKind = Pa rameterKin d.IMPLICIT ; | |
1616 | } | |
1617 | } | |
1618 | @O verride | |
1619 | pu blic Tag g etTag() { | |
1620 | return L AMBDA; | |
1621 | } | |
1622 | @O verride | |
1623 | pu blic void accept(Vis itor v) { | |
1624 | v.visitL ambda(this ); | |
1625 | } | |
1626 | @O verride | |
1627 | pu blic <R, D > R accept (TreeVisit or<R, D> v , D d) { | |
1628 | return v .visitLamb daExpressi on(this, d ); | |
1629 | } | |
1630 | pu blic Kind getKind() { | |
1631 | return K ind.LAMBDA _EXPRESSIO N; | |
1632 | } | |
1633 | pu blic JCTre e getBody( ) { | |
1634 | return b ody; | |
1635 | } | |
1636 | pu blic java. util.List< ? extends VariableTr ee> getPar ameters() { | |
1637 | return p arams; | |
1638 | } | |
1639 | @O verride | |
1640 | pu blic JCLam bda setTyp e(Type typ e) { | |
1641 | super.se tType(type ); | |
1642 | return t his; | |
1643 | } | |
1644 | @O verride | |
1645 | pu blic BodyK ind getBod yKind() { | |
1646 | return b ody.hasTag (BLOCK) ? | |
1647 | BodyKind.S TATEMENT : | |
1648 | BodyKind.E XPRESSION; | |
1649 | } | |
1650 | } | |
1651 | ||
1652 | /** | |
1653 | * A p arenthesiz ed subexpr ession ( . .. ) | |
1654 | */ | |
1655 | public static cl ass JCPare ns extends JCExpress ion implem ents Paren thesizedTr ee { | |
1656 | pu blic JCExp ression ex pr; | |
1657 | pr otected JC Parens(JCE xpression expr) { | |
1658 | this.exp r = expr; | |
1659 | } | |
1660 | @O verride | |
1661 | pu blic void accept(Vis itor v) { v.visitPar ens(this); } | |
1662 | ||
1663 | pu blic Kind getKind() { return K ind.PARENT HESIZED; } | |
1664 | pu blic JCExp ression ge tExpressio n() { retu rn expr; } | |
1665 | @O verride | |
1666 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1667 | return v .visitPare nthesized( this, d); | |
1668 | } | |
1669 | @O verride | |
1670 | pu blic Tag g etTag() { | |
1671 | return P ARENS; | |
1672 | } | |
1673 | } | |
1674 | ||
1675 | /** | |
1676 | * A a ssignment with "=". | |
1677 | */ | |
1678 | public static cl ass JCAssi gn extends JCExpress ion implem ents Assig nmentTree { | |
1679 | pu blic JCExp ression lh s; | |
1680 | pu blic JCExp ression rh s; | |
1681 | pr otected JC Assign(JCE xpression lhs, JCExp ression rh s) { | |
1682 | this.lhs = lhs; | |
1683 | this.rhs = rhs; | |
1684 | } | |
1685 | @O verride | |
1686 | pu blic void accept(Vis itor v) { v.visitAss ign(this); } | |
1687 | ||
1688 | pu blic Kind getKind() { return K ind.ASSIGN MENT; } | |
1689 | pu blic JCExp ression ge tVariable( ) { return lhs; } | |
1690 | pu blic JCExp ression ge tExpressio n() { retu rn rhs; } | |
1691 | @O verride | |
1692 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1693 | return v .visitAssi gnment(thi s, d); | |
1694 | } | |
1695 | @O verride | |
1696 | pu blic Tag g etTag() { | |
1697 | return A SSIGN; | |
1698 | } | |
1699 | } | |
1700 | ||
1701 | /** | |
1702 | * An assignment with "+=" , "|=" ... | |
1703 | */ | |
1704 | public static cl ass JCAssi gnOp exten ds JCExpre ssion impl ements Com poundAssig nmentTree { | |
1705 | pr ivate Tag opcode; | |
1706 | pu blic JCExp ression lh s; | |
1707 | pu blic JCExp ression rh s; | |
1708 | pu blic Symbo l operator ; | |
1709 | pr otected JC AssignOp(T ag opcode, JCTree lh s, JCTree rhs, Symbo l operator ) { | |
1710 | this.opc ode = opco de; | |
1711 | this.lhs = (JCExpr ession)lhs ; | |
1712 | this.rhs = (JCExpr ession)rhs ; | |
1713 | this.ope rator = op erator; | |
1714 | } | |
1715 | @O verride | |
1716 | pu blic void accept(Vis itor v) { v.visitAss ignop(this ); } | |
1717 | ||
1718 | pu blic Kind getKind() { return T reeInfo.ta gToKind(ge tTag()); } | |
1719 | pu blic JCExp ression ge tVariable( ) { return lhs; } | |
1720 | pu blic JCExp ression ge tExpressio n() { retu rn rhs; } | |
1721 | pu blic Symbo l getOpera tor() { | |
1722 | return o perator; | |
1723 | } | |
1724 | @O verride | |
1725 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1726 | return v .visitComp oundAssign ment(this, d); | |
1727 | } | |
1728 | @O verride | |
1729 | pu blic Tag g etTag() { | |
1730 | return o pcode; | |
1731 | } | |
1732 | } | |
1733 | ||
1734 | /** | |
1735 | * A u nary opera tion. | |
1736 | */ | |
1737 | public static cl ass JCUnar y extends JCExpressi on impleme nts UnaryT ree { | |
1738 | pr ivate Tag opcode; | |
1739 | pu blic JCExp ression ar g; | |
1740 | pu blic Symbo l operator ; | |
1741 | pr otected JC Unary(Tag opcode, JC Expression arg) { | |
1742 | this.opc ode = opco de; | |
1743 | this.arg = arg; | |
1744 | } | |
1745 | @O verride | |
1746 | pu blic void accept(Vis itor v) { v.visitUna ry(this); } | |
1747 | ||
1748 | pu blic Kind getKind() { return T reeInfo.ta gToKind(ge tTag()); } | |
1749 | pu blic JCExp ression ge tExpressio n() { retu rn arg; } | |
1750 | pu blic Symbo l getOpera tor() { | |
1751 | return o perator; | |
1752 | } | |
1753 | @O verride | |
1754 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1755 | return v .visitUnar y(this, d) ; | |
1756 | } | |
1757 | @O verride | |
1758 | pu blic Tag g etTag() { | |
1759 | return o pcode; | |
1760 | } | |
1761 | ||
1762 | pu blic void setTag(Tag tag) { | |
1763 | opcode = tag; | |
1764 | } | |
1765 | } | |
1766 | ||
1767 | /** | |
1768 | * A b inary oper ation. | |
1769 | */ | |
1770 | public static cl ass JCBina ry extends JCExpress ion implem ents Binar yTree { | |
1771 | pr ivate Tag opcode; | |
1772 | pu blic JCExp ression lh s; | |
1773 | pu blic JCExp ression rh s; | |
1774 | pu blic Symbo l operator ; | |
1775 | pr otected JC Binary(Tag opcode, | |
1776 | JCExp ression lh s, | |
1777 | JCExp ression rh s, | |
1778 | Symbo l operator ) { | |
1779 | this.opc ode = opco de; | |
1780 | this.lhs = lhs; | |
1781 | this.rhs = rhs; | |
1782 | this.ope rator = op erator; | |
1783 | } | |
1784 | @O verride | |
1785 | pu blic void accept(Vis itor v) { v.visitBin ary(this); } | |
1786 | ||
1787 | pu blic Kind getKind() { return T reeInfo.ta gToKind(ge tTag()); } | |
1788 | pu blic JCExp ression ge tLeftOpera nd() { ret urn lhs; } | |
1789 | pu blic JCExp ression ge tRightOper and() { re turn rhs; } | |
1790 | pu blic Symbo l getOpera tor() { | |
1791 | return o perator; | |
1792 | } | |
1793 | @O verride | |
1794 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1795 | return v .visitBina ry(this, d ); | |
1796 | } | |
1797 | @O verride | |
1798 | pu blic Tag g etTag() { | |
1799 | return o pcode; | |
1800 | } | |
1801 | } | |
1802 | ||
1803 | /** | |
1804 | * A t ype cast. | |
1805 | */ | |
1806 | public static cl ass JCType Cast exten ds JCExpre ssion impl ements Typ eCastTree { | |
1807 | pu blic JCTre e clazz; | |
1808 | pu blic JCExp ression ex pr; | |
1809 | pr otected JC TypeCast(J CTree claz z, JCExpre ssion expr ) { | |
1810 | this.cla zz = clazz ; | |
1811 | this.exp r = expr; | |
1812 | } | |
1813 | @O verride | |
1814 | pu blic void accept(Vis itor v) { v.visitTyp eCast(this ); } | |
1815 | ||
1816 | pu blic Kind getKind() { return K ind.TYPE_C AST; } | |
1817 | pu blic JCTre e getType( ) { return clazz; } | |
1818 | pu blic JCExp ression ge tExpressio n() { retu rn expr; } | |
1819 | @O verride | |
1820 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1821 | return v .visitType Cast(this, d); | |
1822 | } | |
1823 | @O verride | |
1824 | pu blic Tag g etTag() { | |
1825 | return T YPECAST; | |
1826 | } | |
1827 | } | |
1828 | ||
1829 | /** | |
1830 | * A t ype test. | |
1831 | */ | |
1832 | public static cl ass JCInst anceOf ext ends JCExp ression im plements I nstanceOfT ree { | |
1833 | pu blic JCExp ression ex pr; | |
1834 | pu blic JCTre e clazz; | |
1835 | pr otected JC InstanceOf (JCExpress ion expr, JCTree cla zz) { | |
1836 | this.exp r = expr; | |
1837 | this.cla zz = clazz ; | |
1838 | } | |
1839 | @O verride | |
1840 | pu blic void accept(Vis itor v) { v.visitTyp eTest(this ); } | |
1841 | ||
1842 | pu blic Kind getKind() { return K ind.INSTAN CE_OF; } | |
1843 | pu blic JCTre e getType( ) { return clazz; } | |
1844 | pu blic JCExp ression ge tExpressio n() { retu rn expr; } | |
1845 | @O verride | |
1846 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1847 | return v .visitInst anceOf(thi s, d); | |
1848 | } | |
1849 | @O verride | |
1850 | pu blic Tag g etTag() { | |
1851 | return T YPETEST; | |
1852 | } | |
1853 | } | |
1854 | ||
1855 | /** | |
1856 | * An array sele ction | |
1857 | */ | |
1858 | public static cl ass JCArra yAccess ex tends JCEx pression i mplements ArrayAcces sTree { | |
1859 | pu blic JCExp ression in dexed; | |
1860 | pu blic JCExp ression in dex; | |
1861 | pr otected JC ArrayAcces s(JCExpres sion index ed, JCExpr ession ind ex) { | |
1862 | this.ind exed = ind exed; | |
1863 | this.ind ex = index ; | |
1864 | } | |
1865 | @O verride | |
1866 | pu blic void accept(Vis itor v) { v.visitInd exed(this) ; } | |
1867 | ||
1868 | pu blic Kind getKind() { return K ind.ARRAY_ ACCESS; } | |
1869 | pu blic JCExp ression ge tExpressio n() { retu rn indexed ; } | |
1870 | pu blic JCExp ression ge tIndex() { return in dex; } | |
1871 | @O verride | |
1872 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1873 | return v .visitArra yAccess(th is, d); | |
1874 | } | |
1875 | @O verride | |
1876 | pu blic Tag g etTag() { | |
1877 | return I NDEXED; | |
1878 | } | |
1879 | } | |
1880 | ||
1881 | /** | |
1882 | * Sel ects throu gh package s and clas ses | |
1883 | */ | |
1884 | public static cl ass JCFiel dAccess ex tends JCEx pression i mplements MemberSele ctTree { | |
1885 | /* * selected Tree hier archy */ | |
1886 | pu blic JCExp ression se lected; | |
1887 | /* * name of field to s elect thru */ | |
1888 | pu blic Name name; | |
1889 | /* * symbol o f the sele cted class */ | |
1890 | pu blic Symbo l sym; | |
1891 | pr otected JC FieldAcces s(JCExpres sion selec ted, Name name, Symb ol sym) { | |
1892 | this.sel ected = se lected; | |
1893 | this.nam e = name; | |
1894 | this.sym = sym; | |
1895 | } | |
1896 | @O verride | |
1897 | pu blic void accept(Vis itor v) { v.visitSel ect(this); } | |
1898 | ||
1899 | pu blic Kind getKind() { return K ind.MEMBER _SELECT; } | |
1900 | pu blic JCExp ression ge tExpressio n() { retu rn selecte d; } | |
1901 | @O verride | |
1902 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1903 | return v .visitMemb erSelect(t his, d); | |
1904 | } | |
1905 | pu blic Name getIdentif ier() { re turn name; } | |
1906 | @O verride | |
1907 | pu blic Tag g etTag() { | |
1908 | return S ELECT; | |
1909 | } | |
1910 | } | |
1911 | ||
1912 | /** | |
1913 | * Sel ects a mem ber expres sion. | |
1914 | */ | |
1915 | public static cl ass JCMemb erReferenc e extends JCFunction alExpressi on impleme nts Member ReferenceT ree { | |
1916 | ||
1917 | pu blic Refer enceMode m ode; | |
1918 | pu blic Refer enceKind k ind; | |
1919 | pu blic Name name; | |
1920 | pu blic JCExp ression ex pr; | |
1921 | pu blic List< JCExpressi on> typear gs; | |
1922 | pu blic Symbo l sym; | |
1923 | pu blic Type varargsEle ment; | |
1924 | pu blic PolyK ind refPol yKind; | |
1925 | pu blic boole an ownerAc cessible; | |
1926 | pu blic Overl oadKind ov erloadKind ; | |
1927 | ||
1928 | pu blic enum OverloadKi nd { | |
1929 | OVERLOAD ED, | |
1930 | UNOVERLO ADED; | |
1931 | } | |
1932 | ||
1933 | /* * | |
1934 | * Javac-dep endent cla ssificatio n for memb er referen ces, based | |
1935 | * on releva nt propert ies w.r.t. code-gene ration | |
1936 | * / | |
1937 | pu blic enum ReferenceK ind { | |
1938 | /** supe r # instMe thod */ | |
1939 | SUPER(Re ferenceMod e.INVOKE, false), | |
1940 | /** Type # instMet hod */ | |
1941 | UNBOUND( ReferenceM ode.INVOKE , true), | |
1942 | /** Type # staticM ethod */ | |
1943 | STATIC(R eferenceMo de.INVOKE, false), | |
1944 | /** Expr # instMet hod */ | |
1945 | BOUND(Re ferenceMod e.INVOKE, false), | |
1946 | /** Inne r # new */ | |
1947 | IMPLICIT _INNER(Ref erenceMode .NEW, fals e), | |
1948 | /** Topl evel # new */ | |
1949 | TOPLEVEL (Reference Mode.NEW, false), | |
1950 | /** Arra yType # ne w */ | |
1951 | ARRAY_CT OR(Referen ceMode.NEW , false); | |
1952 | ||
1953 | final Re ferenceMod e mode; | |
1954 | final bo olean unbo und; | |
1955 | ||
1956 | private ReferenceK ind(Refere nceMode mo de, boolea n unbound) { | |
1957 | this .mode = mo de; | |
1958 | this .unbound = unbound; | |
1959 | } | |
1960 | ||
1961 | public b oolean isU nbound() { | |
1962 | retu rn unbound ; | |
1963 | } | |
1964 | } | |
1965 | ||
1966 | pr otected JC MemberRefe rence(Refe renceMode mode, Name name, JCE xpression expr, List <JCExpress ion> typea rgs) { | |
1967 | this.mod e = mode; | |
1968 | this.nam e = name; | |
1969 | this.exp r = expr; | |
1970 | this.typ eargs = ty peargs; | |
1971 | } | |
1972 | @O verride | |
1973 | pu blic void accept(Vis itor v) { v.visitRef erence(thi s); } | |
1974 | ||
1975 | pu blic Kind getKind() { return K ind.MEMBER _REFERENCE ; } | |
1976 | @O verride | |
1977 | pu blic Refer enceMode g etMode() { return mo de; } | |
1978 | @O verride | |
1979 | pu blic JCExp ression ge tQualifier Expression () { retur n expr; } | |
1980 | @O verride | |
1981 | pu blic Name getName() { return n ame; } | |
1982 | @O verride | |
1983 | pu blic List< JCExpressi on> getTyp eArguments () { retur n typeargs ; } | |
1984 | ||
1985 | @O verride | |
1986 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
1987 | return v .visitMemb erReferenc e(this, d) ; | |
1988 | } | |
1989 | @O verride | |
1990 | pu blic Tag g etTag() { | |
1991 | return R EFERENCE; | |
1992 | } | |
1993 | pu blic boole an hasKind (Reference Kind kind) { | |
1994 | return t his.kind = = kind; | |
1995 | } | |
1996 | } | |
1997 | ||
1998 | /** | |
1999 | * An identifier | |
2000 | */ | |
2001 | public static cl ass JCIden t extends JCExpressi on impleme nts Identi fierTree { | |
2002 | /* * the name */ | |
2003 | pu blic Name name; | |
2004 | /* * the symb ol */ | |
2005 | pu blic Symbo l sym; | |
2006 | pr otected JC Ident(Name name, Sym bol sym) { | |
2007 | this.nam e = name; | |
2008 | this.sym = sym; | |
2009 | } | |
2010 | @O verride | |
2011 | pu blic void accept(Vis itor v) { v.visitIde nt(this); } | |
2012 | ||
2013 | pu blic Kind getKind() { return K ind.IDENTI FIER; } | |
2014 | pu blic Name getName() { return n ame; } | |
2015 | @O verride | |
2016 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2017 | return v .visitIden tifier(thi s, d); | |
2018 | } | |
2019 | @O verride | |
2020 | pu blic Tag g etTag() { | |
2021 | return I DENT; | |
2022 | } | |
2023 | } | |
2024 | ||
2025 | /** | |
2026 | * A c onstant va lue given literally. | |
2027 | */ | |
2028 | public static cl ass JCLite ral extend s JCExpres sion imple ments Lite ralTree { | |
2029 | pu blic TypeT ag typetag ; | |
2030 | /* * value re presentati on */ | |
2031 | pu blic Objec t value; | |
2032 | pr otected JC Literal(Ty peTag type tag, Objec t value) { | |
2033 | this.typ etag = typ etag; | |
2034 | this.val ue = value ; | |
2035 | } | |
2036 | @O verride | |
2037 | pu blic void accept(Vis itor v) { v.visitLit eral(this) ; } | |
2038 | ||
2039 | pu blic Kind getKind() { | |
2040 | return t ypetag.get KindLitera l(); | |
2041 | } | |
2042 | ||
2043 | pu blic Objec t getValue () { | |
2044 | switch ( typetag) { | |
2045 | case BOOLEAN: | |
2046 | int bi = ( Integer) v alue; | |
2047 | return (bi != 0); | |
2048 | case CHAR: | |
2049 | int ci = ( Integer) v alue; | |
2050 | char c = ( char) ci; | |
2051 | if (c != c i) | |
2052 | throw new Assert ionError(" bad value for char l iteral"); | |
2053 | return c; | |
2054 | defa ult: | |
2055 | return val ue; | |
2056 | } | |
2057 | } | |
2058 | @O verride | |
2059 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2060 | return v .visitLite ral(this, d); | |
2061 | } | |
2062 | @O verride | |
2063 | pu blic JCLit eral setTy pe(Type ty pe) { | |
2064 | super.se tType(type ); | |
2065 | return t his; | |
2066 | } | |
2067 | @O verride | |
2068 | pu blic Tag g etTag() { | |
2069 | return L ITERAL; | |
2070 | } | |
2071 | } | |
2072 | ||
2073 | /** | |
2074 | * Ide ntifies a basic type . | |
2075 | * @se e TypeTag | |
2076 | */ | |
2077 | public static cl ass JCPrim itiveTypeT ree extend s JCExpres sion imple ments Prim itiveTypeT ree { | |
2078 | /* * the basi c type id */ | |
2079 | pu blic TypeT ag typetag ; | |
2080 | pr otected JC PrimitiveT ypeTree(Ty peTag type tag) { | |
2081 | this.typ etag = typ etag; | |
2082 | } | |
2083 | @O verride | |
2084 | pu blic void accept(Vis itor v) { v.visitTyp eIdent(thi s); } | |
2085 | ||
2086 | pu blic Kind getKind() { return K ind.PRIMIT IVE_TYPE; } | |
2087 | pu blic TypeK ind getPri mitiveType Kind() { | |
2088 | return t ypetag.get PrimitiveT ypeKind(); | |
2089 | } | |
2090 | ||
2091 | @O verride | |
2092 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2093 | return v .visitPrim itiveType( this, d); | |
2094 | } | |
2095 | @O verride | |
2096 | pu blic Tag g etTag() { | |
2097 | return T YPEIDENT; | |
2098 | } | |
2099 | } | |
2100 | ||
2101 | /** | |
2102 | * An array type , A[] | |
2103 | */ | |
2104 | public static cl ass JCArra yTypeTree extends JC Expression implement s ArrayTyp eTree { | |
2105 | pu blic JCExp ression el emtype; | |
2106 | pr otected JC ArrayTypeT ree(JCExpr ession ele mtype) { | |
2107 | this.ele mtype = el emtype; | |
2108 | } | |
2109 | @O verride | |
2110 | pu blic void accept(Vis itor v) { v.visitTyp eArray(thi s); } | |
2111 | ||
2112 | pu blic Kind getKind() { return K ind.ARRAY_ TYPE; } | |
2113 | pu blic JCTre e getType( ) { return elemtype; } | |
2114 | @O verride | |
2115 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2116 | return v .visitArra yType(this , d); | |
2117 | } | |
2118 | @O verride | |
2119 | pu blic Tag g etTag() { | |
2120 | return T YPEARRAY; | |
2121 | } | |
2122 | } | |
2123 | ||
2124 | /** | |
2125 | * A p arameteriz ed type, { @literal T <...>} | |
2126 | */ | |
2127 | public static cl ass JCType Apply exte nds JCExpr ession imp lements Pa rameterize dTypeTree { | |
2128 | pu blic JCExp ression cl azz; | |
2129 | pu blic List< JCExpressi on> argume nts; | |
2130 | pr otected JC TypeApply( JCExpressi on clazz, List<JCExp ression> a rguments) { | |
2131 | this.cla zz = clazz ; | |
2132 | this.arg uments = a rguments; | |
2133 | } | |
2134 | @O verride | |
2135 | pu blic void accept(Vis itor v) { v.visitTyp eApply(thi s); } | |
2136 | ||
2137 | pu blic Kind getKind() { return K ind.PARAME TERIZED_TY PE; } | |
2138 | pu blic JCTre e getType( ) { return clazz; } | |
2139 | pu blic List< JCExpressi on> getTyp eArguments () { | |
2140 | return a rguments; | |
2141 | } | |
2142 | @O verride | |
2143 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2144 | return v .visitPara meterizedT ype(this, d); | |
2145 | } | |
2146 | @O verride | |
2147 | pu blic Tag g etTag() { | |
2148 | return T YPEAPPLY; | |
2149 | } | |
2150 | } | |
2151 | ||
2152 | /** | |
2153 | * A u nion type, T1 | T2 | ... Tn (u sed in mul ticatch st atements) | |
2154 | */ | |
2155 | public static cl ass JCType Union exte nds JCExpr ession imp lements Un ionTypeTre e { | |
2156 | ||
2157 | pu blic List< JCExpressi on> altern atives; | |
2158 | ||
2159 | pr otected JC TypeUnion( List<JCExp ression> c omponents) { | |
2160 | this.alt ernatives = componen ts; | |
2161 | } | |
2162 | @O verride | |
2163 | pu blic void accept(Vis itor v) { v.visitTyp eUnion(thi s); } | |
2164 | ||
2165 | pu blic Kind getKind() { return K ind.UNION_ TYPE; } | |
2166 | ||
2167 | pu blic List< JCExpressi on> getTyp eAlternati ves() { | |
2168 | return a lternative s; | |
2169 | } | |
2170 | @O verride | |
2171 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2172 | return v .visitUnio nType(this , d); | |
2173 | } | |
2174 | @O verride | |
2175 | pu blic Tag g etTag() { | |
2176 | return T YPEUNION; | |
2177 | } | |
2178 | } | |
2179 | ||
2180 | /** | |
2181 | * An intersecti on type, T 1 & T2 & . .. Tn (use d in cast expression s) | |
2182 | */ | |
2183 | public static cl ass JCType Intersecti on extends JCExpress ion implem ents Inter sectionTyp eTree { | |
2184 | ||
2185 | pu blic List< JCExpressi on> bounds ; | |
2186 | ||
2187 | pr otected JC TypeInters ection(Lis t<JCExpres sion> boun ds) { | |
2188 | this.bou nds = boun ds; | |
2189 | } | |
2190 | @O verride | |
2191 | pu blic void accept(Vis itor v) { v.visitTyp eIntersect ion(this); } | |
2192 | ||
2193 | pu blic Kind getKind() { return K ind.INTERS ECTION_TYP E; } | |
2194 | ||
2195 | pu blic List< JCExpressi on> getBou nds() { | |
2196 | return b ounds; | |
2197 | } | |
2198 | @O verride | |
2199 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2200 | return v .visitInte rsectionTy pe(this, d ); | |
2201 | } | |
2202 | @O verride | |
2203 | pu blic Tag g etTag() { | |
2204 | return T YPEINTERSE CTION; | |
2205 | } | |
2206 | } | |
2207 | ||
2208 | /** | |
2209 | * A f ormal clas s paramete r. | |
2210 | */ | |
2211 | public static cl ass JCType Parameter extends JC Tree imple ments Type ParameterT ree { | |
2212 | /* * name */ | |
2213 | pu blic Name name; | |
2214 | /* * bounds * / | |
2215 | pu blic List< JCExpressi on> bounds ; | |
2216 | /* * type ann otations o n type par ameter */ | |
2217 | pu blic List< JCAnnotati on> annota tions; | |
2218 | pr otected JC TypeParame ter(Name n ame, List< JCExpressi on> bounds , List<JCA nnotation> annotatio ns) { | |
2219 | this.nam e = name; | |
2220 | this.bou nds = boun ds; | |
2221 | this.ann otations = annotatio ns; | |
2222 | } | |
2223 | @O verride | |
2224 | pu blic void accept(Vis itor v) { v.visitTyp eParameter (this); } | |
2225 | ||
2226 | pu blic Kind getKind() { return K ind.TYPE_P ARAMETER; } | |
2227 | pu blic Name getName() { return n ame; } | |
2228 | pu blic List< JCExpressi on> getBou nds() { | |
2229 | return b ounds; | |
2230 | } | |
2231 | pu blic List< JCAnnotati on> getAnn otations() { | |
2232 | return a nnotations ; | |
2233 | } | |
2234 | @O verride | |
2235 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2236 | return v .visitType Parameter( this, d); | |
2237 | } | |
2238 | @O verride | |
2239 | pu blic Tag g etTag() { | |
2240 | return T YPEPARAMET ER; | |
2241 | } | |
2242 | } | |
2243 | ||
2244 | public static cl ass JCWild card exten ds JCExpre ssion impl ements Wil dcardTree { | |
2245 | pu blic TypeB oundKind k ind; | |
2246 | pu blic JCTre e inner; | |
2247 | pr otected JC Wildcard(T ypeBoundKi nd kind, J CTree inne r) { | |
2248 | kind.get Class(); / / null-che ck | |
2249 | this.kin d = kind; | |
2250 | this.inn er = inner ; | |
2251 | } | |
2252 | @O verride | |
2253 | pu blic void accept(Vis itor v) { v.visitWil dcard(this ); } | |
2254 | ||
2255 | pu blic Kind getKind() { | |
2256 | switch ( kind.kind) { | |
2257 | case UNB OUND: | |
2258 | retu rn Kind.UN BOUNDED_WI LDCARD; | |
2259 | case EXT ENDS: | |
2260 | retu rn Kind.EX TENDS_WILD CARD; | |
2261 | case SUP ER: | |
2262 | retu rn Kind.SU PER_WILDCA RD; | |
2263 | default: | |
2264 | thro w new Asse rtionError ("Unknown wildcard b ound " + k ind); | |
2265 | } | |
2266 | } | |
2267 | pu blic JCTre e getBound () { retur n inner; } | |
2268 | @O verride | |
2269 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2270 | return v .visitWild card(this, d); | |
2271 | } | |
2272 | @O verride | |
2273 | pu blic Tag g etTag() { | |
2274 | return T ag.WILDCAR D; | |
2275 | } | |
2276 | } | |
2277 | ||
2278 | public static cl ass TypeBo undKind ex tends JCTr ee { | |
2279 | pu blic Bound Kind kind; | |
2280 | pr otected Ty peBoundKin d(BoundKin d kind) { | |
2281 | this.kin d = kind; | |
2282 | } | |
2283 | @O verride | |
2284 | pu blic void accept(Vis itor v) { v.visitTyp eBoundKind (this); } | |
2285 | ||
2286 | pu blic Kind getKind() { | |
2287 | throw ne w Assertio nError("Ty peBoundKin d is not p art of a p ublic API" ); | |
2288 | } | |
2289 | @O verride | |
2290 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2291 | throw ne w Assertio nError("Ty peBoundKin d is not p art of a p ublic API" ); | |
2292 | } | |
2293 | @O verride | |
2294 | pu blic Tag g etTag() { | |
2295 | return T YPEBOUNDKI ND; | |
2296 | } | |
2297 | } | |
2298 | ||
2299 | public static cl ass JCAnno tation ext ends JCExp ression im plements A nnotationT ree { | |
2300 | // Either Ta g.ANNOTATI ON or Tag. TYPE_ANNOT ATION | |
2301 | pr ivate Tag tag; | |
2302 | ||
2303 | pu blic JCTre e annotati onType; | |
2304 | pu blic List< JCExpressi on> args; | |
2305 | ||
2306 | // Attribute .Compound if tag is ANNOTATION | |
2307 | // Attribute .TypeCompo und if tag is TYPE_A NNOTATION | |
2308 | pu blic Attri bute.Compo und attrib ute; | |
2309 | ||
2310 | pr otected JC Annotation (Tag tag, JCTree ann otationTyp e, List<JC Expression > args) { | |
2311 | this.tag = tag; | |
2312 | this.ann otationTyp e = annota tionType; | |
2313 | this.arg s = args; | |
2314 | } | |
2315 | ||
2316 | @O verride | |
2317 | pu blic void accept(Vis itor v) { v.visitAnn otation(th is); } | |
2318 | ||
2319 | pu blic Kind getKind() { return T reeInfo.ta gToKind(ge tTag()); } | |
2320 | ||
2321 | pu blic JCTre e getAnnot ationType( ) { return annotatio nType; } | |
2322 | pu blic List< JCExpressi on> getArg uments() { | |
2323 | return a rgs; | |
2324 | } | |
2325 | @O verride | |
2326 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2327 | return v .visitAnno tation(thi s, d); | |
2328 | } | |
2329 | @O verride | |
2330 | pu blic Tag g etTag() { | |
2331 | return t ag; | |
2332 | } | |
2333 | } | |
2334 | ||
2335 | public static cl ass JCModi fiers exte nds JCTree implement s com.sun. source.tre e.Modifier sTree { | |
2336 | pu blic long flags; | |
2337 | pu blic List< JCAnnotati on> annota tions; | |
2338 | pr otected JC Modifiers( long flags , List<JCA nnotation> annotatio ns) { | |
2339 | this.fla gs = flags ; | |
2340 | this.ann otations = annotatio ns; | |
2341 | } | |
2342 | @O verride | |
2343 | pu blic void accept(Vis itor v) { v.visitMod ifiers(thi s); } | |
2344 | ||
2345 | pu blic Kind getKind() { return K ind.MODIFI ERS; } | |
2346 | pu blic Set<M odifier> g etFlags() { | |
2347 | return F lags.asMod ifierSet(f lags); | |
2348 | } | |
2349 | pu blic List< JCAnnotati on> getAnn otations() { | |
2350 | return a nnotations ; | |
2351 | } | |
2352 | @O verride | |
2353 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2354 | return v .visitModi fiers(this , d); | |
2355 | } | |
2356 | @O verride | |
2357 | pu blic Tag g etTag() { | |
2358 | return M ODIFIERS; | |
2359 | } | |
2360 | } | |
2361 | ||
2362 | public static cl ass JCAnno tatedType extends JC Expression implement s com.sun. source.tre e.Annotate dTypeTree { | |
2363 | // type anno tations | |
2364 | pu blic List< JCAnnotati on> annota tions; | |
2365 | pu blic JCExp ression un derlyingTy pe; | |
2366 | ||
2367 | pr otected JC AnnotatedT ype(List<J CAnnotatio n> annotat ions, JCEx pression u nderlyingT ype) { | |
2368 | Assert.c heck(annot ations != null && an notations. nonEmpty() ); | |
2369 | this.ann otations = annotatio ns; | |
2370 | this.und erlyingTyp e = underl yingType; | |
2371 | } | |
2372 | @O verride | |
2373 | pu blic void accept(Vis itor v) { v.visitAnn otatedType (this); } | |
2374 | ||
2375 | pu blic Kind getKind() { return K ind.ANNOTA TED_TYPE; } | |
2376 | pu blic List< JCAnnotati on> getAnn otations() { | |
2377 | return a nnotations ; | |
2378 | } | |
2379 | pu blic JCExp ression ge tUnderlyin gType() { | |
2380 | return u nderlyingT ype; | |
2381 | } | |
2382 | @O verride | |
2383 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2384 | return v .visitAnno tatedType( this, d); | |
2385 | } | |
2386 | @O verride | |
2387 | pu blic Tag g etTag() { | |
2388 | return A NNOTATED_T YPE; | |
2389 | } | |
2390 | } | |
2391 | ||
2392 | public static cl ass JCErro neous exte nds JCExpr ession | |
2393 | implemen ts com.sun .source.tr ee.Erroneo usTree { | |
2394 | pu blic List< ? extends JCTree> er rs; | |
2395 | pr otected JC Erroneous( List<? ext ends JCTre e> errs) { | |
2396 | this.err s = errs; | |
2397 | } | |
2398 | @O verride | |
2399 | pu blic void accept(Vis itor v) { v.visitErr oneous(thi s); } | |
2400 | ||
2401 | pu blic Kind getKind() { return K ind.ERRONE OUS; } | |
2402 | ||
2403 | pu blic List< ? extends JCTree> ge tErrorTree s() { | |
2404 | return e rrs; | |
2405 | } | |
2406 | ||
2407 | @O verride | |
2408 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2409 | return v .visitErro neous(this , d); | |
2410 | } | |
2411 | @O verride | |
2412 | pu blic Tag g etTag() { | |
2413 | return E RRONEOUS; | |
2414 | } | |
2415 | } | |
2416 | ||
2417 | /** (l et int x = 3; in x+2 ) */ | |
2418 | public static cl ass LetExp r extends JCExpressi on { | |
2419 | pu blic List< JCVariable Decl> defs ; | |
2420 | pu blic JCTre e expr; | |
2421 | pr otected Le tExpr(List <JCVariabl eDecl> def s, JCTree expr) { | |
2422 | this.def s = defs; | |
2423 | this.exp r = expr; | |
2424 | } | |
2425 | @O verride | |
2426 | pu blic void accept(Vis itor v) { v.visitLet Expr(this) ; } | |
2427 | ||
2428 | pu blic Kind getKind() { | |
2429 | throw ne w Assertio nError("Le tExpr is n ot part of a public API"); | |
2430 | } | |
2431 | @O verride | |
2432 | pu blic <R,D> R accept( TreeVisito r<R,D> v, D d) { | |
2433 | throw ne w Assertio nError("Le tExpr is n ot part of a public API"); | |
2434 | } | |
2435 | @O verride | |
2436 | pu blic Tag g etTag() { | |
2437 | return L ETEXPR; | |
2438 | } | |
2439 | } | |
2440 | ||
2441 | /** An interface for tree factories | |
2442 | */ | |
2443 | public interface Factory { | |
2444 | JC Compilatio nUnit TopL evel(List< JCAnnotati on> packag eAnnotatio ns, | |
2445 | JCExp ression pi d, | |
2446 | List< JCTree> de fs); | |
2447 | JC Import Imp ort(JCTree qualid, b oolean sta ticImport) ; | |
2448 | JC ClassDecl ClassDef(J CModifiers mods, | |
2449 | Name name, | |
2450 | List <JCTypePar ameter> ty params, | |
2451 | JCEx pression e xtending, | |
2452 | List <JCExpress ion> imple menting, | |
2453 | List <JCTree> d efs); | |
2454 | JC MethodDecl MethodDef (JCModifie rs mods, | |
2455 | Na me name, | |
2456 | JC Expression restype, | |
2457 | Li st<JCTypeP arameter> typarams, | |
2458 | JC VariableDe cl recvpar am, | |
2459 | Li st<JCVaria bleDecl> p arams, | |
2460 | Li st<JCExpre ssion> thr own, | |
2461 | JC Block body , | |
2462 | JC Expression defaultVa lue); | |
2463 | JC VariableDe cl VarDef( JCModifier s mods, | |
2464 | Name nam e, | |
2465 | JCExpres sion varty pe, | |
2466 | JCExpres sion init) ; | |
2467 | JC Skip Skip( ); | |
2468 | JC Block Bloc k(long fla gs, List<J CStatement > stats); | |
2469 | JC DoWhileLoo p DoLoop(J CStatement body, JCE xpression cond); | |
2470 | JC WhileLoop WhileLoop( JCExpressi on cond, J CStatement body); | |
2471 | JC ForLoop Fo rLoop(List <JCStateme nt> init, | |
2472 | JCExpr ession con d, | |
2473 | List<J CExpressio nStatement > step, | |
2474 | JCStat ement body ); | |
2475 | JC EnhancedFo rLoop Fore achLoop(JC VariableDe cl var, JC Expression expr, JCS tatement b ody); | |
2476 | JC LabeledSta tement Lab elled(Name label, JC Statement body); | |
2477 | JC Switch Swi tch(JCExpr ession sel ector, Lis t<JCCase> cases); | |
2478 | JC Case Case( JCExpressi on pat, Li st<JCState ment> stat s); | |
2479 | JC Synchroniz ed Synchro nized(JCEx pression l ock, JCBlo ck body); | |
2480 | JC Try Try(JC Block body , List<JCC atch> catc hers, JCBl ock finali zer); | |
2481 | JC Try Try(Li st<JCTree> resources , | |
2482 | JC Block body , | |
2483 | Li st<JCCatch > catchers , | |
2484 | JC Block fina lizer); | |
2485 | JC Catch Catc h(JCVariab leDecl par am, JCBloc k body); | |
2486 | JC Conditiona l Conditio nal(JCExpr ession con d, | |
2487 | JCExpres sion thenp art, | |
2488 | JCExpres sion elsep art); | |
2489 | JC If If(JCEx pression c ond, JCSta tement the npart, JCS tatement e lsepart); | |
2490 | JC Expression Statement Exec(JCExp ression ex pr); | |
2491 | JC Break Brea k(Name lab el); | |
2492 | JC Continue C ontinue(Na me label); | |
2493 | JC Return Ret urn(JCExpr ession exp r); | |
2494 | JC Throw Thro w(JCExpres sion expr) ; | |
2495 | JC Assert Ass ert(JCExpr ession con d, JCExpre ssion deta il); | |
2496 | JC MethodInvo cation App ly(List<JC Expression > typeargs , | |
2497 | JCExpressi on fn, | |
2498 | List<JCExp ression> a rgs); | |
2499 | JC NewClass N ewClass(JC Expression encl, | |
2500 | List <JCExpress ion> typea rgs, | |
2501 | JCEx pression c lazz, | |
2502 | List <JCExpress ion> args, | |
2503 | JCCl assDecl de f); | |
2504 | JC NewArray N ewArray(JC Expression elemtype, | |
2505 | List <JCExpress ion> dims, | |
2506 | List <JCExpress ion> elems ); | |
2507 | JC Parens Par ens(JCExpr ession exp r); | |
2508 | JC Assign Ass ign(JCExpr ession lhs , JCExpres sion rhs); | |
2509 | JC AssignOp A ssignop(Ta g opcode, JCTree lhs , JCTree r hs); | |
2510 | JC Unary Unar y(Tag opco de, JCExpr ession arg ); | |
2511 | JC Binary Bin ary(Tag op code, JCEx pression l hs, JCExpr ession rhs ); | |
2512 | JC TypeCast T ypeCast(JC Tree expr, JCExpress ion type); | |
2513 | JC InstanceOf TypeTest( JCExpressi on expr, J CTree claz z); | |
2514 | JC ArrayAcces s Indexed( JCExpressi on indexed , JCExpres sion index ); | |
2515 | JC FieldAcces s Select(J CExpressio n selected , Name sel ector); | |
2516 | JC Ident Iden t(Name idn ame); | |
2517 | JC Literal Li teral(Type Tag tag, O bject valu e); | |
2518 | JC PrimitiveT ypeTree Ty peIdent(Ty peTag type tag); | |
2519 | JC ArrayTypeT ree TypeAr ray(JCExpr ession ele mtype); | |
2520 | JC TypeApply TypeApply( JCExpressi on clazz, List<JCExp ression> a rguments); | |
2521 | JC TypeParame ter TypePa rameter(Na me name, L ist<JCExpr ession> bo unds); | |
2522 | JC Wildcard W ildcard(Ty peBoundKin d kind, JC Tree type) ; | |
2523 | Ty peBoundKin d TypeBoun dKind(Boun dKind kind ); | |
2524 | JC Annotation Annotatio n(JCTree a nnotationT ype, List< JCExpressi on> args); | |
2525 | JC Modifiers Modifiers( long flags , List<JCA nnotation> annotatio ns); | |
2526 | JC Erroneous Erroneous( List<? ext ends JCTre e> errs); | |
2527 | Le tExpr LetE xpr(List<J CVariableD ecl> defs, JCTree ex pr); | |
2528 | } | |
2529 | ||
2530 | /** A generic vi sitor clas s for tree s. | |
2531 | */ | |
2532 | public static ab stract cla ss Visitor { | |
2533 | pu blic void visitTopLe vel(JCComp ilationUni t that) { visitTr ee(that); } | |
2534 | pu blic void visitImpor t(JCImport that) { visitTr ee(that); } | |
2535 | pu blic void visitClass Def(JCClas sDecl that ) { visitTr ee(that); } | |
2536 | pu blic void visitMetho dDef(JCMet hodDecl th at) { visitTr ee(that); } | |
2537 | pu blic void visitVarDe f(JCVariab leDecl tha t) { visitTr ee(that); } | |
2538 | pu blic void visitSkip( JCSkip tha t) { visitTr ee(that); } | |
2539 | pu blic void visitBlock (JCBlock t hat) { visitTr ee(that); } | |
2540 | pu blic void visitDoLoo p(JCDoWhil eLoop that ) { visitTr ee(that); } | |
2541 | pu blic void visitWhile Loop(JCWhi leLoop tha t) { visitTr ee(that); } | |
2542 | pu blic void visitForLo op(JCForLo op that) { visitTr ee(that); } | |
2543 | pu blic void visitForea chLoop(JCE nhancedFor Loop that) { visitTr ee(that); } | |
2544 | pu blic void visitLabel led(JCLabe ledStateme nt that) { visitTr ee(that); } | |
2545 | pu blic void visitSwitc h(JCSwitch that) { visitTr ee(that); } | |
2546 | pu blic void visitCase( JCCase tha t) { visitTr ee(that); } | |
2547 | pu blic void visitSynch ronized(JC Synchroniz ed that) { visitTr ee(that); } | |
2548 | pu blic void visitTry(J CTry that) { visitTr ee(that); } | |
2549 | pu blic void visitCatch (JCCatch t hat) { visitTr ee(that); } | |
2550 | pu blic void visitCondi tional(JCC onditional that) { visitTr ee(that); } | |
2551 | pu blic void visitIf(JC If that) { visitTr ee(that); } | |
2552 | pu blic void visitExec( JCExpressi onStatemen t that) { visitTr ee(that); } | |
2553 | pu blic void visitBreak (JCBreak t hat) { visitTr ee(that); } | |
2554 | pu blic void visitConti nue(JCCont inue that) { visitTr ee(that); } | |
2555 | pu blic void visitRetur n(JCReturn that) { visitTr ee(that); } | |
2556 | pu blic void visitThrow (JCThrow t hat) { visitTr ee(that); } | |
2557 | pu blic void visitAsser t(JCAssert that) { visitTr ee(that); } | |
2558 | pu blic void visitApply (JCMethodI nvocation that) { visitTr ee(that); } | |
2559 | pu blic void visitNewCl ass(JCNewC lass that) { visitTr ee(that); } | |
2560 | pu blic void visitNewAr ray(JCNewA rray that) { visitTr ee(that); } | |
2561 | pu blic void visitLambd a(JCLambda that) { visitTr ee(that); } | |
2562 | pu blic void visitParen s(JCParens that) { visitTr ee(that); } | |
2563 | pu blic void visitAssig n(JCAssign that) { visitTr ee(that); } | |
2564 | pu blic void visitAssig nop(JCAssi gnOp that) { visitTr ee(that); } | |
2565 | pu blic void visitUnary (JCUnary t hat) { visitTr ee(that); } | |
2566 | pu blic void visitBinar y(JCBinary that) { visitTr ee(that); } | |
2567 | pu blic void visitTypeC ast(JCType Cast that) { visitTr ee(that); } | |
2568 | pu blic void visitTypeT est(JCInst anceOf tha t) { visitTr ee(that); } | |
2569 | pu blic void visitIndex ed(JCArray Access tha t) { visitTr ee(that); } | |
2570 | pu blic void visitSelec t(JCFieldA ccess that ) { visitTr ee(that); } | |
2571 | pu blic void visitRefer ence(JCMem berReferen ce that) { visitTr ee(that); } | |
2572 | pu blic void visitIdent (JCIdent t hat) { visitTr ee(that); } | |
2573 | pu blic void visitLiter al(JCLiter al that) { visitTr ee(that); } | |
2574 | pu blic void visitTypeI dent(JCPri mitiveType Tree that) { visitTr ee(that); } | |
2575 | pu blic void visitTypeA rray(JCArr ayTypeTree that) { visitTr ee(that); } | |
2576 | pu blic void visitTypeA pply(JCTyp eApply tha t) { visitTr ee(that); } | |
2577 | pu blic void visitTypeU nion(JCTyp eUnion tha t) { visitTr ee(that); } | |
2578 | pu blic void visitTypeI ntersectio n(JCTypeIn tersection that) { visitTree( that); } | |
2579 | pu blic void visitTypeP arameter(J CTypeParam eter that) { visitTr ee(that); } | |
2580 | pu blic void visitWildc ard(JCWild card that) { visitTr ee(that); } | |
2581 | pu blic void visitTypeB oundKind(T ypeBoundKi nd that) { visitTr ee(that); } | |
2582 | pu blic void visitAnnot ation(JCAn notation t hat) { visitTr ee(that); } | |
2583 | pu blic void visitModif iers(JCMod ifiers tha t) { visitTr ee(that); } | |
2584 | pu blic void visitAnnot atedType(J CAnnotated Type that) { visitTr ee(that); } | |
2585 | pu blic void visitErron eous(JCErr oneous tha t) { visitTr ee(that); } | |
2586 | pu blic void visitLetEx pr(LetExpr that) { visitTr ee(that); } | |
2587 | ||
2588 | pu blic void visitTree( JCTree tha t) { Assert. error(); } | |
2589 | } | |
2590 | ||
2591 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.