public override void VisitExpressionStatement(ExpressionStatement node)
        {
            if (!node.IsAssignmentStatement())
            {
                return;
            }

            BinaryExpression assignExpression = node.Expression as BinaryExpression;

            if (assignExpression.Left.CodeNodeType != CodeNodeType.VariableReferenceExpression ||
                assignExpression.Right.CodeNodeType != CodeNodeType.FieldReferenceExpression)
            {
                return;
            }

            FieldReferenceExpression targetFieldRefExpression = assignExpression.Right as FieldReferenceExpression;

            if (targetFieldRefExpression.Target == null ||
                targetFieldRefExpression.Target.CodeNodeType != CodeNodeType.FieldReferenceExpression ||
                targetFieldRefExpression.Field.Name != "Target")
            {
                return;
            }

            FieldDefinition callSiteField = (targetFieldRefExpression.Target as FieldReferenceExpression).Field.Resolve();
            CallSiteInfo    callSiteInfo;

            if (callSiteField == null || !fieldToCallSiteInfoMap.TryGetValue(callSiteField, out callSiteInfo))
            {
                return;
            }

            variableToCallSiteInfoMap.Add((assignExpression.Left as VariableReferenceExpression).Variable, callSiteInfo);
            statementsToRemove.Add(node);
        }
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     if (!node.IsAssignmentStatement())
     {
         return;
     }
     V_0 = node.get_Expression() as BinaryExpression;
     if (V_0.get_Left().get_CodeNodeType() != 26 || V_0.get_Right().get_CodeNodeType() != 30)
     {
         return;
     }
     V_1 = V_0.get_Right() as FieldReferenceExpression;
     if (V_1.get_Target() == null || V_1.get_Target().get_CodeNodeType() != 30 || String.op_Inequality(V_1.get_Field().get_Name(), "Target"))
     {
         return;
     }
     V_2 = (V_1.get_Target() as FieldReferenceExpression).get_Field().Resolve();
     if (V_2 == null || !this.fieldToCallSiteInfoMap.TryGetValue(V_2, out V_3))
     {
         return;
     }
     this.variableToCallSiteInfoMap.Add((V_0.get_Left() as VariableReferenceExpression).get_Variable(), V_3);
     dummyVar0 = this.statementsToRemove.Add(node);
     return;
 }
Exemplo n.º 3
0
        private bool CheckVariableInitialization(ExpressionStatement node)
        {
            if (!node.IsAssignmentStatement())
            {
                return(false);
            }

            BinaryExpression theAssignExpression = node.Expression as BinaryExpression;

            if (theAssignExpression.Left.CodeNodeType != CodeNodeType.VariableReferenceExpression)
            {
                return(false);
            }

            Expression value = theAssignExpression.Right;

            if (value.CodeNodeType == CodeNodeType.CastExpression)
            {
                value = (value as CastExpression).Expression;
            }

            if (value.CodeNodeType != CodeNodeType.LiteralExpression || (value as LiteralExpression).Value != null)
            {
                return(false);
            }

            initializationsToRemove[(theAssignExpression.Left as VariableReferenceExpression).Variable] = node;
            return(true);
        }
Exemplo n.º 4
0
 private bool CheckTheInitializer(ExpressionStatement statement, out VariableReference forVariable)
 {
     forVariable = null;
     if (statement == null || !statement.IsAssignmentStatement())
     {
         return(false);
     }
     return(this.TryGetAssignedVariable(statement, out forVariable));
 }
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     if (!node.IsAssignmentStatement() || !this.CheckBinaryExpression(node.get_Expression() as BinaryExpression))
     {
         this.VisitExpressionStatement(node);
         return;
     }
     dummyVar0 = this.statementsToRemove.Add(node);
     return;
 }
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     if (node.IsAssignmentStatement() && CheckBinaryExpression(node.Expression as BinaryExpression))
     {
         statementsToRemove.Add(node);
     }
     else
     {
         base.VisitExpressionStatement(node);
     }
 }
Exemplo n.º 7
0
        private bool CheckVariableInitialization(ExpressionStatement node)
        {
            if (!node.IsAssignmentStatement())
            {
                return(false);
            }

            BinaryExpression theAssignExpression = node.Expression as BinaryExpression;

            if (theAssignExpression.Left.CodeNodeType != CodeNodeType.VariableReferenceExpression)
            {
                return(false);
            }

            Expression value = theAssignExpression.Right;

            if (value.CodeNodeType == CodeNodeType.CastExpression)
            {
                value = (value as CastExpression).Expression;
            }

            if ((value.CodeNodeType != CodeNodeType.LiteralExpression || (value as LiteralExpression).Value != null) &&
                (value.CodeNodeType != CodeNodeType.FieldReferenceExpression))
            {
                return(false);
            }

            if (value.CodeNodeType == CodeNodeType.FieldReferenceExpression)
            {
                FieldReferenceExpression fieldReferenceExpression = value as FieldReferenceExpression;

                TypeDefinition fieldType = fieldReferenceExpression.ExpressionType.Resolve();
                if (fieldType == null || fieldType.BaseType == null || fieldType.BaseType.FullName != "System.MulticastDelegate")
                {
                    return(false);
                }

                // Slow checks
                FieldDefinition fieldDef = fieldReferenceExpression.Field.Resolve();
                if ((fieldDef.DeclaringType != this.context.MethodContext.Method.DeclaringType &&
                     !fieldDef.DeclaringType.IsNestedIn(this.context.MethodContext.Method.DeclaringType)) ||
                    !fieldDef.DeclaringType.IsCompilerGenerated())
                {
                    return(false);
                }
            }

            initializationsToRemove[(theAssignExpression.Left as VariableReferenceExpression).Variable] = node;
            return(true);
        }
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     if (node.IsAssignmentStatement() && node.Parent.CodeNodeType == CodeNodeType.BlockStatement)
     {
         BinaryExpression assignment = node.Expression as BinaryExpression;
         if (assignment.Left.CodeNodeType == CodeNodeType.VariableReferenceExpression)
         {
             Visit(assignment.Right);
             AddDefinition((assignment.Left as VariableReferenceExpression).Variable.Resolve(), node);
             return;
         }
     }
     base.VisitExpressionStatement(node);
 }
Exemplo n.º 9
0
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     if (node.IsAssignmentStatement() && node.get_Parent().get_CodeNodeType() == CodeNodeType.BlockStatement)
     {
         V_0 = node.get_Expression() as BinaryExpression;
         if (V_0.get_Left().get_CodeNodeType() == 26)
         {
             this.Visit(V_0.get_Right());
             this.AddDefinition((V_0.get_Left() as VariableReferenceExpression).get_Variable().Resolve(), node);
             return;
         }
     }
     this.VisitExpressionStatement(node);
     return;
 }
 public override ICodeNode VisitExpressionStatement(ExpressionStatement node)
 {
     if (node.IsAssignmentStatement())
     {
         V_0 = node.get_Expression() as BinaryExpression;
         if (V_0.get_Left().get_CodeNodeType() == 26 && V_0.get_Right().get_CodeNodeType() == 30)
         {
             V_1 = (V_0.get_Right() as FieldReferenceExpression).get_Field().Resolve();
             if (V_1 != null && this.fieldToCallSiteInfoMap.ContainsKey(V_1))
             {
                 return(null);
             }
         }
     }
     return(this.VisitExpressionStatement(node));
 }
Exemplo n.º 11
0
 public override ICodeNode VisitExpressionStatement(ExpressionStatement node)
 {
     if (node.IsAssignmentStatement())
     {
         BinaryExpression assignExpression = node.Expression as BinaryExpression;
         if (assignExpression.Left.CodeNodeType == CodeNodeType.VariableReferenceExpression &&
             assignExpression.Right.CodeNodeType == CodeNodeType.FieldReferenceExpression)
         {
             FieldDefinition fieldDef = (assignExpression.Right as FieldReferenceExpression).Field.Resolve();
             if (fieldDef != null && fieldToCallSiteInfoMap.ContainsKey(fieldDef))
             {
                 return(null);
             }
         }
     }
     return(base.VisitExpressionStatement(node));
 }
 private bool CheckVariableInitialization(ExpressionStatement node)
 {
     if (!node.IsAssignmentStatement())
     {
         return(false);
     }
     V_0 = node.get_Expression() as BinaryExpression;
     if (V_0.get_Left().get_CodeNodeType() != 26)
     {
         return(false);
     }
     V_1 = V_0.get_Right();
     if (V_1.get_CodeNodeType() == 31)
     {
         V_1 = (V_1 as ExplicitCastExpression).get_Expression();
     }
     if (V_1.get_CodeNodeType() != 22 || (V_1 as LiteralExpression).get_Value() != null && V_1.get_CodeNodeType() != 30)
     {
         return(false);
     }
     if (V_1.get_CodeNodeType() == 30)
     {
         V_2 = V_1 as FieldReferenceExpression;
         V_3 = V_2.get_ExpressionType().Resolve();
         if (V_3 == null || V_3.get_BaseType() == null || String.op_Inequality(V_3.get_BaseType().get_FullName(), "System.MulticastDelegate"))
         {
             return(false);
         }
         V_4 = V_2.get_Field().Resolve();
         if ((object)V_4.get_DeclaringType() != (object)this.context.get_MethodContext().get_Method().get_DeclaringType() && !V_4.get_DeclaringType().IsNestedIn(this.context.get_MethodContext().get_Method().get_DeclaringType()) || !V_4.get_DeclaringType().IsCompilerGenerated())
         {
             return(false);
         }
     }
     this.initializationsToRemove.set_Item((V_0.get_Left() as VariableReferenceExpression).get_Variable(), node);
     return(true);
 }
 private bool CheckTheInitializer(ExpressionStatement statement, out VariableReference forVariable)
 {
     forVariable = null;
     return(statement != null && statement.IsAssignmentStatement() && TryGetAssignedVariable(statement, out forVariable));
 }