1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/utilities/constantTag.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,86 @@ 1.4 +/* 1.5 + * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// constant tags in Java .class files 1.29 + 1.30 + 1.31 +enum { 1.32 + // See jvm.h for shared JVM_CONSTANT_XXX tags 1.33 + // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java 1.34 + // Hotspot specific tags 1.35 + JVM_CONSTANT_Invalid = 0, // For bad value initialization 1.36 + JVM_CONSTANT_InternalMin = 100, // First implementation tag (aside from bad value of course) 1.37 + JVM_CONSTANT_UnresolvedClass = 100, // Temporary tag until actual use 1.38 + JVM_CONSTANT_ClassIndex = 101, // Temporary tag while constructing constant pool 1.39 + JVM_CONSTANT_UnresolvedString = 102, // Temporary tag until actual use 1.40 + JVM_CONSTANT_StringIndex = 103, // Temporary tag while constructing constant pool 1.41 + JVM_CONSTANT_UnresolvedClassInError = 104, // Error tag due to resolution error 1.42 + JVM_CONSTANT_InternalMax = 104 // Last implementation tag 1.43 +}; 1.44 + 1.45 + 1.46 +class constantTag VALUE_OBJ_CLASS_SPEC { 1.47 + private: 1.48 + jbyte _tag; 1.49 + public: 1.50 + bool is_klass() const { return _tag == JVM_CONSTANT_Class; } 1.51 + bool is_field () const { return _tag == JVM_CONSTANT_Fieldref; } 1.52 + bool is_method() const { return _tag == JVM_CONSTANT_Methodref; } 1.53 + bool is_interface_method() const { return _tag == JVM_CONSTANT_InterfaceMethodref; } 1.54 + bool is_string() const { return _tag == JVM_CONSTANT_String; } 1.55 + bool is_int() const { return _tag == JVM_CONSTANT_Integer; } 1.56 + bool is_float() const { return _tag == JVM_CONSTANT_Float; } 1.57 + bool is_long() const { return _tag == JVM_CONSTANT_Long; } 1.58 + bool is_double() const { return _tag == JVM_CONSTANT_Double; } 1.59 + bool is_name_and_type() const { return _tag == JVM_CONSTANT_NameAndType; } 1.60 + bool is_utf8() const { return _tag == JVM_CONSTANT_Utf8; } 1.61 + 1.62 + bool is_invalid() const { return _tag == JVM_CONSTANT_Invalid; } 1.63 + 1.64 + bool is_unresolved_klass() const { 1.65 + return _tag == JVM_CONSTANT_UnresolvedClass || _tag == JVM_CONSTANT_UnresolvedClassInError; 1.66 + } 1.67 + 1.68 + bool is_unresolved_klass_in_error() const { 1.69 + return _tag == JVM_CONSTANT_UnresolvedClassInError; 1.70 + } 1.71 + 1.72 + bool is_klass_index() const { return _tag == JVM_CONSTANT_ClassIndex; } 1.73 + bool is_unresolved_string() const { return _tag == JVM_CONSTANT_UnresolvedString; } 1.74 + bool is_string_index() const { return _tag == JVM_CONSTANT_StringIndex; } 1.75 + 1.76 + bool is_klass_reference() const { return is_klass_index() || is_unresolved_klass(); } 1.77 + bool is_field_or_method() const { return is_field() || is_method() || is_interface_method(); } 1.78 + bool is_symbol() const { return is_utf8(); } 1.79 + 1.80 + constantTag(jbyte tag) { 1.81 + assert((tag >= 0 && tag <= JVM_CONSTANT_NameAndType) || 1.82 + (tag >= JVM_CONSTANT_InternalMin && tag <= JVM_CONSTANT_InternalMax), "Invalid constant tag"); 1.83 + _tag = tag; 1.84 + } 1.85 + 1.86 + jbyte value() { return _tag; } 1.87 + 1.88 + void print_on(outputStream* st) const PRODUCT_RETURN; 1.89 +};