예제 #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);
        }
예제 #2
0
 public CodeBody CreateCodeBody(Method_Common_CLRSharp method)
 {
     return(new CodeBody(this, method.method_CLRSharp));
 }
예제 #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);
        }
예제 #4
0
 public CodeBody CreateCodeBody(Method_Common_CLRSharp method)
 {
     return new CodeBody(this, method.method_CLRSharp);
 }
예제 #5
0
        public IMethod GetMethod(string funcname, MethodParamList types)
        {
            List <KeyValuePair <MethodDefinition, Method_Common_CLRSharp> > methodDefinitions;

            if (methodCache.TryGetValue(funcname, out methodDefinitions))
            {
                {
                    var __list5      = methodDefinitions;
                    var __listCount5 = __list5.Count;
                    for (int __i5 = 0; __i5 < __listCount5; ++__i5)
                    {
                        var mm = __list5[__i5];
                        {
                            var m = mm.Key;
                            if ((types == null) ? !m.HasParameters : (m.Parameters.Count == types.Count))
                            {
                                bool match = true;
                                for (int i = 0; i < ((types == null) ? 0 : types.Count); i++)
                                {
                                    var envtype = env.GetType(m.Parameters[i].ParameterType.FullName);
                                    if (envtype.IsEnum())
                                    {
                                        if (envtype.TypeForSystem != types[i].TypeForSystem)
                                        {
                                            match = false;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (envtype != types[i])
                                        {
                                            match = false;
                                            break;
                                        }
                                    }
                                }
                                if (match)
                                {
                                    return(mm.Value);
                                }
                            }
                        }
                    }
                }
            }

            if (type_CLRSharp.HasMethods)
            {
                {
                    // foreach(var m in type_CLRSharp.Methods)
                    var __enumerator6 = (type_CLRSharp.Methods).GetEnumerator();
                    while (__enumerator6.MoveNext())
                    {
                        var m = __enumerator6.Current;
                        {
                            if (m.Name != funcname)
                            {
                                continue;
                            }
                            if ((types == null) ? !m.HasParameters : (m.Parameters.Count == types.Count))
                            {
                                bool match = true;
                                for (int i = 0; i < ((types == null) ? 0 : types.Count); i++)
                                {
                                    var envtype = env.GetType(m.Parameters[i].ParameterType.FullName);
                                    if (envtype.IsEnum())
                                    {
                                        if (envtype.TypeForSystem != types[i].TypeForSystem)
                                        {
                                            match = false;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (envtype != types[i])
                                        {
                                            match = false;
                                            break;
                                        }
                                    }
                                }
                                if (match)
                                {
                                    List <KeyValuePair <MethodDefinition, Method_Common_CLRSharp> > l;
                                    if (!methodCache.TryGetValue(funcname, out l))
                                    {
                                        l = new List <KeyValuePair <MethodDefinition, Method_Common_CLRSharp> >();
                                        methodCache.Add(funcname, l);
                                    }

                                    var method = new Method_Common_CLRSharp(this, m);;
                                    l.Add(new KeyValuePair <MethodDefinition, Method_Common_CLRSharp>(m, method));

                                    return(method);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }