示例#1
0
        public static tAsyncCall *Resize(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            /*HEAP_PTR*/ byte **ppArray_, pHeap;
            tSystemArray *      pOldArray, pNewArray;
            uint         newSize, oldSize;
            tMD_TypeDef *pArrayTypeDef;
            byte *       pOldElements, pNewElements;

            ppArray_ = (*((byte ***)(pParams + 0)));
            newSize  = (*((uint *)(pParams + Sys.S_PTR)));

            pOldArray = (tSystemArray *)*ppArray_;
            oldSize   = pOldArray->length;

            if (oldSize == newSize)
            {
                // Do nothing if new length equals the current length.
                return(null);
            }

            pArrayTypeDef = Heap.GetType(*ppArray_);
            pHeap         = (byte **)System_Array.NewVector(pArrayTypeDef, newSize);
            pNewArray     = (tSystemArray *)pHeap;
            *ppArray_ = (byte *)pHeap;
            pOldElements = tSystemArray.GetElements(pOldArray);
            pNewElements = tSystemArray.GetElements(pNewArray);
            Mem.memcpy(pNewElements, pOldElements,
                       (SIZE_T)(pArrayTypeDef->pArrayElementType->arrayElementSize * ((newSize < oldSize)?newSize:oldSize)));

            return(null);
        }
示例#2
0
        public static tAsyncCall *CreateInstance(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tRuntimeType *pRuntimeType = (*((tRuntimeType **)(pParams + 0)));
            tMD_TypeDef * pElementType = System_RuntimeType.DeRef((byte *)pRuntimeType);
            tMD_TypeDef * pArrayType   = Type.GetArrayTypeDef(pElementType, null, null);
            uint          length       = (*((uint *)(pParams + Sys.S_PTR)));

            Sys.INTERNALCALL_RESULT_PTR(pReturnValue, System_Array.NewVector(pArrayType, length));
            return(null);
        }
示例#3
0
        public static int Execute(tCLIFile *pThis, string[] args)
        {
            tThread *          pThread;
            /*HEAP_PTR*/ byte *pArgs;
            int i;

            // Create a string array for the program arguments
            // Don't include the argument that is the program name.
            pArgs = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_STRING], (uint)(args.Length - 1));
            Heap.MakeUndeletable(pArgs);
            for (i = 1; i < args.Length; i++)
            {
                tSystemString *pArgStr = System_String.FromMonoString(args[i]);
                System_Array.StoreElement(pArgs, (uint)(i - 1), (byte *)&pArgStr);
            }

            // Create the main application thread
            pThread = Thread.New();
            Thread.SetEntryPoint(pThread, pThis->pMetaData, pThis->entryPoint, (byte *)&pArgs, (uint)sizeof(void *));

            return(Thread.Execute());
        }