Exemple #1
0
 protected bool TryGetAssignedVariable(ExpressionStatement node, out VariableReference variable)
 {
     variable = null;
     V_1      = node.get_Expression() as BinaryExpression;
     if (V_1 != null && !V_1.get_IsAssignmentExpression())
     {
         V_1 = null;
     }
     if (V_1 != null)
     {
         V_0 = V_1.get_Left();
     }
     else
     {
         V_2 = node.get_Expression() as UnaryExpression;
         if (V_2 == null || V_2.get_Operator() != 3 && V_2.get_Operator() != 4 && V_2.get_Operator() != 5 && V_2.get_Operator() != 6)
         {
             return(false);
         }
         V_0 = V_2.get_Operand();
     }
     if (V_0.get_CodeNodeType() != 27)
     {
         if (V_0.get_CodeNodeType() == 26)
         {
             variable = ((VariableReferenceExpression)V_0).get_Variable();
         }
     }
     else
     {
         variable = ((VariableDeclarationExpression)V_0).get_Variable();
     }
     return((object)variable != (object)null);
 }
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     V_0 = null;
     if (node.get_Expression().get_CodeNodeType() == 24 && (node.get_Expression() as BinaryExpression).get_IsAssignmentExpression())
     {
         V_1 = (node.get_Expression() as BinaryExpression).get_Left();
         if (V_1.get_CodeNodeType() != 26)
         {
             if (V_1.get_CodeNodeType() == 27)
             {
                 V_0 = (V_1 as VariableDeclarationExpression).get_Variable();
             }
         }
         else
         {
             V_0 = (V_1 as VariableReferenceExpression).get_Variable();
         }
     }
     if (V_0 == null || node.get_Parent().get_CodeNodeType() != CodeNodeType.BlockStatement || this.bannedVariables.Contains(V_0))
     {
         this.Visit(node.get_Expression());
         return;
     }
     if (this.referenceToDeclarationStatementMap.Remove(V_0))
     {
         dummyVar0 = this.bannedVariables.Add(V_0);
     }
     else
     {
         this.referenceToDeclarationStatementMap.set_Item(V_0, node);
     }
     this.Visit((node.get_Expression() as BinaryExpression).get_Right());
     return;
 }
Exemple #3
0
			private void VisitAssignExpression(ExpressionStatement expressionStatement)
			{
				if (expressionStatement.get_Expression().get_CodeNodeType() != 24 || !(expressionStatement.get_Expression() as BinaryExpression).get_IsAssignmentExpression())
				{
					return;
				}
				V_0 = (BinaryExpression)expressionStatement.get_Expression();
				this.expression = V_0;
				this.VisitVariableReference(V_0);
				return;
			}
 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;
 }
Exemple #5
0
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     if (node.get_Expression() as BinaryExpression != null)
     {
         V_0 = node.get_Expression() as BinaryExpression;
         if (V_0.get_Operator() == 26 && V_0.get_Left() as VariableReferenceExpression != null && V_0.get_Right() as VariableReferenceExpression != null)
         {
             stackVariable18 = (V_0.get_Left() as VariableReferenceExpression).get_Variable();
             V_1             = (V_0.get_Right() as VariableReferenceExpression).get_Variable();
             if ((object)stackVariable18 == (object)V_1)
             {
                 this.statementsToRemove.Add(node);
             }
         }
     }
     return;
 }
 private MethodInvocationExpression GetBinderMethodInvocation(ExpressionStatement callSiteCreationStatement, FieldDefinition callSiteField)
 {
     if (callSiteCreationStatement == null || callSiteCreationStatement.get_Expression().get_CodeNodeType() != 24 || (callSiteCreationStatement.get_Expression() as BinaryExpression).get_Operator() != 26 || (callSiteCreationStatement.get_Expression() as BinaryExpression).get_Left().get_CodeNodeType() != 30 || (object)((callSiteCreationStatement.get_Expression() as BinaryExpression).get_Left() as FieldReferenceExpression).get_Field().Resolve() != (object)callSiteField)
     {
         throw new Exception("Last statement is not CallSite field assignment.");
     }
     V_0 = (callSiteCreationStatement.get_Expression() as BinaryExpression).get_Right() as MethodInvocationExpression;
     if (String.op_Inequality(V_0.get_MethodExpression().get_Method().get_DeclaringType().GetElementType().GetFriendlyFullName(null), "System.Runtime.CompilerServices.CallSite<!0>") || V_0.get_MethodExpression().get_Target() != null || String.op_Inequality(V_0.get_MethodExpression().get_Method().get_Name(), "Create") || V_0.get_Arguments().get_Item(0).get_CodeNodeType() != 19)
     {
         throw new Exception("Invalid CallSite field assignment.");
     }
     V_1 = V_0.get_Arguments().get_Item(0) as MethodInvocationExpression;
     if (V_1.get_MethodExpression().get_Target() != null || String.op_Inequality(V_1.get_MethodExpression().get_Method().get_DeclaringType().GetFriendlyFullName(null), "Microsoft.CSharp.RuntimeBinder.Binder"))
     {
         throw new Exception("Invalid CallSite creation argument.");
     }
     return(V_1);
 }
 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;
 }
 private bool CheckAssignExpression(ExpressionStatement theStatement)
 {
     if (theStatement == null || theStatement.get_Expression().get_CodeNodeType() != 24)
     {
         return(false);
     }
     V_0 = theStatement.get_Expression() as BinaryExpression;
     if (!V_0.get_IsAssignmentExpression())
     {
         return(false);
     }
     V_1 = this.state;
     if (V_1 == RebuildAnonymousDelegatesStep.AnonymousDelegateRebuilder.State.DelegateCreate)
     {
         return(this.CheckDelegateCreation(V_0));
     }
     if (V_1 != 1)
     {
         return(false);
     }
     return(this.CheckFieldAssignment(V_0, theStatement));
 }
Exemple #9
0
 public override ICodeNode VisitExpressionStatement(ExpressionStatement node)
 {
     node.set_Expression((Expression)this.Visit(node.get_Expression()));
     if (node.get_Expression() != null)
     {
         return(node);
     }
     if (node.get_Label() != null && String.op_Inequality(node.get_Label(), String.Empty))
     {
         V_0 = node.GetNextStatement();
         if (V_0 == null || V_0.get_Label() != null && String.op_Inequality(V_0.get_Label(), String.Empty))
         {
             stackVariable19 = new EmptyStatement();
             stackVariable19.set_Label(node.get_Label());
             V_1 = stackVariable19;
             this.methodContext.get_GotoLabels().set_Item(node.get_Label(), V_1);
             return(V_1);
         }
         V_0.set_Label(node.get_Label());
         this.methodContext.get_GotoLabels().set_Item(node.get_Label(), V_0);
     }
     return(null);
 }
Exemple #10
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));
 }
 private bool IsFieldAssignment(ExpressionStatement fieldAssignmentStatement, out Expression assignedValue, out string fieldFullName)
 {
     fieldFullName = null;
     assignedValue = null;
     V_0           = fieldAssignmentStatement.get_Expression() as BinaryExpression;
     if (V_0 == null || !V_0.get_IsAssignmentExpression() || V_0.get_Left().get_CodeNodeType() != 30)
     {
         return(false);
     }
     V_1 = (V_0.get_Left() as FieldReferenceExpression).get_Field();
     if (V_1 == null)
     {
         return(false);
     }
     assignedValue = V_0.get_Right();
     fieldFullName = V_1.get_FullName();
     return(true);
 }
 private bool IsAutoPropertyAssignment(ExpressionStatement propertyAssignmentStatement, out Expression assignedValue, out string propertyFullName)
 {
     propertyFullName = null;
     assignedValue    = null;
     V_0 = propertyAssignmentStatement.get_Expression() as BinaryExpression;
     if (V_0 == null || !V_0.get_IsAssignmentExpression() || V_0.get_Left().get_CodeNodeType() != 91)
     {
         return(false);
     }
     V_1 = (V_0.get_Left() as AutoPropertyConstructorInitializerExpression).get_Property();
     if (V_1 == null)
     {
         return(false);
     }
     assignedValue    = V_0.get_Right();
     propertyFullName = V_1.get_FullName();
     return(true);
 }
 private static bool TryGetVariableDeclaration(ExpressionStatement statement, VariableReferenceExpression variableReference, ref VariableDefinition variableDefinition, ref IEnumerable <Instruction> instructions)
 {
     if (statement != null)
     {
         V_0 = statement.get_Expression() as BinaryExpression;
         if (V_0 != null && V_0.get_IsAssignmentExpression())
         {
             V_1 = V_0.get_Left() as VariableReferenceExpression;
             V_2 = V_0.get_Right() as VariableReferenceExpression;
             if (V_1 != null && V_2 != null && V_2.Equals(variableReference))
             {
                 variableDefinition = V_1.get_Variable().Resolve();
                 instructions       = V_1.get_MappedInstructions();
                 return(true);
             }
         }
     }
     return(false);
 }
 public bool IsOptimisableAssignment(ExpressionStatement statement)
 {
     V_0 = statement.get_Expression() as BinaryExpression;
     if (V_0 == null)
     {
         return(false);
     }
     if (!V_0.get_IsAssignmentExpression())
     {
         return(false);
     }
     if (V_0.get_Right().get_CodeNodeType() == 24 && (V_0.get_Right() as BinaryExpression).get_IsAssignmentExpression() || (V_0.get_Right() as BinaryExpression).get_IsSelfAssign())
     {
         return(false);
     }
     if (V_0.get_Left() as VariableReferenceExpression == null && V_0.get_Left() as VariableDeclarationExpression == null)
     {
         return(false);
     }
     return(!(new SideEffectsFinder()).HasSideEffectsRecursive(V_0.get_Right()));
 }
Exemple #16
0
 public override ICodeNode VisitExpressionStatement(ExpressionStatement node)
 {
     V_0 = (Expression)this.Visit(node.get_Expression());
     if (V_0 != null)
     {
         node.set_Expression(V_0);
         return(node);
     }
     if (!String.IsNullOrEmpty(node.get_Label()))
     {
         V_1 = node.GetNextStatement();
         if (V_1 == null || !String.IsNullOrEmpty(V_1.get_Label()))
         {
             stackVariable16 = new EmptyStatement();
             stackVariable16.set_Label(node.get_Label());
             return(stackVariable16);
         }
         V_1.set_Label(node.get_Label());
     }
     return(null);
 }
 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);
 }
Exemple #18
0
 public virtual void VisitExpressionStatement(ExpressionStatement node)
 {
     this.Visit(node.get_Expression());
     return;
 }
 public override void VisitExpressionStatement(ExpressionStatement node)
 {
     this.Visit(node.get_Expression());
     return;
 }
 public virtual ICodeNode VisitExpressionStatement(ExpressionStatement node)
 {
     node.set_Expression((Expression)this.Visit(node.get_Expression()));
     return(node);
 }