public override void VisitDelegateInvokeExpression(DelegateInvokeExpression node)
        {
            /// Add cast when an argument needs to be of integer type, but the pushed value is of enum type
            base.VisitDelegateInvokeExpression(node);

            CheckArguments(node.InvokeMethodReference.Parameters, node.Arguments);
        }
 public override void VisitDelegateInvokeExpression(DelegateInvokeExpression node)
 {
     if (state == SearchState.Propagation)
     {
         canBePropagated = false;
         return;
     }
     base.VisitDelegateInvokeExpression(node);
 }
        private void ProcessDelegateInvokeExpression(DelegateInvokeExpression delegateInvokeExpression)
        {
            if (delegateInvokeExpression.Target == null ||
                delegateInvokeExpression.Target.CodeNodeType != CodeNodeType.VariableReferenceExpression)
            {
                return;
            }

            ProcessVariableReferenceExpression(delegateInvokeExpression.Target as VariableReferenceExpression);
        }
 public override void VisitDelegateInvokeExpression(DelegateInvokeExpression node)
 {
     if (this.state == ExpressionPropagationStep.ExpressionTreeVisitor.SearchState.Propagation)
     {
         this.canBePropagated = false;
         return;
     }
     this.VisitDelegateInvokeExpression(node);
     return;
 }
        /// <summary>
        /// Create a <c>firedEvent(parameters)</c> invocation.</c>
        /// </summary>
        /// <param name="firedEvent">Delegate to invoke</param>
        /// <param name="parameters">Delegate arguments</param>
        /// <returns></returns>
        public static DelegateInvokeExpression DelegateInvoke(
            EventReferenceExpression firedEvent,
            params Expression[] parameters
            )
        {
            if (firedEvent == null)
            {
                throw new ArgumentNullException("firedEvent");
            }
            DelegateInvokeExpression expr = new DelegateInvokeExpression(firedEvent, parameters);

            return(expr);
        }
Exemple #6
0
 public virtual void VisitDelegateInvokeExpression(DelegateInvokeExpression node)
 {
     Visit(node.Target);
     Visit(node.Arguments);
 }
Exemple #7
0
 public virtual ICodeNode VisitDelegateInvokeExpression(DelegateInvokeExpression node)
 {
     node.Target    = (Expression)Visit(node.Target);
     node.Arguments = (ExpressionCollection)Visit(node.Arguments);
     return(node);
 }
Exemple #8
0
 public virtual void VisitDelegateInvokeExpression(DelegateInvokeExpression node)
 {
     this.Visit(node.get_Target());
     this.Visit(node.get_Arguments());
     return;
 }
        private bool TryMatchInternal(StatementCollection statements, int startIndex, out Statement result)
        {
            result = null;

            if (startIndex + 1 >= statements.Count)
            {
                return(false);
            }

            if (statements[startIndex].CodeNodeType != CodeNodeType.ExpressionStatement ||
                statements[startIndex + 1].CodeNodeType != CodeNodeType.IfStatement)
            {
                return(false);
            }

            ExpressionStatement eventVariableAssignmentStatement = (statements[startIndex] as ExpressionStatement);

            if (eventVariableAssignmentStatement.Expression.CodeNodeType != CodeNodeType.BinaryExpression)
            {
                return(false);
            }

            BinaryExpression eventVariableAssignmentExpression = eventVariableAssignmentStatement.Expression as BinaryExpression;

            if (eventVariableAssignmentExpression.Left.CodeNodeType != CodeNodeType.VariableReferenceExpression ||
                eventVariableAssignmentExpression.Right.CodeNodeType != CodeNodeType.EventReferenceExpression)
            {
                return(false);
            }

            VariableReferenceExpression eventVariableDeclaration = eventVariableAssignmentExpression.Left as VariableReferenceExpression;
            EventReferenceExpression    eventReferenceExpression = eventVariableAssignmentExpression.Right as EventReferenceExpression;

            IfStatement theIf = statements[startIndex + 1] as IfStatement;

            if (theIf.Then == null ||
                theIf.Else != null ||
                theIf.Condition.CodeNodeType != CodeNodeType.BinaryExpression)
            {
                return(false);
            }

            BinaryExpression condition = theIf.Condition as BinaryExpression;

            if (condition.Left.CodeNodeType != CodeNodeType.VariableReferenceExpression ||
                condition.Right.CodeNodeType != CodeNodeType.LiteralExpression ||
                condition.Operator != BinaryOperator.ValueInequality)
            {
                return(false);
            }

            VariableReferenceExpression eventVariableReference = condition.Left as VariableReferenceExpression;

            if (eventVariableDeclaration.Variable != eventVariableReference.Variable)
            {
                return(false);
            }

            LiteralExpression theLiteral = condition.Right as LiteralExpression;

            if (theLiteral.Value != null)
            {
                return(false);
            }

            StatementCollection thenStatements = theIf.Then.Statements;

            if (thenStatements.Count != 1 ||
                thenStatements[0].CodeNodeType != CodeNodeType.ExpressionStatement)
            {
                return(false);
            }

            ExpressionStatement delegateInvocationStatement = thenStatements[0] as ExpressionStatement;

            if (delegateInvocationStatement.Expression.CodeNodeType != CodeNodeType.DelegateInvokeExpression)
            {
                return(false);
            }

            DelegateInvokeExpression delegateInvocationExpression = delegateInvocationStatement.Expression as DelegateInvokeExpression;

            if (delegateInvocationExpression.Target.CodeNodeType != CodeNodeType.VariableReferenceExpression)
            {
                return(false);
            }

            VariableReferenceExpression delegateInvocationVariableReferece = delegateInvocationExpression.Target as VariableReferenceExpression;

            if (delegateInvocationVariableReferece.Variable != eventVariableDeclaration.Variable)
            {
                return(false);
            }

            List <Instruction> instructions = new List <Instruction>();

            instructions.AddRange(eventVariableAssignmentStatement.UnderlyingSameMethodInstructions);
            instructions.AddRange(theIf.UnderlyingSameMethodInstructions);

            result = new ExpressionStatement(new RaiseEventExpression(eventReferenceExpression.Event, delegateInvocationExpression.InvokeMethodReference, delegateInvocationExpression.Arguments, instructions));

            return(true);
        }
 public override void VisitDelegateInvokeExpression(DelegateInvokeExpression node)
 {
     this.VisitDelegateInvokeExpression(node);
     this.CheckArguments(node.get_InvokeMethodReference().get_Parameters(), node.get_Arguments());
     return;
 }
 public virtual ICodeNode VisitDelegateInvokeExpression(DelegateInvokeExpression node)
 {
     node.set_Target((Expression)this.Visit(node.get_Target()));
     node.set_Arguments((ExpressionCollection)this.Visit(node.get_Arguments()));
     return(node);
 }