📄 typeid.h
字号:
/* * @(#)typeid.h 1.52 06/10/10 * * Copyright 1990-2008 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * *//* * This file gives the interface to the type system. */#ifndef _INCLUDED_TYPEID_H#define _INCLUDED_TYPEID_H#include "javavm/include/defs.h"#include "javavm/include/porting/ansi/stddef.h" /* size_t *//* * An CVMxxxTypeID has two parts: the name part and the type part. * The high-order 16 bits is the name part. It is an index into the * member-name table. * The low-order 16 bits is the type part. It is either a method-type, * which is an index into the method-type table, or it is a field-type, * in which case it can be decoded, as described below. * Because of this context-dependence, there are two type ID types. * Needless to say, when only type information is to be represented, the * high-order bits are ignored. *//* * A CVMTypeID type is used as the basis for CVMMethodTypeID, CVMFieldTypeID, * or CVMClassTypeID as appropriate. Additionally two typedefs for the name * and type part of a typeid were added and a type which is used when both * types of part are acceptable. The use of these typedefs are enforced * throughout the code. */typedef CVMUint32 CVMTypeID;typedef CVMUint16 CVMTypeIDPart;typedef CVMTypeID CVMMethodTypeID;typedef CVMTypeID CVMFieldTypeID;typedef CVMTypeID CVMClassTypeID;typedef CVMTypeIDPart CVMTypeIDNamePart;typedef CVMTypeIDPart CVMTypeIDTypePart;/* * This value is returned by any of the lookup routines * when the entry cannot be found, or for allocation * errors for the underlying tables, or for a syntax * error on input (especially a malformed signature string) *//* * Use CVMTypeID instead of CVUint32. */#define CVM_TYPEID_ERROR ((CVMTypeID)-1)/* * This value is a limitation of the VM definition. * It is the deepest array you can have on any Java VM. * This is enforced by the verifier. */#define CVM_MAX_ARRAY_DIMENSIONS 255/* * A field type is a 16-bit cookie. * Many can be interpreted directly. * Others are in the form of table index or key, * that indicate where more data is buried. * These are (currently) in no special order. * * +--2--+----14-------+ * | ary | basetype | * +-----+-------------+ * where: * ary -- if value is 3, then the basetype field is an * index into a table giving array depth & basetype. Otherwise, * this is the array depth, for 0 <= depth <= 2. This should cover * the majority of arrays. * basetype -- if it is a little number (in below list), then the base type * is self-evident. Otherwise it is an index into a table where * more information is kept. * * All this should be opaque to the client. *//* there is no 0 type. if you see one, it is a bug */#define CVM_TYPEID_NONE 0#define CVM_TYPEID_ENDFUNC 1#define CVM_TYPEID_VOID 2#define CVM_TYPEID_INT 3#define CVM_TYPEID_SHORT 4#define CVM_TYPEID_CHAR 5#define CVM_TYPEID_LONG 6#define CVM_TYPEID_BYTE 7#define CVM_TYPEID_FLOAT 8#define CVM_TYPEID_DOUBLE 9#define CVM_TYPEID_BOOLEAN 10#define CVM_TYPEID_OBJ 11#define CVM_TYPEID_LAST_PREDEFINED_TYPE CVM_TYPEID_OBJ#define CVMtypeidIsPrimitive(t) \ ((((t) & CVMtypeidTypeMask) >= CVM_TYPEID_VOID) && \ (((t) & CVMtypeidTypeMask) <= CVM_TYPEID_BOOLEAN))#define CVMtypeidIsBigArray(t) \ (((t)&CVMtypeidArrayMask)==CVMtypeidBigArray)#define CVMtypeidIsArray( t ) (((t)&CVMtypeidArrayMask) != 0 )#define CVMtypeidGetArrayDepth( t ) \ (CVMtypeidIsBigArray(t)? CVMtypeidGetArrayDepthX(t) \ : (((t)&CVMtypeidArrayMask)>>CVMtypeidArrayShift))#define CVMtypeidGetArrayBasetype( t ) \ (CVMtypeidIsBigArray(t)? CVMtypeidGetArrayBasetypeX(t) \ : ((t)&CVMtypeidBasetypeMask))extern int CVMtypeidGetArrayDepthX( CVMClassTypeID );extern CVMClassTypeID CVMtypeidGetArrayBasetypeX( CVMClassTypeID );#define CVMtypeidEncodeBasicPrimitiveArrayType(primitiveBaseType) \ (CVMassert(CVMtypeidIsPrimitive(primitiveBaseType)), \ ((1 << CVMtypeidArrayShift) | (primitiveBaseType)))/* * Extracts the name part of a typeid. Expects an argument of type CVMTypeID * (or equivalent) and returns a CVMTypeIDNamePart. */#define CVMtypeidGetNamePart(typeID) \ ((CVMTypeIDNamePart) ((typeID) >> CVMtypeidNameShift))/* * Extracts the type part of a typeid. Expects an argument of type * CVMTypeID (or equivalent) and returns a CVMTypeIDTypePart. This * should not be confused with CVMtypeidGetType(), which returns a * CVMTypeID with the name part nulled out. */#define CVMtypeidGetTypePart(typeID) \ ((CVMTypeIDTypePart) ((typeID) & CVMtypeidTypeMask))/* * Constructs a CVMTypeID (or equivalent) from a CVMTypeIDTypePart and a * CVMTypeIDNamePart. */#define CVMtypeidCreateTypeIDFromParts(namePart, typePart) \ ((((CVMTypeID) ((CVMTypeIDNamePart) (namePart))) << CVMtypeidNameShift) | ((CVMTypeIDTypePart) (typePart)))/* * A limitation of the implementation */#define CVM_TYPEID_MAX_BASETYPE 0x3fff/* * Initialize the type Id system * Register some well-known typeID's */extern CVMBoolCVMtypeidInit(CVMExecEnv *ee);/* * A second stage of type ID initialization. * Register all pre-loaded packages using * CVMpackagesAddEntry( pkgName, "<preloaded>" ) */extern voidCVMtypeidRegisterPreloadedPackages();/* * Delete all allocated data * at VM shutdown. */extern voidCVMtypeidDestroy();/* * Make a method type ID out of a UTF8 method name and signature * CVMtypeidLookupMethodIDFromNameAndSig will find already-existing * entries, and return the values. Use this when querying something * that may exist, but which you do not plan to instantiate. * CVMtypeidNewMethodIDFromNameAndSig will find entries, inserting if * necessary, and will increment reference counts. Use this when * instantiating a new method. */extern CVMMethodTypeIDCVMtypeidLookupMethodIDFromNameAndSig( CVMExecEnv *ee, const CVMUtf8* memberName, const CVMUtf8* memberSig);extern CVMMethodTypeIDCVMtypeidNewMethodIDFromNameAndSig( CVMExecEnv *ee, const CVMUtf8* memberName, const CVMUtf8* memberSig);/* * Manipulate the reference counts on existing method type IDs. * Use one when copying one. Use the other when unloading or otherwise * deleting the reference. */extern CVMMethodTypeIDCVMtypeidCloneMethodID( CVMExecEnv *ee, CVMMethodTypeID cookie );extern voidCVMtypeidDisposeMethodID( CVMExecEnv *ee, CVMMethodTypeID cookie );/* * Make a field type ID out of a UTF8 field name and signature * CVMtypeidLookupFieldIDFromNameAndSig will find already-existing * entries, and return the values. Use this when querying something * that may exist, but which you do not plan to instantiate. * CVMtypeidNewFieldIDFromNameAndSig will find entries, inserting if * necessary, and will increment reference counts. Use this when * instantiating a new field. */extern CVMFieldTypeIDCVMtypeidLookupFieldIDFromNameAndSig( CVMExecEnv *ee, const CVMUtf8* memberName, const CVMUtf8* memberSig);extern CVMFieldTypeIDCVMtypeidNewFieldIDFromNameAndSig( CVMExecEnv *ee, const CVMUtf8* memberName, const CVMUtf8* memberSig);/* * Manipulate the reference counts on existing field type IDs. * Use one when copying one. Use the other when unloading or otherwise * deleting the reference. */extern CVMFieldTypeIDCVMtypeidCloneFieldID( CVMExecEnv *ee, CVMFieldTypeID cookie );extern voidCVMtypeidDisposeFieldID( CVMExecEnv *ee, CVMFieldTypeID cookie );/* * Make a class type ID out of a UTF8 class name. (This is equivalent to a field * type ID.) * CVMtypeidLookupClassID will find already-existing * entries, and return the values. Use this when querying something * that may exist, but which you do not plan to instantiate. * CVMtypeidNewClassID will find entries, inserting if * necessary, and will increment reference counts. Use this when * instantiating a new class. */extern CVMClassTypeIDCVMtypeidLookupClassID( CVMExecEnv *ee, const char * name, int nameLength );extern CVMClassTypeIDCVMtypeidNewClassID( CVMExecEnv *ee, const char * name, int nameLength );/* * Manipulate the reference counts on existing class type IDs. * Use one when copying one. Use the other when unloading or otherwise * deleting the reference. */extern CVMClassTypeIDCVMtypeidCloneClassID( CVMExecEnv *ee, CVMClassTypeID cookie );extern voidCVMtypeidDisposeClassID( CVMExecEnv *ee, CVMClassTypeID cookie );/* * Make a member name ID out of a UTF8 string. This can be either a method * name or a field name. It is >not< a class name, which is dealt with above. * CVMtypeidLookupMembername will find an already-existing * entry, and return the value. Use this when querying something * that may exist, but which you do not plan to instantiate. * CVMtypeidNewMembername will find an entry, inserting if * necessary, and will increment the reference count. Use this when * instantiating a new member. */extern CVMTypeIDCVMtypeidLookupMembername( CVMExecEnv *ee, const char * name );extern CVMTypeIDCVMtypeidNewMembername( CVMExecEnv *ee, const char * name );/* * Manipulate the reference counts on existing member name IDs. * Use one when copying one. Use the other when unloading or otherwise * deleting the reference. */extern CVMTypeIDCVMtypeidCloneMembername( CVMExecEnv *ee, CVMTypeID cookie );extern voidCVMtypeidDisposeMembername( CVMExecEnv *ee, CVMTypeID cookie );/* * A limitation of the implementation */#define CVM_TYPEID_MAX_MEMBERNAME 0xfffe/* * Are two TypeIDs' type components equal? * If they are proper entries in our system, the answer * is easily derived. */#define CVMtypeidIsSameType(type1, type2) \ (((type1) & CVMtypeidTypeMask)==((type2) & CVMtypeidTypeMask))/* * Are two names equal? * If they are proper entries in our system, the answer * is easily derived. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -