public static tAsyncCall *Equals(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue) { tSystemString *a, b; uint ret; char * pAChars, pBChars; a = (*((tSystemString **)(pParams + 0))); b = (*((tSystemString **)(pParams + Sys.S_PTR))); if (a == b) { ret = 1; } else if (a == null || b == null || a->length != b->length) { ret = 0; } else { pAChars = tSystemString.GetChars(a); pBChars = tSystemString.GetChars(b); ret = (uint)((Mem.memcmp(pAChars, pBChars, (SIZE_T)(a->length << 1)) == 0)?1:0); } Sys.INTERNALCALL_RESULT_U32(pReturnValue, ret); return(null); }
public static tAsyncCall *get_Length(tJITCallNative *pCallNative, byte *pThis, byte *pParams, byte *pReturnValue) { string s = ToMonoString((tSystemString *)pThis); Sys.INTERNALCALL_RESULT_U32(pReturnValue, (uint)s.Length); return(null); }
public static tAsyncCall *get_Chars(tJITCallNative *pCallNative, byte *pThis, byte *pParams, byte *pReturnValue) { int index; string s; index = (*((int *)(pParams + 0))); s = ToMonoString((tSystemString *)pThis); Sys.INTERNALCALL_RESULT_U32(pReturnValue, (uint)(s[index])); return(null); }
public static tAsyncCall *GetHashCode(tJITCallNative *pCallNative, byte *pThis, byte *pParams, byte *pReturnValue) { int hash; string s; s = ToMonoString((tSystemString *)pThis); hash = s.GetHashCode(); Sys.INTERNALCALL_RESULT_U32(pReturnValue, (uint)hash); return(null); }
public static tAsyncCall *get_Chars(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue) { tSystemString *pThis = (tSystemString *)pThis_; uint index; char * pChars; index = (*((uint *)(pParams + 0))); pChars = tSystemString.GetChars(pThis); Sys.INTERNALCALL_RESULT_U32(pReturnValue, (uint)(pChars[index])); return(null); }
public static tAsyncCall *Internal_Copy(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue) { tSystemArray *pSrc, pDst; tMD_TypeDef * pSrcType, pDstType, pSrcElementType; byte * pSrcElements, pDstElements; pSrc = (*((tSystemArray **)(pParams + 0))); pDst = (*((tSystemArray **)(pParams + Sys.S_PTR + Sys.S_INT32))); // Check if we can do a fast-copy with these two arrays pSrcType = Heap.GetType((/*HEAP_PTR*/ byte *)pSrc); pDstType = Heap.GetType((/*HEAP_PTR*/ byte *)pDst); pSrcElementType = pSrcType->pArrayElementType; if (Type.IsAssignableFrom(pDstType->pArrayElementType, pSrcElementType) != 0) { // Can do fast-copy uint srcIndex, dstIndex, length, elementSize; srcIndex = (*((uint *)(pParams + Sys.S_PTR))); dstIndex = (*((uint *)(pParams + Sys.S_PTR + Sys.S_INT32 + Sys.S_PTR))); length = (*((uint *)(pParams + Sys.S_PTR + Sys.S_INT32 + Sys.S_PTR + Sys.S_INT32))); #if WIN32 && _DEBUG // Do bounds check if (srcIndex + length > pSrc->length || dstIndex + length > pDst->length) { printf("[Array] Internal_Copy() Bounds check failed\n"); __debugbreak(); } #endif elementSize = pSrcElementType->arrayElementSize; pSrcElements = tSystemArray.GetElements(pSrc); pDstElements = tSystemArray.GetElements(pDst); Mem.memcpy(pDstElements + dstIndex * elementSize, pSrcElements + srcIndex * elementSize, (SIZE_T)(length * elementSize)); Sys.INTERNALCALL_RESULT_U32(pReturnValue, 1); } else { // Cannot do fast-copy Sys.INTERNALCALL_RESULT_U32(pReturnValue, 0); } return(null); }
public static tAsyncCall *Equals(tJITCallNative *pCallNative, byte *pThis, byte *pParams, byte *pReturnValue) { tSystemString *a, b; string aStr, bStr; uint ret; a = (*((tSystemString **)(pParams + 0))); aStr = ToMonoString(a); b = (*((tSystemString **)(pParams + Sys.S_PTR))); bStr = ToMonoString(b); ret = (a == b ? 1U : 0U); Sys.INTERNALCALL_RESULT_U32(pReturnValue, ret); return(null); }
public static tAsyncCall *GetHashCode(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue) { tSystemString *pThis = (tSystemString *)pThis_; char * pChar, pEnd; int hash; hash = 0; pChar = tSystemString.GetChars(pThis); pEnd = pChar + pThis->length - 1; for (; pChar < pEnd; pChar += 2) { hash = (hash << 5) - hash + pChar[0]; hash = (hash << 5) - hash + pChar[1]; } if (pChar <= pEnd) { hash = (hash << 5) - hash + pChar[0]; } Sys.INTERNALCALL_RESULT_U32(pReturnValue, (uint)hash); return(null); }
// Value-Type.types will be boxed public static tAsyncCall *Internal_SetValue(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue) { tSystemArray * pArray = (tSystemArray *)pThis_; tMD_TypeDef * pArrayType, pObjType; uint index, elementSize; /*HEAP_PTR*/ byte *obj; tMD_TypeDef * pElementType; byte * pElement; pArrayType = Heap.GetType(pThis_); obj = (*((byte **)(pParams + 0))); pObjType = Heap.GetType(obj); pElementType = pArrayType->pArrayElementType; // Check to see if the Type is ok to put in the array if (!(Type.IsAssignableFrom(pElementType, pObjType) != 0 || (pElementType->pGenericDefinition == Type.types[Type.TYPE_SYSTEM_NULLABLE] && pElementType->ppClassTypeArgs[0] == pObjType))) { // Can't be done Sys.INTERNALCALL_RESULT_U32(pReturnValue, 0); return(null); } index = (*((uint *)(pParams + Sys.S_PTR))); #if WIN32 && _DEBUG // Do a bounds-check if (index >= pArray->length) { printf("[Array] Internal_SetValue() Bounds-check failed\n"); __debugbreak(); } #endif elementSize = pElementType->arrayElementSize; pElement = tSystemArray.GetElements(pArray) + elementSize * index; if (pElementType->isValueType != 0) { if (pElementType->pGenericDefinition == Type.types[Type.TYPE_SYSTEM_NULLABLE]) { // Nullable type, so treat specially if (obj == null) { Mem.memset(pElement, 0, elementSize); } else { *(uint *)pElement = 1; Mem.memcpy(pElement + 4, obj, elementSize - 4); } } else { // Get the value out of the box Mem.memcpy(pElement, obj, elementSize); } } else { // This must be a reference type, so it must be 32-bits wide *(/*HEAP_PTR*/ byte **)pElement = obj; } Sys.INTERNALCALL_RESULT_U32(pReturnValue, 1); return(null); }