langtools/src/share/classes/com/sun/tools/javac/code/TypeTag.java
author vromero
Mon, 10 Dec 2012 16:21:26 +0000
changeset 14801 d66cab4ef397
parent 14366 af625e568667
child 18395 d56a5fbf0b32
permissions -rw-r--r--
8003967: detect and remove all mutable implicit static enum fields in langtools Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
14259
fb94a1df0d53 8000208: fix langtools javadoc comment issues
jjg
parents: 14057
diff changeset
     2
 * Copyright (c) 1999, 2012, 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: 10
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: 10
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: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
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.code;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    28
import com.sun.source.tree.Tree.Kind;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    29
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    30
import javax.lang.model.type.TypeKind;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
/** An interface for type tag values, which distinguish between different
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 *  sorts of types.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    35
 *  <p><b>This is NOT part of any supported API.
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    36
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    40
public enum TypeTag {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
    /** The tag of the basic type `byte'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    43
    BYTE(1),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /** The tag of the basic type `char'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    47
    CHAR(2),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /** The tag of the basic type `short'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    51
    SHORT(3),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /** The tag of the basic type `int'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    55
    INT(4),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    /** The tag of the basic type `long'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    59
    LONG(5),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /** The tag of the basic type `float'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    63
    FLOAT(6),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /** The tag of the basic type `double'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    67
    DOUBLE(7),
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /** The tag of the basic type `boolean'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    71
    BOOLEAN,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /** The tag of the type `void'.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    75
    VOID,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
    /** The tag of all class and interface types.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    79
    CLASS,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /** The tag of all array types.
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    83
    ARRAY,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /** The tag of all (monomorphic) method types.
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    87
    METHOD,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
    /** The tag of all package "types".
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    91
    PACKAGE,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    /** The tag of all (source-level) type variables.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    95
    TYPEVAR,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    /** The tag of all type arguments.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
    99
    WILDCARD,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
    /** The tag of all polymorphic (method-) types.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   103
    FORALL,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
14057
b4b0377b8dba 7177387: Add target-typing support in method context
mcimadamore
parents: 5847
diff changeset
   105
    /** The tag of deferred expression types in method context
b4b0377b8dba 7177387: Add target-typing support in method context
mcimadamore
parents: 5847
diff changeset
   106
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   107
    DEFERRED,
14057
b4b0377b8dba 7177387: Add target-typing support in method context
mcimadamore
parents: 5847
diff changeset
   108
14366
af625e568667 8001929: fix doclint errors in langtools doc comments
jjg
parents: 14359
diff changeset
   109
    /** The tag of the bottom type {@code <null>}.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   111
    BOT,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    /** The tag of a missing type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   115
    NONE,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    /** The tag of the error type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   119
    ERROR,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    /** The tag of an unknown type
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   123
    UNKNOWN,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    /** The tag of all instantiatable type variables.
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   127
    UNDETVAR,
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   128
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   129
    /** Pseudo-types, these are special tags
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   130
     */
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   131
    UNINITIALIZED_THIS,
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   132
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   133
    UNINITIALIZED_OBJECT;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   134
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   135
    /** This field will only be used for tags related with numeric types for
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   136
     *  optimization reasons.
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   137
     */
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14366
diff changeset
   138
    private final int order;
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   139
14801
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14366
diff changeset
   140
    private TypeTag() {
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14366
diff changeset
   141
        this(0);
d66cab4ef397 8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents: 14366
diff changeset
   142
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   144
    private TypeTag(int order) {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   145
        this.order = order;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   146
    }
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   147
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   148
    private static final int MIN_NUMERIC_TAG_ORDER = 1;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   149
    private static final int MAX_NUMERIC_TAG_ORDER = 7;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   150
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   151
    /** Returns the number of type tags.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
     */
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   153
    public static int getTypeTagCount() {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   154
        // last two tags are not included in the total as long as they are pseudo-types
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   155
        return (UNDETVAR.ordinal() + 1);
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   156
    }
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   157
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   158
    public boolean isSubRangeOf(TypeTag range) {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   159
        return (this == range) || isStrictSubRangeOf(range);
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   160
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   162
    public boolean isStrictSubRangeOf(TypeTag range) {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   163
        if (this.order >= MIN_NUMERIC_TAG_ORDER && this.order <= MAX_NUMERIC_TAG_ORDER &&
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   164
            range.order >= MIN_NUMERIC_TAG_ORDER && this.order <= MAX_NUMERIC_TAG_ORDER) {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   165
            if (this == range)
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   166
                return false;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   167
            switch (this) {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   168
                case BYTE:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   169
                    return true;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   170
                case CHAR: case SHORT: case INT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   171
                case LONG: case FLOAT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   172
                    return this.order < range.order && range.order <= MAX_NUMERIC_TAG_ORDER;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   173
                default:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   174
                    return false;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   175
            }
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   176
        }
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   177
        else
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   178
            return false;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   179
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
14359
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   181
    public Kind getKindLiteral() {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   182
        switch (this) {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   183
        case INT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   184
            return Kind.INT_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   185
        case LONG:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   186
            return Kind.LONG_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   187
        case FLOAT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   188
            return Kind.FLOAT_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   189
        case DOUBLE:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   190
            return Kind.DOUBLE_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   191
        case BOOLEAN:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   192
            return Kind.BOOLEAN_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   193
        case CHAR:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   194
            return Kind.CHAR_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   195
        case CLASS:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   196
            return Kind.STRING_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   197
        case BOT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   198
            return Kind.NULL_LITERAL;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   199
        default:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   200
            throw new AssertionError("unknown literal kind " + this);
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   201
        }
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   202
    }
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   203
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   204
    public TypeKind getPrimitiveTypeKind() {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   205
        switch (this) {
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   206
        case BOOLEAN:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   207
            return TypeKind.BOOLEAN;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   208
        case BYTE:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   209
            return TypeKind.BYTE;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   210
        case SHORT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   211
            return TypeKind.SHORT;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   212
        case INT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   213
            return TypeKind.INT;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   214
        case LONG:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   215
            return TypeKind.LONG;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   216
        case CHAR:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   217
            return TypeKind.CHAR;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   218
        case FLOAT:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   219
            return TypeKind.FLOAT;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   220
        case DOUBLE:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   221
            return TypeKind.DOUBLE;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   222
        case VOID:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   223
            return TypeKind.VOID;
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   224
        default:
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   225
            throw new AssertionError("unknown primitive type " + this);
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   226
        }
d4099818ab70 7200915: convert TypeTags from a series of small ints to an enum
jjg
parents: 14259
diff changeset
   227
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
}