コード例 #1
0
ファイル: GeneratorRewriter.cs プロジェクト: SueDou/python
        protected override Expression VisitUnary(UnaryExpression 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 o      = Visit(node.Operand);

            if (o == node.Operand)
            {
                return(node);
            }
            // Void convert can be jumped into, no need to spill
            // TODO: remove when that feature goes away.
            if (yields == _yields.Count ||
                (node.NodeType == ExpressionType.Convert && node.Type == typeof(void)))
            {
                return(Expression.MakeUnary(node.NodeType, o, node.Type, node.Method));
            }
            return(Expression.Block(
                       ToTemp(ref o),
                       Expression.MakeUnary(node.NodeType, o, node.Type, node.Method)
                       ));
        }
コード例 #2
0
        private Node ResolveQuery <T>(UnaryExpression unaryExpression)
        {
            var exptype = unaryExpression.NodeType;

            switch (exptype)
            {
            case ExpressionType.Convert:

                if (unaryExpression.Method != null)
                {
                    return(ResolveQuery <T>(unaryExpression.Reduce() as MethodCallExpression));
                }

                return(ResolveQuery <T>((dynamic)unaryExpression.Operand));

                break;

            default:
                return(new SingleOperationNode()
                {
                    Operator = unaryExpression.NodeType,
                    Child = ResolveQuery((dynamic)unaryExpression.Operand)
                });

                break;
            }

            //return new SingleOperationNode()
            //{
            //    Operator = unaryExpression.NodeType,
            //    Child = ResolveQuery((dynamic)unaryExpression.Operand)
            //};
        }
コード例 #3
0
        public void CannotReduceThrow()
        {
            UnaryExpression throwExp = Expression.Throw(Expression.Constant(new TestException()));

            Assert.False(throwExp.CanReduce);
            Assert.Same(throwExp, throwExp.Reduce());
            Assert.Throws <ArgumentException>(() => throwExp.ReduceAndCheck());
        }
コード例 #4
0
ファイル: LoopCompiler.cs プロジェクト: modulexcite/pash-1
 protected override Expression VisitUnary(UnaryExpression node)
 {
     if (node.CanReduce)
     {
         return(this.Visit(node.Reduce()));
     }
     return(base.VisitUnary(node));
 }
コード例 #5
0
 protected override Expression VisitUnary(UnaryExpression node)
 {
     // reduce inplace increment/decrement:
     if (node.CanReduce)
     {
         return(Visit(node.Reduce()));
     }
     Debug.Assert(!node.NodeType.IsReadWriteAssignment());
     return(base.VisitUnary(node));
 }
コード例 #6
0
ファイル: Reducer.cs プロジェクト: geppy/ExpressionFutures
            protected override Expression VisitUnary(UnaryExpression node)
            {
                // NB: This reduces assignment operators so that the stack spiller doesn't have to worry about it.
                if (node.CanReduce)
                {
                    return(node.Reduce());
                }

                return(base.VisitUnary(node));
            }