Пример #1
0
        public ApplicableFunction FindConstructor(Type t, Operand[] args)
        {
            ApplicableFunction ctor = OverloadResolver.Resolve(GetConstructors(t), TypeMapper, args);

            if (ctor == null)
            {
                throw new MissingMemberException(Messages.ErrMissingConstructor);
            }

            return(ctor);
        }
        public ContextualOperand New(Type type, params Operand[] args)
        {
            ApplicableFunction ctor = OverloadResolver.Resolve(_typeMapper.TypeInfo.GetConstructors(type), _typeMapper, args);

            if (ctor == null)
            {
                throw new MissingMethodException(Messages.ErrMissingConstructor);
            }

            return(new ContextualOperand(new NewObject(ctor, args), _typeMapper));
        }
Пример #3
0
        public static Operand New(Type type, params Operand[] args)
        {
            ApplicableFunction ctor = OverloadResolver.Resolve(TypeInfo.GetConstructors(type), args);

            if (ctor == null)
            {
                throw new MissingMethodException(Properties.Messages.ErrMissingConstructor);
            }

            return(new NewObject(ctor, args));
        }
Пример #4
0
        public static ApplicableFunction FindConstructor(Type t, Operand[] args)
        {
            ApplicableFunction ctor = OverloadResolver.Resolve(GetConstructors(t), args);

            if (ctor == null)
            {
                throw new MissingMemberException("Cannot find constructor");
            }

            return(ctor);
        }
Пример #5
0
        public static ApplicableFunction FindMethod(Type t, string name, Operand[] args, bool @static)
        {
            for (; t != null; t = t.BaseType)
            {
                ApplicableFunction af = OverloadResolver.Resolve(Filter(GetMethods(t), name, false, @static, false), args);

                if (af != null)
                {
                    return(af);
                }
            }

            throw new MissingMethodException(Properties.Messages.ErrMissingMethod);
        }
Пример #6
0
        public ApplicableFunction FindMethod(Type t, string name, Operand[] args, bool @static)
        {
            foreach (Type type in SearchableTypes(t))
            {
                IEnumerable <IMemberInfo> methods = GetMethods(type);
                IEnumerable <IMemberInfo> filter  = Filter(methods, name, false, @static, false);
                ApplicableFunction        af      = OverloadResolver.Resolve(filter, TypeMapper, args);

                if (af != null)
                {
                    return(af);
                }
            }

            throw new MissingMethodException(Messages.ErrMissingMethod);
        }
Пример #7
0
        public static ApplicableFunction FindMethod(Type t, string name, Operand[] args, bool allowOverrides, bool @static)
        {
            Type ot = t;

            for (; t != null; t = t.BaseType)
            {
                ApplicableFunction af = OverloadResolver.Resolve(Filter(GetMethods(t), name, false, @static, allowOverrides), args);

                if (af != null)
                {
                    return(af);
                }
            }

            throw new MissingMethodException("Cannot find method" + " " + name + " in " + ot.FullName);
        }
Пример #8
0
        public static ApplicableFunction FindProperty(Type t, string name, Operand[] indexes, bool @static)
        {
            if (name == null)
            {
                name = GetDefaultMember(t);
            }

            for (; t != null; t = t.BaseType)
            {
                ApplicableFunction af = OverloadResolver.Resolve(Filter(GetProperties(t), name, false, @static, false), indexes);

                if (af != null)
                {
                    return(af);
                }
            }

            throw new MissingMemberException(Properties.Messages.ErrMissingProperty);
        }
Пример #9
0
        public ApplicableFunction FindMethod(MethodInfo method)
        {
            var t = method.ReflectedType;

            foreach (Type type in SearchableTypes(t))
            {
                IEnumerable <IMemberInfo> methods = GetMethods(type);
                IEnumerable <IMemberInfo> filter  = Filter(methods, method.Name, false, method.IsStatic, !type.IsValueType);
                ApplicableFunction        af      = OverloadResolver.ResolveStrict(filter, TypeMapper, ArrayUtils.GetTypes(method.GetParameters()));

                if (af != null)
                {
                    return(af);
                }
            }


            throw new MissingMethodException(Properties.Messages.ErrMissingMethod + ": " + method.ToString());
        }
Пример #10
0
        public static ApplicableFunction FindProperty(Type t, string name, Operand[] indexes, bool @static)
        {
            if (name == null)
            {
                name = GetDefaultMember(t);
            }
            var ot = t;

            for (; t != null; t = t.BaseType)
            {
                ApplicableFunction af = OverloadResolver.Resolve(Filter(GetProperties(t), name, false, @static, false), indexes);

                if (af != null)
                {
                    return(af);
                }
            }

            throw new MissingMemberException("Cannot find property" + " " + name + " in " + ot.FullName);
        }
Пример #11
0
        internal List <ApplicableFunction> FindUserCandidates(ITypeMapper typeMapper, params Operand[] args)
        {
            List <Type> usedTypes = new List <Type>();
            List <ApplicableFunction> candidates = null;
            string name = "op_" + MethodName;
            bool   expandedCandidates = false;

            foreach (Operand arg in args)
            {
                for (Type t = Operand.GetType(arg, typeMapper); t != null && t != typeMapper.MapType(typeof(object)) && (t.IsClass || t.IsValueType) && !usedTypes.Contains(t); t = t.IsValueType ? null : t.BaseType)
                {
                    usedTypes.Add(t);

                    OverloadResolver.FindApplicable(ref candidates, ref expandedCandidates, typeMapper.TypeInfo.Filter(typeMapper.TypeInfo.GetMethods(t), name, true, true, false), typeMapper, args);
                }
            }

            if (expandedCandidates)
            {
                OverloadResolver.RemoveExpanded(candidates);
            }

            return(candidates);
        }