17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "utilities/constantTag.hpp"
26 #include "utilities/ostream.hpp"
27
28 #ifndef PRODUCT
29
30 void constantTag::print_on(outputStream* st) const {
31 st->print("%s", internal_name());
32 }
33
34 #endif // PRODUCT
35
36 BasicType constantTag::basic_type() const {
37 switch (_tag) {
38 case JVM_CONSTANT_Integer :
39 return T_INT;
40 case JVM_CONSTANT_Float :
41 return T_FLOAT;
42 case JVM_CONSTANT_Long :
43 return T_LONG;
44 case JVM_CONSTANT_Double :
45 return T_DOUBLE;
46
47 case JVM_CONSTANT_Class :
48 case JVM_CONSTANT_String :
49 case JVM_CONSTANT_UnresolvedClass :
50 case JVM_CONSTANT_UnresolvedClassInError :
51 case JVM_CONSTANT_ClassIndex :
52 case JVM_CONSTANT_StringIndex :
53 case JVM_CONSTANT_MethodHandle :
54 case JVM_CONSTANT_MethodHandleInError :
55 case JVM_CONSTANT_MethodType :
56 case JVM_CONSTANT_MethodTypeInError :
57 return T_OBJECT;
58
59 case JVM_CONSTANT_Dynamic :
60 case JVM_CONSTANT_DynamicInError :
61 assert(false, "Dynamic constant has no fixed basic type");
62
63 default:
64 ShouldNotReachHere();
65 return T_ILLEGAL;
66 }
67 }
68
69
70 jbyte constantTag::non_error_value() const {
71 switch (_tag) {
72 case JVM_CONSTANT_UnresolvedClassInError:
73 return JVM_CONSTANT_UnresolvedClass;
74 case JVM_CONSTANT_MethodHandleInError:
75 return JVM_CONSTANT_MethodHandle;
76 case JVM_CONSTANT_MethodTypeInError:
77 return JVM_CONSTANT_MethodType;
78 case JVM_CONSTANT_DynamicInError:
79 return JVM_CONSTANT_Dynamic;
80 default:
81 return _tag;
82 }
83 }
84
85
86 jbyte constantTag::error_value() const {
87 switch (_tag) {
88 case JVM_CONSTANT_UnresolvedClass:
89 return JVM_CONSTANT_UnresolvedClassInError;
90 case JVM_CONSTANT_MethodHandle:
91 return JVM_CONSTANT_MethodHandleInError;
92 case JVM_CONSTANT_MethodType:
93 return JVM_CONSTANT_MethodTypeInError;
94 case JVM_CONSTANT_Dynamic:
95 return JVM_CONSTANT_DynamicInError;
96 default:
97 ShouldNotReachHere();
98 return JVM_CONSTANT_Invalid;
99 }
100 }
101
102 const char* constantTag::internal_name() const {
103 switch (_tag) {
104 case JVM_CONSTANT_Invalid :
105 return "Invalid index";
106 case JVM_CONSTANT_Class :
107 return "Class";
108 case JVM_CONSTANT_Fieldref :
109 return "Field";
110 case JVM_CONSTANT_Methodref :
111 return "Method";
112 case JVM_CONSTANT_InterfaceMethodref :
113 return "InterfaceMethod";
114 case JVM_CONSTANT_String :
115 return "String";
116 case JVM_CONSTANT_Integer :
117 return "Integer";
118 case JVM_CONSTANT_Float :
119 return "Float";
120 case JVM_CONSTANT_Long :
121 return "Long";
122 case JVM_CONSTANT_Double :
123 return "Double";
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "utilities/constantTag.hpp"
26 #include "utilities/ostream.hpp"
27
28 #ifndef PRODUCT
29
30 void constantTag::print_on(outputStream* st) const {
31 st->print("%s", internal_name());
32 }
33
34 #endif // PRODUCT
35
36 BasicType constantTag::basic_type() const {
37 switch (value()) {
38 case JVM_CONSTANT_Integer :
39 return T_INT;
40 case JVM_CONSTANT_Float :
41 return T_FLOAT;
42 case JVM_CONSTANT_Long :
43 return T_LONG;
44 case JVM_CONSTANT_Double :
45 return T_DOUBLE;
46
47 case JVM_CONSTANT_Class :
48 case JVM_CONSTANT_String :
49 case JVM_CONSTANT_UnresolvedClass :
50 case JVM_CONSTANT_UnresolvedClassInError :
51 case JVM_CONSTANT_ClassIndex :
52 case JVM_CONSTANT_StringIndex :
53 case JVM_CONSTANT_MethodHandle :
54 case JVM_CONSTANT_MethodHandleInError :
55 case JVM_CONSTANT_MethodType :
56 case JVM_CONSTANT_MethodTypeInError :
57 return T_OBJECT;
58
59 case JVM_CONSTANT_Dynamic :
60 case JVM_CONSTANT_DynamicInError :
61 assert(false, "Dynamic constant has no fixed basic type");
62
63 default:
64 ShouldNotReachHere();
65 return T_ILLEGAL;
66 }
67 }
68
69
70 jbyte constantTag::non_error_value() const {
71 switch (value()) {
72 case JVM_CONSTANT_UnresolvedClassInError:
73 return JVM_CONSTANT_UnresolvedClass;
74 case JVM_CONSTANT_MethodHandleInError:
75 return JVM_CONSTANT_MethodHandle;
76 case JVM_CONSTANT_MethodTypeInError:
77 return JVM_CONSTANT_MethodType;
78 case JVM_CONSTANT_DynamicInError:
79 return JVM_CONSTANT_Dynamic;
80 default:
81 return value();
82 }
83 }
84
85
86 jbyte constantTag::error_value() const {
87 switch (value()) {
88 case JVM_CONSTANT_UnresolvedClass:
89 return JVM_CONSTANT_UnresolvedClassInError;
90 case JVM_CONSTANT_MethodHandle:
91 return JVM_CONSTANT_MethodHandleInError;
92 case JVM_CONSTANT_MethodType:
93 return JVM_CONSTANT_MethodTypeInError;
94 case JVM_CONSTANT_Dynamic:
95 return JVM_CONSTANT_DynamicInError;
96 default:
97 ShouldNotReachHere();
98 return JVM_CONSTANT_Invalid;
99 }
100 }
101
102 const char* constantTag::internal_name() const {
103 switch (value()) {
104 case JVM_CONSTANT_Invalid :
105 return "Invalid index";
106 case JVM_CONSTANT_Class :
107 return "Class";
108 case JVM_CONSTANT_Fieldref :
109 return "Field";
110 case JVM_CONSTANT_Methodref :
111 return "Method";
112 case JVM_CONSTANT_InterfaceMethodref :
113 return "InterfaceMethod";
114 case JVM_CONSTANT_String :
115 return "String";
116 case JVM_CONSTANT_Integer :
117 return "Integer";
118 case JVM_CONSTANT_Float :
119 return "Float";
120 case JVM_CONSTANT_Long :
121 return "Long";
122 case JVM_CONSTANT_Double :
123 return "Double";
|