Example #1
0
        public ApplicableFunction FindProperty(Type t, string name, Operand[] indexes, bool @static)
        {
            if (name == null)
            {
                name = GetDefaultMember(t);
            }

            foreach (Type type in SearchableTypes(t))
            {
                ApplicableFunction af = OverloadResolver.Resolve(Filter(GetProperties(type), name, false, @static, false), TypeMapper, indexes);

                if (af != null)
                {
                    return(af);
                }
            }
            //for (; t != null; t = t.BaseType)
            //{

            //}

            throw new MissingMemberException(Messages.ErrMissingProperty);
        }
Example #2
0
        public static Better GetBetterCandidate(ApplicableFunction left, ApplicableFunction right)
        {
            if (!ArrayUtils.Equals(left.paramsSignature, right.paramsSignature))
            {
                throw new InvalidOperationException();
            }

            int leftBetter = 0, rightBetter = 0;

            for (int i = 0; i < left.appliedSignature.Length; i++)
            {
                Better better = GetBetterConversion(left.paramsSignature[i], left.appliedSignature[i], right.appliedSignature[i]);
                if (better == Better.Left)
                {
                    leftBetter++;
                }
                else if (better == Better.Right)
                {
                    rightBetter++;
                }

                if (leftBetter != 0 && rightBetter != 0)
                {
                    return(0);
                }
            }

            if (leftBetter > 0)
            {
                return(Better.Left);
            }
            if (rightBetter > 0)
            {
                return(Better.Right);
            }
            return(Better.Neither);
        }
		internal AttributeGen(AttributeTargets target, AttributeType attributeType, object[] args)
		{
			if (args != null)
			{
				foreach (object arg in args)
				{
					CheckValue(arg);
				}
			}

			// TODO: target validation

			this.attributeType = attributeType;

			Operand[] argOperands;
			if (args == null || args.Length == 0)
			{
				this.args = EmptyArray<object>.Instance;
				argOperands = Operand.EmptyArray;
			}
			else
			{
				this.args = args;
				argOperands = new Operand[args.Length];
				for (int i = 0; i < args.Length; i++)
				{
					argOperands[i] = GetOperand(args[i]);
				}
			}

			this.ctor = TypeInfo.FindConstructor(attributeType, argOperands);
		}
Example #4
0
 public bool SignatureEquals(ApplicableFunction other)
 {
     return(ArrayUtils.Equals(appliedSignature, other.appliedSignature));
 }
Example #5
0
        public static Better GetBetterCandidate(ApplicableFunction left, ApplicableFunction right)
        {
            if (!ArrayUtils.Equals(left.paramsSignature, right.paramsSignature))
                throw new InvalidOperationException();

            int leftBetter = 0, rightBetter = 0;

            for (int i = 0; i < left.appliedSignature.Length; i++)
            {
                Better better = GetBetterConversion(left.paramsSignature[i], left.appliedSignature[i], right.appliedSignature[i]);
                if (better == Better.Left)
                    leftBetter++;
                else if (better == Better.Right)
                    rightBetter++;

                if (leftBetter != 0 && rightBetter != 0)
                    return 0;
            }

            if (leftBetter > 0)
                return Better.Left;
            if (rightBetter > 0)
                return Better.Right;
            return Better.Neither;
        }
Example #6
0
 public bool SignatureEquals(ApplicableFunction other)
 {
     return ArrayUtils.Equals(appliedSignature, other.appliedSignature);
 }