Exemple #1
0
        protected override bool ProcessCFG()
        {
            if (!GetStateField() || !RemoveStateSavingBlocks())
            {
                return(false);
            }

            AsyncMoveNextMethodAnalyzer         analyzer = new AsyncMoveNextMethodAnalyzer(this.moveNextMethodContext, this.stateField);
            StateMachineFinallyCheckRemoverBase finallyCheckRemover;

            if (analyzer.StateMachineVersion == AsyncStateMachineVersion.V1)
            {
                finallyCheckRemover = new StateMachineDoFinallyCheckRemover(this.moveNextMethodContext);
                finallyCheckRemover.MarkFinallyConditionsForRemoval(analyzer.DoFinallyVariable);
            }
            else
            {
                finallyCheckRemover = new StateMachineFinallyStateCheckRemover(this.moveNextMethodContext);
                finallyCheckRemover.MarkFinallyConditionsForRemoval(analyzer.StateVariable);
            }

            toBeRemoved.UnionWith(finallyCheckRemover.BlocksMarkedForRemoval);

            AsyncStateControllerRemover asyncControllerRemover =
                new AsyncStateControllerRemover(this.moveNextMethodContext, this.stateField, analyzer.DoFinallyVariable, analyzer.StateMachineVersion);

            if (!asyncControllerRemover.RemoveStateMachineController() && asyncControllerRemover.FoundControllerBlocks)
            {
                return(false);
            }
            toBeRemoved.UnionWith(asyncControllerRemover.BlocksMarkedForRemoval);

            SwitchData controllerSwitchData;

            if (asyncControllerRemover.SwitchData != null)
            {
                controllerSwitchData = asyncControllerRemover.SwitchData;
            }
            else if (!CreateFakeSwitchData(out controllerSwitchData))
            {
                return(false);
            }

            StateMachineCFGCleaner cfgCleaner = new StateMachineCFGCleaner(this.theCFG, controllerSwitchData, controllerSwitchData.DefaultCase);

            if (!cfgCleaner.CleanUpTheCFG(toBeRemoved))
            {
                return(false);
            }

            this.moveNextMethodContext.AsyncData = new Decompiler.AsyncData(stateField, awaiterVariables, analyzer.variableToFieldMap);
            return(true);
        }
 protected override bool ProcessCFG()
 {
     if (!this.GetStateField() || !this.RemoveStateSavingBlocks())
     {
         return(false);
     }
     V_0 = new AsyncMoveNextMethodAnalyzer(this.moveNextMethodContext, this.stateField);
     if (V_0.get_StateMachineVersion() != AsyncStateMachineVersion.V1)
     {
         V_1 = new StateMachineFinallyStateCheckRemover(this.moveNextMethodContext);
         V_1.MarkFinallyConditionsForRemoval(V_0.get_StateVariable());
     }
     else
     {
         V_1 = new StateMachineDoFinallyCheckRemover(this.moveNextMethodContext);
         V_1.MarkFinallyConditionsForRemoval(V_0.get_DoFinallyVariable());
     }
     this.toBeRemoved.UnionWith(V_1.get_BlocksMarkedForRemoval());
     V_2 = new AsyncStateControllerRemover(this.moveNextMethodContext, this.stateField, V_0.get_DoFinallyVariable(), V_0.get_StateMachineVersion());
     if (!V_2.RemoveStateMachineController() && V_2.get_FoundControllerBlocks())
     {
         return(false);
     }
     this.toBeRemoved.UnionWith(V_2.get_BlocksMarkedForRemoval());
     if (V_2.get_SwitchData() == null)
     {
         if (!this.CreateFakeSwitchData(out V_3))
         {
             return(false);
         }
     }
     else
     {
         V_3 = V_2.get_SwitchData();
     }
     if (!(new StateMachineCFGCleaner(this.theCFG, V_3, V_3.get_DefaultCase())).CleanUpTheCFG(this.toBeRemoved))
     {
         return(false);
     }
     this.moveNextMethodContext.set_AsyncData(new AsyncData(this.stateField, this.awaiterVariables, V_0.variableToFieldMap));
     return(true);
 }