author | alundblad |
Thu, 30 Apr 2015 12:21:50 +0200 | |
changeset 30069 | 5686d5e44a83 |
parent 25874 | 83c19f00452c |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
18395
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.code; |
|
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 | 31 |
|
18395
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
32 |
import static com.sun.tools.javac.code.TypeTag.NumericClasses.*; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
33 |
|
10 | 34 |
/** An interface for type tag values, which distinguish between different |
35 |
* sorts of types. |
|
36 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
37 |
* <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
|
38 |
* If you write code that depends on this, you do so at your own risk. |
10 | 39 |
* This code and its internal interfaces are subject to change or |
40 |
* deletion without notice.</b> |
|
41 |
*/ |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
42 |
public enum TypeTag { |
10 | 43 |
/** The tag of the basic type `byte'. |
44 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
45 |
BYTE(BYTE_CLASS, BYTE_SUPERCLASSES, true), |
10 | 46 |
|
47 |
/** The tag of the basic type `char'. |
|
48 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
49 |
CHAR(CHAR_CLASS, CHAR_SUPERCLASSES, true), |
10 | 50 |
|
51 |
/** The tag of the basic type `short'. |
|
52 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
53 |
SHORT(SHORT_CLASS, SHORT_SUPERCLASSES, true), |
10 | 54 |
|
55 |
/** The tag of the basic type `long'. |
|
56 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
57 |
LONG(LONG_CLASS, LONG_SUPERCLASSES, true), |
10 | 58 |
|
59 |
/** The tag of the basic type `float'. |
|
60 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
61 |
FLOAT(FLOAT_CLASS, FLOAT_SUPERCLASSES, true), |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
62 |
/** The tag of the basic type `int'. |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
63 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
64 |
INT(INT_CLASS, INT_SUPERCLASSES, true), |
10 | 65 |
/** The tag of the basic type `double'. |
66 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
67 |
DOUBLE(DOUBLE_CLASS, DOUBLE_CLASS, true), |
10 | 68 |
/** The tag of the basic type `boolean'. |
69 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
70 |
BOOLEAN(0, 0, true), |
10 | 71 |
|
72 |
/** The tag of the type `void'. |
|
73 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
74 |
VOID, |
10 | 75 |
|
76 |
/** The tag of all class and interface types. |
|
77 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
78 |
CLASS, |
10 | 79 |
|
80 |
/** The tag of all array types. |
|
81 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
82 |
ARRAY, |
10 | 83 |
|
84 |
/** The tag of all (monomorphic) method types. |
|
85 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
86 |
METHOD, |
10 | 87 |
|
88 |
/** The tag of all package "types". |
|
89 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
90 |
PACKAGE, |
10 | 91 |
|
92 |
/** The tag of all (source-level) type variables. |
|
93 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
94 |
TYPEVAR, |
10 | 95 |
|
96 |
/** The tag of all type arguments. |
|
97 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
98 |
WILDCARD, |
10 | 99 |
|
100 |
/** The tag of all polymorphic (method-) types. |
|
101 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
102 |
FORALL, |
10 | 103 |
|
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
5847
diff
changeset
|
104 |
/** The tag of deferred expression types in method context |
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
5847
diff
changeset
|
105 |
*/ |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
106 |
DEFERRED, |
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
5847
diff
changeset
|
107 |
|
14366
af625e568667
8001929: fix doclint errors in langtools doc comments
jjg
parents:
14359
diff
changeset
|
108 |
/** The tag of the bottom type {@code <null>}. |
10 | 109 |
*/ |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
110 |
BOT, |
10 | 111 |
|
112 |
/** The tag of a missing type. |
|
113 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
114 |
NONE, |
10 | 115 |
|
116 |
/** The tag of the error type. |
|
117 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
118 |
ERROR, |
10 | 119 |
|
120 |
/** The tag of an unknown type |
|
121 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
122 |
UNKNOWN, |
10 | 123 |
|
124 |
/** The tag of all instantiatable type variables. |
|
125 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
126 |
UNDETVAR, |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
127 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
128 |
/** Pseudo-types, these are special tags |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
129 |
*/ |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
130 |
UNINITIALIZED_THIS, |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
131 |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
132 |
UNINITIALIZED_OBJECT; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
133 |
|
18395
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
134 |
final int superClasses; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
135 |
final int numericClass; |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
136 |
final boolean isPrimitive; |
18395
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
137 |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
138 |
private TypeTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
139 |
this(0, 0, false); |
18395
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
140 |
} |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
141 |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
142 |
private TypeTag(int numericClass, int superClasses, boolean isPrimitive) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
143 |
this.superClasses = superClasses; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
144 |
this.numericClass = numericClass; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
145 |
this.isPrimitive = isPrimitive; |
14801
d66cab4ef397
8003967: detect and remove all mutable implicit static enum fields in langtools
vromero
parents:
14366
diff
changeset
|
146 |
} |
10 | 147 |
|
18395
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
148 |
public static class NumericClasses { |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
149 |
public static final int BYTE_CLASS = 1; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
150 |
public static final int CHAR_CLASS = 2; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
151 |
public static final int SHORT_CLASS = 4; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
152 |
public static final int INT_CLASS = 8; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
153 |
public static final int LONG_CLASS = 16; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
154 |
public static final int FLOAT_CLASS = 32; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
155 |
public static final int DOUBLE_CLASS = 64; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
156 |
|
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
157 |
static final int BYTE_SUPERCLASSES = BYTE_CLASS | SHORT_CLASS | INT_CLASS | |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
158 |
LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
159 |
|
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
160 |
static final int CHAR_SUPERCLASSES = CHAR_CLASS | INT_CLASS | |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
161 |
LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
162 |
|
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
163 |
static final int SHORT_SUPERCLASSES = SHORT_CLASS | INT_CLASS | |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
164 |
LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
165 |
|
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
166 |
static final int INT_SUPERCLASSES = INT_CLASS | LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
167 |
|
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
168 |
static final int LONG_SUPERCLASSES = LONG_CLASS | FLOAT_CLASS | DOUBLE_CLASS; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
169 |
|
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
170 |
static final int FLOAT_SUPERCLASSES = FLOAT_CLASS | DOUBLE_CLASS; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
171 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
172 |
|
18395
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
173 |
public boolean isStrictSubRangeOf(TypeTag tag) { |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
174 |
/* Please don't change the implementation of this method to call method |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
175 |
* isSubRangeOf. Both methods are called from hotspot code, the current |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
176 |
* implementation is better performance-wise than the commented modification. |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
177 |
*/ |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
178 |
return (this.superClasses & tag.numericClass) != 0 && this != tag; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
179 |
} |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
180 |
|
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
181 |
public boolean isSubRangeOf(TypeTag tag) { |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
182 |
return (this.superClasses & tag.numericClass) != 0; |
d56a5fbf0b32
8016267: javac, TypeTag refactoring has provoked performance issues
vromero
parents:
14801
diff
changeset
|
183 |
} |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
184 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
185 |
/** Returns the number of type tags. |
10 | 186 |
*/ |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
187 |
public static int getTypeTagCount() { |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
188 |
// 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
|
189 |
return (UNDETVAR.ordinal() + 1); |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
190 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
191 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
192 |
public Kind getKindLiteral() { |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
193 |
switch (this) { |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
194 |
case INT: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
195 |
return Kind.INT_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
196 |
case LONG: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
197 |
return Kind.LONG_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
198 |
case FLOAT: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
199 |
return Kind.FLOAT_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
200 |
case DOUBLE: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
201 |
return Kind.DOUBLE_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
202 |
case BOOLEAN: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
203 |
return Kind.BOOLEAN_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
204 |
case CHAR: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
205 |
return Kind.CHAR_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
206 |
case CLASS: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
207 |
return Kind.STRING_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
208 |
case BOT: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
209 |
return Kind.NULL_LITERAL; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
210 |
default: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
211 |
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
|
212 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
213 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
214 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
215 |
public TypeKind getPrimitiveTypeKind() { |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
216 |
switch (this) { |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
217 |
case BOOLEAN: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
218 |
return TypeKind.BOOLEAN; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
219 |
case BYTE: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
220 |
return TypeKind.BYTE; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
221 |
case SHORT: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
222 |
return TypeKind.SHORT; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
223 |
case INT: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
224 |
return TypeKind.INT; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
225 |
case LONG: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
226 |
return TypeKind.LONG; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
227 |
case CHAR: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
228 |
return TypeKind.CHAR; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
229 |
case FLOAT: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
230 |
return TypeKind.FLOAT; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
231 |
case DOUBLE: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
232 |
return TypeKind.DOUBLE; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
233 |
case VOID: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
234 |
return TypeKind.VOID; |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
235 |
default: |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
236 |
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
|
237 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14259
diff
changeset
|
238 |
} |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
239 |
|
10 | 240 |
} |