langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java
author mcimadamore
Thu, 24 Nov 2011 13:38:40 +0000
changeset 11142 45d0ec1e7463
parent 11141 7d112a1ecd0f
child 12333 7b02d0529a97
permissions -rw-r--r--
7115049: Add AST node for method references Summary: Add tree nodes for representing method/constructor references and update relevant visitors interfaces Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
8031
d5fe2c1cecfc 6992999: fully remove JSR 308 from langtools
jjg
parents: 7681
diff changeset
     2
 * Copyright (c) 1999, 2011, 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 java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.io.StringWriter;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import javax.lang.model.element.Modifier;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import javax.lang.model.type.TypeKind;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
import javax.tools.JavaFileObject;
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
import com.sun.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
import com.sun.tools.javac.util.List;
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
import com.sun.tools.javac.code.*;
7615
8bc078486f2b 7004029: intermittent failures compiling pack200
jjg
parents: 7074
diff changeset
    40
import com.sun.tools.javac.code.Scope.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
import com.sun.tools.javac.code.Symbol.*;
11055
ec1418effa77 7106166: (javac) re-factor EndPos parser
ksrini
parents: 10950
diff changeset
    42
import com.sun.tools.javac.parser.EndPosTable;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
import com.sun.source.tree.*;
11141
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
    44
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
11142
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
    45
import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
import static com.sun.tools.javac.code.BoundKind.*;
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    48
import static com.sun.tools.javac.tree.JCTree.Tag.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * Root class for abstract syntax tree nodes. It provides definitions
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * for specific tree nodes as subclasses nested inside.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * <p>Each subclass is highly standardized.  It generally contains
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * only tree fields for the syntactic subcomponents of the node.  Some
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * classes that represent identifier uses or definitions also define a
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * Symbol field that denotes the represented identifier.  Classes for
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * non-local jumps also carry the jump target as a field.  The root
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * class Tree itself defines fields for the tree's type and position.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 * No other fields are kept in a tree node; instead parameters are
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 * passed to methods accessing the node.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 * <p>Except for the methods defined by com.sun.source, the only
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
 * method defined in subclasses is `visit' which applies a given
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
 * visitor to the tree. The actual tree processing is done by visitor
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
 * classes in other packages. The abstract class Visitor, as well as
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 * an Factory interface for trees, are defined as inner classes in
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
 * Tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
 * <p>To avoid ambiguities with the Tree API in com.sun.source all sub
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 * classes should, by convention, start with JC (javac).
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    73
 * <p><b>This is NOT part of any supported API.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
 * If you write code that depends on this, you do so at your own risk.
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
 * This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
 * deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
 * @see TreeMaker
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
 * @see TreeInfo
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
 * @see TreeTranslator
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
 * @see Pretty
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /* Tree tag values, identifying kinds of trees */
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    86
    public enum Tag{
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    87
        /** For methods that return an invalid tag if a given condition is not met
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    88
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    89
        NO_TAG,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    91
        /** Toplevel nodes, of type TopLevel, representing entire source files.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    92
        */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    93
        TOPLEVEL,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    95
        /** Import clauses, of type Import.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    96
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    97
        IMPORT,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
    99
        /** Class definitions, of type ClassDef.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   100
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   101
        CLASSDEF,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   103
        /** Method definitions, of type MethodDef.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   104
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   105
        METHODDEF,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   107
        /** Variable definitions, of type VarDef.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   108
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   109
        VARDEF,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   111
        /** The no-op statement ";", of type Skip
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   112
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   113
        SKIP,
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   114
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   115
        /** Blocks, of type Block.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   116
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   117
        BLOCK,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   119
        /** Do-while loops, of type DoLoop.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   120
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   121
        DOLOOP,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   123
        /** While-loops, of type WhileLoop.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   124
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   125
        WHILELOOP,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   127
        /** For-loops, of type ForLoop.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   128
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   129
        FORLOOP,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   131
        /** Foreach-loops, of type ForeachLoop.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   132
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   133
        FOREACHLOOP,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   135
        /** Labelled statements, of type Labelled.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   136
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   137
        LABELLED,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   139
        /** Switch statements, of type Switch.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   140
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   141
        SWITCH,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   143
        /** Case parts in switch statements, of type Case.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   144
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   145
        CASE,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   147
        /** Synchronized statements, of type Synchonized.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   148
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   149
        SYNCHRONIZED,
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   150
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   151
        /** Try statements, of type Try.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   152
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   153
        TRY,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   155
        /** Catch clauses in try statements, of type Catch.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   156
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   157
        CATCH,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   159
        /** Conditional expressions, of type Conditional.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   160
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   161
        CONDEXPR,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   163
        /** Conditional statements, of type If.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   164
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   165
        IF,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   167
        /** Expression statements, of type Exec.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   168
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   169
        EXEC,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   171
        /** Break statements, of type Break.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   172
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   173
        BREAK,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   175
        /** Continue statements, of type Continue.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   176
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   177
        CONTINUE,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   179
        /** Return statements, of type Return.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   180
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   181
        RETURN,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   183
        /** Throw statements, of type Throw.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   184
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   185
        THROW,
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   186
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   187
        /** Assert statements, of type Assert.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   188
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   189
        ASSERT,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   191
        /** Method invocation expressions, of type Apply.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   192
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   193
        APPLY,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   195
        /** Class instance creation expressions, of type NewClass.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   196
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   197
        NEWCLASS,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   199
        /** Array creation expressions, of type NewArray.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   200
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   201
        NEWARRAY,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
11141
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
   203
        /** Lambda expression, of type Lambda.
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
   204
         */
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
   205
        LAMBDA,
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
   206
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   207
        /** Parenthesized subexpressions, of type Parens.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   208
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   209
        PARENS,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   211
        /** Assignment expressions, of type Assign.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   212
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   213
        ASSIGN,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   215
        /** Type cast expressions, of type TypeCast.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   216
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   217
        TYPECAST,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   219
        /** Type test expressions, of type TypeTest.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   220
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   221
        TYPETEST,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   223
        /** Indexed array expressions, of type Indexed.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   224
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   225
        INDEXED,
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   226
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   227
        /** Selections, of type Select.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   228
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   229
        SELECT,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
11142
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   231
        /** Member references, of type Reference.
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   232
         */
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   233
        REFERENCE,
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
   234
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   235
        /** Simple identifiers, of type Ident.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   236
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   237
        IDENT,
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   238
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   239
        /** Literals, of type Literal.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   240
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   241
        LITERAL,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   243
        /** Basic type identifiers, of type TypeIdent.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   244
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   245
        TYPEIDENT,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   247
        /** Array types, of type TypeArray.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   248
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   249
        TYPEARRAY,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   251
        /** Parameterized types, of type TypeApply.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   252
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   253
        TYPEAPPLY,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   255
        /** Union types, of type TypeUnion
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   256
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   257
        TYPEUNION,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   259
        /** Formal type parameters, of type TypeParameter.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   260
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   261
        TYPEPARAMETER,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   263
        /** Type argument.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   264
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   265
        WILDCARD,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   267
        /** Bound kind: extends, super, exact, or unbound
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   268
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   269
        TYPEBOUNDKIND,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   271
        /** metadata: Annotation.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   272
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   273
        ANNOTATION,
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
   274
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   275
        /** metadata: Modifiers
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   276
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   277
        MODIFIERS,
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   278
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   279
        ANNOTATED_TYPE,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   281
        /** Error trees, of type Erroneous.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   282
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   283
        ERRONEOUS,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   285
        /** Unary operators, of type Unary.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   286
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   287
        POS,                             // +
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   288
        NEG,                             // -
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   289
        NOT,                             // !
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   290
        COMPL,                           // ~
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   291
        PREINC,                          // ++ _
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   292
        PREDEC,                          // -- _
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   293
        POSTINC,                         // _ ++
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   294
        POSTDEC,                         // _ --
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   296
        /** unary operator for null reference checks, only used internally.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   297
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   298
        NULLCHK,
3149
0cd06d598d6f 6843077: JSR 308: Annotations on types
jjg
parents: 2212
diff changeset
   299
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   300
        /** Binary operators, of type Binary.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   301
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   302
        OR,                              // ||
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   303
        AND,                             // &&
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   304
        BITOR,                           // |
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   305
        BITXOR,                          // ^
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   306
        BITAND,                          // &
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   307
        EQ,                              // ==
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   308
        NE,                              // !=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   309
        LT,                              // <
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   310
        GT,                              // >
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   311
        LE,                              // <=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   312
        GE,                              // >=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   313
        SL,                              // <<
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   314
        SR,                              // >>
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   315
        USR,                             // >>>
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   316
        PLUS,                            // +
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   317
        MINUS,                           // -
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   318
        MUL,                             // *
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   319
        DIV,                             // /
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   320
        MOD,                             // %
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   322
        /** Assignment operators, of type Assignop.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   323
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   324
        BITOR_ASG(BITOR),                // |=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   325
        BITXOR_ASG(BITXOR),              // ^=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   326
        BITAND_ASG(BITAND),              // &=
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   328
        SL_ASG(SL),                      // <<=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   329
        SR_ASG(SR),                      // >>=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   330
        USR_ASG(USR),                    // >>>=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   331
        PLUS_ASG(PLUS),                  // +=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   332
        MINUS_ASG(MINUS),                // -=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   333
        MUL_ASG(MUL),                    // *=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   334
        DIV_ASG(DIV),                    // /=
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   335
        MOD_ASG(MOD),                    // %=
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   337
        /** A synthetic let expression, of type LetExpr.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   338
         */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   339
        LETEXPR;                         // ala scheme
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   340
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   341
        private Tag noAssignTag;
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   342
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   343
        private static int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   344
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   345
        private Tag(Tag noAssignTag) {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   346
            this.noAssignTag = noAssignTag;
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   347
        }
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   348
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   349
        private Tag() { }
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   350
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   351
        public static int getNumberOfOperators() {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   352
            return numberOfOperators;
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   353
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   355
        public Tag noAssignOp() {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   356
            if (noAssignTag != null)
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   357
                return noAssignTag;
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   358
            throw new AssertionError("noAssignOp() method is not available for non assignment tags");
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   359
        }
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   360
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   361
        public boolean isPostUnaryOp() {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   362
            return (this == POSTINC || this == POSTDEC);
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   363
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   365
        public boolean isIncOrDecUnaryOp() {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   366
            return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC);
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   367
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   369
        public boolean isAssignop() {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   370
            return noAssignTag != null;
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   371
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   373
        public int operatorIndex() {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   374
            return (this.ordinal() - POS.ordinal());
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   375
        }
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   376
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
    /* The (encoded) position in the source file. @see util.Position.
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
    public int pos;
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
    /* The type of this node.
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
    public Type type;
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    /* The tag of this node -- one of the constants declared above.
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
     */
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   388
    public abstract Tag getTag();
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   389
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   390
    /* Returns true if the tag of this node is equals to tag.
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   391
     */
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   392
    public boolean hasTag(Tag tag) {
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   393
        return tag == getTag();
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   394
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
    /** Convert a tree to a pretty-printed string. */
6580
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   397
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
    public String toString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
        StringWriter s = new StringWriter();
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
            new Pretty(s, false).printExpr(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
        catch (IOException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
            // should never happen, because StringWriter is defined
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
            // never to throw any IOExceptions
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
            throw new AssertionError(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
        return s.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
    /** Set position field and return this tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
    public JCTree setPos(int pos) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
        this.pos = pos;
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
        return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
    /** Set type field and return this tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
    public JCTree setType(Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
        this.type = type;
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
        return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
    /** Visit this tree with a given visitor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
    public abstract void accept(Visitor v);
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
    public abstract <R,D> R accept(TreeVisitor<R,D> v, D d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
    /** Return a shallow copy of this tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
     */
6580
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   433
    @Override
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
    public Object clone() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
            return super.clone();
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
        } catch(CloneNotSupportedException e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
            throw new RuntimeException(e);
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
    /** Get a default position for this tree node.
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
    public DiagnosticPosition pos() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
        return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
    // for default DiagnosticPosition
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
    public JCTree getTree() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
        return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
    // for default DiagnosticPosition
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
    public int getStartPosition() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
        return TreeInfo.getStartPos(this);
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
    // for default DiagnosticPosition
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
    public int getPreferredPosition() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
        return pos;
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
    // for default DiagnosticPosition
11055
ec1418effa77 7106166: (javac) re-factor EndPos parser
ksrini
parents: 10950
diff changeset
   464
    public int getEndPosition(EndPosTable endPosTable) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
        return TreeInfo.getEndPos(this, endPosTable);
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
     * Everything in one source file is kept in a TopLevel structure.
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
     * @param pid              The tree representing the package clause.
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
     * @param sourcefile       The source file name.
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
     * @param defs             All definitions in this file (ClassDef, Import, and Skip)
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
     * @param packge           The package it belongs to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
     * @param namedImportScope A scope for all named imports.
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
     * @param starImportScope  A scope for all import-on-demands.
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
     * @param lineMap          Line starting positions, defined only
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
     *                         if option -g is set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
     * @param docComments      A hashtable that stores all documentation comments
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
     *                         indexed by the tree nodes they refer to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
     *                         defined only if option -s is set.
11055
ec1418effa77 7106166: (javac) re-factor EndPos parser
ksrini
parents: 10950
diff changeset
   481
     * @param endPositions     An object encapsulating ending positions of source
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
     *                         ranges indexed by the tree nodes they belong to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
     *                         Defined only if option -Xjcov is set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
    public static class JCCompilationUnit extends JCTree implements CompilationUnitTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   486
        public List<JCAnnotation> packageAnnotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
        public JCExpression pid;
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
        public List<JCTree> defs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
        public JavaFileObject sourcefile;
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
        public PackageSymbol packge;
7615
8bc078486f2b 7004029: intermittent failures compiling pack200
jjg
parents: 7074
diff changeset
   491
        public ImportScope namedImportScope;
8bc078486f2b 7004029: intermittent failures compiling pack200
jjg
parents: 7074
diff changeset
   492
        public StarImportScope starImportScope;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
        public Position.LineMap lineMap = null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
        public Map<JCTree, String> docComments = null;
11055
ec1418effa77 7106166: (javac) re-factor EndPos parser
ksrini
parents: 10950
diff changeset
   495
        public EndPosTable endPositions = null;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
        protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
                        JCExpression pid,
06bc494ca11e Initial load
duke
parents:
diff changeset
   498
                        List<JCTree> defs,
06bc494ca11e Initial load
duke
parents:
diff changeset
   499
                        JavaFileObject sourcefile,
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
                        PackageSymbol packge,
7615
8bc078486f2b 7004029: intermittent failures compiling pack200
jjg
parents: 7074
diff changeset
   501
                        ImportScope namedImportScope,
8bc078486f2b 7004029: intermittent failures compiling pack200
jjg
parents: 7074
diff changeset
   502
                        StarImportScope starImportScope) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
            this.packageAnnotations = packageAnnotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
            this.pid = pid;
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
            this.defs = defs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
            this.sourcefile = sourcefile;
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
            this.packge = packge;
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
            this.namedImportScope = namedImportScope;
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
            this.starImportScope = starImportScope;
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
        public void accept(Visitor v) { v.visitTopLevel(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
06bc494ca11e Initial load
duke
parents:
diff changeset
   514
        public Kind getKind() { return Kind.COMPILATION_UNIT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   515
        public List<JCAnnotation> getPackageAnnotations() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   516
            return packageAnnotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
   517
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
        public List<JCImport> getImports() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
            ListBuffer<JCImport> imports = new ListBuffer<JCImport>();
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
            for (JCTree tree : defs) {
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   521
                if (tree.hasTag(IMPORT))
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
                    imports.append((JCImport)tree);
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   523
                else if (!tree.hasTag(SKIP))
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
            return imports.toList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
        public JCExpression getPackageName() { return pid; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
        public JavaFileObject getSourceFile() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
            return sourcefile;
06bc494ca11e Initial load
duke
parents:
diff changeset
   531
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
        public Position.LineMap getLineMap() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
            return lineMap;
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
        public List<JCTree> getTypeDecls() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
            List<JCTree> typeDefs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
            for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail)
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   538
                if (!typeDefs.head.hasTag(IMPORT))
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   539
                    break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   540
            return typeDefs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   541
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   542
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   543
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   544
            return v.visitCompilationUnit(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   545
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   546
06bc494ca11e Initial load
duke
parents:
diff changeset
   547
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   548
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   549
            return TOPLEVEL;
06bc494ca11e Initial load
duke
parents:
diff changeset
   550
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   551
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   552
06bc494ca11e Initial load
duke
parents:
diff changeset
   553
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   554
     * An import clause.
06bc494ca11e Initial load
duke
parents:
diff changeset
   555
     * @param qualid    The imported class(es).
06bc494ca11e Initial load
duke
parents:
diff changeset
   556
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   557
    public static class JCImport extends JCTree implements ImportTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
        public boolean staticImport;
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
        public JCTree qualid;
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
        protected JCImport(JCTree qualid, boolean importStatic) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
            this.qualid = qualid;
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
            this.staticImport = importStatic;
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
        public void accept(Visitor v) { v.visitImport(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
        public boolean isStatic() { return staticImport; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
        public JCTree getQualifiedIdentifier() { return qualid; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   569
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
        public Kind getKind() { return Kind.IMPORT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
            return v.visitImport(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   577
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
            return IMPORT;
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
    public static abstract class JCStatement extends JCTree implements StatementTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
        public JCStatement setType(Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
            super.setType(type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
            return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
        public JCStatement setPos(int pos) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
            super.setPos(pos);
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
            return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
06bc494ca11e Initial load
duke
parents:
diff changeset
   595
    public static abstract class JCExpression extends JCTree implements ExpressionTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   596
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   597
        public JCExpression setType(Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   598
            super.setType(type);
06bc494ca11e Initial load
duke
parents:
diff changeset
   599
            return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   600
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   601
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   602
        public JCExpression setPos(int pos) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   603
            super.setPos(pos);
06bc494ca11e Initial load
duke
parents:
diff changeset
   604
            return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   605
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   606
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
     * A class definition.
06bc494ca11e Initial load
duke
parents:
diff changeset
   610
     * @param modifiers the modifiers
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
     * @param name the name of the class
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
     * @param typarams formal class parameters
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
     * @param extending the classes this class extends
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
     * @param implementing the interfaces implemented by this class
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
     * @param defs all variables and methods defined in this class
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
     * @param sym the symbol
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
    public static class JCClassDecl extends JCStatement implements ClassTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
        public JCModifiers mods;
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
        public Name name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
        public List<JCTypeParameter> typarams;
8625
6b51ef804d49 6639645: Modeling type implementing missing interfaces
jjg
parents: 8221
diff changeset
   622
        public JCExpression extending;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
        public List<JCExpression> implementing;
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
        public List<JCTree> defs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   625
        public ClassSymbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
        protected JCClassDecl(JCModifiers mods,
06bc494ca11e Initial load
duke
parents:
diff changeset
   627
                           Name name,
06bc494ca11e Initial load
duke
parents:
diff changeset
   628
                           List<JCTypeParameter> typarams,
8625
6b51ef804d49 6639645: Modeling type implementing missing interfaces
jjg
parents: 8221
diff changeset
   629
                           JCExpression extending,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   630
                           List<JCExpression> implementing,
06bc494ca11e Initial load
duke
parents:
diff changeset
   631
                           List<JCTree> defs,
06bc494ca11e Initial load
duke
parents:
diff changeset
   632
                           ClassSymbol sym)
06bc494ca11e Initial load
duke
parents:
diff changeset
   633
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
   634
            this.mods = mods;
06bc494ca11e Initial load
duke
parents:
diff changeset
   635
            this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   636
            this.typarams = typarams;
06bc494ca11e Initial load
duke
parents:
diff changeset
   637
            this.extending = extending;
06bc494ca11e Initial load
duke
parents:
diff changeset
   638
            this.implementing = implementing;
06bc494ca11e Initial load
duke
parents:
diff changeset
   639
            this.defs = defs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   640
            this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   641
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   642
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   643
        public void accept(Visitor v) { v.visitClassDef(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   644
6580
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   645
        public Kind getKind() {
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   646
            if ((mods.flags & Flags.ANNOTATION) != 0)
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   647
                return Kind.ANNOTATION_TYPE;
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   648
            else if ((mods.flags & Flags.INTERFACE) != 0)
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   649
                return Kind.INTERFACE;
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   650
            else if ((mods.flags & Flags.ENUM) != 0)
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   651
                return Kind.ENUM;
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   652
            else
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   653
                return Kind.CLASS;
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   654
        }
d3d578d22cc7 6570730: com.sun.source.tree.ModifiersTree.getFlags() should return class type
jjg
parents: 6148
diff changeset
   655
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   656
        public JCModifiers getModifiers() { return mods; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   657
        public Name getSimpleName() { return name; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   658
        public List<JCTypeParameter> getTypeParameters() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   659
            return typarams;
06bc494ca11e Initial load
duke
parents:
diff changeset
   660
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   661
        public JCTree getExtendsClause() { return extending; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   662
        public List<JCExpression> getImplementsClause() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   663
            return implementing;
06bc494ca11e Initial load
duke
parents:
diff changeset
   664
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   665
        public List<JCTree> getMembers() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   666
            return defs;
06bc494ca11e Initial load
duke
parents:
diff changeset
   667
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   668
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   669
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   670
            return v.visitClass(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   671
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   672
06bc494ca11e Initial load
duke
parents:
diff changeset
   673
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   674
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   675
            return CLASSDEF;
06bc494ca11e Initial load
duke
parents:
diff changeset
   676
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   677
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   678
06bc494ca11e Initial load
duke
parents:
diff changeset
   679
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   680
     * A method definition.
06bc494ca11e Initial load
duke
parents:
diff changeset
   681
     * @param modifiers method modifiers
06bc494ca11e Initial load
duke
parents:
diff changeset
   682
     * @param name method name
06bc494ca11e Initial load
duke
parents:
diff changeset
   683
     * @param restype type of method return value
06bc494ca11e Initial load
duke
parents:
diff changeset
   684
     * @param typarams type parameters
06bc494ca11e Initial load
duke
parents:
diff changeset
   685
     * @param params value parameters
06bc494ca11e Initial load
duke
parents:
diff changeset
   686
     * @param thrown exceptions thrown by this method
06bc494ca11e Initial load
duke
parents:
diff changeset
   687
     * @param stats statements in the method
06bc494ca11e Initial load
duke
parents:
diff changeset
   688
     * @param sym method symbol
06bc494ca11e Initial load
duke
parents:
diff changeset
   689
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   690
    public static class JCMethodDecl extends JCTree implements MethodTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   691
        public JCModifiers mods;
06bc494ca11e Initial load
duke
parents:
diff changeset
   692
        public Name name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   693
        public JCExpression restype;
06bc494ca11e Initial load
duke
parents:
diff changeset
   694
        public List<JCTypeParameter> typarams;
06bc494ca11e Initial load
duke
parents:
diff changeset
   695
        public List<JCVariableDecl> params;
06bc494ca11e Initial load
duke
parents:
diff changeset
   696
        public List<JCExpression> thrown;
06bc494ca11e Initial load
duke
parents:
diff changeset
   697
        public JCBlock body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   698
        public JCExpression defaultValue; // for annotation types
06bc494ca11e Initial load
duke
parents:
diff changeset
   699
        public MethodSymbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   700
        protected JCMethodDecl(JCModifiers mods,
06bc494ca11e Initial load
duke
parents:
diff changeset
   701
                            Name name,
06bc494ca11e Initial load
duke
parents:
diff changeset
   702
                            JCExpression restype,
06bc494ca11e Initial load
duke
parents:
diff changeset
   703
                            List<JCTypeParameter> typarams,
06bc494ca11e Initial load
duke
parents:
diff changeset
   704
                            List<JCVariableDecl> params,
06bc494ca11e Initial load
duke
parents:
diff changeset
   705
                            List<JCExpression> thrown,
06bc494ca11e Initial load
duke
parents:
diff changeset
   706
                            JCBlock body,
06bc494ca11e Initial load
duke
parents:
diff changeset
   707
                            JCExpression defaultValue,
06bc494ca11e Initial load
duke
parents:
diff changeset
   708
                            MethodSymbol sym)
06bc494ca11e Initial load
duke
parents:
diff changeset
   709
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
   710
            this.mods = mods;
06bc494ca11e Initial load
duke
parents:
diff changeset
   711
            this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   712
            this.restype = restype;
06bc494ca11e Initial load
duke
parents:
diff changeset
   713
            this.typarams = typarams;
06bc494ca11e Initial load
duke
parents:
diff changeset
   714
            this.params = params;
06bc494ca11e Initial load
duke
parents:
diff changeset
   715
            this.thrown = thrown;
06bc494ca11e Initial load
duke
parents:
diff changeset
   716
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   717
            this.defaultValue = defaultValue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   718
            this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   719
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   720
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   721
        public void accept(Visitor v) { v.visitMethodDef(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   722
06bc494ca11e Initial load
duke
parents:
diff changeset
   723
        public Kind getKind() { return Kind.METHOD; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   724
        public JCModifiers getModifiers() { return mods; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   725
        public Name getName() { return name; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   726
        public JCTree getReturnType() { return restype; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   727
        public List<JCTypeParameter> getTypeParameters() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   728
            return typarams;
06bc494ca11e Initial load
duke
parents:
diff changeset
   729
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   730
        public List<JCVariableDecl> getParameters() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   731
            return params;
06bc494ca11e Initial load
duke
parents:
diff changeset
   732
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   733
        public List<JCExpression> getThrows() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   734
            return thrown;
06bc494ca11e Initial load
duke
parents:
diff changeset
   735
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   736
        public JCBlock getBody() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   737
        public JCTree getDefaultValue() { // for annotation types
06bc494ca11e Initial load
duke
parents:
diff changeset
   738
            return defaultValue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   739
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   740
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   741
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   742
            return v.visitMethod(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   743
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   744
06bc494ca11e Initial load
duke
parents:
diff changeset
   745
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   746
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   747
            return METHODDEF;
06bc494ca11e Initial load
duke
parents:
diff changeset
   748
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   749
  }
06bc494ca11e Initial load
duke
parents:
diff changeset
   750
06bc494ca11e Initial load
duke
parents:
diff changeset
   751
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   752
     * A variable definition.
06bc494ca11e Initial load
duke
parents:
diff changeset
   753
     * @param modifiers variable modifiers
06bc494ca11e Initial load
duke
parents:
diff changeset
   754
     * @param name variable name
06bc494ca11e Initial load
duke
parents:
diff changeset
   755
     * @param vartype type of the variable
06bc494ca11e Initial load
duke
parents:
diff changeset
   756
     * @param init variables initial value
06bc494ca11e Initial load
duke
parents:
diff changeset
   757
     * @param sym symbol
06bc494ca11e Initial load
duke
parents:
diff changeset
   758
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   759
    public static class JCVariableDecl extends JCStatement implements VariableTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   760
        public JCModifiers mods;
06bc494ca11e Initial load
duke
parents:
diff changeset
   761
        public Name name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   762
        public JCExpression vartype;
06bc494ca11e Initial load
duke
parents:
diff changeset
   763
        public JCExpression init;
06bc494ca11e Initial load
duke
parents:
diff changeset
   764
        public VarSymbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   765
        protected JCVariableDecl(JCModifiers mods,
06bc494ca11e Initial load
duke
parents:
diff changeset
   766
                         Name name,
06bc494ca11e Initial load
duke
parents:
diff changeset
   767
                         JCExpression vartype,
06bc494ca11e Initial load
duke
parents:
diff changeset
   768
                         JCExpression init,
06bc494ca11e Initial load
duke
parents:
diff changeset
   769
                         VarSymbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   770
            this.mods = mods;
06bc494ca11e Initial load
duke
parents:
diff changeset
   771
            this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
   772
            this.vartype = vartype;
06bc494ca11e Initial load
duke
parents:
diff changeset
   773
            this.init = init;
06bc494ca11e Initial load
duke
parents:
diff changeset
   774
            this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   775
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   776
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   777
        public void accept(Visitor v) { v.visitVarDef(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   778
06bc494ca11e Initial load
duke
parents:
diff changeset
   779
        public Kind getKind() { return Kind.VARIABLE; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   780
        public JCModifiers getModifiers() { return mods; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   781
        public Name getName() { return name; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   782
        public JCTree getType() { return vartype; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   783
        public JCExpression getInitializer() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   784
            return init;
06bc494ca11e Initial load
duke
parents:
diff changeset
   785
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   786
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   787
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   788
            return v.visitVariable(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   789
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   790
06bc494ca11e Initial load
duke
parents:
diff changeset
   791
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   792
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   793
            return VARDEF;
06bc494ca11e Initial load
duke
parents:
diff changeset
   794
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   795
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   796
06bc494ca11e Initial load
duke
parents:
diff changeset
   797
      /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   798
     * A no-op statement ";".
06bc494ca11e Initial load
duke
parents:
diff changeset
   799
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   800
    public static class JCSkip extends JCStatement implements EmptyStatementTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   801
        protected JCSkip() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   802
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   803
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   804
        public void accept(Visitor v) { v.visitSkip(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   805
06bc494ca11e Initial load
duke
parents:
diff changeset
   806
        public Kind getKind() { return Kind.EMPTY_STATEMENT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   807
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   808
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   809
            return v.visitEmptyStatement(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   810
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   811
06bc494ca11e Initial load
duke
parents:
diff changeset
   812
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   813
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   814
            return SKIP;
06bc494ca11e Initial load
duke
parents:
diff changeset
   815
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   816
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   817
06bc494ca11e Initial load
duke
parents:
diff changeset
   818
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   819
     * A statement block.
06bc494ca11e Initial load
duke
parents:
diff changeset
   820
     * @param stats statements
06bc494ca11e Initial load
duke
parents:
diff changeset
   821
     * @param flags flags
06bc494ca11e Initial load
duke
parents:
diff changeset
   822
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   823
    public static class JCBlock extends JCStatement implements BlockTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   824
        public long flags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   825
        public List<JCStatement> stats;
06bc494ca11e Initial load
duke
parents:
diff changeset
   826
        /** Position of closing brace, optional. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   827
        public int endpos = Position.NOPOS;
06bc494ca11e Initial load
duke
parents:
diff changeset
   828
        protected JCBlock(long flags, List<JCStatement> stats) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   829
            this.stats = stats;
06bc494ca11e Initial load
duke
parents:
diff changeset
   830
            this.flags = flags;
06bc494ca11e Initial load
duke
parents:
diff changeset
   831
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   832
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   833
        public void accept(Visitor v) { v.visitBlock(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   834
06bc494ca11e Initial load
duke
parents:
diff changeset
   835
        public Kind getKind() { return Kind.BLOCK; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   836
        public List<JCStatement> getStatements() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   837
            return stats;
06bc494ca11e Initial load
duke
parents:
diff changeset
   838
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   839
        public boolean isStatic() { return (flags & Flags.STATIC) != 0; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   840
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   841
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   842
            return v.visitBlock(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   843
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   844
06bc494ca11e Initial load
duke
parents:
diff changeset
   845
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   846
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   847
            return BLOCK;
06bc494ca11e Initial load
duke
parents:
diff changeset
   848
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   849
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   850
06bc494ca11e Initial load
duke
parents:
diff changeset
   851
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   852
     * A do loop
06bc494ca11e Initial load
duke
parents:
diff changeset
   853
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   854
    public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   855
        public JCStatement body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   856
        public JCExpression cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
   857
        protected JCDoWhileLoop(JCStatement body, JCExpression cond) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   858
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   859
            this.cond = cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
   860
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   861
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   862
        public void accept(Visitor v) { v.visitDoLoop(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   863
06bc494ca11e Initial load
duke
parents:
diff changeset
   864
        public Kind getKind() { return Kind.DO_WHILE_LOOP; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   865
        public JCExpression getCondition() { return cond; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   866
        public JCStatement getStatement() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   867
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   868
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   869
            return v.visitDoWhileLoop(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   870
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   871
06bc494ca11e Initial load
duke
parents:
diff changeset
   872
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   873
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   874
            return DOLOOP;
06bc494ca11e Initial load
duke
parents:
diff changeset
   875
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   876
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   877
06bc494ca11e Initial load
duke
parents:
diff changeset
   878
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   879
     * A while loop
06bc494ca11e Initial load
duke
parents:
diff changeset
   880
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   881
    public static class JCWhileLoop extends JCStatement implements WhileLoopTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   882
        public JCExpression cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
   883
        public JCStatement body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   884
        protected JCWhileLoop(JCExpression cond, JCStatement body) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   885
            this.cond = cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
   886
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   887
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   888
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   889
        public void accept(Visitor v) { v.visitWhileLoop(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   890
06bc494ca11e Initial load
duke
parents:
diff changeset
   891
        public Kind getKind() { return Kind.WHILE_LOOP; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   892
        public JCExpression getCondition() { return cond; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   893
        public JCStatement getStatement() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   894
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   895
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   896
            return v.visitWhileLoop(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   897
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   898
06bc494ca11e Initial load
duke
parents:
diff changeset
   899
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   900
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   901
            return WHILELOOP;
06bc494ca11e Initial load
duke
parents:
diff changeset
   902
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   903
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   904
06bc494ca11e Initial load
duke
parents:
diff changeset
   905
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   906
     * A for loop.
06bc494ca11e Initial load
duke
parents:
diff changeset
   907
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   908
    public static class JCForLoop extends JCStatement implements ForLoopTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   909
        public List<JCStatement> init;
06bc494ca11e Initial load
duke
parents:
diff changeset
   910
        public JCExpression cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
   911
        public List<JCExpressionStatement> step;
06bc494ca11e Initial load
duke
parents:
diff changeset
   912
        public JCStatement body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   913
        protected JCForLoop(List<JCStatement> init,
06bc494ca11e Initial load
duke
parents:
diff changeset
   914
                          JCExpression cond,
06bc494ca11e Initial load
duke
parents:
diff changeset
   915
                          List<JCExpressionStatement> update,
06bc494ca11e Initial load
duke
parents:
diff changeset
   916
                          JCStatement body)
06bc494ca11e Initial load
duke
parents:
diff changeset
   917
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
   918
            this.init = init;
06bc494ca11e Initial load
duke
parents:
diff changeset
   919
            this.cond = cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
   920
            this.step = update;
06bc494ca11e Initial load
duke
parents:
diff changeset
   921
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   922
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   923
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   924
        public void accept(Visitor v) { v.visitForLoop(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   925
06bc494ca11e Initial load
duke
parents:
diff changeset
   926
        public Kind getKind() { return Kind.FOR_LOOP; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   927
        public JCExpression getCondition() { return cond; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   928
        public JCStatement getStatement() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   929
        public List<JCStatement> getInitializer() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   930
            return init;
06bc494ca11e Initial load
duke
parents:
diff changeset
   931
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   932
        public List<JCExpressionStatement> getUpdate() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   933
            return step;
06bc494ca11e Initial load
duke
parents:
diff changeset
   934
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   935
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   936
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   937
            return v.visitForLoop(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   938
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   939
06bc494ca11e Initial load
duke
parents:
diff changeset
   940
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   941
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   942
            return FORLOOP;
06bc494ca11e Initial load
duke
parents:
diff changeset
   943
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   944
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   945
06bc494ca11e Initial load
duke
parents:
diff changeset
   946
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   947
     * The enhanced for loop.
06bc494ca11e Initial load
duke
parents:
diff changeset
   948
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   949
    public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   950
        public JCVariableDecl var;
06bc494ca11e Initial load
duke
parents:
diff changeset
   951
        public JCExpression expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   952
        public JCStatement body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   953
        protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   954
            this.var = var;
06bc494ca11e Initial load
duke
parents:
diff changeset
   955
            this.expr = expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
   956
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   957
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   958
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   959
        public void accept(Visitor v) { v.visitForeachLoop(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   960
06bc494ca11e Initial load
duke
parents:
diff changeset
   961
        public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   962
        public JCVariableDecl getVariable() { return var; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   963
        public JCExpression getExpression() { return expr; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   964
        public JCStatement getStatement() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   965
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   966
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   967
            return v.visitEnhancedForLoop(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   968
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   969
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   970
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   971
            return FOREACHLOOP;
06bc494ca11e Initial load
duke
parents:
diff changeset
   972
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   973
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   974
06bc494ca11e Initial load
duke
parents:
diff changeset
   975
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   976
     * A labelled expression or statement.
06bc494ca11e Initial load
duke
parents:
diff changeset
   977
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   978
    public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
   979
        public Name label;
06bc494ca11e Initial load
duke
parents:
diff changeset
   980
        public JCStatement body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   981
        protected JCLabeledStatement(Name label, JCStatement body) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   982
            this.label = label;
06bc494ca11e Initial load
duke
parents:
diff changeset
   983
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
   984
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   985
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   986
        public void accept(Visitor v) { v.visitLabelled(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
   987
        public Kind getKind() { return Kind.LABELED_STATEMENT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   988
        public Name getLabel() { return label; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   989
        public JCStatement getStatement() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
   990
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   991
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   992
            return v.visitLabeledStatement(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
   993
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   994
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
   995
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   996
            return LABELLED;
06bc494ca11e Initial load
duke
parents:
diff changeset
   997
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   998
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   999
06bc494ca11e Initial load
duke
parents:
diff changeset
  1000
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1001
     * A "switch ( ) { }" construction.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1002
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1003
    public static class JCSwitch extends JCStatement implements SwitchTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1004
        public JCExpression selector;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1005
        public List<JCCase> cases;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1006
        protected JCSwitch(JCExpression selector, List<JCCase> cases) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1007
            this.selector = selector;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1008
            this.cases = cases;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1009
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1010
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1011
        public void accept(Visitor v) { v.visitSwitch(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1012
06bc494ca11e Initial load
duke
parents:
diff changeset
  1013
        public Kind getKind() { return Kind.SWITCH; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1014
        public JCExpression getExpression() { return selector; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1015
        public List<JCCase> getCases() { return cases; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1016
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1017
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1018
            return v.visitSwitch(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1019
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1020
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1021
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1022
            return SWITCH;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1023
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1024
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1025
06bc494ca11e Initial load
duke
parents:
diff changeset
  1026
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1027
     * A "case  :" of a switch.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1028
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1029
    public static class JCCase extends JCStatement implements CaseTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1030
        public JCExpression pat;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1031
        public List<JCStatement> stats;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1032
        protected JCCase(JCExpression pat, List<JCStatement> stats) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1033
            this.pat = pat;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1034
            this.stats = stats;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1035
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1036
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1037
        public void accept(Visitor v) { v.visitCase(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1038
06bc494ca11e Initial load
duke
parents:
diff changeset
  1039
        public Kind getKind() { return Kind.CASE; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1040
        public JCExpression getExpression() { return pat; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1041
        public List<JCStatement> getStatements() { return stats; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1042
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1043
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1044
            return v.visitCase(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1045
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1046
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1047
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1048
            return CASE;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1049
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1050
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1051
06bc494ca11e Initial load
duke
parents:
diff changeset
  1052
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1053
     * A synchronized block.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1054
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1055
    public static class JCSynchronized extends JCStatement implements SynchronizedTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1056
        public JCExpression lock;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1057
        public JCBlock body;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1058
        protected JCSynchronized(JCExpression lock, JCBlock body) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1059
            this.lock = lock;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1060
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1061
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1062
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1063
        public void accept(Visitor v) { v.visitSynchronized(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1064
06bc494ca11e Initial load
duke
parents:
diff changeset
  1065
        public Kind getKind() { return Kind.SYNCHRONIZED; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1066
        public JCExpression getExpression() { return lock; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1067
        public JCBlock getBlock() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1068
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1069
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1070
            return v.visitSynchronized(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1071
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1072
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1073
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1074
            return SYNCHRONIZED;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1075
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1076
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1077
06bc494ca11e Initial load
duke
parents:
diff changeset
  1078
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1079
     * A "try { } catch ( ) { } finally { }" block.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1080
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1081
    public static class JCTry extends JCStatement implements TryTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1082
        public JCBlock body;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1083
        public List<JCCatch> catchers;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1084
        public JCBlock finalizer;
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1085
        public List<JCTree> resources;
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1086
        protected JCTry(List<JCTree> resources,
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1087
                        JCBlock body,
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1088
                        List<JCCatch> catchers,
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1089
                        JCBlock finalizer) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1090
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1091
            this.catchers = catchers;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1092
            this.finalizer = finalizer;
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1093
            this.resources = resources;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1094
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1095
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1096
        public void accept(Visitor v) { v.visitTry(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1097
06bc494ca11e Initial load
duke
parents:
diff changeset
  1098
        public Kind getKind() { return Kind.TRY; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1099
        public JCBlock getBlock() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1100
        public List<JCCatch> getCatches() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1101
            return catchers;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1102
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1103
        public JCBlock getFinallyBlock() { return finalizer; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1104
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1105
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1106
            return v.visitTry(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1107
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1108
        @Override
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1109
        public List<? extends JCTree> getResources() {
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1110
            return resources;
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1111
        }
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  1112
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1113
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1114
            return TRY;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1115
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1116
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1117
06bc494ca11e Initial load
duke
parents:
diff changeset
  1118
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1119
     * A catch block.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1120
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1121
    public static class JCCatch extends JCTree implements CatchTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1122
        public JCVariableDecl param;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1123
        public JCBlock body;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1124
        protected JCCatch(JCVariableDecl param, JCBlock body) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1125
            this.param = param;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1126
            this.body = body;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1127
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1128
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1129
        public void accept(Visitor v) { v.visitCatch(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1130
06bc494ca11e Initial load
duke
parents:
diff changeset
  1131
        public Kind getKind() { return Kind.CATCH; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1132
        public JCVariableDecl getParameter() { return param; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1133
        public JCBlock getBlock() { return body; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1134
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1135
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1136
            return v.visitCatch(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1137
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1138
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1139
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1140
            return CATCH;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1141
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1142
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1143
06bc494ca11e Initial load
duke
parents:
diff changeset
  1144
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1145
     * A ( ) ? ( ) : ( ) conditional expression
06bc494ca11e Initial load
duke
parents:
diff changeset
  1146
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1147
    public static class JCConditional extends JCExpression implements ConditionalExpressionTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1148
        public JCExpression cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1149
        public JCExpression truepart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1150
        public JCExpression falsepart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1151
        protected JCConditional(JCExpression cond,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1152
                              JCExpression truepart,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1153
                              JCExpression falsepart)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1154
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1155
            this.cond = cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1156
            this.truepart = truepart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1157
            this.falsepart = falsepart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1158
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1159
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1160
        public void accept(Visitor v) { v.visitConditional(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1161
06bc494ca11e Initial load
duke
parents:
diff changeset
  1162
        public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1163
        public JCExpression getCondition() { return cond; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1164
        public JCExpression getTrueExpression() { return truepart; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1165
        public JCExpression getFalseExpression() { return falsepart; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1166
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1167
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1168
            return v.visitConditionalExpression(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1169
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1170
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1171
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1172
            return CONDEXPR;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1173
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1174
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1175
06bc494ca11e Initial load
duke
parents:
diff changeset
  1176
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1177
     * An "if ( ) { } else { }" block
06bc494ca11e Initial load
duke
parents:
diff changeset
  1178
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1179
    public static class JCIf extends JCStatement implements IfTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1180
        public JCExpression cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1181
        public JCStatement thenpart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1182
        public JCStatement elsepart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1183
        protected JCIf(JCExpression cond,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1184
                     JCStatement thenpart,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1185
                     JCStatement elsepart)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1186
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1187
            this.cond = cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1188
            this.thenpart = thenpart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1189
            this.elsepart = elsepart;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1190
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1191
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1192
        public void accept(Visitor v) { v.visitIf(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1193
06bc494ca11e Initial load
duke
parents:
diff changeset
  1194
        public Kind getKind() { return Kind.IF; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1195
        public JCExpression getCondition() { return cond; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1196
        public JCStatement getThenStatement() { return thenpart; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1197
        public JCStatement getElseStatement() { return elsepart; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1198
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1199
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1200
            return v.visitIf(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1201
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1202
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1203
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1204
            return IF;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1205
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1206
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1207
06bc494ca11e Initial load
duke
parents:
diff changeset
  1208
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1209
     * an expression statement
06bc494ca11e Initial load
duke
parents:
diff changeset
  1210
     * @param expr expression structure
06bc494ca11e Initial load
duke
parents:
diff changeset
  1211
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1212
    public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1213
        public JCExpression expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1214
        protected JCExpressionStatement(JCExpression expr)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1215
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1216
            this.expr = expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1217
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1218
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1219
        public void accept(Visitor v) { v.visitExec(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1220
06bc494ca11e Initial load
duke
parents:
diff changeset
  1221
        public Kind getKind() { return Kind.EXPRESSION_STATEMENT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1222
        public JCExpression getExpression() { return expr; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1223
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1224
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1225
            return v.visitExpressionStatement(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1226
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1227
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1228
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1229
            return EXEC;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1230
        }
10632
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1231
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1232
        /** Convert a expression-statement tree to a pretty-printed string. */
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1233
        @Override
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1234
        public String toString() {
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1235
            StringWriter s = new StringWriter();
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1236
            try {
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1237
                new Pretty(s, false).printStat(this);
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1238
            }
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1239
            catch (IOException e) {
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1240
                // should never happen, because StringWriter is defined
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1241
                // never to throw any IOExceptions
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1242
                throw new AssertionError(e);
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1243
            }
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1244
            return s.toString();
e6c5a7c372df 7090700: fix for 7080267 breaks two tests
jjg
parents: 10630
diff changeset
  1245
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1246
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1247
06bc494ca11e Initial load
duke
parents:
diff changeset
  1248
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1249
     * A break from a loop or switch.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1250
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1251
    public static class JCBreak extends JCStatement implements BreakTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1252
        public Name label;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1253
        public JCTree target;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1254
        protected JCBreak(Name label, JCTree target) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1255
            this.label = label;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1256
            this.target = target;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1257
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1258
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1259
        public void accept(Visitor v) { v.visitBreak(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1260
06bc494ca11e Initial load
duke
parents:
diff changeset
  1261
        public Kind getKind() { return Kind.BREAK; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1262
        public Name getLabel() { return label; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1263
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1264
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1265
            return v.visitBreak(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1266
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1267
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1268
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1269
            return BREAK;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1270
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1271
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1272
06bc494ca11e Initial load
duke
parents:
diff changeset
  1273
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1274
     * A continue of a loop.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1275
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1276
    public static class JCContinue extends JCStatement implements ContinueTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1277
        public Name label;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1278
        public JCTree target;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1279
        protected JCContinue(Name label, JCTree target) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1280
            this.label = label;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1281
            this.target = target;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1282
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1283
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1284
        public void accept(Visitor v) { v.visitContinue(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1285
06bc494ca11e Initial load
duke
parents:
diff changeset
  1286
        public Kind getKind() { return Kind.CONTINUE; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1287
        public Name getLabel() { return label; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1288
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1289
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1290
            return v.visitContinue(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1291
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1292
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1293
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1294
            return CONTINUE;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1295
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1296
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1297
06bc494ca11e Initial load
duke
parents:
diff changeset
  1298
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1299
     * A return statement.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1300
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1301
    public static class JCReturn extends JCStatement implements ReturnTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1302
        public JCExpression expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1303
        protected JCReturn(JCExpression expr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1304
            this.expr = expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1305
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1306
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1307
        public void accept(Visitor v) { v.visitReturn(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1308
06bc494ca11e Initial load
duke
parents:
diff changeset
  1309
        public Kind getKind() { return Kind.RETURN; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1310
        public JCExpression getExpression() { return expr; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1311
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1312
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1313
            return v.visitReturn(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1314
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1315
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1316
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1317
            return RETURN;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1318
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1319
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1320
06bc494ca11e Initial load
duke
parents:
diff changeset
  1321
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1322
     * A throw statement.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1323
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1324
    public static class JCThrow extends JCStatement implements ThrowTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1325
        public JCExpression expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1326
        protected JCThrow(JCTree expr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1327
            this.expr = (JCExpression)expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1328
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1329
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1330
        public void accept(Visitor v) { v.visitThrow(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1331
06bc494ca11e Initial load
duke
parents:
diff changeset
  1332
        public Kind getKind() { return Kind.THROW; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1333
        public JCExpression getExpression() { return expr; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1334
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1335
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1336
            return v.visitThrow(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1337
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1338
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1339
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1340
            return THROW;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1341
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1342
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1343
06bc494ca11e Initial load
duke
parents:
diff changeset
  1344
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1345
     * An assert statement.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1346
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1347
    public static class JCAssert extends JCStatement implements AssertTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1348
        public JCExpression cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1349
        public JCExpression detail;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1350
        protected JCAssert(JCExpression cond, JCExpression detail) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1351
            this.cond = cond;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1352
            this.detail = detail;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1353
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1354
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1355
        public void accept(Visitor v) { v.visitAssert(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1356
06bc494ca11e Initial load
duke
parents:
diff changeset
  1357
        public Kind getKind() { return Kind.ASSERT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1358
        public JCExpression getCondition() { return cond; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1359
        public JCExpression getDetail() { return detail; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1360
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1361
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1362
            return v.visitAssert(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1363
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1364
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1365
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1366
            return ASSERT;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1367
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1368
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1369
06bc494ca11e Initial load
duke
parents:
diff changeset
  1370
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1371
     * A method invocation
06bc494ca11e Initial load
duke
parents:
diff changeset
  1372
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1373
    public static class JCMethodInvocation extends JCExpression implements MethodInvocationTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1374
        public List<JCExpression> typeargs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1375
        public JCExpression meth;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1376
        public List<JCExpression> args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1377
        public Type varargsElement;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1378
        protected JCMethodInvocation(List<JCExpression> typeargs,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1379
                        JCExpression meth,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1380
                        List<JCExpression> args)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1381
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1382
            this.typeargs = (typeargs == null) ? List.<JCExpression>nil()
06bc494ca11e Initial load
duke
parents:
diff changeset
  1383
                                               : typeargs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1384
            this.meth = meth;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1385
            this.args = args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1386
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1387
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1388
        public void accept(Visitor v) { v.visitApply(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1389
06bc494ca11e Initial load
duke
parents:
diff changeset
  1390
        public Kind getKind() { return Kind.METHOD_INVOCATION; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1391
        public List<JCExpression> getTypeArguments() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1392
            return typeargs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1393
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1394
        public JCExpression getMethodSelect() { return meth; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1395
        public List<JCExpression> getArguments() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1396
            return args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1397
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1398
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1399
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1400
            return v.visitMethodInvocation(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1401
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1402
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1403
        public JCMethodInvocation setType(Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1404
            super.setType(type);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1405
            return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1406
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1407
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1408
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1409
            return(APPLY);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1410
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1411
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1412
06bc494ca11e Initial load
duke
parents:
diff changeset
  1413
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1414
     * A new(...) operation.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1415
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1416
    public static class JCNewClass extends JCExpression implements NewClassTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1417
        public JCExpression encl;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1418
        public List<JCExpression> typeargs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1419
        public JCExpression clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1420
        public List<JCExpression> args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1421
        public JCClassDecl def;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1422
        public Symbol constructor;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1423
        public Type varargsElement;
1791
d378f023c36d 6723444: javac fails to substitute type variables into a constructor's throws clause
mcimadamore
parents: 1264
diff changeset
  1424
        public Type constructorType;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1425
        protected JCNewClass(JCExpression encl,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1426
                           List<JCExpression> typeargs,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1427
                           JCExpression clazz,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1428
                           List<JCExpression> args,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1429
                           JCClassDecl def)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1430
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1431
            this.encl = encl;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1432
            this.typeargs = (typeargs == null) ? List.<JCExpression>nil()
06bc494ca11e Initial load
duke
parents:
diff changeset
  1433
                                               : typeargs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1434
            this.clazz = clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1435
            this.args = args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1436
            this.def = def;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1437
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1438
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1439
        public void accept(Visitor v) { v.visitNewClass(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1440
06bc494ca11e Initial load
duke
parents:
diff changeset
  1441
        public Kind getKind() { return Kind.NEW_CLASS; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1442
        public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
06bc494ca11e Initial load
duke
parents:
diff changeset
  1443
            return encl;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1444
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1445
        public List<JCExpression> getTypeArguments() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1446
            return typeargs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1447
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1448
        public JCExpression getIdentifier() { return clazz; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1449
        public List<JCExpression> getArguments() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1450
            return args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1451
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1452
        public JCClassDecl getClassBody() { return def; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1453
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1454
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1455
            return v.visitNewClass(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1456
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1457
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1458
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1459
            return NEWCLASS;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1460
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1461
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1462
06bc494ca11e Initial load
duke
parents:
diff changeset
  1463
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1464
     * A new[...] operation.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1465
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1466
    public static class JCNewArray extends JCExpression implements NewArrayTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1467
        public JCExpression elemtype;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1468
        public List<JCExpression> dims;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1469
        public List<JCExpression> elems;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1470
        protected JCNewArray(JCExpression elemtype,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1471
                           List<JCExpression> dims,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1472
                           List<JCExpression> elems)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1473
        {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1474
            this.elemtype = elemtype;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1475
            this.dims = dims;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1476
            this.elems = elems;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1477
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1478
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1479
        public void accept(Visitor v) { v.visitNewArray(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1480
06bc494ca11e Initial load
duke
parents:
diff changeset
  1481
        public Kind getKind() { return Kind.NEW_ARRAY; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1482
        public JCExpression getType() { return elemtype; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1483
        public List<JCExpression> getDimensions() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1484
            return dims;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1485
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1486
        public List<JCExpression> getInitializers() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1487
            return elems;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1488
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1489
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1490
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1491
            return v.visitNewArray(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1492
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1493
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1494
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1495
            return NEWARRAY;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1496
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1497
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1498
06bc494ca11e Initial load
duke
parents:
diff changeset
  1499
    /**
11141
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1500
     * A lambda expression.
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1501
     */
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1502
    public static class JCLambda extends JCExpression implements LambdaExpressionTree {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1503
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1504
        public List<JCVariableDecl> params;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1505
        public JCTree body;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1506
        public Type targetType;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1507
        public boolean canCompleteNormally = true;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1508
        public List<Type> inferredThrownTypes;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1509
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1510
        public JCLambda(List<JCVariableDecl> params,
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1511
                        JCTree body) {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1512
            this.params = params;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1513
            this.body = body;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1514
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1515
        @Override
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1516
        public Tag getTag() {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1517
            return LAMBDA;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1518
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1519
        @Override
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1520
        public void accept(Visitor v) {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1521
            v.visitLambda(this);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1522
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1523
        @Override
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1524
        public <R, D> R accept(TreeVisitor<R, D> v, D d) {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1525
            return v.visitLambdaExpression(this, d);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1526
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1527
        public Kind getKind() {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1528
            return Kind.LAMBDA_EXPRESSION;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1529
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1530
        public JCTree getBody() {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1531
            return body;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1532
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1533
        public java.util.List<? extends VariableTree> getParameters() {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1534
            return params;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1535
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1536
        @Override
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1537
        public JCLambda setType(Type type) {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1538
            super.setType(type);
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1539
            return this;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1540
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1541
        @Override
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1542
        public BodyKind getBodyKind() {
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1543
            return body.hasTag(BLOCK) ?
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1544
                    BodyKind.STATEMENT :
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1545
                    BodyKind.EXPRESSION;
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1546
        }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1547
    }
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1548
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  1549
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1550
     * A parenthesized subexpression ( ... )
06bc494ca11e Initial load
duke
parents:
diff changeset
  1551
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1552
    public static class JCParens extends JCExpression implements ParenthesizedTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1553
        public JCExpression expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1554
        protected JCParens(JCExpression expr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1555
            this.expr = expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1556
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1557
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1558
        public void accept(Visitor v) { v.visitParens(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1559
06bc494ca11e Initial load
duke
parents:
diff changeset
  1560
        public Kind getKind() { return Kind.PARENTHESIZED; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1561
        public JCExpression getExpression() { return expr; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1562
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1563
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1564
            return v.visitParenthesized(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1565
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1566
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1567
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1568
            return PARENS;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1569
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1570
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1571
06bc494ca11e Initial load
duke
parents:
diff changeset
  1572
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1573
     * A assignment with "=".
06bc494ca11e Initial load
duke
parents:
diff changeset
  1574
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1575
    public static class JCAssign extends JCExpression implements AssignmentTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1576
        public JCExpression lhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1577
        public JCExpression rhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1578
        protected JCAssign(JCExpression lhs, JCExpression rhs) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1579
            this.lhs = lhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1580
            this.rhs = rhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1581
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1582
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1583
        public void accept(Visitor v) { v.visitAssign(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1584
06bc494ca11e Initial load
duke
parents:
diff changeset
  1585
        public Kind getKind() { return Kind.ASSIGNMENT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1586
        public JCExpression getVariable() { return lhs; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1587
        public JCExpression getExpression() { return rhs; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1588
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1589
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1590
            return v.visitAssignment(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1591
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1592
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1593
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1594
            return ASSIGN;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1595
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1596
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1597
06bc494ca11e Initial load
duke
parents:
diff changeset
  1598
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1599
     * An assignment with "+=", "|=" ...
06bc494ca11e Initial load
duke
parents:
diff changeset
  1600
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1601
    public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree {
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1602
        private Tag opcode;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1603
        public JCExpression lhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1604
        public JCExpression rhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1605
        public Symbol operator;
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1606
        protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1607
            this.opcode = opcode;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1608
            this.lhs = (JCExpression)lhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1609
            this.rhs = (JCExpression)rhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1610
            this.operator = operator;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1611
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1612
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1613
        public void accept(Visitor v) { v.visitAssignop(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1614
06bc494ca11e Initial load
duke
parents:
diff changeset
  1615
        public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1616
        public JCExpression getVariable() { return lhs; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1617
        public JCExpression getExpression() { return rhs; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1618
        public Symbol getOperator() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1619
            return operator;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1620
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1621
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1622
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1623
            return v.visitCompoundAssignment(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1624
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1625
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1626
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1627
            return opcode;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1628
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1629
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1630
06bc494ca11e Initial load
duke
parents:
diff changeset
  1631
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1632
     * A unary operation.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1633
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1634
    public static class JCUnary extends JCExpression implements UnaryTree {
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1635
        private Tag opcode;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1636
        public JCExpression arg;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1637
        public Symbol operator;
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1638
        protected JCUnary(Tag opcode, JCExpression arg) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1639
            this.opcode = opcode;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1640
            this.arg = arg;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1641
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1642
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1643
        public void accept(Visitor v) { v.visitUnary(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1644
06bc494ca11e Initial load
duke
parents:
diff changeset
  1645
        public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1646
        public JCExpression getExpression() { return arg; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1647
        public Symbol getOperator() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1648
            return operator;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1649
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1650
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1651
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1652
            return v.visitUnary(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1653
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1654
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1655
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1656
            return opcode;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1657
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1658
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1659
        public void setTag(Tag tag) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1660
            opcode = tag;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1661
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1662
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1663
06bc494ca11e Initial load
duke
parents:
diff changeset
  1664
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1665
     * A binary operation.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1666
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1667
    public static class JCBinary extends JCExpression implements BinaryTree {
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1668
        private Tag opcode;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1669
        public JCExpression lhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1670
        public JCExpression rhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1671
        public Symbol operator;
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1672
        protected JCBinary(Tag opcode,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1673
                         JCExpression lhs,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1674
                         JCExpression rhs,
06bc494ca11e Initial load
duke
parents:
diff changeset
  1675
                         Symbol operator) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1676
            this.opcode = opcode;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1677
            this.lhs = lhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1678
            this.rhs = rhs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1679
            this.operator = operator;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1680
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1681
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1682
        public void accept(Visitor v) { v.visitBinary(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1683
06bc494ca11e Initial load
duke
parents:
diff changeset
  1684
        public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1685
        public JCExpression getLeftOperand() { return lhs; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1686
        public JCExpression getRightOperand() { return rhs; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1687
        public Symbol getOperator() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1688
            return operator;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1689
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1690
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1691
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1692
            return v.visitBinary(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1693
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1694
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1695
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1696
            return opcode;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1697
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1698
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1699
06bc494ca11e Initial load
duke
parents:
diff changeset
  1700
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1701
     * A type cast.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1702
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1703
    public static class JCTypeCast extends JCExpression implements TypeCastTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1704
        public JCTree clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1705
        public JCExpression expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1706
        protected JCTypeCast(JCTree clazz, JCExpression expr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1707
            this.clazz = clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1708
            this.expr = expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1709
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1710
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1711
        public void accept(Visitor v) { v.visitTypeCast(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1712
06bc494ca11e Initial load
duke
parents:
diff changeset
  1713
        public Kind getKind() { return Kind.TYPE_CAST; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1714
        public JCTree getType() { return clazz; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1715
        public JCExpression getExpression() { return expr; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1716
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1717
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1718
            return v.visitTypeCast(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1719
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1720
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1721
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1722
            return TYPECAST;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1723
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1724
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1725
06bc494ca11e Initial load
duke
parents:
diff changeset
  1726
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1727
     * A type test.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1728
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1729
    public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1730
        public JCExpression expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1731
        public JCTree clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1732
        protected JCInstanceOf(JCExpression expr, JCTree clazz) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1733
            this.expr = expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1734
            this.clazz = clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1735
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1736
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1737
        public void accept(Visitor v) { v.visitTypeTest(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1738
06bc494ca11e Initial load
duke
parents:
diff changeset
  1739
        public Kind getKind() { return Kind.INSTANCE_OF; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1740
        public JCTree getType() { return clazz; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1741
        public JCExpression getExpression() { return expr; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1742
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1743
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1744
            return v.visitInstanceOf(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1745
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1746
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1747
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1748
            return TYPETEST;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1749
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1750
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1751
06bc494ca11e Initial load
duke
parents:
diff changeset
  1752
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1753
     * An array selection
06bc494ca11e Initial load
duke
parents:
diff changeset
  1754
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1755
    public static class JCArrayAccess extends JCExpression implements ArrayAccessTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1756
        public JCExpression indexed;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1757
        public JCExpression index;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1758
        protected JCArrayAccess(JCExpression indexed, JCExpression index) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1759
            this.indexed = indexed;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1760
            this.index = index;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1761
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1762
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1763
        public void accept(Visitor v) { v.visitIndexed(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1764
06bc494ca11e Initial load
duke
parents:
diff changeset
  1765
        public Kind getKind() { return Kind.ARRAY_ACCESS; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1766
        public JCExpression getExpression() { return indexed; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1767
        public JCExpression getIndex() { return index; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1768
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1769
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1770
            return v.visitArrayAccess(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1771
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1772
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1773
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1774
            return INDEXED;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1775
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1776
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1777
06bc494ca11e Initial load
duke
parents:
diff changeset
  1778
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1779
     * Selects through packages and classes
06bc494ca11e Initial load
duke
parents:
diff changeset
  1780
     * @param selected selected Tree hierarchie
06bc494ca11e Initial load
duke
parents:
diff changeset
  1781
     * @param selector name of field to select thru
06bc494ca11e Initial load
duke
parents:
diff changeset
  1782
     * @param sym symbol of the selected class
06bc494ca11e Initial load
duke
parents:
diff changeset
  1783
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1784
    public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1785
        public JCExpression selected;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1786
        public Name name;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1787
        public Symbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1788
        protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1789
            this.selected = selected;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1790
            this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1791
            this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1792
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1793
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1794
        public void accept(Visitor v) { v.visitSelect(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1795
06bc494ca11e Initial load
duke
parents:
diff changeset
  1796
        public Kind getKind() { return Kind.MEMBER_SELECT; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1797
        public JCExpression getExpression() { return selected; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1798
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1799
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1800
            return v.visitMemberSelect(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1801
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1802
        public Name getIdentifier() { return name; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1803
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1804
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1805
            return SELECT;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1806
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1807
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1808
06bc494ca11e Initial load
duke
parents:
diff changeset
  1809
    /**
11142
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1810
     * Selects a member expression.
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1811
     */
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1812
    public static class JCMemberReference extends JCExpression implements MemberReferenceTree {
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1813
        public ReferenceMode mode;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1814
        public Name name;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1815
        public JCExpression expr;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1816
        public List<JCExpression> typeargs;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1817
        public Type targetType;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1818
        public Symbol sym;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1819
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1820
        protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1821
            this.mode = mode;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1822
            this.name = name;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1823
            this.expr = expr;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1824
            this.typeargs = typeargs;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1825
        }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1826
        @Override
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1827
        public void accept(Visitor v) { v.visitReference(this); }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1828
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1829
        public Kind getKind() { return Kind.MEMBER_REFERENCE; }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1830
        @Override
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1831
        public ReferenceMode getMode() { return mode; }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1832
        @Override
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1833
        public JCExpression getQualifierExpression() { return expr; }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1834
        @Override
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1835
        public Name getName() { return name; }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1836
        @Override
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1837
        public List<JCExpression> getTypeArguments() { return typeargs; }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1838
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1839
        @Override
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1840
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1841
            return v.visitMemberReference(this, d);
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1842
        }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1843
        @Override
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1844
        public Tag getTag() {
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1845
            return REFERENCE;
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1846
        }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1847
    }
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1848
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  1849
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1850
     * An identifier
06bc494ca11e Initial load
duke
parents:
diff changeset
  1851
     * @param idname the name
06bc494ca11e Initial load
duke
parents:
diff changeset
  1852
     * @param sym the symbol
06bc494ca11e Initial load
duke
parents:
diff changeset
  1853
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1854
    public static class JCIdent extends JCExpression implements IdentifierTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1855
        public Name name;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1856
        public Symbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1857
        protected JCIdent(Name name, Symbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1858
            this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1859
            this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1860
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1861
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1862
        public void accept(Visitor v) { v.visitIdent(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1863
06bc494ca11e Initial load
duke
parents:
diff changeset
  1864
        public Kind getKind() { return Kind.IDENTIFIER; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1865
        public Name getName() { return name; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1866
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1867
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1868
            return v.visitIdentifier(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1869
        }
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1870
        @Override
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1871
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1872
            return IDENT;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1873
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1874
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1875
06bc494ca11e Initial load
duke
parents:
diff changeset
  1876
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1877
     * A constant value given literally.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1878
     * @param value value representation
06bc494ca11e Initial load
duke
parents:
diff changeset
  1879
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1880
    public static class JCLiteral extends JCExpression implements LiteralTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1881
        public int typetag;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1882
        public Object value;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1883
        protected JCLiteral(int typetag, Object value) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1884
            this.typetag = typetag;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1885
            this.value = value;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1886
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1887
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1888
        public void accept(Visitor v) { v.visitLiteral(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1889
06bc494ca11e Initial load
duke
parents:
diff changeset
  1890
        public Kind getKind() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1891
            switch (typetag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1892
            case TypeTags.INT:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1893
                return Kind.INT_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1894
            case TypeTags.LONG:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1895
                return Kind.LONG_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1896
            case TypeTags.FLOAT:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1897
                return Kind.FLOAT_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1898
            case TypeTags.DOUBLE:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1899
                return Kind.DOUBLE_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1900
            case TypeTags.BOOLEAN:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1901
                return Kind.BOOLEAN_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1902
            case TypeTags.CHAR:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1903
                return Kind.CHAR_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1904
            case TypeTags.CLASS:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1905
                return Kind.STRING_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1906
            case TypeTags.BOT:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1907
                return Kind.NULL_LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1908
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1909
                throw new AssertionError("unknown literal kind " + this);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1910
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1911
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1912
        public Object getValue() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1913
            switch (typetag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1914
                case TypeTags.BOOLEAN:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1915
                    int bi = (Integer) value;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1916
                    return (bi != 0);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1917
                case TypeTags.CHAR:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1918
                    int ci = (Integer) value;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1919
                    char c = (char) ci;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1920
                    if (c != ci)
06bc494ca11e Initial load
duke
parents:
diff changeset
  1921
                        throw new AssertionError("bad value for char literal");
06bc494ca11e Initial load
duke
parents:
diff changeset
  1922
                    return c;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1923
                default:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1924
                    return value;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1925
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1926
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1927
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1928
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1929
            return v.visitLiteral(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1930
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1931
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1932
        public JCLiteral setType(Type type) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1933
            super.setType(type);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1934
            return this;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1935
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1936
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1937
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1938
            return LITERAL;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1939
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1940
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1941
06bc494ca11e Initial load
duke
parents:
diff changeset
  1942
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1943
     * Identifies a basic type.
06bc494ca11e Initial load
duke
parents:
diff changeset
  1944
     * @param tag the basic type id
06bc494ca11e Initial load
duke
parents:
diff changeset
  1945
     * @see TypeTags
06bc494ca11e Initial load
duke
parents:
diff changeset
  1946
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1947
    public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1948
        public int typetag;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1949
        protected JCPrimitiveTypeTree(int typetag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1950
            this.typetag = typetag;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1951
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1952
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1953
        public void accept(Visitor v) { v.visitTypeIdent(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1954
06bc494ca11e Initial load
duke
parents:
diff changeset
  1955
        public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1956
        public TypeKind getPrimitiveTypeKind() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1957
            switch (typetag) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1958
            case TypeTags.BOOLEAN:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1959
                return TypeKind.BOOLEAN;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1960
            case TypeTags.BYTE:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1961
                return TypeKind.BYTE;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1962
            case TypeTags.SHORT:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1963
                return TypeKind.SHORT;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1964
            case TypeTags.INT:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1965
                return TypeKind.INT;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1966
            case TypeTags.LONG:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1967
                return TypeKind.LONG;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1968
            case TypeTags.CHAR:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1969
                return TypeKind.CHAR;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1970
            case TypeTags.FLOAT:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1971
                return TypeKind.FLOAT;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1972
            case TypeTags.DOUBLE:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1973
                return TypeKind.DOUBLE;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1974
            case TypeTags.VOID:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1975
                return TypeKind.VOID;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1976
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
  1977
                throw new AssertionError("unknown primitive type " + this);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1978
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1979
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1980
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1981
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1982
            return v.visitPrimitiveType(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  1983
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1984
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  1985
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  1986
            return TYPEIDENT;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1987
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1988
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1989
06bc494ca11e Initial load
duke
parents:
diff changeset
  1990
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  1991
     * An array type, A[]
06bc494ca11e Initial load
duke
parents:
diff changeset
  1992
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  1993
    public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1994
        public JCExpression elemtype;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1995
        protected JCArrayTypeTree(JCExpression elemtype) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  1996
            this.elemtype = elemtype;
06bc494ca11e Initial load
duke
parents:
diff changeset
  1997
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  1998
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  1999
        public void accept(Visitor v) { v.visitTypeArray(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2000
06bc494ca11e Initial load
duke
parents:
diff changeset
  2001
        public Kind getKind() { return Kind.ARRAY_TYPE; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2002
        public JCTree getType() { return elemtype; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2003
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2004
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2005
            return v.visitArrayType(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2006
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2007
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2008
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2009
            return TYPEARRAY;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2010
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2011
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2012
06bc494ca11e Initial load
duke
parents:
diff changeset
  2013
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
  2014
     * A parameterized type, T<...>
06bc494ca11e Initial load
duke
parents:
diff changeset
  2015
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  2016
    public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2017
        public JCExpression clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2018
        public List<JCExpression> arguments;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2019
        protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2020
            this.clazz = clazz;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2021
            this.arguments = arguments;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2022
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2023
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2024
        public void accept(Visitor v) { v.visitTypeApply(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2025
06bc494ca11e Initial load
duke
parents:
diff changeset
  2026
        public Kind getKind() { return Kind.PARAMETERIZED_TYPE; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2027
        public JCTree getType() { return clazz; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2028
        public List<JCExpression> getTypeArguments() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2029
            return arguments;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2030
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2031
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2032
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2033
            return v.visitParameterizedType(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2034
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2035
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2036
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2037
            return TYPEAPPLY;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2038
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2039
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2040
06bc494ca11e Initial load
duke
parents:
diff changeset
  2041
    /**
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2042
     * A union type, T1 | T2 | ... Tn (used in multicatch statements)
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2043
     */
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2044
    public static class JCTypeUnion extends JCExpression implements UnionTypeTree {
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2045
7074
0183c3f9614e 6949587: rename "DisjointType" to "DisjunctType"
jjg
parents: 7072
diff changeset
  2046
        public List<JCExpression> alternatives;
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2047
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2048
        protected JCTypeUnion(List<JCExpression> components) {
7074
0183c3f9614e 6949587: rename "DisjointType" to "DisjunctType"
jjg
parents: 7072
diff changeset
  2049
            this.alternatives = components;
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2050
        }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2051
        @Override
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2052
        public void accept(Visitor v) { v.visitTypeUnion(this); }
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2053
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2054
        public Kind getKind() { return Kind.UNION_TYPE; }
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2055
7074
0183c3f9614e 6949587: rename "DisjointType" to "DisjunctType"
jjg
parents: 7072
diff changeset
  2056
        public List<JCExpression> getTypeAlternatives() {
0183c3f9614e 6949587: rename "DisjointType" to "DisjunctType"
jjg
parents: 7072
diff changeset
  2057
            return alternatives;
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2058
        }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2059
        @Override
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2060
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2061
            return v.visitUnionType(this, d);
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2062
        }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2063
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2064
        public Tag getTag() {
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2065
            return TYPEUNION;
5492
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2066
        }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2067
    }
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2068
515e4b33b335 6943289: Project Coin: Improved Exception Handling for Java (aka 'multicatch')
mcimadamore
parents: 3149
diff changeset
  2069
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2070
     * A formal class parameter.
06bc494ca11e Initial load
duke
parents:
diff changeset
  2071
     * @param name name
06bc494ca11e Initial load
duke
parents:
diff changeset
  2072
     * @param bounds bounds
06bc494ca11e Initial load
duke
parents:
diff changeset
  2073
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  2074
    public static class JCTypeParameter extends JCTree implements TypeParameterTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2075
        public Name name;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2076
        public List<JCExpression> bounds;
8031
d5fe2c1cecfc 6992999: fully remove JSR 308 from langtools
jjg
parents: 7681
diff changeset
  2077
        protected JCTypeParameter(Name name, List<JCExpression> bounds) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2078
            this.name = name;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2079
            this.bounds = bounds;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2080
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2081
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2082
        public void accept(Visitor v) { v.visitTypeParameter(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2083
06bc494ca11e Initial load
duke
parents:
diff changeset
  2084
        public Kind getKind() { return Kind.TYPE_PARAMETER; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2085
        public Name getName() { return name; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2086
        public List<JCExpression> getBounds() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2087
            return bounds;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2088
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2089
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2090
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2091
            return v.visitTypeParameter(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2092
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2093
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2094
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2095
            return TYPEPARAMETER;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2096
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2097
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2098
06bc494ca11e Initial load
duke
parents:
diff changeset
  2099
    public static class JCWildcard extends JCExpression implements WildcardTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2100
        public TypeBoundKind kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2101
        public JCTree inner;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2102
        protected JCWildcard(TypeBoundKind kind, JCTree inner) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2103
            kind.getClass(); // null-check
06bc494ca11e Initial load
duke
parents:
diff changeset
  2104
            this.kind = kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2105
            this.inner = inner;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2106
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2107
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2108
        public void accept(Visitor v) { v.visitWildcard(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2109
06bc494ca11e Initial load
duke
parents:
diff changeset
  2110
        public Kind getKind() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2111
            switch (kind.kind) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2112
            case UNBOUND:
06bc494ca11e Initial load
duke
parents:
diff changeset
  2113
                return Kind.UNBOUNDED_WILDCARD;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2114
            case EXTENDS:
06bc494ca11e Initial load
duke
parents:
diff changeset
  2115
                return Kind.EXTENDS_WILDCARD;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2116
            case SUPER:
06bc494ca11e Initial load
duke
parents:
diff changeset
  2117
                return Kind.SUPER_WILDCARD;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2118
            default:
06bc494ca11e Initial load
duke
parents:
diff changeset
  2119
                throw new AssertionError("Unknown wildcard bound " + kind);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2120
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2121
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2122
        public JCTree getBound() { return inner; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2123
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2124
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2125
            return v.visitWildcard(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2126
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2127
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2128
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2129
            return WILDCARD;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2130
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2131
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2132
06bc494ca11e Initial load
duke
parents:
diff changeset
  2133
    public static class TypeBoundKind extends JCTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2134
        public BoundKind kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2135
        protected TypeBoundKind(BoundKind kind) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2136
            this.kind = kind;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2137
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2138
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2139
        public void accept(Visitor v) { v.visitTypeBoundKind(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2140
06bc494ca11e Initial load
duke
parents:
diff changeset
  2141
        public Kind getKind() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2142
            throw new AssertionError("TypeBoundKind is not part of a public API");
06bc494ca11e Initial load
duke
parents:
diff changeset
  2143
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2144
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2145
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2146
            throw new AssertionError("TypeBoundKind is not part of a public API");
06bc494ca11e Initial load
duke
parents:
diff changeset
  2147
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2148
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2149
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2150
            return TYPEBOUNDKIND;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2151
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2152
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2153
06bc494ca11e Initial load
duke
parents:
diff changeset
  2154
    public static class JCAnnotation extends JCExpression implements AnnotationTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2155
        public JCTree annotationType;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2156
        public List<JCExpression> args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2157
        protected JCAnnotation(JCTree annotationType, List<JCExpression> args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2158
            this.annotationType = annotationType;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2159
            this.args = args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2160
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2161
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2162
        public void accept(Visitor v) { v.visitAnnotation(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2163
06bc494ca11e Initial load
duke
parents:
diff changeset
  2164
        public Kind getKind() { return Kind.ANNOTATION; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2165
        public JCTree getAnnotationType() { return annotationType; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2166
        public List<JCExpression> getArguments() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2167
            return args;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2168
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2169
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2170
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2171
            return v.visitAnnotation(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2172
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2173
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2174
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2175
            return ANNOTATION;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2176
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2177
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2178
06bc494ca11e Initial load
duke
parents:
diff changeset
  2179
    public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2180
        public long flags;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2181
        public List<JCAnnotation> annotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2182
        protected JCModifiers(long flags, List<JCAnnotation> annotations) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2183
            this.flags = flags;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2184
            this.annotations = annotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2185
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2186
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2187
        public void accept(Visitor v) { v.visitModifiers(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2188
06bc494ca11e Initial load
duke
parents:
diff changeset
  2189
        public Kind getKind() { return Kind.MODIFIERS; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2190
        public Set<Modifier> getFlags() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2191
            return Flags.asModifierSet(flags);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2192
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2193
        public List<JCAnnotation> getAnnotations() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2194
            return annotations;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2195
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2196
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2197
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2198
            return v.visitModifiers(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2199
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2200
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2201
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2202
            return MODIFIERS;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2203
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2204
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2205
06bc494ca11e Initial load
duke
parents:
diff changeset
  2206
    public static class JCErroneous extends JCExpression
06bc494ca11e Initial load
duke
parents:
diff changeset
  2207
            implements com.sun.source.tree.ErroneousTree {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2208
        public List<? extends JCTree> errs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2209
        protected JCErroneous(List<? extends JCTree> errs) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2210
            this.errs = errs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2211
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2212
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2213
        public void accept(Visitor v) { v.visitErroneous(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2214
06bc494ca11e Initial load
duke
parents:
diff changeset
  2215
        public Kind getKind() { return Kind.ERRONEOUS; }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2216
06bc494ca11e Initial load
duke
parents:
diff changeset
  2217
        public List<? extends JCTree> getErrorTrees() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2218
            return errs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2219
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2220
06bc494ca11e Initial load
duke
parents:
diff changeset
  2221
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2222
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2223
            return v.visitErroneous(this, d);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2224
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2225
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2226
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2227
            return ERRONEOUS;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2228
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2230
06bc494ca11e Initial load
duke
parents:
diff changeset
  2231
    /** (let int x = 3; in x+2) */
06bc494ca11e Initial load
duke
parents:
diff changeset
  2232
    public static class LetExpr extends JCExpression {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2233
        public List<JCVariableDecl> defs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2234
        public JCTree expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2235
        protected LetExpr(List<JCVariableDecl> defs, JCTree expr) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2236
            this.defs = defs;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2237
            this.expr = expr;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2238
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2239
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2240
        public void accept(Visitor v) { v.visitLetExpr(this); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2241
06bc494ca11e Initial load
duke
parents:
diff changeset
  2242
        public Kind getKind() {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2243
            throw new AssertionError("LetExpr is not part of a public API");
06bc494ca11e Initial load
duke
parents:
diff changeset
  2244
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2245
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
  2246
        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2247
            throw new AssertionError("LetExpr is not part of a public API");
06bc494ca11e Initial load
duke
parents:
diff changeset
  2248
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2249
        @Override
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2250
        public Tag getTag() {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2251
            return LETEXPR;
06bc494ca11e Initial load
duke
parents:
diff changeset
  2252
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2253
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2254
06bc494ca11e Initial load
duke
parents:
diff changeset
  2255
    /** An interface for tree factories
06bc494ca11e Initial load
duke
parents:
diff changeset
  2256
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  2257
    public interface Factory {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2258
        JCCompilationUnit TopLevel(List<JCAnnotation> packageAnnotations,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2259
                                   JCExpression pid,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2260
                                   List<JCTree> defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2261
        JCImport Import(JCTree qualid, boolean staticImport);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2262
        JCClassDecl ClassDef(JCModifiers mods,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2263
                          Name name,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2264
                          List<JCTypeParameter> typarams,
8625
6b51ef804d49 6639645: Modeling type implementing missing interfaces
jjg
parents: 8221
diff changeset
  2265
                          JCExpression extending,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2266
                          List<JCExpression> implementing,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2267
                          List<JCTree> defs);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2268
        JCMethodDecl MethodDef(JCModifiers mods,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2269
                            Name name,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2270
                            JCExpression restype,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2271
                            List<JCTypeParameter> typarams,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2272
                            List<JCVariableDecl> params,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2273
                            List<JCExpression> thrown,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2274
                            JCBlock body,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2275
                            JCExpression defaultValue);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2276
        JCVariableDecl VarDef(JCModifiers mods,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2277
                      Name name,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2278
                      JCExpression vartype,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2279
                      JCExpression init);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2280
        JCSkip Skip();
06bc494ca11e Initial load
duke
parents:
diff changeset
  2281
        JCBlock Block(long flags, List<JCStatement> stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2282
        JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2283
        JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2284
        JCForLoop ForLoop(List<JCStatement> init,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2285
                        JCExpression cond,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2286
                        List<JCExpressionStatement> step,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2287
                        JCStatement body);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2288
        JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2289
        JCLabeledStatement Labelled(Name label, JCStatement body);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2290
        JCSwitch Switch(JCExpression selector, List<JCCase> cases);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2291
        JCCase Case(JCExpression pat, List<JCStatement> stats);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2292
        JCSynchronized Synchronized(JCExpression lock, JCBlock body);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2293
        JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
6148
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  2294
        JCTry Try(List<JCTree> resources,
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  2295
                  JCBlock body,
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  2296
                  List<JCCatch> catchers,
3a8158299c51 6911256: Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
darcy
parents: 5847
diff changeset
  2297
                  JCBlock finalizer);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2298
        JCCatch Catch(JCVariableDecl param, JCBlock body);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2299
        JCConditional Conditional(JCExpression cond,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2300
                                JCExpression thenpart,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2301
                                JCExpression elsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2302
        JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2303
        JCExpressionStatement Exec(JCExpression expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2304
        JCBreak Break(Name label);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2305
        JCContinue Continue(Name label);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2306
        JCReturn Return(JCExpression expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2307
        JCThrow Throw(JCTree expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2308
        JCAssert Assert(JCExpression cond, JCExpression detail);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2309
        JCMethodInvocation Apply(List<JCExpression> typeargs,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2310
                    JCExpression fn,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2311
                    List<JCExpression> args);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2312
        JCNewClass NewClass(JCExpression encl,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2313
                          List<JCExpression> typeargs,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2314
                          JCExpression clazz,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2315
                          List<JCExpression> args,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2316
                          JCClassDecl def);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2317
        JCNewArray NewArray(JCExpression elemtype,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2318
                          List<JCExpression> dims,
06bc494ca11e Initial load
duke
parents:
diff changeset
  2319
                          List<JCExpression> elems);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2320
        JCParens Parens(JCExpression expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2321
        JCAssign Assign(JCExpression lhs, JCExpression rhs);
10950
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2322
        JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2323
        JCUnary Unary(Tag opcode, JCExpression arg);
e87b50888909 6921494: provide way to print javac tree tag values
jjg
parents: 10636
diff changeset
  2324
        JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2325
        JCTypeCast TypeCast(JCTree expr, JCExpression type);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2326
        JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2327
        JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2328
        JCFieldAccess Select(JCExpression selected, Name selector);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2329
        JCIdent Ident(Name idname);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2330
        JCLiteral Literal(int tag, Object value);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2331
        JCPrimitiveTypeTree TypeIdent(int typetag);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2332
        JCArrayTypeTree TypeArray(JCExpression elemtype);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2333
        JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2334
        JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2335
        JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2336
        TypeBoundKind TypeBoundKind(BoundKind kind);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2337
        JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2338
        JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2339
        JCErroneous Erroneous(List<? extends JCTree> errs);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2340
        LetExpr LetExpr(List<JCVariableDecl> defs, JCTree expr);
06bc494ca11e Initial load
duke
parents:
diff changeset
  2341
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2342
06bc494ca11e Initial load
duke
parents:
diff changeset
  2343
    /** A generic visitor class for trees.
06bc494ca11e Initial load
duke
parents:
diff changeset
  2344
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
  2345
    public static abstract class Visitor {
06bc494ca11e Initial load
duke
parents:
diff changeset
  2346
        public void visitTopLevel(JCCompilationUnit that)    { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2347
        public void visitImport(JCImport that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2348
        public void visitClassDef(JCClassDecl that)          { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2349
        public void visitMethodDef(JCMethodDecl that)        { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2350
        public void visitVarDef(JCVariableDecl that)         { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2351
        public void visitSkip(JCSkip that)                   { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2352
        public void visitBlock(JCBlock that)                 { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2353
        public void visitDoLoop(JCDoWhileLoop that)          { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2354
        public void visitWhileLoop(JCWhileLoop that)         { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2355
        public void visitForLoop(JCForLoop that)             { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2356
        public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2357
        public void visitLabelled(JCLabeledStatement that)   { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2358
        public void visitSwitch(JCSwitch that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2359
        public void visitCase(JCCase that)                   { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2360
        public void visitSynchronized(JCSynchronized that)   { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2361
        public void visitTry(JCTry that)                     { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2362
        public void visitCatch(JCCatch that)                 { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2363
        public void visitConditional(JCConditional that)     { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2364
        public void visitIf(JCIf that)                       { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2365
        public void visitExec(JCExpressionStatement that)    { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2366
        public void visitBreak(JCBreak that)                 { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2367
        public void visitContinue(JCContinue that)           { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2368
        public void visitReturn(JCReturn that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2369
        public void visitThrow(JCThrow that)                 { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2370
        public void visitAssert(JCAssert that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2371
        public void visitApply(JCMethodInvocation that)      { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2372
        public void visitNewClass(JCNewClass that)           { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2373
        public void visitNewArray(JCNewArray that)           { visitTree(that); }
11141
7d112a1ecd0f 7115046: Add AST node for lambda expressions
mcimadamore
parents: 11055
diff changeset
  2374
        public void visitLambda(JCLambda that)               { visitTree(that); }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2375
        public void visitParens(JCParens that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2376
        public void visitAssign(JCAssign that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2377
        public void visitAssignop(JCAssignOp that)           { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2378
        public void visitUnary(JCUnary that)                 { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2379
        public void visitBinary(JCBinary that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2380
        public void visitTypeCast(JCTypeCast that)           { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2381
        public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2382
        public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2383
        public void visitSelect(JCFieldAccess that)          { visitTree(that); }
11142
45d0ec1e7463 7115049: Add AST node for method references
mcimadamore
parents: 11141
diff changeset
  2384
        public void visitReference(JCMemberReference that)   { visitTree(that); }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2385
        public void visitIdent(JCIdent that)                 { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2386
        public void visitLiteral(JCLiteral that)             { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2387
        public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2388
        public void visitTypeArray(JCArrayTypeTree that)     { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2389
        public void visitTypeApply(JCTypeApply that)         { visitTree(that); }
9300
c2de4dd9853b 7033809: Rename "disjunctive" to "union" in javax.lang.model
darcy
parents: 8625
diff changeset
  2390
        public void visitTypeUnion(JCTypeUnion that)         { visitTree(that); }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2391
        public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2392
        public void visitWildcard(JCWildcard that)           { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2393
        public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2394
        public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2395
        public void visitModifiers(JCModifiers that)         { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2396
        public void visitErroneous(JCErroneous that)         { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2397
        public void visitLetExpr(LetExpr that)               { visitTree(that); }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2398
8032
e1aa25ccdabb 6396503: javac should not require assertions enabled
jjg
parents: 8031
diff changeset
  2399
        public void visitTree(JCTree that)                   { Assert.error(); }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
  2400
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
  2401
06bc494ca11e Initial load
duke
parents:
diff changeset
  2402
}