langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
author jjg
Wed, 23 Jan 2013 13:27:24 -0800
changeset 15385 ee1eebe7e210
parent 14725 65836e833f59
child 17578 46ac954e4a84
permissions -rw-r--r--
8006775: JSR 308: Compiler changes in JDK8 Reviewed-by: jjg Contributed-by: mernst@cs.washington.edu, wmdietl@cs.washington.edu, mpapi@csail.mit.edu, mahmood@notnoop.com
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) 1999, 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.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.javac.tree.JCTree.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/** A subclass of Tree.Visitor, this class defines
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 *  a general tree translator pattern. Translation proceeds recursively in
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 *  left-to-right order down a tree, constructing translated nodes by
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *  overwriting existing ones. There is one visitor method in this class
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 *  for every possible kind of tree node.  To obtain a specific
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *  translator, it suffices to override those visitor methods which
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *  do some interesting work. The translator class itself takes care of all
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *  navigational aspects.
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    40
 *  <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
    41
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
public class TreeTranslator extends JCTree.Visitor {
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    /** Visitor result field: a tree
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    protected JCTree result;
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    /** Visitor method: Translate a single node.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    @SuppressWarnings("unchecked")
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
    public <T extends JCTree> T translate(T tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
        if (tree == null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
            return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
            tree.accept(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
            JCTree result = this.result;
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
            this.result = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
            return (T)result; // XXX cast
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /** Visitor method: translate a list of nodes.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    public <T extends JCTree> List<T> translate(List<T> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        if (trees == null) return null;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
        for (List<T> l = trees; l.nonEmpty(); l = l.tail)
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
            l.head = translate(l.head);
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
        return trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    /**  Visitor method: translate a list of variable definitions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    public List<JCVariableDecl> translateVarDefs(List<JCVariableDecl> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        for (List<JCVariableDecl> l = trees; l.nonEmpty(); l = l.tail)
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
            l.head = translate(l.head);
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        return trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    /**  Visitor method: translate a list of type parameters.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    public List<JCTypeParameter> translateTypeParams(List<JCTypeParameter> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
        for (List<JCTypeParameter> l = trees; l.nonEmpty(); l = l.tail)
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
            l.head = translate(l.head);
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
        return trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**  Visitor method: translate a list of case parts of switch statements.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
    public List<JCCase> translateCases(List<JCCase> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
        for (List<JCCase> l = trees; l.nonEmpty(); l = l.tail)
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
            l.head = translate(l.head);
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        return trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    /**  Visitor method: translate a list of catch clauses in try statements.
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    public List<JCCatch> translateCatchers(List<JCCatch> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        for (List<JCCatch> l = trees; l.nonEmpty(); l = l.tail)
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
            l.head = translate(l.head);
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        return trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /**  Visitor method: translate a list of catch clauses in try statements.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    public List<JCAnnotation> translateAnnotations(List<JCAnnotation> trees) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        for (List<JCAnnotation> l = trees; l.nonEmpty(); l = l.tail)
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
            l.head = translate(l.head);
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        return trees;
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
/* ***************************************************************************
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
 * Visitor methods
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
 ****************************************************************************/
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
    public void visitTopLevel(JCCompilationUnit tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        tree.pid = translate(tree.pid);
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        tree.defs = translate(tree.defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        result = tree;
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 void visitImport(JCImport tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        tree.qualid = translate(tree.qualid);
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    public void visitClassDef(JCClassDecl tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        tree.mods = translate(tree.mods);
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        tree.typarams = translateTypeParams(tree.typarams);
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        tree.extending = translate(tree.extending);
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        tree.implementing = translate(tree.implementing);
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        tree.defs = translate(tree.defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    public void visitMethodDef(JCMethodDecl tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        tree.mods = translate(tree.mods);
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        tree.restype = translate(tree.restype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        tree.typarams = translateTypeParams(tree.typarams);
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   142
        tree.recvparam = translate(tree.recvparam);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        tree.params = translateVarDefs(tree.params);
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        tree.thrown = translate(tree.thrown);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        result = tree;
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 void visitVarDef(JCVariableDecl tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        tree.mods = translate(tree.mods);
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        tree.vartype = translate(tree.vartype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        tree.init = translate(tree.init);
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        result = 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 void visitSkip(JCSkip tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
    public void visitBlock(JCBlock tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        tree.stats = translate(tree.stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    public void visitDoLoop(JCDoWhileLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    public void visitWhileLoop(JCWhileLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
    public void visitForLoop(JCForLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        tree.init = translate(tree.init);
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        tree.step = translate(tree.step);
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        result = tree;
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 void visitForeachLoop(JCEnhancedForLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        tree.var = translate(tree.var);
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
    public void visitLabelled(JCLabeledStatement tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
    public void visitSwitch(JCSwitch tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        tree.selector = translate(tree.selector);
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        tree.cases = translateCases(tree.cases);
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
    public void visitCase(JCCase tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        tree.pat = translate(tree.pat);
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        tree.stats = translate(tree.stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    public void visitSynchronized(JCSynchronized tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        tree.lock = translate(tree.lock);
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
    public void visitTry(JCTry tree) {
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
   216
        tree.resources = translate(tree.resources);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        tree.catchers = translateCatchers(tree.catchers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        tree.finalizer = translate(tree.finalizer);
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    public void visitCatch(JCCatch tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        tree.param = translate(tree.param);
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
        result = 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 void visitConditional(JCConditional tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        tree.truepart = translate(tree.truepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        tree.falsepart = translate(tree.falsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
    public void visitIf(JCIf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        tree.thenpart = translate(tree.thenpart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        tree.elsepart = translate(tree.elsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
    public void visitExec(JCExpressionStatement tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    public void visitBreak(JCBreak tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    public void visitContinue(JCContinue tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    public void visitReturn(JCReturn tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
    public void visitThrow(JCThrow tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
        result = tree;
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 void visitAssert(JCAssert tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        tree.detail = translate(tree.detail);
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
        result = tree;
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 void visitApply(JCMethodInvocation tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        tree.meth = translate(tree.meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
    public void visitNewClass(JCNewClass tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        tree.encl = translate(tree.encl);
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        tree.def = translate(tree.def);
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
11141
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   286
    public void visitLambda(JCLambda tree) {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   287
        tree.params = translate(tree.params);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   288
        tree.body = translate(tree.body);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   289
        result = tree;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   290
    }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 9300
diff changeset
   291
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
    public void visitNewArray(JCNewArray tree) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   293
        tree.annotations = translate(tree.annotations);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   294
        List<List<JCAnnotation>> dimAnnos = List.nil();
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   295
        for (List<JCAnnotation> origDimAnnos : tree.dimAnnotations)
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   296
            dimAnnos = dimAnnos.append(translate(origDimAnnos));
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   297
        tree.dimAnnotations = dimAnnos;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        tree.elemtype = translate(tree.elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        tree.dims = translate(tree.dims);
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
        tree.elems = translate(tree.elems);
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
    public void visitParens(JCParens tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
        result = tree;
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 void visitAssign(JCAssign tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
        result = 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 void visitAssignop(JCAssignOp tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
        result = 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 void visitUnary(JCUnary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
        tree.arg = translate(tree.arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
    public void visitBinary(JCBinary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
    public void visitTypeCast(JCTypeCast tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    public void visitTypeTest(JCInstanceOf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
    public void visitIndexed(JCArrayAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        tree.indexed = translate(tree.indexed);
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
        tree.index = translate(tree.index);
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
    public void visitSelect(JCFieldAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
        tree.selected = translate(tree.selected);
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
11142
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   355
    public void visitReference(JCMemberReference tree) {
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   356
        tree.expr = translate(tree.expr);
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   357
        result = tree;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   358
    }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   359
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
    public void visitIdent(JCIdent tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
        result = tree;
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 void visitLiteral(JCLiteral tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
    public void visitTypeIdent(JCPrimitiveTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
    public void visitTypeArray(JCArrayTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
        tree.elemtype = translate(tree.elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
        result = 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 void visitTypeApply(JCTypeApply tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
        tree.arguments = translate(tree.arguments);
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8031
diff changeset
   383
    public void visitTypeUnion(JCTypeUnion tree) {
7074
0183c3f9614e 6949587: rename "DisjointType" to "DisjunctType"
jjg
parents: 6148
diff changeset
   384
        tree.alternatives = translate(tree.alternatives);
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   385
        result = tree;
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   386
    }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   387
14725
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   388
    public void visitTypeIntersection(JCTypeIntersection tree) {
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   389
        tree.bounds = translate(tree.bounds);
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   390
        result = tree;
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   391
    }
65836e833f59 8002099: Add support for intersection types in cast expression
mcimadamore
parents: 11142
diff changeset
   392
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
    public void visitTypeParameter(JCTypeParameter tree) {
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   394
        tree.annotations = translate(tree.annotations);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
        tree.bounds = translate(tree.bounds);
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
    public void visitWildcard(JCWildcard tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
        tree.kind = translate(tree.kind);
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
        tree.inner = translate(tree.inner);
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
    public void visitTypeBoundKind(TypeBoundKind tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
    public void visitErroneous(JCErroneous tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
        result = tree;
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 void visitLetExpr(LetExpr tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
        tree.defs = translateVarDefs(tree.defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
        result = tree;
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 void visitModifiers(JCModifiers tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        tree.annotations = translateAnnotations(tree.annotations);
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
    public void visitAnnotation(JCAnnotation tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
        tree.annotationType = translate(tree.annotationType);
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
15385
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   432
    public void visitAnnotatedType(JCAnnotatedType tree) {
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   433
        tree.annotations = translate(tree.annotations);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   434
        tree.underlyingType = translate(tree.underlyingType);
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   435
        result = tree;
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   436
    }
ee1eebe7e210 8006775: JSR 308: Compiler changes in JDK8
jjg
parents: 14725
diff changeset
   437
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
    public void visitTree(JCTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        throw new AssertionError(tree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
}