langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
author jjg
Thu, 10 Jun 2010 16:08:01 -0700
changeset 5847 1908176fd6e3
parent 5520 86e4b9a9da40
child 6148 3a8158299c51
permissions -rw-r--r--
6944312: Potential rebranding issues in openjdk/langtools repository sources Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5492
diff changeset
     2
 * Copyright (c) 1999, 2006, 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);
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        tree.params = translateVarDefs(tree.params);
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        tree.thrown = translate(tree.thrown);
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    public void visitVarDef(JCVariableDecl tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        tree.mods = translate(tree.mods);
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        tree.vartype = translate(tree.vartype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        tree.init = translate(tree.init);
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
    public void visitSkip(JCSkip tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        result = tree;
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 void visitBlock(JCBlock tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        tree.stats = translate(tree.stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    public void visitDoLoop(JCDoWhileLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    public void visitWhileLoop(JCWhileLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    public void visitForLoop(JCForLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
        tree.init = translate(tree.init);
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        tree.step = translate(tree.step);
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    public void visitForeachLoop(JCEnhancedForLoop tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
        tree.var = translate(tree.var);
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        result = tree;
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 void visitLabelled(JCLabeledStatement tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    public void visitSwitch(JCSwitch tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
        tree.selector = translate(tree.selector);
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        tree.cases = translateCases(tree.cases);
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    public void visitCase(JCCase tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        tree.pat = translate(tree.pat);
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        tree.stats = translate(tree.stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        result = tree;
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 void visitSynchronized(JCSynchronized tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        tree.lock = translate(tree.lock);
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
    public void visitTry(JCTry tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        tree.catchers = translateCatchers(tree.catchers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        tree.finalizer = translate(tree.finalizer);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        result = tree;
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 void visitCatch(JCCatch tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
        tree.param = translate(tree.param);
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        result = tree;
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 void visitConditional(JCConditional tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        tree.truepart = translate(tree.truepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        tree.falsepart = translate(tree.falsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        result = tree;
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 void visitIf(JCIf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        tree.thenpart = translate(tree.thenpart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        tree.elsepart = translate(tree.elsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
    public void visitExec(JCExpressionStatement tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
    public void visitBreak(JCBreak tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    public void visitContinue(JCContinue tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    public void visitReturn(JCReturn tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
    public void visitThrow(JCThrow tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    public void visitAssert(JCAssert tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        tree.detail = translate(tree.detail);
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
    public void visitApply(JCMethodInvocation tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
        tree.meth = translate(tree.meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
    public void visitNewClass(JCNewClass tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
        tree.encl = translate(tree.encl);
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        tree.def = translate(tree.def);
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
    public void visitNewArray(JCNewArray tree) {
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   285
        tree.annotations = translate(tree.annotations);
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   286
        List<List<JCTypeAnnotation>> dimAnnos = List.nil();
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   287
        for (List<JCTypeAnnotation> origDimAnnos : tree.dimAnnotations)
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   288
            dimAnnos = dimAnnos.append(translate(origDimAnnos));
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   289
        tree.dimAnnotations = dimAnnos;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        tree.elemtype = translate(tree.elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        tree.dims = translate(tree.dims);
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        tree.elems = translate(tree.elems);
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
    public void visitParens(JCParens tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    public void visitAssign(JCAssign tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    public void visitAssignop(JCAssignOp tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
    public void visitUnary(JCUnary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
        tree.arg = translate(tree.arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
    public void visitBinary(JCBinary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
    public void visitTypeCast(JCTypeCast tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
    public void visitTypeTest(JCInstanceOf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    public void visitIndexed(JCArrayAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
        tree.indexed = translate(tree.indexed);
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
        tree.index = translate(tree.index);
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
    public void visitSelect(JCFieldAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
        tree.selected = translate(tree.selected);
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        result = tree;
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 void visitIdent(JCIdent tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
    public void visitLiteral(JCLiteral tree) {
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
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
    public void visitTypeIdent(JCPrimitiveTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
    public void visitTypeArray(JCArrayTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
        tree.elemtype = translate(tree.elemtype);
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 visitTypeApply(JCTypeApply tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
        tree.arguments = translate(tree.arguments);
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   370
    public void visitTypeDisjoint(JCTypeDisjoint tree) {
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   371
        tree.components = translate(tree.components);
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   372
        result = tree;
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   373
    }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   374
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
    public void visitTypeParameter(JCTypeParameter tree) {
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   376
        tree.annotations = translate(tree.annotations);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
        tree.bounds = translate(tree.bounds);
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
    public void visitWildcard(JCWildcard tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
        tree.kind = translate(tree.kind);
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
        tree.inner = translate(tree.inner);
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
    public void visitTypeBoundKind(TypeBoundKind tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
    public void visitErroneous(JCErroneous tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
    public void visitLetExpr(LetExpr tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
        tree.defs = translateVarDefs(tree.defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    public void visitModifiers(JCModifiers tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
        tree.annotations = translateAnnotations(tree.annotations);
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
        result = tree;
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 void visitAnnotation(JCAnnotation tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
        tree.annotationType = translate(tree.annotationType);
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   414
    public void visitAnnotatedType(JCAnnotatedType tree) {
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   415
        tree.annotations = translate(tree.annotations);
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   416
        tree.underlyingType = translate(tree.underlyingType);
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   417
        result = tree;
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   418
    }
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   419
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
    public void visitTree(JCTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
        throw new AssertionError(tree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
}