Exemplo n.º 1
0
        public IMethod GetMethod(string funcname, MethodParamList types)
        {
            bool    hasMethods = this.type_CLRSharp.HasMethods;
            IMethod result;

            if (hasMethods)
            {
                foreach (MethodDefinition current in this.type_CLRSharp.Methods)
                {
                    bool flag = current.Name != funcname;
                    if (!flag)
                    {
                        bool flag2 = (types == null) ? (!current.HasParameters) : (current.Parameters.Count == types.Count);
                        if (flag2)
                        {
                            bool flag3 = true;
                            for (int i = 0; i < ((types == null) ? 0 : types.Count); i++)
                            {
                                ICLRType type  = this.env.GetType(current.Parameters[i].ParameterType.FullName);
                                bool     flag4 = type.IsEnum();
                                if (flag4)
                                {
                                    bool flag5 = type.TypeForSystem != types[i].TypeForSystem;
                                    if (flag5)
                                    {
                                        flag3 = false;
                                        break;
                                    }
                                }
                                else
                                {
                                    bool flag6 = type != types[i];
                                    if (flag6)
                                    {
                                        flag3 = false;
                                        break;
                                    }
                                }
                            }
                            bool flag7 = flag3;
                            if (flag7)
                            {
                                result = new Method_Common_CLRSharp(this, current);
                                return(result);
                            }
                        }
                    }
                }
            }
            result = null;
            return(result);
        }
        public ICLRType GetType(string fullname)
        {
            ICLRType result;

            try
            {
                ICLRType iCLRType = null;
                bool     flag     = this.mapType.TryGetValue(fullname, out iCLRType);
                bool     flag2    = !flag;
                if (flag2)
                {
                    List <ICLRType> list  = new List <ICLRType>();
                    bool            flag3 = fullname.Contains("<>") || fullname.Contains("/");
                    if (flag3)
                    {
                        string[] array = fullname.Split(new char[]
                        {
                            '/'
                        });
                        ICLRType iCLRType2 = this.GetType(array[0]);
                        bool     flag4     = iCLRType2 is ICLRType_Sharp;
                        if (flag4)
                        {
                            for (int i = 1; i < array.Length; i++)
                            {
                                iCLRType2 = iCLRType2.GetNestType(this, array[i]);
                            }
                            result = iCLRType2;
                            return(result);
                        }
                    }
                    string text  = fullname;
                    bool   flag5 = text.Contains("<");
                    if (flag5)
                    {
                        string text2 = "";
                        int    num   = 0;
                        int    num2  = 0;
                        int    j     = 0;
                        while (j < fullname.Length)
                        {
                            bool flag6 = fullname[j] == '/';
                            if (flag6)
                            {
                                goto IL_2AF;
                            }
                            bool flag7 = fullname[j] == '<';
                            if (flag7)
                            {
                                bool flag8 = j != 0;
                                if (flag8)
                                {
                                    num++;
                                }
                                bool flag9 = num == 1;
                                if (!flag9)
                                {
                                    goto IL_2AF;
                                }
                                num2   = j;
                                text2 += "[";
                            }
                            else
                            {
                                bool flag10 = fullname[j] == '>';
                                if (flag10)
                                {
                                    bool flag11 = num == 1;
                                    if (flag11)
                                    {
                                        string   fullname2 = text.Substring(num2 + 1, j - num2 - 1);
                                        ICLRType type      = this.GetType(fullname2);
                                        list.Add(type);
                                        bool flag12 = !type.IsEnum() && type is ICLRType_Sharp;
                                        if (flag12)
                                        {
                                            type = this.GetType(typeof(CLRSharp_Instance));
                                        }
                                        text2 = text2 + "[" + type.FullNameWithAssembly + "]";
                                        num2  = j;
                                    }
                                    num--;
                                    bool flag13 = num == 0;
                                    if (!flag13)
                                    {
                                        bool flag14 = num < 0;
                                        if (flag14)
                                        {
                                            num = 0;
                                        }
                                        goto IL_2AF;
                                    }
                                    text2 += "]";
                                }
                                else
                                {
                                    bool flag15 = fullname[j] == ',';
                                    if (flag15)
                                    {
                                        bool flag16 = num == 1;
                                        if (flag16)
                                        {
                                            string   fullname2 = text.Substring(num2 + 1, j - num2 - 1);
                                            ICLRType type2     = this.GetType(fullname2);
                                            list.Add(type2);
                                            bool flag17 = !type2.IsEnum() && type2 is ICLRType_Sharp;
                                            if (flag17)
                                            {
                                                type2 = this.GetType(typeof(CLRSharp_Instance));
                                            }
                                            text2 = text2 + "[" + type2.FullNameWithAssembly + "],";
                                            num2  = j;
                                        }
                                        goto IL_2AF;
                                    }
                                    goto IL_2AF;
                                }
                            }
IL_2DE:
                            j++;
                            continue;
IL_2AF:
                            bool flag18 = num == 0;
                            if (flag18)
                            {
                                text2 += text[j].ToString();
                            }
                            goto IL_2DE;
                        }
                        text = text2;
                    }
                    text = text.Replace('/', '+');
                    Type type3  = Type.GetType(text);
                    bool flag19 = type3 == null;
                    if (flag19)
                    {
                        bool flag20 = this.assemblylist != null;
                        if (flag20)
                        {
                            foreach (Assembly current in this.assemblylist)
                            {
                                type3 = current.GetType(text);
                                bool flag21 = type3 != null;
                                if (flag21)
                                {
                                    break;
                                }
                            }
                        }
                        bool flag22 = type3 == null;
                        if (flag22)
                        {
                            foreach (string current2 in this.moduleref)
                            {
                                type3 = Type.GetType(text + "," + current2);
                                bool flag23 = type3 != null;
                                if (flag23)
                                {
                                    text = text + "," + current2;
                                    break;
                                }
                            }
                        }
                    }
                    bool flag24 = type3 != null;
                    if (flag24)
                    {
                        bool flag25 = !type3.FullName.Contains("CLRSharp.CLRSharp_Instance");
                        if (flag25)
                        {
                            flag = this.mapType.TryGetValue(type3.FullName, out iCLRType);
                            bool flag26 = flag;
                            if (flag26)
                            {
                                result = iCLRType;
                                return(result);
                            }
                            iCLRType = new Type_Common_System(this, type3, list.ToArray());
                            this.mapType[type3.FullName] = iCLRType;
                            result = iCLRType;
                            return(result);
                        }
                        else
                        {
                            iCLRType = new Type_Common_System(this, type3, list.ToArray());
                            this.mapType[fullname] = iCLRType;
                        }
                    }
                }
                result = iCLRType;
            }
            catch (Exception innerException)
            {
                throw new Exception("Error in getType:" + fullname, innerException);
            }
            return(result);
        }
Exemplo n.º 3
0
        public IMethod GetMethodOverloaded(string funcname, MethodParamList types)
        {
            MethodDefinition methodDefinition = null;
            List <int>       list             = null;
            bool             hasMethods       = this.type_CLRSharp.HasMethods;
            IMethod          result;

            if (hasMethods)
            {
                foreach (MethodDefinition current in this.type_CLRSharp.Methods)
                {
                    bool flag = current.Name != funcname;
                    if (!flag)
                    {
                        bool flag2 = (types == null) ? (!current.HasParameters) : (current.Parameters.Count == types.Count);
                        if (flag2)
                        {
                            bool       flag3 = true;
                            List <int> list2 = new List <int>();
                            for (int i = 0; i < ((types == null) ? 0 : types.Count); i++)
                            {
                                ICLRType type  = this.env.GetType(current.Parameters[i].ParameterType.FullName);
                                bool     flag4 = type.IsEnum();
                                if (flag4)
                                {
                                    bool flag5 = type.TypeForSystem != types[i].TypeForSystem;
                                    if (flag5)
                                    {
                                        flag3 = false;
                                        break;
                                    }
                                }
                                else
                                {
                                    bool flag6 = !type.TypeForSystem.IsAssignableFrom(types[i].TypeForSystem);
                                    if (flag6)
                                    {
                                        flag3 = false;
                                        break;
                                    }
                                    list2.Add(this.GetInheritanceDistance(type.TypeForSystem, types[i].TypeForSystem));
                                }
                            }
                            bool flag7 = flag3;
                            if (flag7)
                            {
                                bool flag8 = list == null;
                                if (flag8)
                                {
                                    methodDefinition = current;
                                    list             = list2;
                                }
                                else
                                {
                                    for (int j = 0; j < list2.Count; j++)
                                    {
                                        bool flag9 = list2[j] < list[j];
                                        if (flag9)
                                        {
                                            methodDefinition = current;
                                            list             = list2;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                bool flag10 = methodDefinition == null;
                if (flag10)
                {
                    result = null;
                }
                else
                {
                    result = new Method_Common_CLRSharp(this, methodDefinition);
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }