private void ProcessArgumentArray(StatementCollection statements, ref int index, VariableReference typesArray, CallSiteInfo callSiteInfo, Action <MethodInvocationExpression, int, CallSiteInfo> action)
 {
     if (statements.get_Item(index) as ExpressionStatement != null && (statements.get_Item(index) as ExpressionStatement).get_Expression() as BinaryExpression != null)
     {
         V_1 = (statements.get_Item(index) as ExpressionStatement).get_Expression() as BinaryExpression;
         if (V_1.get_IsAssignmentExpression() && V_1.get_Left() as VariableReferenceExpression != null && V_1.get_Right() as MethodInvocationExpression != null)
         {
             index = index + 1;
         }
     }
     V_2   = index;
     index = V_2 + 1;
     V_0   = this.CheckNewArrayInitializationAndSize(statements.get_Item(V_2), typesArray);
     V_3   = 0;
     while (V_3 < V_0)
     {
         if (!statements.get_Item(index).IsAssignmentStatement())
         {
             throw new Exception("Invalid statement.");
         }
         V_2   = index;
         index = V_2 + 1;
         V_4   = (statements.get_Item(V_2) as ExpressionStatement).get_Expression() as BinaryExpression;
         if (V_4.get_Left().get_CodeNodeType() != 39 || !this.CheckArrayIndexerExpression(V_4.get_Left() as ArrayIndexerExpression, typesArray, V_3) || V_4.get_Right().get_CodeNodeType() != 19)
         {
             throw new Exception("Invalid statement.");
         }
         action.Invoke(V_4.get_Right() as MethodInvocationExpression, V_3, callSiteInfo);
         V_3 = V_3 + 1;
     }
     return;
 }
Beispiel #2
0
 private bool CheckLoopBody(BlockStatement loopBody, VariableReference v0Variable, VariableReference v1Variable, string operationName)
 {
     if (loopBody.get_Statements().get_Count() != 3)
     {
         return(false);
     }
     if (!loopBody.get_Statements().get_Item(0).IsAssignmentStatement())
     {
         return(false);
     }
     V_0 = (loopBody.get_Statements().get_Item(0) as ExpressionStatement).get_Expression() as BinaryExpression;
     if (V_0.get_Left().get_CodeNodeType() != 26 || V_0.get_Right().get_CodeNodeType() != 26 || (object)(V_0.get_Right() as VariableReferenceExpression).get_Variable() != (object)v0Variable)
     {
         return(false);
     }
     if ((object)(V_0.get_Left() as VariableReferenceExpression).get_Variable() != (object)v1Variable)
     {
         return(false);
     }
     if (!this.IsDelegateOperationStatement(loopBody.get_Statements().get_Item(1), operationName, out V_1, out V_2) || V_1.get_CodeNodeType() != 26 || V_2.get_CodeNodeType() != 26 || (object)(V_2 as VariableReferenceExpression).get_Variable() != (object)v1Variable)
     {
         return(false);
     }
     V_3 = (V_1 as VariableReferenceExpression).get_Variable();
     if (!loopBody.get_Statements().get_Item(2).IsAssignmentStatement())
     {
         return(false);
     }
     V_4 = (loopBody.get_Statements().get_Item(2) as ExpressionStatement).get_Expression() as BinaryExpression;
     if (V_4.get_Left().get_CodeNodeType() != 26 || (object)(V_4.get_Left() as VariableReferenceExpression).get_Variable() != (object)v0Variable || V_4.get_Right().get_CodeNodeType() != 19)
     {
         return(false);
     }
     V_5 = V_4.get_Right() as MethodInvocationExpression;
     if (String.op_Inequality(V_5.get_MethodExpression().get_Method().get_DeclaringType().get_FullName(), "System.Threading.Interlocked") || V_5.get_MethodExpression().get_Method().get_HasThis() || String.op_Inequality(V_5.get_MethodExpression().get_Method().get_Name(), "CompareExchange") || V_5.get_Arguments().get_Count() != 3 || V_5.get_Arguments().get_Item(0).get_CodeNodeType() != 23)
     {
         return(false);
     }
     V_6 = V_5.get_Arguments().get_Item(0) as UnaryExpression;
     if (V_6.get_Operator() != 7 || V_6.get_Operand().get_CodeNodeType() != 30 || (object)(V_6.get_Operand() as FieldReferenceExpression).get_Field().Resolve() != (object)this.eventField)
     {
         return(false);
     }
     if (V_5.get_Arguments().get_Item(1).get_CodeNodeType() == 26 && (object)(V_5.get_Arguments().get_Item(1) as VariableReferenceExpression).get_Variable() == (object)V_3 && V_5.get_Arguments().get_Item(2).get_CodeNodeType() == 26 && (object)(V_5.get_Arguments().get_Item(2) as VariableReferenceExpression).get_Variable() == (object)v1Variable)
     {
         return(true);
     }
     return(false);
 }
Beispiel #3
0
 private TypeDefinition GetGeneratedType()
 {
     if (this.statements.get_Item(0).get_CodeNodeType() != 5)
     {
         return(null);
     }
     V_0 = this.statements.get_Item(0) as ExpressionStatement;
     if (V_0.get_Expression().get_CodeNodeType() != 24)
     {
         if (V_0.get_Expression().get_CodeNodeType() != 57)
         {
             return(null);
         }
         V_5 = V_0.get_Expression() as ReturnExpression;
         if (V_5.get_Value() == null || V_5.get_Value().get_CodeNodeType() != 40)
         {
             return(null);
         }
         V_1 = V_5.get_Value() as ObjectCreationExpression;
     }
     else
     {
         if (!(V_0.get_Expression() as BinaryExpression).get_IsAssignmentExpression())
         {
             return(null);
         }
         V_4 = V_0.get_Expression() as BinaryExpression;
         if (V_4.get_Right().get_CodeNodeType() != 40)
         {
             return(null);
         }
         V_1 = V_4.get_Right() as ObjectCreationExpression;
     }
     V_2 = V_1.get_Constructor();
     if (V_2 == null || V_2.get_DeclaringType() == null)
     {
         return(null);
     }
     V_3 = V_2.get_DeclaringType().Resolve();
     if (V_3 != null && V_3.get_IsNestedPrivate() && V_3.HasCompilerGeneratedAttribute())
     {
         return(V_3);
     }
     return(null);
 }
 private static bool TryMatchVariableDeclaration(BlockStatement filter, out VariableDeclarationExpression variableDeclaration)
 {
     variableDeclaration = null;
     V_0 = filter.get_Statements().get_Item(0) as ExpressionStatement;
     if (V_0 == null)
     {
         return(false);
     }
     V_1 = V_0.get_Expression() as BinaryExpression;
     if (V_1 == null || !V_1.get_IsAssignmentExpression())
     {
         return(false);
     }
     V_2 = V_1.get_Left() as VariableReferenceExpression;
     if (V_2 == null)
     {
         return(false);
     }
     if (V_1.get_Right() as SafeCastExpression == null)
     {
         return(false);
     }
     V_3 = filter.get_Statements().get_Item(1) as IfStatement;
     if (V_3 == null)
     {
         return(false);
     }
     V_4 = V_3.get_Condition() as BinaryExpression;
     if (V_4 == null)
     {
         return(false);
     }
     V_5 = V_4.get_Left() as VariableReferenceExpression;
     if (V_5 == null)
     {
         return(false);
     }
     V_6 = V_4.get_Right() as LiteralExpression;
     if (V_6 == null)
     {
         return(false);
     }
     if (!V_5.Equals(V_2) || V_6.get_Value() != null || V_4.get_Operator() != 9 && V_4.get_Operator() != 10)
     {
         return(false);
     }
     V_7 = V_2.get_Variable().Resolve();
     V_8 = V_2.get_MappedInstructions();
     if (V_4.get_Operator() != 10)
     {
         V_9 = V_3.get_Else();
     }
     else
     {
         V_9 = V_3.get_Then();
     }
     if (!CatchClausesFilterPattern.TryGetVariableDeclaration(V_9.get_Statements().get_Item(0) as ExpressionStatement, V_2, ref V_7, ref V_8) && V_9.get_Statements().get_Count() >= 2)
     {
         dummyVar0 = CatchClausesFilterPattern.TryGetVariableDeclaration(V_9.get_Statements().get_Item(1) as ExpressionStatement, V_2, ref V_7, ref V_8);
     }
     variableDeclaration = new VariableDeclarationExpression(V_7, V_8);
     return(true);
 }
 private void InlineAssignmentInSameBlock()
 {
     V_0 = this.methodContext.get_Expressions().get_BlockExpressions().GetEnumerator();
     try
     {
         while (V_0.MoveNext())
         {
             V_1 = V_0.get_Current();
             V_2 = V_1.get_Value();
             V_3 = 0;
             while (V_3 < V_2.get_Count() - 1)
             {
                 V_4 = V_2.get_Item(V_3) as BinaryExpression;
                 if (V_4 != null && V_4.get_IsAssignmentExpression() && V_4.get_Left().get_CodeNodeType() == 26)
                 {
                     V_5 = (V_4.get_Left() as VariableReferenceExpression).get_Variable().Resolve();
                     if (this.variablesToInline.Contains(V_5))
                     {
                         V_6 = V_4.get_Right();
                         V_7 = new SideEffectsFinder();
                         V_8 = V_7.HasSideEffectsRecursive(V_6);
                         V_9 = new StackVariablesInliner.VariablesArgumentsAndFieldsFinder();
                         V_9.Visit(V_6);
                         V_10 = new StackVariablesInliner.VariableReferenceFinder(V_9.get_Variables(), V_9.get_Parameters());
                         V_11 = V_3 + 1;
                         while (V_11 < V_2.get_Count())
                         {
                             if (!this.inliner.TryInlineVariable(V_5, V_6, V_2.get_Item(V_11), true, out V_12))
                             {
                                 if (V_8 && V_7.HasSideEffectsRecursive(V_2.get_Item(V_11)) || V_10.ContainsReference(V_2.get_Item(V_11)))
                                 {
                                     break;
                                 }
                                 if (V_2.get_Item(V_11).get_CodeNodeType() == 24 && (V_2.get_Item(V_11) as BinaryExpression).get_IsAssignmentExpression())
                                 {
                                     V_13 = (V_2.get_Item(V_11) as BinaryExpression).get_Left();
                                     if (V_13.get_CodeNodeType() == 25 && V_9.get_Parameters().Contains((V_13 as ArgumentReferenceExpression).get_Parameter().Resolve()) || V_13.get_CodeNodeType() == 26 && V_9.get_Variables().Contains((V_13 as VariableReferenceExpression).get_Variable().Resolve()) || V_13.get_CodeNodeType() == 30 && V_9.get_Fields().Contains((V_13 as FieldReferenceExpression).get_Field().Resolve()))
                                     {
                                         break;
                                     }
                                 }
                                 V_11 = V_11 + 1;
                             }
                             else
                             {
                                 this.FixContextAfterInlining(V_5);
                                 dummyVar0 = this.variablesToInline.Remove(V_5);
                                 V_2.set_Item(V_11, (Expression)V_12);
                                 V_2.RemoveAt(V_3);
                                 stackVariable141 = V_3;
                                 if (V_3 > 0)
                                 {
                                     stackVariable144 = 2;
                                 }
                                 else
                                 {
                                     stackVariable144 = 1;
                                 }
                                 V_3 = stackVariable141 - stackVariable144;
                                 break;
                             }
                         }
                     }
                 }
                 V_3 = V_3 + 1;
             }
         }
     }
     finally
     {
         ((IDisposable)V_0).Dispose();
     }
     return;
 }