1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
package com.sun.tools.javafx.comp; |
26 | |
|
27 | |
import com.sun.tools.javac.code.BoundKind; |
28 | |
import com.sun.tools.javac.code.Flags; |
29 | |
import com.sun.tools.javac.code.Symbol; |
30 | |
import com.sun.tools.javac.code.Type; |
31 | |
import com.sun.tools.javac.code.Type.*; |
32 | |
import com.sun.tools.javac.code.TypeTags; |
33 | |
import com.sun.tools.javac.tree.JCTree; |
34 | |
import com.sun.tools.javac.tree.JCTree.*; |
35 | |
import com.sun.tools.javac.tree.Pretty; |
36 | |
import com.sun.tools.javac.tree.TreeMaker; |
37 | |
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
38 | |
import com.sun.tools.javac.util.List; |
39 | |
import com.sun.tools.javac.util.ListBuffer; |
40 | |
import com.sun.tools.javac.util.Log; |
41 | |
import com.sun.tools.javac.util.Name; |
42 | |
import com.sun.tools.javafx.code.JavafxSymtab; |
43 | |
import com.sun.tools.javafx.code.JavafxTypes; |
44 | |
import com.sun.tools.javafx.comp.JavafxTypeMorpher.TypeMorphInfo; |
45 | |
import com.sun.tools.javafx.comp.JavafxTypeMorpher.VarMorphInfo; |
46 | |
import com.sun.tools.javafx.tree.*; |
47 | |
import com.sun.tools.javac.util.Context; |
48 | |
|
49 | |
import java.io.OutputStreamWriter; |
50 | |
import static com.sun.tools.javafx.comp.JavafxDefs.*; |
51 | |
import static com.sun.tools.javafx.code.JavafxVarSymbol.*; |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
public abstract class JavafxTranslationSupport extends JCTree.Visitor { |
60 | |
protected final JavafxDefs defs; |
61 | |
protected final Log log; |
62 | |
protected final JavafxTreeMaker fxmake; |
63 | |
protected final TreeMaker make; |
64 | |
protected final Name.Table names; |
65 | |
protected final JavafxResolve rs; |
66 | |
protected final JavafxSymtab syms; |
67 | |
protected final JavafxTypes types; |
68 | |
protected final JavafxTypeMorpher typeMorpher; |
69 | |
|
70 | |
private static final String privateAnnotationStr = "com.sun.javafx.runtime.Private"; |
71 | |
private static final String protectedAnnotationStr = "com.sun.javafx.runtime.Protected"; |
72 | |
private static final String publicAnnotationStr = "com.sun.javafx.runtime.Public"; |
73 | |
private static final String staticAnnotationStr = "com.sun.javafx.runtime.Static"; |
74 | |
|
75 | |
protected static final String sequencesEmptyString = "com.sun.javafx.runtime.sequence.Sequences.emptySequence"; |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | 1197 | private int syntheticNameCounter = 0; |
81 | |
|
82 | 1197 | protected JavafxTranslationSupport(Context context) { |
83 | 1197 | make = fxmake = JavafxTreeMaker.instance(context); |
84 | 1197 | log = Log.instance(context); |
85 | 1197 | names = Name.Table.instance(context); |
86 | 1197 | types = JavafxTypes.instance(context); |
87 | 1197 | syms = (JavafxSymtab)JavafxSymtab.instance(context); |
88 | 1197 | typeMorpher = JavafxTypeMorpher.instance(context); |
89 | 1197 | rs = JavafxResolve.instance(context); |
90 | 1197 | defs = JavafxDefs.instance(context); |
91 | |
|
92 | 1197 | syntheticNameCounter = 0; |
93 | 1197 | } |
94 | |
|
95 | |
protected Symbol expressionSymbol(JCExpression tree) { |
96 | 7139 | switch (tree.getTag()) { |
97 | |
case JavafxTag.IDENT: |
98 | 2925 | return ((JCIdent) tree).sym; |
99 | |
case JavafxTag.SELECT: |
100 | 4076 | return ((JCFieldAccess) tree).sym; |
101 | |
default: |
102 | 138 | return null; |
103 | |
} |
104 | |
} |
105 | |
|
106 | |
protected Type elementType(Type seqType) { |
107 | 2137 | Type elemType = seqType.getTypeArguments().head; |
108 | 2137 | if (elemType instanceof CapturedType) |
109 | 218 | elemType = ((CapturedType) elemType).wildcard; |
110 | 2137 | if (elemType instanceof WildcardType) |
111 | 1884 | elemType = ((WildcardType) elemType).type; |
112 | 2137 | return elemType; |
113 | |
} |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
protected Name interfaceName(JFXClassDeclaration cDecl) { |
119 | 5171 | Name name = cDecl.getName(); |
120 | 5171 | if (cDecl.generateClassOnly()) |
121 | 400 | return name; |
122 | 4771 | return names.fromString(name.toString() + interfaceSuffix); |
123 | |
} |
124 | |
|
125 | |
protected JCExpression makeIdentifier(DiagnosticPosition diagPos, Name aName) { |
126 | 2092 | return fxmake.at(diagPos).Identifier(aName); |
127 | |
} |
128 | |
|
129 | |
protected JCExpression makeIdentifier(DiagnosticPosition diagPos, String str) { |
130 | 4402 | return fxmake.at(diagPos).Identifier(str); |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
protected JCExpression makeLaziness(DiagnosticPosition diagPos) { |
139 | 227 | return make.at(diagPos).Literal(TypeTags.BOOLEAN, 0); |
140 | |
} |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
protected JCExpression makeNull(DiagnosticPosition diagPos) { |
147 | 5 | return make.at(diagPos).Literal(TypeTags.BOT, null); |
148 | |
} |
149 | |
|
150 | |
protected JCExpression makeQualifiedTree(DiagnosticPosition diagPos, String str) { |
151 | 29513 | JCExpression tree = null; |
152 | |
int inx; |
153 | 29513 | int lastInx = 0; |
154 | |
do { |
155 | 113687 | inx = str.indexOf('.', lastInx); |
156 | |
int endInx; |
157 | 113687 | if (inx < 0) { |
158 | 29513 | endInx = str.length(); |
159 | |
} else { |
160 | 84174 | endInx = inx; |
161 | |
} |
162 | 113687 | String part = str.substring(lastInx, endInx); |
163 | 113687 | Name partName = Name.fromString(names, part); |
164 | 113687 | tree = tree == null? |
165 | |
make.at(diagPos).Ident(partName) : |
166 | |
make.at(diagPos).Select(tree, partName); |
167 | 113687 | lastInx = endInx + 1; |
168 | 113687 | } while (inx >= 0); |
169 | 29513 | return tree; |
170 | |
} |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
protected JCExpression makeTypeTree(DiagnosticPosition diagPos, Type t) { |
177 | 14180 | return makeTypeTree(diagPos, t, true); |
178 | |
} |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
protected JCExpression makeTypeTree(DiagnosticPosition diagPos, Type t, boolean makeIntf) { |
185 | 34297 | while (t instanceof CapturedType) |
186 | 11 | t = ((CapturedType) t).wildcard; |
187 | 34286 | switch (t.tag) { |
188 | |
case TypeTags.CLASS: { |
189 | 25546 | JCExpression texp = null; |
190 | |
|
191 | 25546 | if (makeIntf && types.isCompoundClass(t.tsym)) { |
192 | 3332 | texp = makeQualifiedTree(diagPos, t.tsym.getQualifiedName().toString() + interfaceSuffix); |
193 | |
} else { |
194 | 22214 | if (t.isCompound()) { |
195 | 15 | t = syms.objectType; |
196 | |
} |
197 | 22214 | texp = makeQualifiedTree(diagPos, t.tsym.getQualifiedName().toString()); |
198 | |
} |
199 | |
|
200 | |
|
201 | 25546 | if (!t.getTypeArguments().isEmpty()) { |
202 | 3533 | List<JCExpression> targs = List.nil(); |
203 | 3533 | for (Type ta : t.getTypeArguments()) { |
204 | 3958 | targs = targs.append(makeTypeTree(diagPos, ta, makeIntf)); |
205 | |
} |
206 | 3533 | texp = make.at(diagPos).TypeApply(texp, targs); |
207 | |
} |
208 | 25546 | return texp; |
209 | |
} |
210 | |
case TypeTags.BOT: { |
211 | 11 | return makeQualifiedTree(diagPos, syms.objectType.tsym.getQualifiedName().toString()); |
212 | |
} |
213 | |
case TypeTags.WILDCARD: { |
214 | 1288 | WildcardType wtype = (WildcardType) t; |
215 | 1288 | return make.at(diagPos).Wildcard(make.TypeBoundKind(wtype.kind), |
216 | |
wtype.kind == BoundKind.UNBOUND ? null |
217 | |
: makeTypeTree(diagPos,wtype.type, makeIntf)); |
218 | |
} |
219 | |
case TypeTags.ARRAY: { |
220 | 154 | return make.at(diagPos).TypeArray(makeTypeTree(diagPos,types.elemtype(t), makeIntf)); |
221 | |
} |
222 | |
default: { |
223 | 7287 | return make.at(diagPos).Type(t); |
224 | |
} |
225 | |
} |
226 | |
} |
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
public JCExpression makeReturnTypeTree(DiagnosticPosition diagPos, MethodSymbol mth, boolean isBound) { |
233 | 2389 | Type returnType = mth.getReturnType(); |
234 | 2389 | if (isBound) { |
235 | 57 | VarMorphInfo vmi = typeMorpher.varMorphInfo(mth); |
236 | 57 | returnType = vmi.getLocationType(); |
237 | |
} |
238 | 2389 | return makeTypeTree(diagPos, returnType); |
239 | |
} |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
JCVariableDecl makeReceiverParam(JFXClassDeclaration cDecl) { |
246 | 3305 | return make.VarDef( |
247 | |
make.Modifiers(Flags.FINAL | Flags.PARAMETER), |
248 | |
defs.receiverName, |
249 | |
make.Ident(interfaceName(cDecl)), |
250 | |
null); |
251 | |
} |
252 | |
|
253 | |
JCExpression makeDefaultValue(DiagnosticPosition diagPos, TypeMorphInfo tmi) { |
254 | 1860 | return tmi.getTypeKind() == TYPE_KIND_SEQUENCE ? |
255 | |
makeEmptySequenceCreator(diagPos, tmi.getElementType()) : |
256 | |
tmi.getRealType() == syms.javafx_StringType ? |
257 | |
make.Literal("") : |
258 | |
makeLit(diagPos, tmi.getRealType(), tmi.getDefaultValue()); |
259 | |
} |
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
JCExpression makeLit(DiagnosticPosition diagPos, Type type, Object value) { |
267 | 1461 | int tag = value==null? TypeTags.BOT : type.tag; |
268 | 1461 | return make.at(diagPos).Literal(tag, value).setType(type.constType(value)); |
269 | |
} |
270 | |
|
271 | |
JCExpression makeLocationLocalVariable(TypeMorphInfo tmi, |
272 | |
DiagnosticPosition diagPos, |
273 | |
List<JCExpression> makeArgs) { |
274 | 358 | return makeLocationVariable(tmi, diagPos, makeArgs, defs.makeMethodName); |
275 | |
} |
276 | |
|
277 | |
JCExpression makeLocationAttributeVariable(TypeMorphInfo tmi, |
278 | |
DiagnosticPosition diagPos) { |
279 | 1572 | return makeLocationVariable(tmi, diagPos, List.<JCExpression>nil(), defs.makeMethodName); |
280 | |
} |
281 | |
|
282 | |
JCExpression makeLocationVariable(TypeMorphInfo tmi, |
283 | |
DiagnosticPosition diagPos, |
284 | |
List<JCExpression> makeArgs, |
285 | |
Name makeMethod) { |
286 | 1930 | if (tmi.getTypeKind() == TYPE_KIND_SEQUENCE) { |
287 | 456 | makeArgs = makeArgs.prepend( makeElementClassObject(diagPos, tmi.getElementType()) ); |
288 | |
} |
289 | 1930 | Name locName = typeMorpher.variableNCT[tmi.getTypeKind()].name; |
290 | 1930 | JCExpression locationTypeExp = makeIdentifier(diagPos, locName); |
291 | 1930 | JCFieldAccess makeSelect = make.at(diagPos).Select(locationTypeExp, makeMethod); |
292 | 1930 | List<JCExpression> typeArgs = null; |
293 | 1930 | if (tmi.getTypeKind() == TYPE_KIND_OBJECT) { |
294 | 767 | typeArgs = List.of(makeTypeTree( diagPos,tmi.getRealType(), true)); |
295 | |
} |
296 | 1163 | else if (tmi.getTypeKind() == TYPE_KIND_SEQUENCE) { |
297 | 456 | typeArgs = List.of(makeTypeTree( diagPos,tmi.getElementType(), true)); |
298 | |
} |
299 | 1930 | return make.at(diagPos).Apply(typeArgs, makeSelect, makeArgs); |
300 | |
} |
301 | |
|
302 | |
JCExpression makeConstantLocation(DiagnosticPosition diagPos, Type type, JCExpression expr) { |
303 | 211 | TypeMorphInfo tmi = typeMorpher.typeMorphInfo(type); |
304 | 211 | List<JCExpression> makeArgs = List.of(expr); |
305 | 211 | JCExpression locationTypeExp = makeTypeTree( diagPos,tmi.getConstantLocationType(), true); |
306 | 211 | JCFieldAccess makeSelect = make.at(diagPos).Select(locationTypeExp, defs.makeMethodName); |
307 | 211 | List<JCExpression> typeArgs = null; |
308 | 211 | if (tmi.getTypeKind() == TYPE_KIND_OBJECT || tmi.getTypeKind() == TYPE_KIND_SEQUENCE) { |
309 | 42 | typeArgs = List.of(makeTypeTree( diagPos,tmi.getElementType(), true)); |
310 | |
} |
311 | 211 | return make.at(diagPos).Apply(typeArgs, makeSelect, makeArgs); |
312 | |
} |
313 | |
|
314 | |
JCExpression makeUnboundLocation(DiagnosticPosition diagPos, TypeMorphInfo tmi, JCExpression expr) { |
315 | 205 | List<JCExpression> makeArgs = List.of(expr); |
316 | 205 | return makeLocationLocalVariable(tmi, diagPos, makeArgs); |
317 | |
} |
318 | |
|
319 | |
protected JCExpression makeUnboundLocation(DiagnosticPosition diagPos, Type type, JCExpression expr) { |
320 | 3 | return makeUnboundLocation(diagPos, typeMorpher.typeMorphInfo(type), expr); |
321 | |
} |
322 | |
|
323 | |
protected JCExpression runtime(DiagnosticPosition diagPos, String cString, String methString) { |
324 | 0 | return runtime(diagPos, cString, methString, null, List.<JCExpression>nil()); |
325 | |
} |
326 | |
|
327 | |
protected JCExpression runtime(DiagnosticPosition diagPos, String cString, String methString, List<JCExpression> args) { |
328 | 237 | return runtime(diagPos, cString, methString, null, args); |
329 | |
} |
330 | |
|
331 | |
protected JCExpression runtime(DiagnosticPosition diagPos, String cString, String methString, List<JCExpression> typeArgs, List<JCExpression> args) { |
332 | 274 | JCExpression meth = make.at(diagPos).Select(makeQualifiedTree(diagPos, cString), names.fromString(methString)); |
333 | 274 | return make.at(diagPos).Apply(typeArgs, meth, args); |
334 | |
} |
335 | |
|
336 | |
protected JCExpression runtime(DiagnosticPosition diagPos, String cString, String methString, ListBuffer<JCExpression> args) { |
337 | 26 | return runtime(diagPos, cString, methString, null, args.toList()); |
338 | |
} |
339 | |
|
340 | |
JCMethodInvocation callExpression(DiagnosticPosition diagPos, JCExpression receiver, Name methodName) { |
341 | 1081 | return callExpression(diagPos, receiver, methodName, null); |
342 | |
} |
343 | |
|
344 | |
JCMethodInvocation callExpression(DiagnosticPosition diagPos, JCExpression receiver, Name methodName, Object args) { |
345 | 10699 | JCExpression expr = null; |
346 | 10699 | if (receiver == null) { |
347 | 1629 | expr = make.at(diagPos).Ident(methodName); |
348 | |
} else { |
349 | 9070 | expr = make.at(diagPos).Select(receiver, methodName); |
350 | |
} |
351 | 10699 | return make.at(diagPos).Apply(List.<JCExpression>nil(), expr, (args == null) ? List.<JCExpression>nil() : (args instanceof List) ? (List<JCExpression>) args : (args instanceof ListBuffer) ? ((ListBuffer<JCExpression>) args).toList() : (args instanceof JCExpression) ? List.<JCExpression>of((JCExpression) args) : null); |
352 | |
} |
353 | |
|
354 | |
JCMethodInvocation callExpression(DiagnosticPosition diagPos, JCExpression receiver, String method) { |
355 | 1375 | return callExpression(diagPos, receiver, method, null); |
356 | |
} |
357 | |
|
358 | |
JCMethodInvocation callExpression(DiagnosticPosition diagPos, JCExpression receiver, String method, Object args) { |
359 | 2584 | return callExpression(diagPos, receiver, names.fromString(method), args); |
360 | |
} |
361 | |
|
362 | |
JCStatement callStatement(DiagnosticPosition diagPos, JCExpression receiver, Name methodName) { |
363 | 656 | return callStatement(diagPos, receiver, methodName, null); |
364 | |
} |
365 | |
|
366 | |
JCStatement callStatement(DiagnosticPosition diagPos, JCExpression receiver, Name methodName, Object args) { |
367 | 4307 | return make.at(diagPos).Exec(callExpression(diagPos, receiver, methodName, args)); |
368 | |
} |
369 | |
|
370 | |
JCStatement callStatement(DiagnosticPosition diagPos, JCExpression receiver, String method) { |
371 | 25 | return callStatement(diagPos, receiver, method, null); |
372 | |
} |
373 | |
|
374 | |
JCStatement callStatement(DiagnosticPosition diagPos, JCExpression receiver, String method, Object args) { |
375 | 922 | return make.at(diagPos).Exec(callExpression(diagPos, receiver, method, args)); |
376 | |
} |
377 | |
|
378 | |
Name functionInterfaceName(MethodSymbol sym, boolean isBound) { |
379 | 0 | return functionName(sym, isBound); |
380 | |
} |
381 | |
|
382 | |
Name functionName(MethodSymbol sym) { |
383 | 785 | return functionName(sym, false); |
384 | |
} |
385 | |
|
386 | |
Name functionName(MethodSymbol sym, String full, boolean markAsImpl, boolean isBound) { |
387 | 1308 | if (markAsImpl) { |
388 | 1211 | full = full + JavafxDefs.implFunctionSuffix; |
389 | |
} |
390 | 1308 | if (isBound) { |
391 | 140 | full = full + JavafxDefs.boundFunctionDollarSuffix + getParameterTypeSuffix(sym); |
392 | |
} |
393 | 1308 | return names.fromString(full); |
394 | |
} |
395 | |
|
396 | |
Name functionName(MethodSymbol sym, boolean isBound) { |
397 | 785 | return functionName(sym, false, isBound); |
398 | |
} |
399 | |
|
400 | |
Name functionName(MethodSymbol sym, boolean markAsImpl, boolean isBound) { |
401 | 3983 | if (!markAsImpl && !isBound) { |
402 | 2675 | return sym.name; |
403 | |
} |
404 | 1308 | return functionName(sym, sym.name.toString(), markAsImpl, isBound); |
405 | |
} |
406 | |
|
407 | |
private String getParameterTypeSuffix(MethodSymbol sym) { |
408 | 140 | StringBuilder sb = new StringBuilder(); |
409 | 140 | if (sym != null && sym.type != null) { |
410 | 140 | Type mtype = sym.type; |
411 | 140 | if (sym.type.tag == TypeTags.FORALL) { |
412 | 2 | mtype = ((ForAll) mtype).asMethodType(); |
413 | |
} |
414 | 140 | if (mtype.tag == TypeTags.METHOD) { |
415 | 140 | List<Type> argtypes = ((MethodType) mtype).getParameterTypes(); |
416 | 140 | int argtypesCount = argtypes.length(); |
417 | 140 | int counter = 0; |
418 | 140 | for (Type argtype : argtypes) { |
419 | 54 | sb.append(escapeTypeName(types.erasure(argtype))); |
420 | 54 | if (counter < argtypesCount - 1) { |
421 | |
|
422 | 1 | sb.append(defs.escapeTypeChar); |
423 | |
|
424 | 1 | sb.append(defs.escapeTypeChar); |
425 | |
} |
426 | 54 | counter++; |
427 | |
} |
428 | |
} |
429 | |
} |
430 | 140 | return sb.toString(); |
431 | |
} |
432 | |
|
433 | |
JCExpression makeEmptySequenceCreator(DiagnosticPosition diagPos, Type elemType) { |
434 | 193 | JCExpression meth = makeQualifiedTree(diagPos, sequencesEmptyString); |
435 | 193 | ListBuffer<JCExpression> args = ListBuffer.lb(); |
436 | 193 | args.append(makeElementClassObject(diagPos, elemType)); |
437 | 193 | List<JCExpression> typeArgs = List.of(makeTypeTree(diagPos, elemType, true)); |
438 | 193 | return make.at(diagPos).Apply(typeArgs, meth, args.toList()); |
439 | |
} |
440 | |
|
441 | |
private String escapeTypeName(Type type) { |
442 | 54 | return type.toString().replace(defs.typeCharToEscape, defs.escapeTypeChar); |
443 | |
} |
444 | |
|
445 | |
|
446 | |
|
447 | |
|
448 | |
|
449 | |
|
450 | |
|
451 | |
JCExpression makeElementClassObject(DiagnosticPosition diagPos, Type elemType) { |
452 | 1425 | return make.at(diagPos).Select(makeTypeTree( diagPos,syms.boxIfNeeded(elemType), true), names._class); |
453 | |
} |
454 | |
|
455 | |
protected abstract String getSyntheticPrefix(); |
456 | |
|
457 | |
Name getSyntheticName(String kind) { |
458 | 1300 | return Name.fromString(names, getSyntheticPrefix() + syntheticNameCounter++ + kind); |
459 | |
} |
460 | |
|
461 | |
public Name indexVarName(JFXForExpressionInClause clause) { |
462 | 75 | Name forVar = clause.getVar().getName(); |
463 | 75 | return names.fromString("$indexof$" + forVar.toString()); |
464 | |
} |
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
JCExpression makeAttributeAccess(DiagnosticPosition diagPos, String attribName) { |
471 | 119 | return callExpression(diagPos, |
472 | |
make.Ident(defs.receiverName), |
473 | |
attributeGetMethodNamePrefix + attribName); |
474 | |
} |
475 | |
|
476 | |
JFXBlockExpression makeBlockExpression(DiagnosticPosition diagPos, ListBuffer<JCStatement> stmts, JCExpression value) { |
477 | 1040 | return ((JavafxTreeMaker) make).at(diagPos).BlockExpression(0, stmts.toList(), value); |
478 | |
} |
479 | |
|
480 | |
JCVariableDecl makeTmpVar(DiagnosticPosition diagPos, String rootName, Type type, JCExpression value) { |
481 | 633 | return make.at(diagPos).VarDef(make.at(diagPos).Modifiers(Flags.FINAL), getSyntheticName(rootName), makeTypeTree(diagPos, type), value); |
482 | |
} |
483 | |
|
484 | |
JCVariableDecl makeTmpVar(DiagnosticPosition diagPos, Type type, JCExpression value) { |
485 | 10 | return makeTmpVar(diagPos, "tmp", type, value); |
486 | |
} |
487 | |
|
488 | |
protected JCModifiers addAccessAnnotationModifiers(DiagnosticPosition diagPos, long flags, JCModifiers mods) { |
489 | 4437 | make.at(diagPos); |
490 | 4437 | JCModifiers ret = mods; |
491 | 4437 | ListBuffer<JCAnnotation> annotations = ListBuffer.lb(); |
492 | 4437 | if ((flags & Flags.PUBLIC) != 0) { |
493 | 1919 | annotations.append(make.Annotation(makeIdentifier(diagPos, publicAnnotationStr), List.<JCExpression>nil())); |
494 | |
} |
495 | 2518 | else if ((flags & Flags.PRIVATE) != 0) { |
496 | 46 | annotations.append(make.Annotation(makeIdentifier(diagPos, privateAnnotationStr), List.<JCExpression>nil())); |
497 | |
} |
498 | 2472 | else if ((flags & Flags.PROTECTED) != 0) { |
499 | 18 | annotations.append(make.Annotation(makeIdentifier(diagPos, protectedAnnotationStr), List.<JCExpression>nil())); |
500 | |
} |
501 | |
|
502 | 4437 | if ((flags & Flags.STATIC) != 0) { |
503 | 711 | annotations.append(make.Annotation(makeIdentifier(diagPos, staticAnnotationStr), List.<JCExpression>nil())); |
504 | |
} |
505 | |
|
506 | 4437 | if (annotations.nonEmpty()) { |
507 | 2274 | ret = make.Modifiers(mods.flags, annotations.toList()); |
508 | |
} |
509 | 4437 | return ret; |
510 | |
} |
511 | |
|
512 | |
protected void pretty(JCTree tree) { |
513 | 0 | OutputStreamWriter osw = new OutputStreamWriter(System.out); |
514 | 0 | Pretty pretty = new Pretty(osw, false); |
515 | |
try { |
516 | 0 | pretty.println(); |
517 | 0 | pretty.print("+++++++++++++++++++++++++++++++++"); |
518 | 0 | pretty.println(); |
519 | 0 | pretty.printExpr(tree); |
520 | 0 | pretty.println(); |
521 | 0 | pretty.print("---------------------------------"); |
522 | 0 | pretty.println(); |
523 | 0 | osw.flush(); |
524 | 0 | }catch(Exception ex) { |
525 | 0 | System.err.println("Pretty print got: " + ex); |
526 | 0 | } |
527 | 0 | } |
528 | |
|
529 | |
protected void fxPretty(JCTree tree) { |
530 | 0 | OutputStreamWriter osw = new OutputStreamWriter(System.out); |
531 | 0 | Pretty pretty = new JavafxPretty(osw, false); |
532 | |
try { |
533 | 0 | pretty.println(); |
534 | 0 | pretty.print("+++++++++++++++++++++++++++++++++"); |
535 | 0 | pretty.println(); |
536 | 0 | pretty.printExpr(tree); |
537 | 0 | pretty.println(); |
538 | 0 | pretty.print("---------------------------------"); |
539 | 0 | pretty.println(); |
540 | 0 | osw.flush(); |
541 | 0 | }catch(Exception ex) { |
542 | 0 | System.err.println("Pretty print got: " + ex); |
543 | 0 | } |
544 | 0 | } |
545 | |
} |