private bool IsUnconditionJumpBlock(InstructionBlock block)
 {
     if ((object)block.get_First() != (object)block.get_Last() || block.get_First().get_OpCode().get_Code() != 55 && block.get_First().get_OpCode().get_Code() != 42)
     {
         return(false);
     }
     return((int)block.get_Successors().Length == 1);
 }
Ejemplo n.º 2
0
 private static InstructionBlock SkipSingleNopInstructionBlock(InstructionBlock theBlock)
 {
     V_0 = theBlock;
     if ((object)theBlock.get_First() == (object)theBlock.get_Last() && theBlock.get_First().get_OpCode().get_Code() == null && (int)theBlock.get_Successors().Length == 1)
     {
         V_0 = theBlock.get_Successors()[0];
     }
     return(V_0);
 }
Ejemplo n.º 3
0
 private InstructionBlock GetActualCase(InstructionBlock theBlock)
 {
     while ((object)theBlock.get_First() == (object)theBlock.get_Last() && theBlock.get_First().get_OpCode().get_Code() == 55 || theBlock.get_First().get_OpCode().get_Code() == 42)
     {
         V_0      = theBlock.get_First().get_Operand() as Instruction;
         theBlock = this.theDisposeCFG.get_InstructionToBlockMapping().get_Item(V_0.get_Offset());
     }
     theBlock = StateMachineDisposeAnalyzer.SkipSingleNopInstructionBlock(theBlock);
     return(theBlock);
 }
Ejemplo n.º 4
0
        private bool TryGetExceptionHandler(InstructionBlock theBlock, out ExceptionHandler theHandler)
        {
            V_0 = this.theDisposeCFG.get_RawExceptionHandlers().GetEnumerator();
            try
            {
                while (V_0.MoveNext())
                {
                    V_1 = V_0.get_Current();
                    if ((object)V_1.get_TryStart() != (object)theBlock.get_First())
                    {
                        continue;
                    }
                    theHandler = V_1;
                    V_2        = true;
                    goto Label1;
                }
                goto Label0;
            }
            finally
            {
                V_0.Dispose();
            }
Label1:
            return(V_2);

Label0:
            theHandler = null;
            return(false);
        }
 protected override bool IsFinallyCheckBlock(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     while (V_0.get_OpCode().get_Code() == null)
     {
         if ((object)V_0 == (object)theBlock.get_Last())
         {
             return(false);
         }
         V_0 = V_0.get_Next();
     }
     if ((object)V_0 == (object)theBlock.get_Last() || !StateMachineUtilities.TryGetVariableFromInstruction(V_0, this.methodVariables, out V_1) || (object)V_1 != (object)this.doFinallyVariable)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() == 56 || V_0.get_OpCode().get_Code() == 43)
     {
         return(true);
     }
     if (this.IsCSharpDebugCheck(theBlock, V_0))
     {
         return(true);
     }
     return(this.IsVisualBasicDebugCheck(theBlock, V_0));
 }
 private void MarkOptimizationAndCaseBlocks(InstructionBlock block, RemoveCompilerOptimizationsStep.SwitchData data)
 {
     V_0 = new Queue <InstructionBlock>();
     V_1 = new HashSet <int>();
     V_2 = block.get_Successors();
     V_3 = 0;
     while (V_3 < (int)V_2.Length)
     {
         V_0.Enqueue(V_2[V_3]);
         V_3 = V_3 + 1;
     }
     while (V_0.get_Count() > 0)
     {
         V_5       = V_0.Dequeue();
         dummyVar0 = V_1.Add(V_5.get_First().get_Offset());
         if (!this.IsOptimizationBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_OptimizationVariable()))
         {
             if (!this.IsCaseBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_SwitchExpression()) && !this.IsNullCaseBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_SwitchExpression()))
             {
                 continue;
             }
             this.switchBlocksToCasesMap.get_Item(block.get_First().get_Offset()).Add(V_5.get_First().get_Offset());
             V_8 = V_5.get_Successors()[1];
             if (this.IsEmptyStringCaseBlock(this.blockExpressions.get_Item(V_8.get_First().get_Offset()), data.get_SwitchExpression()))
             {
                 V_5.set_Last(V_8.get_Last());
                 V_5.set_Successors(V_8.get_Successors());
                 V_9 = this.blockExpressions.get_Item(V_5.get_First().get_Offset()).get_Item(0) as BinaryExpression;
                 V_9.set_Right(new LiteralExpression("", this.methodContext.get_Method().get_Module().get_TypeSystem(), null));
                 V_10 = this.blockExpressions.get_Item(V_8.get_First().get_Offset()).get_Item(0).get_UnderlyingSameMethodInstructions();
                 V_9  = V_9.CloneAndAttachInstructions(V_10) as BinaryExpression;
                 this.blockExpressions.get_Item(V_5.get_First().get_Offset()).set_Item(0, new UnaryExpression(11, V_9, null));
                 this.blocksToBeRemoved.Add(V_8.get_First().get_Offset());
             }
             dummyVar1 = this.MarkSecondSuccessorForRemovalIfItIsUnconditionalJump(V_5);
         }
         else
         {
             V_6 = V_5.get_Successors()[0];
             if (!V_1.Contains(V_6.get_First().get_Offset()))
             {
                 V_0.Enqueue(V_6);
             }
             V_7 = this.MarkSecondSuccessorForRemovalIfItIsUnconditionalJump(V_5);
             if (!V_1.Contains(V_7.get_First().get_Offset()) && this.IsOptimizationBlock(this.blockExpressions.get_Item(V_5.get_First().get_Offset()), data.get_OptimizationVariable()))
             {
                 V_0.Enqueue(V_7);
             }
             this.blocksToBeRemoved.Add(V_5.get_First().get_Offset());
         }
     }
     return;
 }
Ejemplo n.º 7
0
 private bool IsVersion2Disposer(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     if (V_0.get_OpCode().get_Code() != 2)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 23)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 122 || V_0.get_Operand() as FieldReference == null)
     {
         return(false);
     }
     this.disposingField = ((FieldReference)V_0.get_Operand()).Resolve();
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 2)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 39 || V_0.get_Operand() as MethodReference == null || (object)(V_0.get_Operand() as MethodReference).Resolve() != (object)this.moveNextMethodDefinition)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 37)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 2)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 21)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 122 || V_0.get_Operand() as FieldReference == null)
     {
         return(false);
     }
     this.stateField = ((FieldReference)V_0.get_Operand()).Resolve();
     V_1             = V_0.get_Next().get_OpCode();
     return(V_1.get_Code() == 41);
 }
 private bool ContainsStateVariableSet(InstructionBlock theBlock)
 {
     V_1 = theBlock.get_First();
     while ((object)V_1 != (object)theBlock.get_Last())
     {
         if (this.IsStloc(V_1) && this.TryGetVariableFromInstruction(V_1, out V_0) && (object)V_0 == (object)this.stateVariable)
         {
             return(true);
         }
         V_1 = V_1.get_Next();
     }
     return(false);
 }
 protected bool ContainsStateFieldLoad(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     while ((object)V_0 != (object)theBlock.get_Last())
     {
         if (V_0.get_OpCode().get_Code() == 120 && (object)((FieldReference)V_0.get_Operand()).Resolve() == (object)this.stateField)
         {
             return(true);
         }
         V_0 = V_0.get_Next();
     }
     return(false);
 }
 private bool CheckForStateFieldSet(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     while ((object)V_0 != (object)theBlock.get_Last())
     {
         if (V_0.get_OpCode().get_Code() == 122 && (object)((FieldReference)V_0.get_Operand()).Resolve() == (object)this.stateField)
         {
             return(true);
         }
         V_0 = V_0.get_Next();
     }
     return(false);
 }
Ejemplo n.º 11
0
 private bool IsDoFinallySetBlock(InstructionBlock theBlock)
 {
     if (!this.BeginsWithDoFinallySet(theBlock))
     {
         return(false);
     }
     V_0 = theBlock.get_First().get_Next();
     if ((object)V_0 == (object)theBlock.get_Last())
     {
         return(true);
     }
     return(this.IsNopTillEnd(theBlock, V_0.get_Next()));
 }
Ejemplo n.º 12
0
 private bool BeginsWithDoFinallySet(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     if ((object)V_0 == (object)theBlock.get_Last() || V_0.get_OpCode().get_Code() != 23)
     {
         return(false);
     }
     if (!StateMachineUtilities.TryGetVariableFromInstruction(V_0.get_Next(), this.methodContext.get_Body().get_Variables(), out V_1))
     {
         return(false);
     }
     return((object)V_1 == (object)this.doFinallyVariable);
 }
Ejemplo n.º 13
0
 private bool IsDummyStateControllerBlock(InstructionBlock theBlock)
 {
     if (this.version == AsyncStateMachineVersion.V1)
     {
         if (!this.ContainsStateFieldLoad(theBlock))
         {
             return(false);
         }
         V_0 = theBlock.get_Last();
         V_1 = 0;
         while (V_1 < 2)
         {
             if ((object)V_0 == (object)theBlock.get_First() || V_0.get_OpCode().get_Code() != 37)
             {
                 return(false);
             }
             V_0 = V_0.get_Previous();
             V_1 = V_1 + 1;
         }
         dummyVar0 = this.toBeRemoved.Add(theBlock);
         return(true);
     }
     V_3 = theBlock.get_First();
     if (!this.TryGetVariableFromInstruction(V_3, out V_4) || (object)V_4 != (object)this.stateVariable)
     {
         return(false);
     }
     if (V_3.get_Next().get_OpCode().get_Code() != 37 || V_3.get_Next().get_Next().get_OpCode().get_Code() != null)
     {
         return(false);
     }
     if ((object)V_3.get_Next().get_Next() != (object)theBlock.get_Last())
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 14
0
 private bool IsFalseReturnBlock(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     if (V_0.get_OpCode().get_Code() != 22 || (object)V_0 == (object)theBlock.get_Last())
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (!this.TryGetVariableFromInstruction(V_0, out V_1) || (object)V_0 == (object)theBlock.get_Last() || !this.CheckAndSaveReturnFlagVariable(V_1))
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     return(StateMachineUtilities.IsUnconditionalBranch(V_0));
 }
 private bool IsDebugControllerBlock(InstructionBlock theBlock, out int stateNumber)
 {
     if ((object)theBlock.get_First() == (object)theBlock.get_Last())
     {
         stateNumber = -1;
         return(false);
     }
     V_0 = theBlock.get_First().get_Next();
     if ((object)V_0 == (object)theBlock.get_Last() || V_0.get_OpCode().get_Code() != 120 || (object)((FieldReference)V_0.get_Operand()).Resolve() != (object)this.stateField)
     {
         stateNumber = -1;
         return(false);
     }
     V_0 = V_0.get_Next();
     if ((object)V_0 == (object)theBlock.get_Last() || !StateMachineUtilities.TryGetOperandOfLdc(V_0, out stateNumber))
     {
         stateNumber = -1;
         return(false);
     }
     V_0 = V_0.get_Next();
     if ((object)V_0 == (object)theBlock.get_Last() || V_0.get_OpCode().get_Code() != 192)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if ((object)V_0 == (object)theBlock.get_Last() || V_0.get_OpCode().get_Code() != 22)
     {
         return(false);
     }
     if (theBlock.get_Last().get_OpCode().get_Code() == 57)
     {
         return(true);
     }
     V_1 = theBlock.get_Last().get_OpCode();
     return(V_1.get_Code() == 44);
 }
 private bool CheckForIsCompletedCall(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     while ((object)V_0 != (object)theBlock.get_Last())
     {
         if (V_0.get_OpCode().get_Code() == 39 || V_0.get_OpCode().get_Code() == 110 && String.op_Equality(((MethodReference)V_0.get_Operand()).get_Name(), "get_IsCompleted"))
         {
             if (!StateMachineUtilities.TryGetVariableFromInstruction(V_0.get_Previous(), this.moveNextMethodContext.get_Body().get_Variables(), out V_2))
             {
                 return(false);
             }
             dummyVar0 = this.awaiterVariables.Add(V_2);
             return(true);
         }
         V_0 = V_0.get_Next();
     }
     return(false);
 }
Ejemplo n.º 17
0
 private bool IsDisposingBlock(InstructionBlock theBlock)
 {
     V_0 = theBlock.get_First();
     if (V_0.get_OpCode().get_Code() != 2 || (object)V_0 == (object)theBlock.get_Last())
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 120 || (object)((FieldReference)V_0.get_Operand()).Resolve() != (object)this.disposingField || (object)V_0 == (object)theBlock.get_Last())
     {
         return(false);
     }
     V_1 = theBlock.get_Last();
     if (V_1.get_OpCode().get_Code() == 56 || V_1.get_OpCode().get_Code() == 43 || V_1.get_OpCode().get_Code() == 57)
     {
         return(true);
     }
     return(V_1.get_OpCode().get_Code() == 44);
 }
 protected override bool IsFinallyCheckBlock(InstructionBlock finallyEntry)
 {
     V_0 = finallyEntry.get_First();
     if (!StateMachineUtilities.TryGetVariableFromInstruction(V_0, this.methodVariables, out V_1) || (object)V_1 != (object)this.stateVariable)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 22)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 59 && V_0.get_OpCode().get_Code() != 46)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 19
0
 private bool IsFinallyMethodInvocationBlock(InstructionBlock block)
 {
     V_0 = block.get_First();
     if (V_0.get_OpCode().get_Code() != 2)
     {
         return(false);
     }
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() != 39)
     {
         return(false);
     }
     V_1 = V_0;
     V_0 = V_0.get_Next();
     if (V_0.get_OpCode().get_Code() == null)
     {
         V_0 = V_0.get_Next();
     }
     if (!StateMachineUtilities.IsUnconditionalBranch(V_0))
     {
         return(false);
     }
     if ((object)block.get_Last() != (object)V_0)
     {
         return(false);
     }
     V_2 = V_1.get_Operand() as MethodReference;
     if (V_2 == null)
     {
         return(false);
     }
     if (!V_2.get_Name().StartsWith("<>m__Finally"))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 20
0
 private YieldStateMachineControlFlowRebuilder.NextStateNumberSearchResult TryGetNextStateNumber(InstructionBlock theBlock, out int newStateNumber)
 {
     V_0 = theBlock.get_Last();
     while ((object)V_0 != (object)theBlock.get_First())
     {
         if (V_0.get_OpCode().get_Code() == 122 && (object)this.stateField == (object)((FieldReference)V_0.get_Operand()).Resolve())
         {
             V_0 = V_0.get_Previous();
             if (!StateMachineUtilities.TryGetOperandOfLdc(V_0, out newStateNumber))
             {
                 return(0);
             }
             V_0 = V_0.get_Previous().get_Previous();
             if (V_0.get_OpCode().get_Code() == 122 && this.CheckAndSaveCurrentItemField((FieldReference)V_0.get_Operand()))
             {
                 return(1);
             }
             return(0);
         }
         V_0 = V_0.get_Previous();
     }
     newStateNumber = 0;
     return(2);
 }
 protected virtual bool IsUnconditionalBranchBlock(InstructionBlock theBlock)
 {
     return(StateMachineUtilities.IsUnconditionalBranch(theBlock.get_First()));
 }
Ejemplo n.º 22
0
 private bool IsNopBlock(InstructionBlock theBlock)
 {
     return(this.IsNopTillEnd(theBlock, theBlock.get_First()));
 }