コード例 #1
0
 public override void VisitYieldReturnExpression(YieldReturnExpression node)
 {
     if (state == SearchState.Propagation)
     {
         canBePropagated = false;
         return;
     }
     base.VisitYieldReturnExpression(node);
 }
コード例 #2
0
 public override void VisitYieldReturnExpression(YieldReturnExpression node)
 {
     if (this.state == ExpressionPropagationStep.ExpressionTreeVisitor.SearchState.Propagation)
     {
         this.canBePropagated = false;
         return;
     }
     this.VisitYieldReturnExpression(node);
     return;
 }
コード例 #3
0
 public virtual void VisitYieldReturnExpression(YieldReturnExpression node)
 {
     Visit(node.Expression);
 }
コード例 #4
0
 public virtual ICodeNode VisitYieldReturnExpression(YieldReturnExpression node)
 {
     node.Expression = (Expression)Visit(node.Expression);
     return(node);
 }
コード例 #5
0
        public override void VisitBoxExpression(BoxExpression node)
        {
            Stack <Expression> removedExpressions = new Stack <Expression>();

            removedExpressions.Push(parentExpressions.Pop());            // pop the box expression
            if (parentExpressions.Count > 0)
            {
                Expression containingExpression = parentExpressions.Peek();
                if (containingExpression is MemberReferenceExpresion)
                {
                    MemberReferenceExpresion memberExpression = parentExpressions.Pop() as MemberReferenceExpresion;
                    removedExpressions.Push(memberExpression);
                    if (memberExpression.Member is MethodReference)
                    {
                        //The box expression is the method target.
                        // This is automatically handled by C#/VB compilers.
                        node.IsAutoBox = true;
                    }
                }
                else if (containingExpression is MethodInvocationExpression ||
                         containingExpression is FieldReferenceExpression ||
                         containingExpression is PropertyReferenceExpression)
                {
                    // The boxed expression is an argument to a method call.
                    // This is automatically handled by C#/VB compilers.
                    node.IsAutoBox = true;
                }
                else if (containingExpression is BinaryExpression)
                {
                    BinaryExpression binary = containingExpression as BinaryExpression;

                    // Check for expressions of the type:
                    //		a = B;
                    //	where a is of type object and B is the boxed expression.
                    if (binary.IsAssignmentExpression && binary.Right.Equals(node))
                    {
                        node.IsAutoBox = true;
                    }

                    // check for expressions of the type:
                    //		X == null
                    //		X != null
                    //		null == X
                    //		null != X
                    //	where X is the boxed expression and X is of some generic parameter type T
                    if (binary.IsComparisonExpression && node.BoxedAs.IsGenericParameter)
                    {
                        if (binary.Left == node)
                        {
                            if (binary.Right is LiteralExpression && (binary.Right as LiteralExpression).Value == null)
                            {
                                node.IsAutoBox = true;
                            }
                        }
                        if (binary.Right == node)
                        {
                            if (binary.Left is LiteralExpression && (binary.Left as LiteralExpression).Value == null)
                            {
                                node.IsAutoBox = true;
                            }
                        }
                    }
                }
                else if (containingExpression is ReturnExpression)
                {
                    if (context.Method.ReturnType.FullName == "System.Object")
                    {
                        node.IsAutoBox = true;
                    }
                    else
                    {
                        TypeDefinition type = node.BoxedExpression.ExpressionType.Resolve();
                        if (type != null && type.IsValueType)
                        {
                            node.IsAutoBox = true;
                        }
                    }
                }
                else if (containingExpression is YieldReturnExpression)
                {
                    YieldReturnExpression yieldReturn = containingExpression as YieldReturnExpression;
                    if (yieldReturn.Expression.Equals(node))
                    {
                        node.IsAutoBox = true;
                    }
                }
            }

            // push back the popped expressions
            while (removedExpressions.Count > 0)
            {
                parentExpressions.Push(removedExpressions.Pop());
            }

            base.VisitBoxExpression(node);
        }
コード例 #6
0
 public virtual void VisitYieldReturnExpression(YieldReturnExpression node)
 {
     this.Visit(node.get_Expression());
     return;
 }
コード例 #7
0
 public virtual ICodeNode VisitYieldReturnExpression(YieldReturnExpression node)
 {
     node.set_Expression((Expression)this.Visit(node.get_Expression()));
     return(node);
 }