📄 typeid.h
字号:
#define CVMtypeidIsSameName(type1, type2) \ (((type1)&CVMtypeidNameMask) == ((type2)&CVMtypeidNameMask))/* * Are two TypeIDs' name -and- type components equal? * If they are proper entries in our system, the answer * is easily derived. */#define CVMtypeidIsSame(type1, type2) ((type1) == (type2))/* * Returns true if the ID is for a finalizer method */#define CVMtypeidIsFinalizer(type) \ (CVMtypeidIsSameName(type, CVMglobals.finalizeTid))/* * Returns true if the ID is for a constructor method */#define CVMtypeidIsConstructor(type) \ (CVMtypeidIsSameName(type, CVMglobals.initTid))/* * Returns true if the ID is for a static initializer ("<clinit>" "()V") */#define CVMtypeidIsStaticInitializer(type) \ (CVMtypeidIsSame(type, CVMglobals.clinitTid))/* * Like above, but ignores signature */#define CVMtypeidIsClinit(type) \ (CVMtypeidIsSameName(type, CVMglobals.clinitTid))/* * Return only the type component of a typeid. * Useful if you want to go from field typeid -> class typeid. */#define CVMtypeidGetType(type1) ((type1) & CVMtypeidTypeMask)/* * Return only the primitive type component of a fieldID. */#define CVMtypeidGetPrimitiveType(fid) \ (CVMtypeidFieldIsRef(fid) ? CVM_TYPEID_OBJ : CVMtypeidGetType(fid))/* * Returns the return type of a method type. * This returns one of the CVM_TYPEID_ type syllables. */extern charCVMtypeidGetReturnType(CVMMethodTypeID type);/* * Returns the total number of words that the method arguments occupy. * * WARNING: does not account for the "this" argument. */extern CVMUint16CVMtypeidGetArgsSize( CVMMethodTypeID methodTypeID );#ifdef CVM_JIT/* * Returns the total number of arguments that the method has. * * WARNING: does not account for the "this" argument. */extern CVMUint16CVMtypeidGetArgsCount( CVMMethodTypeID methodTypeID );#endif/* * Returns true if the ID is a double-word (long or double). */#define CVMtypeidFieldIsDoubleword( t ) \ (( ((t)&CVMtypeidTypeMask) == CVM_TYPEID_LONG) || \ ( ((t)&CVMtypeidTypeMask) == CVM_TYPEID_DOUBLE))/* * Returns true if the ID is a ref. The first works for reference-typed * data types, and the second for method return types. * The field version is pretty trivial. The method version requires * more grubbing around. */#define CVMtypeidFieldIsRef( t ) \ ( ((t)&CVMtypeidTypeMask) > CVMtypeidLastScalar)extern CVMBoolCVMtypeidMethodIsRef(CVMMethodTypeID type);extern size_tCVMtypeidFieldTypeLength0(CVMFieldTypeID type, CVMBool isField);extern size_tCVMtypeidMethodTypeLength(CVMMethodTypeID type);extern size_tCVMtypeidMemberNameLength(CVMMethodTypeID type);extern size_tCVMtypeidClassNameLength(CVMClassTypeID type);#define CVMtypeidFieldTypeLength(tid) \ CVMtypeidFieldTypeLength0((tid), CVM_TRUE)#define CVMtypeidClassNameLength(tid) \ CVMtypeidFieldTypeLength0((tid), CVM_FALSE)#define CVMtypeidFieldNameLength(tid) \ CVMtypeidMemberNameLength((tid))#define CVMtypeidMethodNameLength(tid) \ CVMtypeidMemberNameLength((tid))/* * Convert type ID to string for printouts */extern CVMBoolCVMtypeidMethodTypeToCString(CVMMethodTypeID type, char* buf, int bufLength);extern CVMBoolCVMtypeidFieldTypeToCString(CVMFieldTypeID type, char* buf, int bufLength);extern CVMBoolCVMtypeidMethodNameToCString(CVMMethodTypeID type, char* buf, int bufLength);extern CVMBoolCVMtypeidFieldNameToCString(CVMFieldTypeID type, char* buf, int bufLength);extern CVMBoolCVMtypeidClassNameToCString(CVMClassTypeID type, char* buf, int bufLength);/* * Variants of the above that * calculate the size of the necessary buffer and allocate it for you * using malloc(). * Warning! * You are responsible for de-allocating the resulting object yourself! */extern char *CVMtypeidMethodTypeToAllocatedCString( CVMMethodTypeID type );extern char *CVMtypeidFieldTypeToAllocatedCString( CVMFieldTypeID type );extern char *CVMtypeidMethodNameToAllocatedCString( CVMMethodTypeID type );extern char *CVMtypeidFieldNameToAllocatedCString( CVMFieldTypeID type );extern char *CVMtypeidClassNameToAllocatedCString( CVMClassTypeID type );/* * Reference counting functions, for use by class loader and class-garbage * collector. */#define CVMtypeidFieldIncRef( t ) \ ( ((t)&CVMtypeidBasetypeMask>CVMtypeidLastScalar) ? \ CVMtypeidIncrementFieldRefcount( t ) : 0 )#define CVMtypeidFieldDecRef( t ) \ ( ((t)&CVMtypeidBasetypeMask>CVMtypeidLastScalar) ? \ CVMtypeidDecrementFieldRefcount( t ) : 0 )int CVMtypeidIncrementFieldRefcount( CVMFieldTypeID );int CVMtypeidDecrementFieldRefcount( CVMFieldTypeID );/* * CVMtypeidIncrementArrayDepth will find an entry, inserting if * necessary, and will increment reference counts. * The resulting ID must be disposed of when finished. See * CVMtypeidDisposeClassID. !! * */extern CVMClassTypeIDCVMtypeidIncrementArrayDepth( CVMExecEnv *ee, CVMClassTypeID base, int depthIncrement );/* * Compare the containing packages of a pair of class types. * In the case of array types, the package of the base type is used. */extern CVMBoolCVMtypeidIsSameClassPackage( CVMClassTypeID classname1, CVMClassTypeID classname2 );/******************************************************************* * TERSE SIGNATURES. * * A terse signature is a way of compactly representing enough of * the parameter-passing and value-returning type information of a method * to allow the passing of information between the Java stack and the C * stack. (Internally we use a terse signature, which we sometimes call a * Form, to represent part of type information.) A terse signature can * be retrieved from an CVMtypeidMethodTypeID, and information can be * extracted from it. In particular, it should be easy to iterate over * the parameter types, and to extract the return type. Here are * the interfaces (and macros) you need to do this. In all cases, they * type syllables returned are from the CVM_TYPEID_ set. All references, * including arrays, are represented as CVM_TYPEID_OBJ. */typedef struct CVMterseSig { CVMUint32 * datap; int nParameters;} CVMterseSig;typedef struct CVMterseSigIterator { CVMterseSig thisSig; int word; int syllableInWord;} CVMterseSigIterator;voidCVMtypeidGetTerseSignature( CVMMethodTypeID tid, CVMterseSig* result );voidCVMtypeidGetTerseSignatureIterator( CVMMethodTypeID tid, CVMterseSigIterator* result );/* * The C terse signature iterator paradigm. */#define CVM_TERSE_ITER_NEXT( tsi ) \ ( ( ((tsi).syllableInWord>=8)? ((tsi).syllableInWord=0, (tsi).word++) : 0 ) , \ ((tsi).thisSig.datap[(tsi).word]>>(4*((tsi).syllableInWord++)) )&0xf )#define CVM_TERSE_ITER_RETURNTYPE( tsi ) ((tsi).thisSig.datap[0]&0xf )/* Since syllable count always includes the return and * end-of-parameter-list marker, the parameter count is two less. */#define CVM_TERSE_ITER_PARAMCOUNT( tsi ) (CVM_TERSE_PARAMCOUNT((tsi).thisSig))/* * This macro operates on a terse signature, not a terse signature iterator. */#define CVM_TERSE_PARAMCOUNT( ts ) ((ts).nParameters )/* * FULL SIGNATURE ITERATION. * A full signature iterator is, very simply, a terse signature * iterator plus a list of object-types we keep on the side. * We run the terse iterator, and if it would return CVM_TYPEID_OBJ, * we replace that return value with the next value from the object-type * array. */typedef struct CVMSigIterator { CVMterseSigIterator terseSig; CVMTypeIDTypePart* parameterDetails; CVMClassTypeID returnType; CVMClassTypeID temp;} CVMSigIterator;voidCVMtypeidGetSignatureIterator( CVMMethodTypeID tid, CVMSigIterator* result );#define CVM_SIGNATURE_ITER_NEXT( sigiter ) \ (( ((sigiter).temp=CVM_TERSE_ITER_NEXT((sigiter).terseSig)) == CVM_TYPEID_OBJ )\ ? *((sigiter).parameterDetails++) \ : (sigiter).temp )#define CVM_SIGNATURE_ITER_RETURNTYPE( sigiter ) ((sigiter).returnType)#define CVM_SIGNATURE_ITER_PARAMCOUNT( sigiter ) CVM_TERSE_ITER_PARAMCOUNT((sigiter).terseSig)/* * Private to the implementation, exposed to make macros work. */#define CVMtypeidNameShift 16#define CVMtypeidArrayShift 14 /* * This is how these masks are derived: * CVMtypeidTypeMask = (1<<CVMtypeidNameShift)-1 * CVMtypeidNameMask = ~CVMtypeidTypeMask * CVMtypeidBasetypeMask = (1<<CVMtypeidArrayShift)-1 * CVMtypeidArrayMask = ((1<<(CVMtypeidNameShift-CVMtypeidArrayShift))-1) * << CVMtypeidArrayShift; * CVMtypeidBigArray = CVYtypeidArrayMask * CVMtypeidMaxSmallArray = (CVMtypeidBigArray>>CVMtypeidArrayShift)-1 */#define CVMtypeidTypeMask 0xffff#define CVMtypeidNameMask 0xffff0000#define CVMtypeidArrayMask 0xc000#define CVMtypeidBasetypeMask 0x3fff#define CVMtypeidBigArray 0xc000#define CVMtypeidLastScalar CVM_TYPEID_BOOLEAN#define CVMtypeidMaxSmallArray 2#ifdef CVM_DEBUG/* * print a little report of type table insertions and deletions * using CVMconsolePrintf. Resets the counters so that the next * call reports incremental numbers. */extern void CVMtypeidPrintStats();/* * print a more verbose report of type table insertions and * deletions. If verbose==0, only report the net changes * deletions cancel insertions. If verbose!=0, report all * changes. */extern void CVMtypeidPrintDiffs( CVMBool verbose );/* * Check integrety of (some) type tables: * follow hash chains and detect duplicates/merging/loops * make sure all reachable entries have non-zero ref count, and * that unreachable entries have zero ref count. */extern void CVMtypeidCheckTables();#endif#endif /* _INCLUDED_TYPEID_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -