langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
author jjg
Mon, 06 Sep 2010 12:55:09 -0700
changeset 6590 f745e683da2c
parent 6148 3a8158299c51
child 7074 0183c3f9614e
permissions -rw-r--r--
6930507: Symbols for anonymous and local classes made too late for use by java tree API Reviewed-by: mcimadamore
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) {
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
   215
        tree.resources = translate(tree.resources);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        tree.catchers = translateCatchers(tree.catchers);
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
        tree.finalizer = translate(tree.finalizer);
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
    public void visitCatch(JCCatch tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
        tree.param = translate(tree.param);
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        tree.body = translate(tree.body);
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
    public void visitConditional(JCConditional tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
        tree.truepart = translate(tree.truepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
        tree.falsepart = translate(tree.falsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public void visitIf(JCIf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        tree.thenpart = translate(tree.thenpart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
        tree.elsepart = translate(tree.elsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    public void visitExec(JCExpressionStatement tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    public void visitBreak(JCBreak tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
    public void visitContinue(JCContinue tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
    public void visitReturn(JCReturn tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    public void visitThrow(JCThrow tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    public void visitAssert(JCAssert tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        tree.cond = translate(tree.cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
        tree.detail = translate(tree.detail);
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
    public void visitApply(JCMethodInvocation tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
        tree.meth = translate(tree.meth);
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
    public void visitNewClass(JCNewClass tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
        tree.encl = translate(tree.encl);
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        tree.args = translate(tree.args);
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
        tree.def = translate(tree.def);
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
    public void visitNewArray(JCNewArray tree) {
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   286
        tree.annotations = translate(tree.annotations);
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   287
        List<List<JCTypeAnnotation>> dimAnnos = List.nil();
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   288
        for (List<JCTypeAnnotation> origDimAnnos : tree.dimAnnotations)
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   289
            dimAnnos = dimAnnos.append(translate(origDimAnnos));
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   290
        tree.dimAnnotations = dimAnnos;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        tree.elemtype = translate(tree.elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        tree.dims = translate(tree.dims);
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        tree.elems = translate(tree.elems);
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    public void visitParens(JCParens tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
    public void visitAssign(JCAssign tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
    public void visitAssignop(JCAssignOp tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
    public void visitUnary(JCUnary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
        tree.arg = translate(tree.arg);
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
    public void visitBinary(JCBinary tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
        tree.lhs = translate(tree.lhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
        tree.rhs = translate(tree.rhs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
    public void visitTypeCast(JCTypeCast tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   326
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
    public void visitTypeTest(JCInstanceOf tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
    public void visitIndexed(JCArrayAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
        tree.indexed = translate(tree.indexed);
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
        tree.index = translate(tree.index);
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
    public void visitSelect(JCFieldAccess tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
        tree.selected = translate(tree.selected);
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    public void visitIdent(JCIdent tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
    public void visitLiteral(JCLiteral tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
    public void visitTypeIdent(JCPrimitiveTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
    public void visitTypeArray(JCArrayTypeTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
        tree.elemtype = translate(tree.elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    public void visitTypeApply(JCTypeApply tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
        tree.clazz = translate(tree.clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
        tree.arguments = translate(tree.arguments);
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   371
    public void visitTypeDisjoint(JCTypeDisjoint tree) {
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   372
        tree.components = translate(tree.components);
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   373
        result = tree;
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   374
    }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   375
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
    public void visitTypeParameter(JCTypeParameter tree) {
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   377
        tree.annotations = translate(tree.annotations);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
        tree.bounds = translate(tree.bounds);
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
    public void visitWildcard(JCWildcard tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
        tree.kind = translate(tree.kind);
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
        tree.inner = translate(tree.inner);
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
    @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
    public void visitTypeBoundKind(TypeBoundKind tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
    public void visitErroneous(JCErroneous tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
    public void visitLetExpr(LetExpr tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
        tree.defs = translateVarDefs(tree.defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        tree.expr = translate(tree.expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
    public void visitModifiers(JCModifiers tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
        tree.annotations = translateAnnotations(tree.annotations);
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
        result = tree;
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
    public void visitAnnotation(JCAnnotation tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
        tree.annotationType = translate(tree.annotationType);
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
        tree.args = translate(tree.args);
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
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   415
    public void visitAnnotatedType(JCAnnotatedType tree) {
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   416
        tree.annotations = translate(tree.annotations);
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   417
        tree.underlyingType = translate(tree.underlyingType);
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   418
        result = tree;
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   419
    }
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 10
diff changeset
   420
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
    public void visitTree(JCTree tree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        throw new AssertionError(tree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
}