Esempio n. 1
0
        public static Expression UnaryOperatorFunc(
            OpFuncArgs args
            )
        {
            Expression le = args.ExprStack.Pop();

            return(((UnaryOperator)args.Op).Func(le));
        }
Esempio n. 2
0
        public static Expression TypeOperatorFunc(
            OpFuncArgs args
            )
        {
            Expression le = args.ExprStack.Pop();

            return(((TypeOperator)args.Op).Func(le, args.T.Type));
        }
Esempio n. 3
0
        public static Expression MethodOperatorFunc(
            OpFuncArgs args
            )
        {
            string     nextToken = ((MemberToken)args.T).Name;
            Expression le        = args.ExprStack.Pop();

            Expression result = ((MethodOperator)args.Op).Func(le, nextToken, args.Args);

            return(result);
        }
Esempio n. 4
0
        public static Expression BinaryOperatorFunc(
            OpFuncArgs args
            )
        {
            Expression re = args.ExprStack.Pop();
            Expression le = args.ExprStack.Pop();

            // perform implicit conversion on known types
            TypeConversion.Convert(ref le, ref re);
            return(((BinaryOperator)args.Op).Func(le, re));
        }
        public static Expression MethodOperatorFunc(
            OpFuncArgs args 
            )
        {
            string nextToken = ((MemberToken)args.T).Name;
            Expression le = args.ExprStack.Pop();

            Expression result = ((MethodOperator)args.Op).Func(args.T.IsFunction, args.T.IsCall, le, nextToken, args.Args);

            return result;
        }
Esempio n. 6
0
        public static Expression TernaryOperatorFunc(OpFuncArgs args)
        {
            Expression falsy     = args.ExprStack.Pop();
            Expression truthy    = args.ExprStack.Pop();
            Expression condition = args.ExprStack.Pop();

            if (condition.Type != typeof(bool))
            {
                condition = Expression.Convert(condition, typeof(bool));
            }

            // perform implicit conversion on known types ???
            TypeConversion.Convert(ref falsy, ref truthy);
            return(((TernaryOperator)args.Op).Func(condition, truthy, falsy));
        }
        public static Expression TernaryOperatorFunc(OpFuncArgs args)
        {
            Expression falsy = args.ExprStack.Pop();
            Expression truthy = args.ExprStack.Pop();
            Expression condition = args.ExprStack.Pop();

            if (condition.Type != typeof(bool))
            {
                condition = Expression.Convert(condition, typeof(bool));
            }

            // perform implicit conversion on known types ???
            TypeConversion.Convert(ref falsy, ref truthy);
            return ((TernaryOperator)args.Op).Func(condition, truthy, falsy);
        }
Esempio n. 8
0
        public static Expression UnaryOperatorFunc(
            OpFuncArgs args
            )
        {
            Expression le = args.ExprStack.Pop();

            // perform implicit conversion on known types

            if (le.Type.IsDynamic())
            {
                return(DynamicUnaryOperatorFunc(le, args.Op.ExpressionType));
            }
            else
            {
                return(((UnaryOperator)args.Op).Func(le));
            }
        }
Esempio n. 9
0
        public static Expression BinaryOperatorFunc(
            OpFuncArgs args
            )
        {
            Expression re = args.ExprStack.Pop();
            Expression le = args.ExprStack.Pop();
            // perform implicit conversion on known types
            var isDynamic = le.Type.GetInterfaces().Contains(typeof(IDynamicMetaObjectProvider)) ||
                            le.Type == typeof(Object);


            if (le.Type.IsDynamic() && re.Type.IsDynamic())
            {
                var expressionType = args.Op.ExpressionType;

                if (expressionType == ExpressionType.OrElse)
                {
                    le             = Expression.IsTrue(Expression.Convert(le, typeof(bool)));
                    expressionType = ExpressionType.Or;
                    return(Expression.Condition(le, Expression.Constant(true), Expression.Convert(DynamicBinaryOperatorFunc(Expression.Constant(false), re, expressionType), typeof(bool))));
                }


                if (expressionType == ExpressionType.AndAlso)
                {
                    le             = Expression.IsFalse(Expression.Convert(le, typeof(bool)));
                    expressionType = ExpressionType.And;
                    return(Expression.Condition(le, Expression.Constant(false), Expression.Convert(DynamicBinaryOperatorFunc(Expression.Constant(true), re, expressionType), typeof(bool))));
                }

                return(DynamicBinaryOperatorFunc(le, re, expressionType));
            }
            else
            {
                TypeConversion.Convert(ref le, ref re);

                return(((BinaryOperator)args.Op).Func(le, re));
            }
        }
Esempio n. 10
0
        public static Expression BinaryOperatorFunc(
            OpFuncArgs args
            )
        {
            Expression re = args.ExprStack.Pop();
            Expression le = args.ExprStack.Pop();
            // perform implicit conversion on known types
            var isDynamic = le.Type.GetInterfaces().Contains(typeof(IDynamicMetaObjectProvider)) ||
                le.Type == typeof(Object);

            if (le.Type.IsDynamic() && re.Type.IsDynamic())
            {
                var expressionType = args.Op.ExpressionType;

                if (expressionType == ExpressionType.OrElse)
                {
                    le = Expression.IsTrue(Expression.Convert(le, typeof(bool)));
                    expressionType = ExpressionType.Or;
                    return Expression.Condition(le, Expression.Constant(true), Expression.Convert(DynamicBinaryOperatorFunc(Expression.Constant(false), re, expressionType), typeof(bool)));
                }

                if (expressionType == ExpressionType.AndAlso)
                {
                    le = Expression.IsFalse(Expression.Convert(le, typeof(bool)));
                    expressionType = ExpressionType.And;
                    return Expression.Condition(le, Expression.Constant(false), Expression.Convert(DynamicBinaryOperatorFunc(Expression.Constant(true), re, expressionType), typeof(bool)));
                }

                return DynamicBinaryOperatorFunc(le, re, expressionType);
            }
            else
            {
                TypeConversion.Convert(ref le, ref re);

                return ((BinaryOperator)args.Op).Func(le, re);
            }
        }
Esempio n. 11
0
 public static Expression TernarySeparatorOperatorFunc(OpFuncArgs args)
 {
     return(args.ExprStack.Pop());
 }
Esempio n. 12
0
        public static Expression UnaryOperatorFunc(
            OpFuncArgs args
            )
        {
            Expression le = args.ExprStack.Pop();
            // perform implicit conversion on known types

            if (le.Type.IsDynamic())
            {
                return DynamicUnaryOperatorFunc(le, args.Op.ExpressionType);
            }
            else
            {
                return ((UnaryOperator)args.Op).Func(le);
            }
        }
Esempio n. 13
0
 public static Expression TypeOperatorFunc(
     OpFuncArgs args
     )
 {
     Expression le = args.ExprStack.Pop();
     return ((TypeOperator)args.Op).Func(le, args.T.Type);
 }
Esempio n. 14
0
 public static Expression TernarySeparatorOperatorFunc(OpFuncArgs args)
 {
     return args.ExprStack.Pop();
 }