1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
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 "precompiled.hpp"
26 #include "utilities/constantTag.hpp"
27 #include "utilities/ostream.hpp"
28
29 #ifndef PRODUCT
30
31 void constantTag::print_on(outputStream* st) const {
32 st->print("%s", internal_name());
33 }
34
35 #endif // PRODUCT
36
37 BasicType constantTag::basic_type() const {
38 switch (_tag) {
39 case JVM_CONSTANT_Integer :
40 return T_INT;
41 case JVM_CONSTANT_Float :
42 return T_FLOAT;
43 case JVM_CONSTANT_Long :
44 return T_LONG;
45 case JVM_CONSTANT_Double :
46 return T_DOUBLE;
47
48 case JVM_CONSTANT_Class :
49 case JVM_CONSTANT_String :
50 case JVM_CONSTANT_UnresolvedClass :
51 case JVM_CONSTANT_UnresolvedClassInError :
52 case JVM_CONSTANT_ClassIndex :
53 case JVM_CONSTANT_StringIndex :
54 case JVM_CONSTANT_MethodHandle :
55 case JVM_CONSTANT_MethodHandleInError :
56 case JVM_CONSTANT_MethodType :
57 case JVM_CONSTANT_MethodTypeInError :
58 return T_OBJECT;
59 default:
60 ShouldNotReachHere();
61 return T_ILLEGAL;
62 }
63 }
64
65
66 jbyte constantTag::non_error_value() const {
67 switch (_tag) {
68 case JVM_CONSTANT_UnresolvedClassInError:
69 return JVM_CONSTANT_UnresolvedClass;
70 case JVM_CONSTANT_MethodHandleInError:
71 return JVM_CONSTANT_MethodHandle;
72 case JVM_CONSTANT_MethodTypeInError:
73 return JVM_CONSTANT_MethodType;
74 default:
75 return _tag;
76 }
77 }
78
79
80 jbyte constantTag::error_value() const {
81 switch (_tag) {
82 case JVM_CONSTANT_UnresolvedClass:
83 return JVM_CONSTANT_UnresolvedClassInError;
84 case JVM_CONSTANT_MethodHandle:
85 return JVM_CONSTANT_MethodHandleInError;
86 case JVM_CONSTANT_MethodType:
87 return JVM_CONSTANT_MethodTypeInError;
88 default:
89 ShouldNotReachHere();
90 return JVM_CONSTANT_Invalid;
91 }
92 }
93
94 const char* constantTag::internal_name() const {
95 switch (_tag) {
96 case JVM_CONSTANT_Invalid :
97 return "Invalid index";
98 case JVM_CONSTANT_Class :
99 return "Class";
100 case JVM_CONSTANT_Fieldref :
101 return "Field";
102 case JVM_CONSTANT_Methodref :
103 return "Method";
104 case JVM_CONSTANT_InterfaceMethodref :
105 return "InterfaceMethod";
106 case JVM_CONSTANT_String :
107 return "String";
108 case JVM_CONSTANT_Integer :
109 return "Integer";
110 case JVM_CONSTANT_Float :
111 return "Float";
112 case JVM_CONSTANT_Long :
113 return "Long";
114 case JVM_CONSTANT_Double :
115 return "Double";
116 case JVM_CONSTANT_NameAndType :
117 return "NameAndType";
118 case JVM_CONSTANT_MethodHandle :
119 return "MethodHandle";
120 case JVM_CONSTANT_MethodHandleInError :
121 return "MethodHandle Error";
122 case JVM_CONSTANT_MethodType :
123 return "MethodType";
124 case JVM_CONSTANT_MethodTypeInError :
125 return "MethodType Error";
126 case JVM_CONSTANT_InvokeDynamic :
127 return "InvokeDynamic";
128 case JVM_CONSTANT_Utf8 :
129 return "Utf8";
130 case JVM_CONSTANT_UnresolvedClass :
131 return "Unresolved Class";
132 case JVM_CONSTANT_UnresolvedClassInError :
133 return "Unresolved Class Error";
134 case JVM_CONSTANT_ClassIndex :
135 return "Unresolved Class Index";
136 case JVM_CONSTANT_StringIndex :
137 return "Unresolved String Index";
138 default:
139 ShouldNotReachHere();
140 return "Illegal";
141 }
142 }
--- EOF ---