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