1 /* 2 * Copyright (c) 1997, 2017, 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 case JVM_CONSTANT_InvokeDynamicInError : 59 return T_OBJECT; 60 default: 61 ShouldNotReachHere(); 62 return T_ILLEGAL; 63 } 64 } 65 66 67 jbyte constantTag::non_error_value() const { 68 switch (_tag) { 69 case JVM_CONSTANT_UnresolvedClassInError: 70 return JVM_CONSTANT_UnresolvedClass; 71 case JVM_CONSTANT_MethodHandleInError: 72 return JVM_CONSTANT_MethodHandle; 73 case JVM_CONSTANT_MethodTypeInError: 74 return JVM_CONSTANT_MethodType; 75 case JVM_CONSTANT_InvokeDynamicInError: 76 return JVM_CONSTANT_InvokeDynamic; 77 default: 78 return _tag; 79 } 80 } 81 82 83 jbyte constantTag::error_value() const { 84 switch (_tag) { 85 case JVM_CONSTANT_UnresolvedClass: 86 return JVM_CONSTANT_UnresolvedClassInError; 87 case JVM_CONSTANT_MethodHandle: 88 return JVM_CONSTANT_MethodHandleInError; 89 case JVM_CONSTANT_MethodType: 90 return JVM_CONSTANT_MethodTypeInError; 91 case JVM_CONSTANT_InvokeDynamic: 92 return JVM_CONSTANT_InvokeDynamicInError; 93 default: 94 ShouldNotReachHere(); 95 return JVM_CONSTANT_Invalid; 96 } 97 } 98 99 const char* constantTag::internal_name() const { 100 switch (_tag) { 101 case JVM_CONSTANT_Invalid : 102 return "Invalid index"; 103 case JVM_CONSTANT_Class : 104 return "Class"; 105 case JVM_CONSTANT_Fieldref : 106 return "Field"; 107 case JVM_CONSTANT_Methodref : 108 return "Method"; 109 case JVM_CONSTANT_InterfaceMethodref : 110 return "InterfaceMethod"; 111 case JVM_CONSTANT_String : 112 return "String"; 113 case JVM_CONSTANT_Integer : 114 return "Integer"; 115 case JVM_CONSTANT_Float : 116 return "Float"; 117 case JVM_CONSTANT_Long : 118 return "Long"; 119 case JVM_CONSTANT_Double : 120 return "Double"; 121 case JVM_CONSTANT_NameAndType : 122 return "NameAndType"; 123 case JVM_CONSTANT_MethodHandle : 124 return "MethodHandle"; 125 case JVM_CONSTANT_MethodHandleInError : 126 return "MethodHandle Error"; 127 case JVM_CONSTANT_MethodType : 128 return "MethodType"; 129 case JVM_CONSTANT_MethodTypeInError : 130 return "MethodType Error"; 131 case JVM_CONSTANT_InvokeDynamic : 132 return "InvokeDynamic"; 133 case JVM_CONSTANT_InvokeDynamicInError : 134 return "InvokeDynamic Error"; 135 case JVM_CONSTANT_Utf8 : 136 return "Utf8"; 137 case JVM_CONSTANT_UnresolvedClass : 138 return "Unresolved Class"; 139 case JVM_CONSTANT_UnresolvedClassInError : 140 return "Unresolved Class Error"; 141 case JVM_CONSTANT_ClassIndex : 142 return "Unresolved Class Index"; 143 case JVM_CONSTANT_StringIndex : 144 return "Unresolved String Index"; 145 default: 146 ShouldNotReachHere(); 147 return "Illegal"; 148 } 149 }