예제 #1
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            if (node.NodeType == ExpressionType.Assign)
            {
                return(VisitAssign(node));
            }
            // For OpAssign nodes: if has a yield, we need to do the generator
            // transformation on the reduced value.
            if (node.CanReduce)
            {
                return(Visit(node.Reduce()));
            }

            int        yields = _yields.Count;
            Expression left   = Visit(node.Left);
            Expression right  = Visit(node.Right);

            if (left == node.Left && right == node.Right)
            {
                return(node);
            }
            if (yields == _yields.Count)
            {
                return(Expression.MakeBinary(node.NodeType, left, right, node.IsLiftedToNull, node.Method, node.Conversion));
            }

            return(Expression.Block(
                       ToTemp(ref left),
                       ToTemp(ref right),
                       Expression.MakeBinary(node.NodeType, left, right, node.IsLiftedToNull, node.Method, node.Conversion)
                       ));
        }
예제 #2
0
        protected override Expression VisitBinary(BinaryExpression node)
        {
            if (node.NodeType == ExpressionType.Assign)
            {
                return(VisitAssign(node));
            }
            // For OpAssign nodes: if has a yield, we need to do the generator
            // transformation on the reduced value.
            if (node.CanReduce)
            {
                return(Visit(node.Reduce()));
            }

            return(Rewrite(node, node.Left, node.Right, node.Update));
        }