langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
author vromero
Mon, 27 May 2013 13:44:14 +0100
changeset 17807 36cff8c58cdf
parent 17578 46ac954e4a84
child 20243 21740b37e9aa
permissions -rw-r--r--
7030476: Fix conflicting use of JCTree/JCExpression Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
     2
 * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.source.tree.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.javac.tree.JCTree.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import com.sun.tools.javac.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.javac.util.ListBuffer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 * Creates a copy of a tree, using a given TreeMaker.
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * Names, literal values, etc are shared with the original.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    37
 *  <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
    38
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
public class TreeCopier<P> implements TreeVisitor<JCTree,P> {
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    private TreeMaker M;
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /** Creates a new instance of TreeCopier */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    public TreeCopier(TreeMaker M) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
        this.M = M;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    public <T extends JCTree> T copy(T tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        return copy(tree, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    @SuppressWarnings("unchecked")
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    public <T extends JCTree> T copy(T tree, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
        if (tree == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        return (T) (tree.accept(this, p));
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    public <T extends JCTree> List<T> copy(List<T> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        return copy(trees, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    public <T extends JCTree> List<T> copy(List<T> trees, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
        if (trees == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        ListBuffer<T> lb = new ListBuffer<T>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        for (T tree: trees)
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
            lb.append(copy(tree, p));
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        return lb.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    74
    public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    75
        JCAnnotatedType t = (JCAnnotatedType) node;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    76
        List<JCAnnotation> annotations = copy(t.annotations, p);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    77
        JCExpression underlyingType = copy(t.underlyingType, p);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    78
        return M.at(t.pos).AnnotatedType(annotations, underlyingType);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    79
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    80
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public JCTree visitAnnotation(AnnotationTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        JCAnnotation t = (JCAnnotation) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        JCTree annotationType = copy(t.annotationType, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        List<JCExpression> args = copy(t.args, p);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    85
        if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    86
            JCAnnotation newTA = M.at(t.pos).TypeAnnotation(annotationType, args);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    87
            newTA.attribute = t.attribute;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    88
            return newTA;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    89
        } else {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    90
            JCAnnotation newT = M.at(t.pos).Annotation(annotationType, args);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    91
            newT.attribute = t.attribute;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    92
            return newT;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
    93
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    public JCTree visitAssert(AssertTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        JCAssert t = (JCAssert) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        JCExpression cond = copy(t.cond, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
        JCExpression detail = copy(t.detail, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        return M.at(t.pos).Assert(cond, detail);
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    public JCTree visitAssignment(AssignmentTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        JCAssign t = (JCAssign) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        JCExpression lhs = copy(t.lhs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        JCExpression rhs = copy(t.rhs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        return M.at(t.pos).Assign(lhs, rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    public JCTree visitCompoundAssignment(CompoundAssignmentTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        JCAssignOp t = (JCAssignOp) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        JCTree lhs = copy(t.lhs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        JCTree rhs = copy(t.rhs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        return M.at(t.pos).Assignop(t.getTag(), lhs, rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    public JCTree visitBinary(BinaryTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        JCBinary t = (JCBinary) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        JCExpression lhs = copy(t.lhs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        JCExpression rhs = copy(t.rhs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        return M.at(t.pos).Binary(t.getTag(), lhs, rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    public JCTree visitBlock(BlockTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        JCBlock t = (JCBlock) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        List<JCStatement> stats = copy(t.stats, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        return M.at(t.pos).Block(t.flags, stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    public JCTree visitBreak(BreakTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        JCBreak t = (JCBreak) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        return M.at(t.pos).Break(t.label);
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    public JCTree visitCase(CaseTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        JCCase t = (JCCase) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        JCExpression pat = copy(t.pat, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        List<JCStatement> stats = copy(t.stats, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        return M.at(t.pos).Case(pat, stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
    public JCTree visitCatch(CatchTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        JCCatch t = (JCCatch) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        JCVariableDecl param = copy(t.param, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        JCBlock body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        return M.at(t.pos).Catch(param, body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
    public JCTree visitClass(ClassTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        JCClassDecl t = (JCClassDecl) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        JCModifiers mods = copy(t.mods, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        List<JCTypeParameter> typarams = copy(t.typarams, p);
8625
6b51ef804d49 6639645: Modeling type implementing missing interfaces
jjg
parents: 8031
diff changeset
   153
        JCExpression extending = copy(t.extending, p);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        List<JCExpression> implementing = copy(t.implementing, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        List<JCTree> defs = copy(t.defs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    public JCTree visitConditionalExpression(ConditionalExpressionTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        JCConditional t = (JCConditional) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        JCExpression cond = copy(t.cond, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        JCExpression truepart = copy(t.truepart, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        JCExpression falsepart = copy(t.falsepart, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        return M.at(t.pos).Conditional(cond, truepart, falsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
    public JCTree visitContinue(ContinueTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        JCContinue t = (JCContinue) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
        return M.at(t.pos).Continue(t.label);
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
    public JCTree visitDoWhileLoop(DoWhileLoopTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        JCDoWhileLoop t = (JCDoWhileLoop) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        JCStatement body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        JCExpression cond = copy(t.cond, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
        return M.at(t.pos).DoLoop(body, cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
    public JCTree visitErroneous(ErroneousTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        JCErroneous t = (JCErroneous) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        List<? extends JCTree> errs = copy(t.errs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        return M.at(t.pos).Erroneous(errs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    public JCTree visitExpressionStatement(ExpressionStatementTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        JCExpressionStatement t = (JCExpressionStatement) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        JCExpression expr = copy(t.expr, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        return M.at(t.pos).Exec(expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
    public JCTree visitEnhancedForLoop(EnhancedForLoopTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        JCEnhancedForLoop t = (JCEnhancedForLoop) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        JCVariableDecl var = copy(t.var, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        JCExpression expr = copy(t.expr, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
        JCStatement body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
        return M.at(t.pos).ForeachLoop(var, expr, body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
    public JCTree visitForLoop(ForLoopTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        JCForLoop t = (JCForLoop) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
        List<JCStatement> init = copy(t.init, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        JCExpression cond = copy(t.cond, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        List<JCExpressionStatement> step = copy(t.step, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        JCStatement body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        return M.at(t.pos).ForLoop(init, cond, step, body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
    public JCTree visitIdentifier(IdentifierTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        JCIdent t = (JCIdent) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        return M.at(t.pos).Ident(t.name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    public JCTree visitIf(IfTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        JCIf t = (JCIf) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        JCExpression cond = copy(t.cond, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        JCStatement thenpart = copy(t.thenpart, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        JCStatement elsepart = copy(t.elsepart, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        return M.at(t.pos).If(cond, thenpart, elsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    public JCTree visitImport(ImportTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
        JCImport t = (JCImport) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        JCTree qualid = copy(t.qualid, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        return M.at(t.pos).Import(qualid, t.staticImport);
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
    public JCTree visitArrayAccess(ArrayAccessTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        JCArrayAccess t = (JCArrayAccess) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        JCExpression indexed = copy(t.indexed, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        JCExpression index = copy(t.index, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        return M.at(t.pos).Indexed(indexed, index);
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    public JCTree visitLabeledStatement(LabeledStatementTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        JCLabeledStatement t = (JCLabeledStatement) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        JCStatement body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        return M.at(t.pos).Labelled(t.label, t.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    public JCTree visitLiteral(LiteralTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        JCLiteral t = (JCLiteral) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        return M.at(t.pos).Literal(t.typetag, t.value);
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    public JCTree visitMethod(MethodTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
        JCMethodDecl t  = (JCMethodDecl) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        JCModifiers mods = copy(t.mods, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        JCExpression restype = copy(t.restype, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        List<JCTypeParameter> typarams = copy(t.typarams, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        List<JCVariableDecl> params = copy(t.params, p);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   251
        JCVariableDecl recvparam = copy(t.recvparam, p);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
        List<JCExpression> thrown = copy(t.thrown, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        JCBlock body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
        JCExpression defaultValue = copy(t.defaultValue, p);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   255
        return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, recvparam, params, thrown, body, defaultValue);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    public JCTree visitMethodInvocation(MethodInvocationTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
        JCMethodInvocation t = (JCMethodInvocation) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        List<JCExpression> typeargs = copy(t.typeargs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        JCExpression meth = copy(t.meth, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
        List<JCExpression> args = copy(t.args, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
        return M.at(t.pos).Apply(typeargs, meth, args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
    public JCTree visitModifiers(ModifiersTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        JCModifiers t = (JCModifiers) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        List<JCAnnotation> annotations = copy(t.annotations, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        return M.at(t.pos).Modifiers(t.flags, annotations);
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    public JCTree visitNewArray(NewArrayTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        JCNewArray t = (JCNewArray) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        JCExpression elemtype = copy(t.elemtype, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
        List<JCExpression> dims = copy(t.dims, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
        List<JCExpression> elems = copy(t.elems, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        return M.at(t.pos).NewArray(elemtype, dims, elems);
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
    public JCTree visitNewClass(NewClassTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        JCNewClass t = (JCNewClass) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        JCExpression encl = copy(t.encl, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
        List<JCExpression> typeargs = copy(t.typeargs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        JCExpression clazz = copy(t.clazz, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
        List<JCExpression> args = copy(t.args, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
        JCClassDecl def = copy(t.def, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
        return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
11141
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 10950
diff changeset
   290
    public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 10950
diff changeset
   291
        JCLambda t = (JCLambda) node;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 10950
diff changeset
   292
        List<JCVariableDecl> params = copy(t.params, p);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 10950
diff changeset
   293
        JCTree body = copy(t.body, p);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 10950
diff changeset
   294
        return M.at(t.pos).Lambda(params, body);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 10950
diff changeset
   295
    }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 10950
diff changeset
   296
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    public JCTree visitParenthesized(ParenthesizedTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        JCParens t = (JCParens) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        JCExpression expr = copy(t.expr, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        return M.at(t.pos).Parens(expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    public JCTree visitReturn(ReturnTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        JCReturn t = (JCReturn) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
        JCExpression expr = copy(t.expr, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        return M.at(t.pos).Return(expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
    public JCTree visitMemberSelect(MemberSelectTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        JCFieldAccess t = (JCFieldAccess) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        JCExpression selected = copy(t.selected, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        return M.at(t.pos).Select(selected, t.name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
11142
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   315
    public JCTree visitMemberReference(MemberReferenceTree node, P p) {
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   316
        JCMemberReference t = (JCMemberReference) node;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   317
        JCExpression expr = copy(t.expr, p);
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   318
        List<JCExpression> typeargs = copy(t.typeargs, p);
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   319
        return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs);
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   320
    }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   321
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
    public JCTree visitEmptyStatement(EmptyStatementTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        JCSkip t = (JCSkip) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
        return M.at(t.pos).Skip();
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 JCTree visitSwitch(SwitchTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        JCSwitch t = (JCSwitch) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
        JCExpression selector = copy(t.selector, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
        List<JCCase> cases = copy(t.cases, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
        return M.at(t.pos).Switch(selector, cases);
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    public JCTree visitSynchronized(SynchronizedTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        JCSynchronized t = (JCSynchronized) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
        JCExpression lock = copy(t.lock, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        JCBlock body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
        return M.at(t.pos).Synchronized(lock, body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
    public JCTree visitThrow(ThrowTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
        JCThrow t = (JCThrow) node;
17807
36cff8c58cdf 7030476: Fix conflicting use of JCTree/JCExpression
vromero
parents: 17578
diff changeset
   343
        JCExpression expr = copy(t.expr, p);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        return M.at(t.pos).Throw(expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
    public JCTree visitCompilationUnit(CompilationUnitTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
        JCCompilationUnit t = (JCCompilationUnit) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        List<JCAnnotation> packageAnnotations = copy(t.packageAnnotations, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
        JCExpression pid = copy(t.pid, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
        List<JCTree> defs = copy(t.defs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        return M.at(t.pos).TopLevel(packageAnnotations, pid, defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
    public JCTree visitTry(TryTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
        JCTry t = (JCTry) node;
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
   357
        List<JCTree> resources = copy(t.resources, p);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
        JCBlock body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
        List<JCCatch> catchers = copy(t.catchers, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
        JCBlock finalizer = copy(t.finalizer, p);
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
   361
        return M.at(t.pos).Try(resources, body, catchers, finalizer);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
    public JCTree visitParameterizedType(ParameterizedTypeTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
        JCTypeApply t = (JCTypeApply) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
        JCExpression clazz = copy(t.clazz, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
        List<JCExpression> arguments = copy(t.arguments, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
        return M.at(t.pos).TypeApply(clazz, arguments);
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
   371
    public JCTree visitUnionType(UnionTypeTree node, P p) {
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
   372
        JCTypeUnion t = (JCTypeUnion) node;
7074
0183c3f9614e 6949587: rename "DisjointType" to "DisjunctType"
jjg
parents: 7072
diff changeset
   373
        List<JCExpression> components = copy(t.alternatives, p);
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
   374
        return M.at(t.pos).TypeUnion(components);
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   375
    }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   376
14725
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   377
    public JCTree visitIntersectionType(IntersectionTypeTree node, P p) {
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   378
        JCTypeIntersection t = (JCTypeIntersection) node;
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   379
        List<JCExpression> bounds = copy(t.bounds, p);
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   380
        return M.at(t.pos).TypeIntersection(bounds);
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   381
    }
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   382
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
    public JCTree visitArrayType(ArrayTypeTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
        JCArrayTypeTree t = (JCArrayTypeTree) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
        JCExpression elemtype = copy(t.elemtype, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
        return M.at(t.pos).TypeArray(elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
    public JCTree visitTypeCast(TypeCastTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
        JCTypeCast t = (JCTypeCast) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
        JCTree clazz = copy(t.clazz, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
        JCExpression expr = copy(t.expr, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
        return M.at(t.pos).TypeCast(clazz, expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
    public JCTree visitPrimitiveType(PrimitiveTypeTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
        JCPrimitiveTypeTree t = (JCPrimitiveTypeTree) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
        return M.at(t.pos).TypeIdent(t.typetag);
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    public JCTree visitTypeParameter(TypeParameterTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
        JCTypeParameter t = (JCTypeParameter) node;
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   403
        List<JCAnnotation> annos = copy(t.annotations, p);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
        List<JCExpression> bounds = copy(t.bounds, p);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   405
        return M.at(t.pos).TypeParameter(t.name, bounds, annos);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
    public JCTree visitInstanceOf(InstanceOfTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
        JCInstanceOf t = (JCInstanceOf) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
        JCExpression expr = copy(t.expr, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
        JCTree clazz = copy(t.clazz, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
        return M.at(t.pos).TypeTest(expr, clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
    public JCTree visitUnary(UnaryTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
        JCUnary t = (JCUnary) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
        JCExpression arg = copy(t.arg, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
        return M.at(t.pos).Unary(t.getTag(), arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
    public JCTree visitVariable(VariableTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        JCVariableDecl t = (JCVariableDecl) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
        JCModifiers mods = copy(t.mods, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
        JCExpression vartype = copy(t.vartype, p);
17578
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   425
        if (t.nameexpr == null) {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   426
            JCExpression init = copy(t.init, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   427
            return M.at(t.pos).VarDef(mods, t.name, vartype, init);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   428
        } else {
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   429
            JCExpression nameexpr = copy(t.nameexpr, p);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   430
            return M.at(t.pos).ReceiverVarDef(mods, nameexpr, vartype);
46ac954e4a84 8013852: update reference impl for type-annotations
jjg
parents: 15385
diff changeset
   431
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
    public JCTree visitWhileLoop(WhileLoopTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
        JCWhileLoop t = (JCWhileLoop) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
        JCStatement body = copy(t.body, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
        JCExpression cond = copy(t.cond, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
        return M.at(t.pos).WhileLoop(cond, body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
    public JCTree visitWildcard(WildcardTree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
        JCWildcard t = (JCWildcard) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
        TypeBoundKind kind = M.at(t.kind.pos).TypeBoundKind(t.kind.kind);
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
        JCTree inner = copy(t.inner, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
        return M.at(t.pos).Wildcard(kind, inner);
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
    public JCTree visitOther(Tree node, P p) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
        JCTree tree = (JCTree) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
        switch (tree.getTag()) {
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 9300
diff changeset
   451
            case LETEXPR: {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
                LetExpr t = (LetExpr) node;
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
                List<JCVariableDecl> defs = copy(t.defs, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
                JCTree expr = copy(t.expr, p);
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
                return M.at(t.pos).LetExpr(defs, expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
                throw new AssertionError("unknown tree tag: " + tree.getTag());
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
}