Exemple #1
0
        protected override Expression DoResolve(ResolveContext rc)
        {
            if (rc.IsRuntimeBinder)
            {
                if (UnwrapLeft == null && !Left.Type.IsNullableType)
                {
                    Left = LiftOperand(rc, Left);
                }

                if (UnwrapRight == null && !Right.Type.IsNullableType)
                {
                    Right = LiftOperand(rc, Right);
                }
            }
            else
            {
                if (UnwrapLeft == null && Left != null && Left.Type.IsNullableType)
                {
                    Left       = Unwrap.CreateUnwrapped(Left);
                    UnwrapLeft = Left as Unwrap;
                }

                if (UnwrapRight == null && Right != null && Right.Type.IsNullableType)
                {
                    Right       = Unwrap.CreateUnwrapped(Right);
                    UnwrapRight = Right as Unwrap;
                }

                if (Left.Type.BuiltinType == BuiltinTypeSpec.Type.Decimal)
                {
                    var decimal_operators = MemberCache.GetUserOperator(Left.Type, Binary.ConvertBinaryToUserOperator(Binary.Oper), false);

                    Arguments args = new Arguments(2);
                    args.Add(new Argument(Left));
                    args.Add(new Argument(Right));

                    const OverloadResolver.Restrictions restr = OverloadResolver.Restrictions.ProbingOnly |
                                                                OverloadResolver.Restrictions.NoBaseMembers | OverloadResolver.Restrictions.BaseMembersIncluded;

                    var res = new OverloadResolver(decimal_operators, restr, loc);
                    UserOperator = res.ResolveOperator(rc, ref args);
                }
            }

            type   = Binary.Type;
            eclass = Binary.eclass;

            return(this);
        }