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