Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public static ApplicableFunction FindConstructor(Type t, Operand[] args)
        {
            ApplicableFunction ctor = OverloadResolver.Resolve(GetConstructors(t), args);

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

            return(ctor);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        internal List <ApplicableFunction> FindUserCandidates(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); t != null && t != typeof(object) && (t.IsClass || t.IsValueType) && !usedTypes.Contains(t); t = t.IsValueType ? null : t.BaseType)
                {
                    usedTypes.Add(t);

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

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

            return(candidates);
        }