示例#1
0
文件: Sys.cs 项目: bmjoy/dnaunity
        public static /*char*/ byte *GetMethodDesc(tMD_MethodDef *pMethod)
        {
            int i;

            byte *namePos = methodNameBuf;
            byte *nameEnd = namePos + METHOD_NAME_BUF_SIZE;

            namePos = S.scatprintf(namePos, nameEnd, "%s.%s.%s(", (PTR)pMethod->pParentType->nameSpace, (PTR)pMethod->pParentType->name, (PTR)pMethod->name);
            for (i = MetaData.METHOD_ISSTATIC(pMethod) ? 0 : 1; i < pMethod->numberOfParameters; i++)
            {
                if (i > (int)(MetaData.METHOD_ISSTATIC(pMethod) ? 0 : 1))
                {
                    namePos = S.scatprintf(namePos, nameEnd, ",");
                }
                tParameter *param = &(pMethod->pParams[i]);
                namePos = S.scatprintf(namePos, nameEnd, "%s", (PTR)param->pStackTypeDef->name);
            }
            S.scatprintf(namePos, nameEnd, ")");

            return(methodNameBuf);
        }
示例#2
0
 public static bool PARAM_ISBYREF(tParameter *pParam)
 {
     return(pParam->pByRefTypeDef != null);
 }
示例#3
0
        public static tMD_TypeDef *PARAM_ACTUAL_TYPE(tParameter *pParam)
        {
            tMD_TypeDef *pByRefType = pParam->pByRefTypeDef;

            return((pByRefType != null) ? pByRefType : pParam->pStackTypeDef);
        }
示例#4
0
        public static uint CompareNameAndMethodInfo(/*STRING*/ byte *name, System.Reflection.MethodBase methodBase, tMetaData *pSigMetaData,
                                                    tMD_TypeDef **ppSigClassTypeArgs, tMD_TypeDef **ppSigMethodTypeArgs, tMD_MethodDef *pMethod, tMD_TypeDef **ppMethodClassTypeArgs,
                                                    tMD_TypeDef **ppMethodMethodTypeArgs)
        {
            if (S.strcmp(name, pMethod->name) == 0)
            {
                uint i;

                if (METHOD_ISSTATIC(pMethod) != methodBase.IsStatic ||
                    METHOD_ISVIRTUAL(pMethod) != methodBase.IsVirtual)
                {
                    return(0);
                }

                System.Reflection.ParameterInfo[] paramInfos = methodBase.GetParameters();

                uint numberOfParameters = (uint)(paramInfos.Length + (methodBase.IsStatic ? 0 : 1));
                if ((uint)pMethod->numberOfParameters != numberOfParameters)
                {
                    return(0);
                }

                if (methodBase.IsGenericMethod != (pMethod->isGenericDefinition != 0))
                {
                    return(0);
                }

                if (methodBase is MethodInfo)
                {
                    if (pMethod->pReturnType == null)
                    {
                        if (((MethodInfo)methodBase).ReturnType != typeof(void))
                        {
                            return(0);
                        }
                    }
                    else if (pMethod->pReturnType != MonoType.GetTypeForMonoType(((MethodInfo)methodBase).ReturnType,
                                                                                 ppMethodClassTypeArgs, ppMethodMethodTypeArgs))
                    {
                        return(0);
                    }
                }

                uint start = 0;
                if (!methodBase.IsStatic)
                {
//                    if (pMethod->pParams[0].pStackTypeDef != MonoType.GetTypeForMonoType(methodInfo.DeclaringType))
//                        return 0;
                    start = 1;
                }

                for (i = start; i < numberOfParameters; i++)
                {
                    tParameter *pParam = &pMethod->pParams[i];
                    System.Reflection.ParameterInfo paramInfo = paramInfos[i - start];

                    // NOTE: We are not checking to see if params are REF params here.  Potentially a problem.
                    if (pParam->pStackTypeDef != MonoType.GetTypeForMonoType(paramInfo.ParameterType,
                                                                             ppMethodClassTypeArgs, ppMethodMethodTypeArgs))
                    {
                        return(0);
                    }
                }

                return(1);
            }
            return(0);
        }