예제 #1
0
        public static tAsyncCall *GetGenericArguments(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tMD_TypeDef *      pType = ((tRuntimeType *)pThis_)->pTypeDef;
            tMD_TypeDef *      pCoreType;
            uint               i, argCount = 0;
            /*HEAP_PTR*/ byte *ret;

            pCoreType = pType->pGenericDefinition;
            if (pCoreType != null)
            {
                // Find the core instantiation of this type
                tGenericInstance *pInst = pCoreType->pGenericInstances;
                while (pInst != null)
                {
                    if (pInst->pInstanceTypeDef == pType)
                    {
                        // Found it!
                        argCount = pInst->numTypeArgs;
                    }
                    pInst = pInst->pNext;
                }
            }

            ret = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_TYPE], argCount);
            // Allocate to return value straight away, so it cannot be GCed
            *(/*HEAP_PTR*/ byte **)pReturnValue = ret;

            for (i = 0; i < argCount; i++)
            {
                /*HEAP_PTR*/ byte *argType = Type.GetTypeObject(pType->ppClassTypeArgs[i]);
                System_Array.StoreElement(ret, i, (byte *)&argType);
            }

            return(null);
        }
예제 #2
0
        public static tAsyncCall *Internal_GetInfo(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tMD_TypeDef *      pEnumType = System_RuntimeType.DeRef((byte *)((tMD_TypeDef **)pParams)[0]);
            uint               i, retIndex;
            /*HEAP_PTR*/ byte *names, values;

            // An enum type always has just one non-literal field, with all other fields being the values.
            names  = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_STRING], pEnumType->numFields - 1);
            values = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_INT32], pEnumType->numFields - 1);

            for (i = 0, retIndex = 0; i < pEnumType->numFields; i++)
            {
                tMD_FieldDef * pField = pEnumType->ppFields[i];
                tSystemString *name;
                int            value;

                if (!MetaData.FIELD_ISLITERAL(pField))
                {
                    continue;
                }

                name = System_String.FromCharPtrASCII(pField->name);
                System_Array.StoreElement(names, retIndex, (byte *)&name);
                MetaData.GetConstant(pField->pMetaData, pField->tableIndex, (byte *)&value);
                System_Array.StoreElement(values, retIndex, (byte *)&value);
                retIndex++;
            }

            *(((/*HEAP_PTR*/ byte ***)pParams)[1]) = names;
            *(((/*HEAP_PTR*/ byte ***)pParams)[2]) = values;

            return(null);
        }
예제 #3
0
        // Get all the fields in the value-Type.types in the parameters.
        // If the 2nd parameter is null, then don't include it!
        // The type of the objects will always be identical.
        public static tAsyncCall *GetFields(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            /*HEAP_PTR*/ byte *o1, o2, ret;
            tMD_TypeDef *      pType;
            //tMetaData *pMetaData;
            uint i, retOfs, numInstanceFields;

            o1    = ((/*HEAP_PTR*/ byte **)pParams)[0];
            o2    = ((/*HEAP_PTR*/ byte **)pParams)[1];
            pType = Heap.GetType(o1);
            //pMetaData = pType->pMetaData;

            numInstanceFields = 0;
            for (i = 0; i < pType->numFields; i++)
            {
                if (!MetaData.FIELD_ISSTATIC(pType->ppFields[i]))
                {
                    numInstanceFields++;
                }
            }

            ret = System_Array.NewVector(Type.types[Type.TYPE_SYSTEM_ARRAY_OBJECT], numInstanceFields << ((o2 == null)?0:1));

            retOfs = 0;
            for (i = 0; i < pType->numFields; i++)
            {
                tMD_FieldDef *pField;

                pField = pType->ppFields[i];
                if (!MetaData.FIELD_ISSTATIC(pField))
                {
                    if (pField->pType->isValueType != 0)
                    {
                        /*HEAP_PTR*/ byte *boxed;

                        boxed = Heap.Box(pField->pType, o1 + pField->memOffset);
                        System_Array.StoreElement(ret, retOfs++, (byte *)&boxed);
                        if (o2 != null)
                        {
                            boxed = Heap.Box(pField->pType, o2 + pField->memOffset);
                            System_Array.StoreElement(ret, retOfs++, (byte *)&boxed);
                        }
                    }
                    else
                    {
                        System_Array.StoreElement(ret, retOfs++, o1 + pField->memOffset);
                        if (o2 != null)
                        {
                            System_Array.StoreElement(ret, retOfs++, o2 + pField->memOffset);
                        }
                    }
                }
            }

            *(/*HEAP_PTR*/ byte **)pReturnValue = ret;

            return(null);
        }
예제 #4
0
    private void PreBinding()
    {
        System_Object.Wrap(L);
        System_MonoType.Wrap(L);
        System_Array.Wrap(L);
        System_Delegate.Wrap(L);

        System_Collections_IList.Wrap(L);
        System_Collections_IEnumerator.Wrap(L);

        UnityEngine_Vector2.Wrap(L);
        UnityEngine_Vector3.Wrap(L);
        UnityEngine_Quaternion.Wrap(L);
        UnityEngine_Color.Wrap(L);
    }
        public static tAsyncCall *InitializeArray(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            /*HEAP_PTR*/ byte *pArray;
            byte *       pRawData;
            tMD_TypeDef *pArrayTypeDef;
            byte *       pElements;
            uint         arrayLength;

            pArray        = (*((/*HEAP_PTR*/ byte **)(pParams + 0)));
            pRawData      = (*((byte **)(pParams + Sys.S_PTR)));
            pArrayTypeDef = Heap.GetType(pArray);
            arrayLength   = System_Array.GetLength(pArray);
            pElements     = System_Array.GetElements(pArray);
            Mem.memcpy(pElements, pRawData, pArrayTypeDef->pArrayElementType->arrayElementSize * arrayLength);

            return(null);
        }
예제 #6
0
        public static tAsyncCall *GetProperties(tJITCallNative *pCallNative, byte *pThis_, byte *pParams, byte *pReturnValue)
        {
            tRuntimeType *pRuntimeType = (tRuntimeType *)pThis_;
            tMD_TypeDef * pTypeDef     = pRuntimeType->pTypeDef;
            tMetaData *   pMetaData    = pTypeDef->pMetaData;

            // First we search through the table of propertymaps to find the propertymap for the requested type
            uint i;
            /*IDX_TABLE*/
            uint firstIdx = 0, lastIdxExc = 0;
            uint numPropertyRows    = pMetaData->tables.numRows[MetaDataTable.MD_TABLE_PROPERTY];
            uint numPropertymapRows = pMetaData->tables.numRows[MetaDataTable.MD_TABLE_PROPERTYMAP];

            for (i = 1; i <= numPropertymapRows; i++)
            {
                tMD_PropertyMap *pPropertyMap = (tMD_PropertyMap *)MetaData.GetTableRow(pMetaData, MetaData.MAKE_TABLE_INDEX(MetaDataTable.MD_TABLE_PROPERTYMAP, i));
                if (pPropertyMap->parent == pTypeDef->tableIndex)
                {
                    firstIdx = MetaData.TABLE_OFS(pPropertyMap->propertyList);
                    if (i < numPropertymapRows)
                    {
                        tMD_PropertyMap *pNextPropertyMap = (tMD_PropertyMap *)MetaData.GetTableRow(pMetaData, MetaData.MAKE_TABLE_INDEX(MetaDataTable.MD_TABLE_PROPERTYMAP, i + 1));
                        lastIdxExc = MetaData.TABLE_OFS(pNextPropertyMap->propertyList);
                    }
                    else
                    {
                        lastIdxExc = numPropertyRows + 1;
                    }
                    break;
                }
            }

            // Instantiate a PropertyInfo[]
            uint         numProperties = lastIdxExc - firstIdx;
            tMD_TypeDef *pArrayType    = Type.GetArrayTypeDef(Type.types[Type.TYPE_SYSTEM_REFLECTION_PROPERTYINFO], null, null);
            /*HEAP_PTR*/
            byte *ret = System_Array.NewVector(pArrayType, numProperties);

            // Allocate to return value straight away, so it cannot be GCed
            *(/*HEAP_PTR*/ byte **)pReturnValue = ret;

            // Now fill the PropertyInfo[]
            for (i = 0; i < numProperties; i++)
            {
                tMD_Property *pPropertyMetadata = (tMD_Property *)MetaData.GetTableRow(pMetaData, MetaData.MAKE_TABLE_INDEX(MetaDataTable.MD_TABLE_PROPERTY, firstIdx + i));

                // Instantiate PropertyInfo and put it in the array
                tPropertyInfo *pPropertyInfo = (tPropertyInfo *)Heap.AllocType(Type.types[Type.TYPE_SYSTEM_REFLECTION_PROPERTYINFO]);
                System_Array.StoreElement(ret, i, (byte *)&pPropertyInfo);

                // Assign ownerType
                pPropertyInfo->ownerType = pThis_;

                // Assign name
                pPropertyInfo->name = System_String.FromCharPtrASCII(pPropertyMetadata->name);

                // Assign propertyType
                uint  sigLength;
                byte *typeSig = MetaData.GetBlob(pPropertyMetadata->typeSig, &sigLength);
                MetaData.DecodeSigEntry(&typeSig); // Ignored: prolog
                MetaData.DecodeSigEntry(&typeSig); // Ignored: number of 'getter' parameters
                tMD_TypeDef *propertyTypeDef = Type.GetTypeFromSig(pMetaData, &typeSig, null, null);
                MetaData.Fill_TypeDef(propertyTypeDef, null, null);
                pPropertyInfo->propertyType = Type.GetTypeObject(propertyTypeDef);
            }

            return(null);
        }