Thu, 09 Oct 2008 16:07:38 +0100
6406133: JCDiagnostic.getMessage ignores locale argument
Summary: Compiler API should take into account locale settings
Reviewed-by: jjg
duke@1 | 1 | /* |
xdono@117 | 2 | * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.javac.tree; |
duke@1 | 27 | |
duke@1 | 28 | import com.sun.tools.javac.code.*; |
duke@1 | 29 | import com.sun.tools.javac.code.Symbol.*; |
duke@1 | 30 | import com.sun.tools.javac.code.Type.*; |
duke@1 | 31 | import com.sun.tools.javac.util.*; |
duke@1 | 32 | import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
duke@1 | 33 | |
duke@1 | 34 | import com.sun.tools.javac.tree.JCTree.*; |
duke@1 | 35 | |
duke@1 | 36 | import static com.sun.tools.javac.code.Flags.*; |
duke@1 | 37 | import static com.sun.tools.javac.code.Kinds.*; |
duke@1 | 38 | import static com.sun.tools.javac.code.TypeTags.*; |
duke@1 | 39 | |
duke@1 | 40 | /** Factory class for trees. |
duke@1 | 41 | * |
duke@1 | 42 | * <p><b>This is NOT part of any API supported by Sun Microsystems. If |
duke@1 | 43 | * you write code that depends on this, you do so at your own risk. |
duke@1 | 44 | * This code and its internal interfaces are subject to change or |
duke@1 | 45 | * deletion without notice.</b> |
duke@1 | 46 | */ |
duke@1 | 47 | public class TreeMaker implements JCTree.Factory { |
duke@1 | 48 | |
duke@1 | 49 | /** The context key for the tree factory. */ |
duke@1 | 50 | protected static final Context.Key<TreeMaker> treeMakerKey = |
duke@1 | 51 | new Context.Key<TreeMaker>(); |
duke@1 | 52 | |
duke@1 | 53 | /** Get the TreeMaker instance. */ |
duke@1 | 54 | public static TreeMaker instance(Context context) { |
duke@1 | 55 | TreeMaker instance = context.get(treeMakerKey); |
duke@1 | 56 | if (instance == null) |
duke@1 | 57 | instance = new TreeMaker(context); |
duke@1 | 58 | return instance; |
duke@1 | 59 | } |
duke@1 | 60 | |
duke@1 | 61 | /** The position at which subsequent trees will be created. |
duke@1 | 62 | */ |
duke@1 | 63 | public int pos = Position.NOPOS; |
duke@1 | 64 | |
duke@1 | 65 | /** The toplevel tree to which created trees belong. |
duke@1 | 66 | */ |
duke@1 | 67 | public JCCompilationUnit toplevel; |
duke@1 | 68 | |
duke@1 | 69 | /** The current name table. */ |
jjg@113 | 70 | Names names; |
duke@1 | 71 | |
duke@1 | 72 | Types types; |
duke@1 | 73 | |
duke@1 | 74 | /** The current symbol table. */ |
duke@1 | 75 | Symtab syms; |
duke@1 | 76 | |
duke@1 | 77 | /** Create a tree maker with null toplevel and NOPOS as initial position. |
duke@1 | 78 | */ |
duke@1 | 79 | protected TreeMaker(Context context) { |
duke@1 | 80 | context.put(treeMakerKey, this); |
duke@1 | 81 | this.pos = Position.NOPOS; |
duke@1 | 82 | this.toplevel = null; |
jjg@113 | 83 | this.names = Names.instance(context); |
duke@1 | 84 | this.syms = Symtab.instance(context); |
duke@1 | 85 | this.types = Types.instance(context); |
duke@1 | 86 | } |
duke@1 | 87 | |
duke@1 | 88 | /** Create a tree maker with a given toplevel and FIRSTPOS as initial position. |
duke@1 | 89 | */ |
jjg@113 | 90 | TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) { |
duke@1 | 91 | this.pos = Position.FIRSTPOS; |
duke@1 | 92 | this.toplevel = toplevel; |
duke@1 | 93 | this.names = names; |
duke@1 | 94 | this.types = types; |
duke@1 | 95 | this.syms = syms; |
duke@1 | 96 | } |
duke@1 | 97 | |
duke@1 | 98 | /** Create a new tree maker for a given toplevel. |
duke@1 | 99 | */ |
duke@1 | 100 | public TreeMaker forToplevel(JCCompilationUnit toplevel) { |
duke@1 | 101 | return new TreeMaker(toplevel, names, types, syms); |
duke@1 | 102 | } |
duke@1 | 103 | |
duke@1 | 104 | /** Reassign current position. |
duke@1 | 105 | */ |
duke@1 | 106 | public TreeMaker at(int pos) { |
duke@1 | 107 | this.pos = pos; |
duke@1 | 108 | return this; |
duke@1 | 109 | } |
duke@1 | 110 | |
duke@1 | 111 | /** Reassign current position. |
duke@1 | 112 | */ |
duke@1 | 113 | public TreeMaker at(DiagnosticPosition pos) { |
duke@1 | 114 | this.pos = (pos == null ? Position.NOPOS : pos.getStartPosition()); |
duke@1 | 115 | return this; |
duke@1 | 116 | } |
duke@1 | 117 | |
duke@1 | 118 | /** |
duke@1 | 119 | * Create given tree node at current position. |
duke@1 | 120 | * @param defs a list of ClassDef, Import, and Skip |
duke@1 | 121 | */ |
duke@1 | 122 | public JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations, |
duke@1 | 123 | JCExpression pid, |
duke@1 | 124 | List<JCTree> defs) { |
duke@1 | 125 | assert packageAnnotations != null; |
duke@1 | 126 | for (JCTree node : defs) |
duke@1 | 127 | assert node instanceof JCClassDecl |
duke@1 | 128 | || node instanceof JCImport |
duke@1 | 129 | || node instanceof JCSkip |
duke@1 | 130 | || node instanceof JCErroneous |
duke@1 | 131 | || (node instanceof JCExpressionStatement |
duke@1 | 132 | && ((JCExpressionStatement)node).expr instanceof JCErroneous) |
duke@1 | 133 | : node.getClass().getSimpleName(); |
duke@1 | 134 | JCCompilationUnit tree = new JCCompilationUnit(packageAnnotations, pid, defs, |
duke@1 | 135 | null, null, null, null); |
duke@1 | 136 | tree.pos = pos; |
duke@1 | 137 | return tree; |
duke@1 | 138 | } |
duke@1 | 139 | |
duke@1 | 140 | public JCImport Import(JCTree qualid, boolean importStatic) { |
duke@1 | 141 | JCImport tree = new JCImport(qualid, importStatic); |
duke@1 | 142 | tree.pos = pos; |
duke@1 | 143 | return tree; |
duke@1 | 144 | } |
duke@1 | 145 | |
duke@1 | 146 | public JCClassDecl ClassDef(JCModifiers mods, |
duke@1 | 147 | Name name, |
duke@1 | 148 | List<JCTypeParameter> typarams, |
duke@1 | 149 | JCTree extending, |
duke@1 | 150 | List<JCExpression> implementing, |
duke@1 | 151 | List<JCTree> defs) |
duke@1 | 152 | { |
duke@1 | 153 | JCClassDecl tree = new JCClassDecl(mods, |
duke@1 | 154 | name, |
duke@1 | 155 | typarams, |
duke@1 | 156 | extending, |
duke@1 | 157 | implementing, |
duke@1 | 158 | defs, |
duke@1 | 159 | null); |
duke@1 | 160 | tree.pos = pos; |
duke@1 | 161 | return tree; |
duke@1 | 162 | } |
duke@1 | 163 | |
duke@1 | 164 | public JCMethodDecl MethodDef(JCModifiers mods, |
duke@1 | 165 | Name name, |
duke@1 | 166 | JCExpression restype, |
duke@1 | 167 | List<JCTypeParameter> typarams, |
duke@1 | 168 | List<JCVariableDecl> params, |
duke@1 | 169 | List<JCExpression> thrown, |
duke@1 | 170 | JCBlock body, |
duke@1 | 171 | JCExpression defaultValue) |
duke@1 | 172 | { |
duke@1 | 173 | JCMethodDecl tree = new JCMethodDecl(mods, |
duke@1 | 174 | name, |
duke@1 | 175 | restype, |
duke@1 | 176 | typarams, |
duke@1 | 177 | params, |
duke@1 | 178 | thrown, |
duke@1 | 179 | body, |
duke@1 | 180 | defaultValue, |
duke@1 | 181 | null); |
duke@1 | 182 | tree.pos = pos; |
duke@1 | 183 | return tree; |
duke@1 | 184 | } |
duke@1 | 185 | |
duke@1 | 186 | public JCVariableDecl VarDef(JCModifiers mods, Name name, JCExpression vartype, JCExpression init) { |
duke@1 | 187 | JCVariableDecl tree = new JCVariableDecl(mods, name, vartype, init, null); |
duke@1 | 188 | tree.pos = pos; |
duke@1 | 189 | return tree; |
duke@1 | 190 | } |
duke@1 | 191 | |
duke@1 | 192 | public JCSkip Skip() { |
duke@1 | 193 | JCSkip tree = new JCSkip(); |
duke@1 | 194 | tree.pos = pos; |
duke@1 | 195 | return tree; |
duke@1 | 196 | } |
duke@1 | 197 | |
duke@1 | 198 | public JCBlock Block(long flags, List<JCStatement> stats) { |
duke@1 | 199 | JCBlock tree = new JCBlock(flags, stats); |
duke@1 | 200 | tree.pos = pos; |
duke@1 | 201 | return tree; |
duke@1 | 202 | } |
duke@1 | 203 | |
duke@1 | 204 | public JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond) { |
duke@1 | 205 | JCDoWhileLoop tree = new JCDoWhileLoop(body, cond); |
duke@1 | 206 | tree.pos = pos; |
duke@1 | 207 | return tree; |
duke@1 | 208 | } |
duke@1 | 209 | |
duke@1 | 210 | public JCWhileLoop WhileLoop(JCExpression cond, JCStatement body) { |
duke@1 | 211 | JCWhileLoop tree = new JCWhileLoop(cond, body); |
duke@1 | 212 | tree.pos = pos; |
duke@1 | 213 | return tree; |
duke@1 | 214 | } |
duke@1 | 215 | |
duke@1 | 216 | public JCForLoop ForLoop(List<JCStatement> init, |
duke@1 | 217 | JCExpression cond, |
duke@1 | 218 | List<JCExpressionStatement> step, |
duke@1 | 219 | JCStatement body) |
duke@1 | 220 | { |
duke@1 | 221 | JCForLoop tree = new JCForLoop(init, cond, step, body); |
duke@1 | 222 | tree.pos = pos; |
duke@1 | 223 | return tree; |
duke@1 | 224 | } |
duke@1 | 225 | |
duke@1 | 226 | public JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body) { |
duke@1 | 227 | JCEnhancedForLoop tree = new JCEnhancedForLoop(var, expr, body); |
duke@1 | 228 | tree.pos = pos; |
duke@1 | 229 | return tree; |
duke@1 | 230 | } |
duke@1 | 231 | |
duke@1 | 232 | public JCLabeledStatement Labelled(Name label, JCStatement body) { |
duke@1 | 233 | JCLabeledStatement tree = new JCLabeledStatement(label, body); |
duke@1 | 234 | tree.pos = pos; |
duke@1 | 235 | return tree; |
duke@1 | 236 | } |
duke@1 | 237 | |
duke@1 | 238 | public JCSwitch Switch(JCExpression selector, List<JCCase> cases) { |
duke@1 | 239 | JCSwitch tree = new JCSwitch(selector, cases); |
duke@1 | 240 | tree.pos = pos; |
duke@1 | 241 | return tree; |
duke@1 | 242 | } |
duke@1 | 243 | |
duke@1 | 244 | public JCCase Case(JCExpression pat, List<JCStatement> stats) { |
duke@1 | 245 | JCCase tree = new JCCase(pat, stats); |
duke@1 | 246 | tree.pos = pos; |
duke@1 | 247 | return tree; |
duke@1 | 248 | } |
duke@1 | 249 | |
duke@1 | 250 | public JCSynchronized Synchronized(JCExpression lock, JCBlock body) { |
duke@1 | 251 | JCSynchronized tree = new JCSynchronized(lock, body); |
duke@1 | 252 | tree.pos = pos; |
duke@1 | 253 | return tree; |
duke@1 | 254 | } |
duke@1 | 255 | |
duke@1 | 256 | public JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer) { |
duke@1 | 257 | JCTry tree = new JCTry(body, catchers, finalizer); |
duke@1 | 258 | tree.pos = pos; |
duke@1 | 259 | return tree; |
duke@1 | 260 | } |
duke@1 | 261 | |
duke@1 | 262 | public JCCatch Catch(JCVariableDecl param, JCBlock body) { |
duke@1 | 263 | JCCatch tree = new JCCatch(param, body); |
duke@1 | 264 | tree.pos = pos; |
duke@1 | 265 | return tree; |
duke@1 | 266 | } |
duke@1 | 267 | |
duke@1 | 268 | public JCConditional Conditional(JCExpression cond, |
duke@1 | 269 | JCExpression thenpart, |
duke@1 | 270 | JCExpression elsepart) |
duke@1 | 271 | { |
duke@1 | 272 | JCConditional tree = new JCConditional(cond, thenpart, elsepart); |
duke@1 | 273 | tree.pos = pos; |
duke@1 | 274 | return tree; |
duke@1 | 275 | } |
duke@1 | 276 | |
duke@1 | 277 | public JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart) { |
duke@1 | 278 | JCIf tree = new JCIf(cond, thenpart, elsepart); |
duke@1 | 279 | tree.pos = pos; |
duke@1 | 280 | return tree; |
duke@1 | 281 | } |
duke@1 | 282 | |
duke@1 | 283 | public JCExpressionStatement Exec(JCExpression expr) { |
duke@1 | 284 | JCExpressionStatement tree = new JCExpressionStatement(expr); |
duke@1 | 285 | tree.pos = pos; |
duke@1 | 286 | return tree; |
duke@1 | 287 | } |
duke@1 | 288 | |
duke@1 | 289 | public JCBreak Break(Name label) { |
duke@1 | 290 | JCBreak tree = new JCBreak(label, null); |
duke@1 | 291 | tree.pos = pos; |
duke@1 | 292 | return tree; |
duke@1 | 293 | } |
duke@1 | 294 | |
duke@1 | 295 | public JCContinue Continue(Name label) { |
duke@1 | 296 | JCContinue tree = new JCContinue(label, null); |
duke@1 | 297 | tree.pos = pos; |
duke@1 | 298 | return tree; |
duke@1 | 299 | } |
duke@1 | 300 | |
duke@1 | 301 | public JCReturn Return(JCExpression expr) { |
duke@1 | 302 | JCReturn tree = new JCReturn(expr); |
duke@1 | 303 | tree.pos = pos; |
duke@1 | 304 | return tree; |
duke@1 | 305 | } |
duke@1 | 306 | |
duke@1 | 307 | public JCThrow Throw(JCTree expr) { |
duke@1 | 308 | JCThrow tree = new JCThrow(expr); |
duke@1 | 309 | tree.pos = pos; |
duke@1 | 310 | return tree; |
duke@1 | 311 | } |
duke@1 | 312 | |
duke@1 | 313 | public JCAssert Assert(JCExpression cond, JCExpression detail) { |
duke@1 | 314 | JCAssert tree = new JCAssert(cond, detail); |
duke@1 | 315 | tree.pos = pos; |
duke@1 | 316 | return tree; |
duke@1 | 317 | } |
duke@1 | 318 | |
duke@1 | 319 | public JCMethodInvocation Apply(List<JCExpression> typeargs, |
duke@1 | 320 | JCExpression fn, |
duke@1 | 321 | List<JCExpression> args) |
duke@1 | 322 | { |
duke@1 | 323 | JCMethodInvocation tree = new JCMethodInvocation(typeargs, fn, args); |
duke@1 | 324 | tree.pos = pos; |
duke@1 | 325 | return tree; |
duke@1 | 326 | } |
duke@1 | 327 | |
duke@1 | 328 | public JCNewClass NewClass(JCExpression encl, |
duke@1 | 329 | List<JCExpression> typeargs, |
duke@1 | 330 | JCExpression clazz, |
duke@1 | 331 | List<JCExpression> args, |
duke@1 | 332 | JCClassDecl def) |
duke@1 | 333 | { |
duke@1 | 334 | JCNewClass tree = new JCNewClass(encl, typeargs, clazz, args, def); |
duke@1 | 335 | tree.pos = pos; |
duke@1 | 336 | return tree; |
duke@1 | 337 | } |
duke@1 | 338 | |
duke@1 | 339 | public JCNewArray NewArray(JCExpression elemtype, |
duke@1 | 340 | List<JCExpression> dims, |
duke@1 | 341 | List<JCExpression> elems) |
duke@1 | 342 | { |
duke@1 | 343 | JCNewArray tree = new JCNewArray(elemtype, dims, elems); |
duke@1 | 344 | tree.pos = pos; |
duke@1 | 345 | return tree; |
duke@1 | 346 | } |
duke@1 | 347 | |
duke@1 | 348 | public JCParens Parens(JCExpression expr) { |
duke@1 | 349 | JCParens tree = new JCParens(expr); |
duke@1 | 350 | tree.pos = pos; |
duke@1 | 351 | return tree; |
duke@1 | 352 | } |
duke@1 | 353 | |
duke@1 | 354 | public JCAssign Assign(JCExpression lhs, JCExpression rhs) { |
duke@1 | 355 | JCAssign tree = new JCAssign(lhs, rhs); |
duke@1 | 356 | tree.pos = pos; |
duke@1 | 357 | return tree; |
duke@1 | 358 | } |
duke@1 | 359 | |
duke@1 | 360 | public JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs) { |
duke@1 | 361 | JCAssignOp tree = new JCAssignOp(opcode, lhs, rhs, null); |
duke@1 | 362 | tree.pos = pos; |
duke@1 | 363 | return tree; |
duke@1 | 364 | } |
duke@1 | 365 | |
duke@1 | 366 | public JCUnary Unary(int opcode, JCExpression arg) { |
duke@1 | 367 | JCUnary tree = new JCUnary(opcode, arg); |
duke@1 | 368 | tree.pos = pos; |
duke@1 | 369 | return tree; |
duke@1 | 370 | } |
duke@1 | 371 | |
duke@1 | 372 | public JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs) { |
duke@1 | 373 | JCBinary tree = new JCBinary(opcode, lhs, rhs, null); |
duke@1 | 374 | tree.pos = pos; |
duke@1 | 375 | return tree; |
duke@1 | 376 | } |
duke@1 | 377 | |
duke@1 | 378 | public JCTypeCast TypeCast(JCTree clazz, JCExpression expr) { |
duke@1 | 379 | JCTypeCast tree = new JCTypeCast(clazz, expr); |
duke@1 | 380 | tree.pos = pos; |
duke@1 | 381 | return tree; |
duke@1 | 382 | } |
duke@1 | 383 | |
duke@1 | 384 | public JCInstanceOf TypeTest(JCExpression expr, JCTree clazz) { |
duke@1 | 385 | JCInstanceOf tree = new JCInstanceOf(expr, clazz); |
duke@1 | 386 | tree.pos = pos; |
duke@1 | 387 | return tree; |
duke@1 | 388 | } |
duke@1 | 389 | |
duke@1 | 390 | public JCArrayAccess Indexed(JCExpression indexed, JCExpression index) { |
duke@1 | 391 | JCArrayAccess tree = new JCArrayAccess(indexed, index); |
duke@1 | 392 | tree.pos = pos; |
duke@1 | 393 | return tree; |
duke@1 | 394 | } |
duke@1 | 395 | |
duke@1 | 396 | public JCFieldAccess Select(JCExpression selected, Name selector) { |
duke@1 | 397 | JCFieldAccess tree = new JCFieldAccess(selected, selector, null); |
duke@1 | 398 | tree.pos = pos; |
duke@1 | 399 | return tree; |
duke@1 | 400 | } |
duke@1 | 401 | |
duke@1 | 402 | public JCIdent Ident(Name name) { |
duke@1 | 403 | JCIdent tree = new JCIdent(name, null); |
duke@1 | 404 | tree.pos = pos; |
duke@1 | 405 | return tree; |
duke@1 | 406 | } |
duke@1 | 407 | |
duke@1 | 408 | public JCLiteral Literal(int tag, Object value) { |
duke@1 | 409 | JCLiteral tree = new JCLiteral(tag, value); |
duke@1 | 410 | tree.pos = pos; |
duke@1 | 411 | return tree; |
duke@1 | 412 | } |
duke@1 | 413 | |
duke@1 | 414 | public JCPrimitiveTypeTree TypeIdent(int typetag) { |
duke@1 | 415 | JCPrimitiveTypeTree tree = new JCPrimitiveTypeTree(typetag); |
duke@1 | 416 | tree.pos = pos; |
duke@1 | 417 | return tree; |
duke@1 | 418 | } |
duke@1 | 419 | |
duke@1 | 420 | public JCArrayTypeTree TypeArray(JCExpression elemtype) { |
duke@1 | 421 | JCArrayTypeTree tree = new JCArrayTypeTree(elemtype); |
duke@1 | 422 | tree.pos = pos; |
duke@1 | 423 | return tree; |
duke@1 | 424 | } |
duke@1 | 425 | |
duke@1 | 426 | public JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments) { |
duke@1 | 427 | JCTypeApply tree = new JCTypeApply(clazz, arguments); |
duke@1 | 428 | tree.pos = pos; |
duke@1 | 429 | return tree; |
duke@1 | 430 | } |
duke@1 | 431 | |
duke@1 | 432 | public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds) { |
duke@1 | 433 | JCTypeParameter tree = new JCTypeParameter(name, bounds); |
duke@1 | 434 | tree.pos = pos; |
duke@1 | 435 | return tree; |
duke@1 | 436 | } |
duke@1 | 437 | |
duke@1 | 438 | public JCWildcard Wildcard(TypeBoundKind kind, JCTree type) { |
duke@1 | 439 | JCWildcard tree = new JCWildcard(kind, type); |
duke@1 | 440 | tree.pos = pos; |
duke@1 | 441 | return tree; |
duke@1 | 442 | } |
duke@1 | 443 | |
duke@1 | 444 | public TypeBoundKind TypeBoundKind(BoundKind kind) { |
duke@1 | 445 | TypeBoundKind tree = new TypeBoundKind(kind); |
duke@1 | 446 | tree.pos = pos; |
duke@1 | 447 | return tree; |
duke@1 | 448 | } |
duke@1 | 449 | |
duke@1 | 450 | public JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args) { |
duke@1 | 451 | JCAnnotation tree = new JCAnnotation(annotationType, args); |
duke@1 | 452 | tree.pos = pos; |
duke@1 | 453 | return tree; |
duke@1 | 454 | } |
duke@1 | 455 | |
duke@1 | 456 | public JCModifiers Modifiers(long flags, List<JCAnnotation> annotations) { |
duke@1 | 457 | JCModifiers tree = new JCModifiers(flags, annotations); |
duke@1 | 458 | boolean noFlags = (flags & Flags.StandardFlags) == 0; |
duke@1 | 459 | tree.pos = (noFlags && annotations.isEmpty()) ? Position.NOPOS : pos; |
duke@1 | 460 | return tree; |
duke@1 | 461 | } |
duke@1 | 462 | |
duke@1 | 463 | public JCModifiers Modifiers(long flags) { |
duke@1 | 464 | return Modifiers(flags, List.<JCAnnotation>nil()); |
duke@1 | 465 | } |
duke@1 | 466 | |
duke@1 | 467 | public JCErroneous Erroneous() { |
duke@1 | 468 | return Erroneous(List.<JCTree>nil()); |
duke@1 | 469 | } |
duke@1 | 470 | |
duke@1 | 471 | public JCErroneous Erroneous(List<? extends JCTree> errs) { |
duke@1 | 472 | JCErroneous tree = new JCErroneous(errs); |
duke@1 | 473 | tree.pos = pos; |
duke@1 | 474 | return tree; |
duke@1 | 475 | } |
duke@1 | 476 | |
duke@1 | 477 | public LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr) { |
duke@1 | 478 | LetExpr tree = new LetExpr(defs, expr); |
duke@1 | 479 | tree.pos = pos; |
duke@1 | 480 | return tree; |
duke@1 | 481 | } |
duke@1 | 482 | |
duke@1 | 483 | /* *************************************************************************** |
duke@1 | 484 | * Derived building blocks. |
duke@1 | 485 | ****************************************************************************/ |
duke@1 | 486 | |
duke@1 | 487 | public JCClassDecl AnonymousClassDef(JCModifiers mods, |
duke@1 | 488 | List<JCTree> defs) |
duke@1 | 489 | { |
duke@1 | 490 | return ClassDef(mods, |
duke@1 | 491 | names.empty, |
duke@1 | 492 | List.<JCTypeParameter>nil(), |
duke@1 | 493 | null, |
duke@1 | 494 | List.<JCExpression>nil(), |
duke@1 | 495 | defs); |
duke@1 | 496 | } |
duke@1 | 497 | |
duke@1 | 498 | public LetExpr LetExpr(JCVariableDecl def, JCTree expr) { |
duke@1 | 499 | LetExpr tree = new LetExpr(List.of(def), expr); |
duke@1 | 500 | tree.pos = pos; |
duke@1 | 501 | return tree; |
duke@1 | 502 | } |
duke@1 | 503 | |
duke@1 | 504 | /** Create an identifier from a symbol. |
duke@1 | 505 | */ |
duke@1 | 506 | public JCIdent Ident(Symbol sym) { |
duke@1 | 507 | return (JCIdent)new JCIdent((sym.name != names.empty) |
duke@1 | 508 | ? sym.name |
duke@1 | 509 | : sym.flatName(), sym) |
duke@1 | 510 | .setPos(pos) |
duke@1 | 511 | .setType(sym.type); |
duke@1 | 512 | } |
duke@1 | 513 | |
duke@1 | 514 | /** Create a selection node from a qualifier tree and a symbol. |
duke@1 | 515 | * @param base The qualifier tree. |
duke@1 | 516 | */ |
duke@1 | 517 | public JCExpression Select(JCExpression base, Symbol sym) { |
duke@1 | 518 | return new JCFieldAccess(base, sym.name, sym).setPos(pos).setType(sym.type); |
duke@1 | 519 | } |
duke@1 | 520 | |
duke@1 | 521 | /** Create a qualified identifier from a symbol, adding enough qualifications |
duke@1 | 522 | * to make the reference unique. |
duke@1 | 523 | */ |
duke@1 | 524 | public JCExpression QualIdent(Symbol sym) { |
duke@1 | 525 | return isUnqualifiable(sym) |
duke@1 | 526 | ? Ident(sym) |
duke@1 | 527 | : Select(QualIdent(sym.owner), sym); |
duke@1 | 528 | } |
duke@1 | 529 | |
duke@1 | 530 | /** Create an identifier that refers to the variable declared in given variable |
duke@1 | 531 | * declaration. |
duke@1 | 532 | */ |
duke@1 | 533 | public JCExpression Ident(JCVariableDecl param) { |
duke@1 | 534 | return Ident(param.sym); |
duke@1 | 535 | } |
duke@1 | 536 | |
duke@1 | 537 | /** Create a list of identifiers referring to the variables declared |
duke@1 | 538 | * in given list of variable declarations. |
duke@1 | 539 | */ |
duke@1 | 540 | public List<JCExpression> Idents(List<JCVariableDecl> params) { |
duke@1 | 541 | ListBuffer<JCExpression> ids = new ListBuffer<JCExpression>(); |
duke@1 | 542 | for (List<JCVariableDecl> l = params; l.nonEmpty(); l = l.tail) |
duke@1 | 543 | ids.append(Ident(l.head)); |
duke@1 | 544 | return ids.toList(); |
duke@1 | 545 | } |
duke@1 | 546 | |
duke@1 | 547 | /** Create a tree representing `this', given its type. |
duke@1 | 548 | */ |
duke@1 | 549 | public JCExpression This(Type t) { |
duke@1 | 550 | return Ident(new VarSymbol(FINAL, names._this, t, t.tsym)); |
duke@1 | 551 | } |
duke@1 | 552 | |
duke@1 | 553 | /** Create a tree representing a class literal. |
duke@1 | 554 | */ |
duke@1 | 555 | public JCExpression ClassLiteral(ClassSymbol clazz) { |
duke@1 | 556 | return ClassLiteral(clazz.type); |
duke@1 | 557 | } |
duke@1 | 558 | |
duke@1 | 559 | /** Create a tree representing a class literal. |
duke@1 | 560 | */ |
duke@1 | 561 | public JCExpression ClassLiteral(Type t) { |
duke@1 | 562 | VarSymbol lit = new VarSymbol(STATIC | PUBLIC | FINAL, |
duke@1 | 563 | names._class, |
duke@1 | 564 | t, |
duke@1 | 565 | t.tsym); |
duke@1 | 566 | return Select(Type(t), lit); |
duke@1 | 567 | } |
duke@1 | 568 | |
duke@1 | 569 | /** Create a tree representing `super', given its type and owner. |
duke@1 | 570 | */ |
duke@1 | 571 | public JCIdent Super(Type t, TypeSymbol owner) { |
duke@1 | 572 | return Ident(new VarSymbol(FINAL, names._super, t, owner)); |
duke@1 | 573 | } |
duke@1 | 574 | |
duke@1 | 575 | /** |
duke@1 | 576 | * Create a method invocation from a method tree and a list of |
duke@1 | 577 | * argument trees. |
duke@1 | 578 | */ |
duke@1 | 579 | public JCMethodInvocation App(JCExpression meth, List<JCExpression> args) { |
duke@1 | 580 | return Apply(null, meth, args).setType(meth.type.getReturnType()); |
duke@1 | 581 | } |
duke@1 | 582 | |
duke@1 | 583 | /** |
duke@1 | 584 | * Create a no-arg method invocation from a method tree |
duke@1 | 585 | */ |
duke@1 | 586 | public JCMethodInvocation App(JCExpression meth) { |
duke@1 | 587 | return Apply(null, meth, List.<JCExpression>nil()).setType(meth.type.getReturnType()); |
duke@1 | 588 | } |
duke@1 | 589 | |
duke@1 | 590 | /** Create a method invocation from a method tree and a list of argument trees. |
duke@1 | 591 | */ |
duke@1 | 592 | public JCExpression Create(Symbol ctor, List<JCExpression> args) { |
duke@1 | 593 | Type t = ctor.owner.erasure(types); |
duke@1 | 594 | JCNewClass newclass = NewClass(null, null, Type(t), args, null); |
duke@1 | 595 | newclass.constructor = ctor; |
duke@1 | 596 | newclass.setType(t); |
duke@1 | 597 | return newclass; |
duke@1 | 598 | } |
duke@1 | 599 | |
duke@1 | 600 | /** Create a tree representing given type. |
duke@1 | 601 | */ |
duke@1 | 602 | public JCExpression Type(Type t) { |
duke@1 | 603 | if (t == null) return null; |
duke@1 | 604 | JCExpression tp; |
duke@1 | 605 | switch (t.tag) { |
duke@1 | 606 | case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT: |
duke@1 | 607 | case DOUBLE: case BOOLEAN: case VOID: |
duke@1 | 608 | tp = TypeIdent(t.tag); |
duke@1 | 609 | break; |
duke@1 | 610 | case TYPEVAR: |
duke@1 | 611 | tp = Ident(t.tsym); |
duke@1 | 612 | break; |
duke@1 | 613 | case WILDCARD: { |
duke@1 | 614 | WildcardType a = ((WildcardType) t); |
duke@1 | 615 | tp = Wildcard(TypeBoundKind(a.kind), Type(a.type)); |
duke@1 | 616 | break; |
duke@1 | 617 | } |
duke@1 | 618 | case CLASS: |
duke@1 | 619 | Type outer = t.getEnclosingType(); |
duke@1 | 620 | JCExpression clazz = outer.tag == CLASS && t.tsym.owner.kind == TYP |
duke@1 | 621 | ? Select(Type(outer), t.tsym) |
duke@1 | 622 | : QualIdent(t.tsym); |
duke@1 | 623 | tp = t.getTypeArguments().isEmpty() |
duke@1 | 624 | ? clazz |
duke@1 | 625 | : TypeApply(clazz, Types(t.getTypeArguments())); |
duke@1 | 626 | break; |
duke@1 | 627 | case ARRAY: |
duke@1 | 628 | tp = TypeArray(Type(types.elemtype(t))); |
duke@1 | 629 | break; |
duke@1 | 630 | case ERROR: |
duke@1 | 631 | tp = TypeIdent(ERROR); |
duke@1 | 632 | break; |
duke@1 | 633 | default: |
duke@1 | 634 | throw new AssertionError("unexpected type: " + t); |
duke@1 | 635 | } |
duke@1 | 636 | return tp.setType(t); |
duke@1 | 637 | } |
duke@1 | 638 | //where |
duke@1 | 639 | private JCExpression Selectors(JCExpression base, Symbol sym, Symbol limit) { |
duke@1 | 640 | if (sym == limit) return base; |
duke@1 | 641 | else return Select(Selectors(base, sym.owner, limit), sym); |
duke@1 | 642 | } |
duke@1 | 643 | |
duke@1 | 644 | /** Create a list of trees representing given list of types. |
duke@1 | 645 | */ |
duke@1 | 646 | public List<JCExpression> Types(List<Type> ts) { |
duke@1 | 647 | ListBuffer<JCExpression> types = new ListBuffer<JCExpression>(); |
duke@1 | 648 | for (List<Type> l = ts; l.nonEmpty(); l = l.tail) |
duke@1 | 649 | types.append(Type(l.head)); |
duke@1 | 650 | return types.toList(); |
duke@1 | 651 | } |
duke@1 | 652 | |
duke@1 | 653 | /** Create a variable definition from a variable symbol and an initializer |
duke@1 | 654 | * expression. |
duke@1 | 655 | */ |
duke@1 | 656 | public JCVariableDecl VarDef(VarSymbol v, JCExpression init) { |
duke@1 | 657 | return (JCVariableDecl) |
duke@1 | 658 | new JCVariableDecl( |
duke@1 | 659 | Modifiers(v.flags(), Annotations(v.getAnnotationMirrors())), |
duke@1 | 660 | v.name, |
duke@1 | 661 | Type(v.type), |
duke@1 | 662 | init, |
duke@1 | 663 | v).setPos(pos).setType(v.type); |
duke@1 | 664 | } |
duke@1 | 665 | |
duke@1 | 666 | /** Create annotation trees from annotations. |
duke@1 | 667 | */ |
duke@1 | 668 | public List<JCAnnotation> Annotations(List<Attribute.Compound> attributes) { |
duke@1 | 669 | if (attributes == null) return List.nil(); |
duke@1 | 670 | ListBuffer<JCAnnotation> result = new ListBuffer<JCAnnotation>(); |
duke@1 | 671 | for (List<Attribute.Compound> i = attributes; i.nonEmpty(); i=i.tail) { |
duke@1 | 672 | Attribute a = i.head; |
duke@1 | 673 | result.append(Annotation(a)); |
duke@1 | 674 | } |
duke@1 | 675 | return result.toList(); |
duke@1 | 676 | } |
duke@1 | 677 | |
duke@1 | 678 | public JCLiteral Literal(Object value) { |
duke@1 | 679 | JCLiteral result = null; |
duke@1 | 680 | if (value instanceof String) { |
duke@1 | 681 | result = Literal(CLASS, value). |
duke@1 | 682 | setType(syms.stringType.constType(value)); |
duke@1 | 683 | } else if (value instanceof Integer) { |
duke@1 | 684 | result = Literal(INT, value). |
duke@1 | 685 | setType(syms.intType.constType(value)); |
duke@1 | 686 | } else if (value instanceof Long) { |
duke@1 | 687 | result = Literal(LONG, value). |
duke@1 | 688 | setType(syms.longType.constType(value)); |
duke@1 | 689 | } else if (value instanceof Byte) { |
duke@1 | 690 | result = Literal(BYTE, value). |
duke@1 | 691 | setType(syms.byteType.constType(value)); |
duke@1 | 692 | } else if (value instanceof Character) { |
duke@1 | 693 | result = Literal(CHAR, value). |
duke@1 | 694 | setType(syms.charType.constType(value)); |
duke@1 | 695 | } else if (value instanceof Double) { |
duke@1 | 696 | result = Literal(DOUBLE, value). |
duke@1 | 697 | setType(syms.doubleType.constType(value)); |
duke@1 | 698 | } else if (value instanceof Float) { |
duke@1 | 699 | result = Literal(FLOAT, value). |
duke@1 | 700 | setType(syms.floatType.constType(value)); |
duke@1 | 701 | } else if (value instanceof Short) { |
duke@1 | 702 | result = Literal(SHORT, value). |
duke@1 | 703 | setType(syms.shortType.constType(value)); |
duke@1 | 704 | } else { |
duke@1 | 705 | throw new AssertionError(value); |
duke@1 | 706 | } |
duke@1 | 707 | return result; |
duke@1 | 708 | } |
duke@1 | 709 | |
duke@1 | 710 | class AnnotationBuilder implements Attribute.Visitor { |
duke@1 | 711 | JCExpression result = null; |
duke@1 | 712 | public void visitConstant(Attribute.Constant v) { |
duke@1 | 713 | result = Literal(v.value); |
duke@1 | 714 | } |
duke@1 | 715 | public void visitClass(Attribute.Class clazz) { |
duke@1 | 716 | result = ClassLiteral(clazz.type).setType(syms.classType); |
duke@1 | 717 | } |
duke@1 | 718 | public void visitEnum(Attribute.Enum e) { |
duke@1 | 719 | result = QualIdent(e.value); |
duke@1 | 720 | } |
duke@1 | 721 | public void visitError(Attribute.Error e) { |
duke@1 | 722 | result = Erroneous(); |
duke@1 | 723 | } |
duke@1 | 724 | public void visitCompound(Attribute.Compound compound) { |
duke@1 | 725 | result = visitCompoundInternal(compound); |
duke@1 | 726 | } |
duke@1 | 727 | public JCAnnotation visitCompoundInternal(Attribute.Compound compound) { |
duke@1 | 728 | ListBuffer<JCExpression> args = new ListBuffer<JCExpression>(); |
duke@1 | 729 | for (List<Pair<Symbol.MethodSymbol,Attribute>> values = compound.values; values.nonEmpty(); values=values.tail) { |
duke@1 | 730 | Pair<MethodSymbol,Attribute> pair = values.head; |
duke@1 | 731 | JCExpression valueTree = translate(pair.snd); |
duke@1 | 732 | args.append(Assign(Ident(pair.fst), valueTree).setType(valueTree.type)); |
duke@1 | 733 | } |
duke@1 | 734 | return Annotation(Type(compound.type), args.toList()); |
duke@1 | 735 | } |
duke@1 | 736 | public void visitArray(Attribute.Array array) { |
duke@1 | 737 | ListBuffer<JCExpression> elems = new ListBuffer<JCExpression>(); |
duke@1 | 738 | for (int i = 0; i < array.values.length; i++) |
duke@1 | 739 | elems.append(translate(array.values[i])); |
duke@1 | 740 | result = NewArray(null, List.<JCExpression>nil(), elems.toList()).setType(array.type); |
duke@1 | 741 | } |
duke@1 | 742 | JCExpression translate(Attribute a) { |
duke@1 | 743 | a.accept(this); |
duke@1 | 744 | return result; |
duke@1 | 745 | } |
duke@1 | 746 | JCAnnotation translate(Attribute.Compound a) { |
duke@1 | 747 | return visitCompoundInternal(a); |
duke@1 | 748 | } |
duke@1 | 749 | } |
duke@1 | 750 | AnnotationBuilder annotationBuilder = new AnnotationBuilder(); |
duke@1 | 751 | |
duke@1 | 752 | /** Create an annotation tree from an attribute. |
duke@1 | 753 | */ |
duke@1 | 754 | public JCAnnotation Annotation(Attribute a) { |
duke@1 | 755 | return annotationBuilder.translate((Attribute.Compound)a); |
duke@1 | 756 | } |
duke@1 | 757 | |
duke@1 | 758 | /** Create a method definition from a method symbol and a method body. |
duke@1 | 759 | */ |
duke@1 | 760 | public JCMethodDecl MethodDef(MethodSymbol m, JCBlock body) { |
duke@1 | 761 | return MethodDef(m, m.type, body); |
duke@1 | 762 | } |
duke@1 | 763 | |
duke@1 | 764 | /** Create a method definition from a method symbol, method type |
duke@1 | 765 | * and a method body. |
duke@1 | 766 | */ |
duke@1 | 767 | public JCMethodDecl MethodDef(MethodSymbol m, Type mtype, JCBlock body) { |
duke@1 | 768 | return (JCMethodDecl) |
duke@1 | 769 | new JCMethodDecl( |
duke@1 | 770 | Modifiers(m.flags(), Annotations(m.getAnnotationMirrors())), |
duke@1 | 771 | m.name, |
duke@1 | 772 | Type(mtype.getReturnType()), |
duke@1 | 773 | TypeParams(mtype.getTypeArguments()), |
duke@1 | 774 | Params(mtype.getParameterTypes(), m), |
duke@1 | 775 | Types(mtype.getThrownTypes()), |
duke@1 | 776 | body, |
duke@1 | 777 | null, |
duke@1 | 778 | m).setPos(pos).setType(mtype); |
duke@1 | 779 | } |
duke@1 | 780 | |
duke@1 | 781 | /** Create a type parameter tree from its name and type. |
duke@1 | 782 | */ |
duke@1 | 783 | public JCTypeParameter TypeParam(Name name, TypeVar tvar) { |
duke@1 | 784 | return (JCTypeParameter) |
duke@1 | 785 | TypeParameter(name, Types(types.getBounds(tvar))).setPos(pos).setType(tvar); |
duke@1 | 786 | } |
duke@1 | 787 | |
duke@1 | 788 | /** Create a list of type parameter trees from a list of type variables. |
duke@1 | 789 | */ |
duke@1 | 790 | public List<JCTypeParameter> TypeParams(List<Type> typarams) { |
duke@1 | 791 | ListBuffer<JCTypeParameter> tparams = new ListBuffer<JCTypeParameter>(); |
duke@1 | 792 | int i = 0; |
duke@1 | 793 | for (List<Type> l = typarams; l.nonEmpty(); l = l.tail) |
duke@1 | 794 | tparams.append(TypeParam(l.head.tsym.name, (TypeVar)l.head)); |
duke@1 | 795 | return tparams.toList(); |
duke@1 | 796 | } |
duke@1 | 797 | |
duke@1 | 798 | /** Create a value parameter tree from its name, type, and owner. |
duke@1 | 799 | */ |
duke@1 | 800 | public JCVariableDecl Param(Name name, Type argtype, Symbol owner) { |
duke@1 | 801 | return VarDef(new VarSymbol(0, name, argtype, owner), null); |
duke@1 | 802 | } |
duke@1 | 803 | |
duke@1 | 804 | /** Create a a list of value parameter trees x0, ..., xn from a list of |
duke@1 | 805 | * their types and an their owner. |
duke@1 | 806 | */ |
duke@1 | 807 | public List<JCVariableDecl> Params(List<Type> argtypes, Symbol owner) { |
duke@1 | 808 | ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>(); |
duke@1 | 809 | MethodSymbol mth = (owner.kind == MTH) ? ((MethodSymbol)owner) : null; |
duke@1 | 810 | if (mth != null && mth.params != null && argtypes.length() == mth.params.length()) { |
duke@1 | 811 | for (VarSymbol param : ((MethodSymbol)owner).params) |
duke@1 | 812 | params.append(VarDef(param, null)); |
duke@1 | 813 | } else { |
duke@1 | 814 | int i = 0; |
duke@1 | 815 | for (List<Type> l = argtypes; l.nonEmpty(); l = l.tail) |
duke@1 | 816 | params.append(Param(paramName(i++), l.head, owner)); |
duke@1 | 817 | } |
duke@1 | 818 | return params.toList(); |
duke@1 | 819 | } |
duke@1 | 820 | |
duke@1 | 821 | /** Wrap a method invocation in an expression statement or return statement, |
duke@1 | 822 | * depending on whether the method invocation expression's type is void. |
duke@1 | 823 | */ |
duke@1 | 824 | public JCStatement Call(JCExpression apply) { |
duke@1 | 825 | return apply.type.tag == VOID ? Exec(apply) : Return(apply); |
duke@1 | 826 | } |
duke@1 | 827 | |
duke@1 | 828 | /** Construct an assignment from a variable symbol and a right hand side. |
duke@1 | 829 | */ |
duke@1 | 830 | public JCStatement Assignment(Symbol v, JCExpression rhs) { |
duke@1 | 831 | return Exec(Assign(Ident(v), rhs).setType(v.type)); |
duke@1 | 832 | } |
duke@1 | 833 | |
duke@1 | 834 | /** Construct an index expression from a variable and an expression. |
duke@1 | 835 | */ |
duke@1 | 836 | public JCArrayAccess Indexed(Symbol v, JCExpression index) { |
duke@1 | 837 | JCArrayAccess tree = new JCArrayAccess(QualIdent(v), index); |
duke@1 | 838 | tree.type = ((ArrayType)v.type).elemtype; |
duke@1 | 839 | return tree; |
duke@1 | 840 | } |
duke@1 | 841 | |
duke@1 | 842 | /** Make an attributed type cast expression. |
duke@1 | 843 | */ |
duke@1 | 844 | public JCTypeCast TypeCast(Type type, JCExpression expr) { |
duke@1 | 845 | return (JCTypeCast)TypeCast(Type(type), expr).setType(type); |
duke@1 | 846 | } |
duke@1 | 847 | |
duke@1 | 848 | /* *************************************************************************** |
duke@1 | 849 | * Helper methods. |
duke@1 | 850 | ****************************************************************************/ |
duke@1 | 851 | |
duke@1 | 852 | /** Can given symbol be referred to in unqualified form? |
duke@1 | 853 | */ |
duke@1 | 854 | boolean isUnqualifiable(Symbol sym) { |
duke@1 | 855 | if (sym.name == names.empty || |
duke@1 | 856 | sym.owner == null || |
duke@1 | 857 | sym.owner.kind == MTH || sym.owner.kind == VAR) { |
duke@1 | 858 | return true; |
duke@1 | 859 | } else if (sym.kind == TYP && toplevel != null) { |
duke@1 | 860 | Scope.Entry e; |
duke@1 | 861 | e = toplevel.namedImportScope.lookup(sym.name); |
duke@1 | 862 | if (e.scope != null) { |
duke@1 | 863 | return |
duke@1 | 864 | e.sym == sym && |
duke@1 | 865 | e.next().scope == null; |
duke@1 | 866 | } |
duke@1 | 867 | e = toplevel.packge.members().lookup(sym.name); |
duke@1 | 868 | if (e.scope != null) { |
duke@1 | 869 | return |
duke@1 | 870 | e.sym == sym && |
duke@1 | 871 | e.next().scope == null; |
duke@1 | 872 | } |
duke@1 | 873 | e = toplevel.starImportScope.lookup(sym.name); |
duke@1 | 874 | if (e.scope != null) { |
duke@1 | 875 | return |
duke@1 | 876 | e.sym == sym && |
duke@1 | 877 | e.next().scope == null; |
duke@1 | 878 | } |
duke@1 | 879 | } |
duke@1 | 880 | return false; |
duke@1 | 881 | } |
duke@1 | 882 | |
duke@1 | 883 | /** The name of synthetic parameter number `i'. |
duke@1 | 884 | */ |
duke@1 | 885 | public Name paramName(int i) { return names.fromString("x" + i); } |
duke@1 | 886 | |
duke@1 | 887 | /** The name of synthetic type parameter number `i'. |
duke@1 | 888 | */ |
duke@1 | 889 | public Name typaramName(int i) { return names.fromString("A" + i); } |
duke@1 | 890 | } |