示例#1
0
        private void ProcessImpl(TMachineEvent ev)
        {
            var stateDispatcher = this.machineDispatcher.FindStateDispatcher(CurrentState);

            if (stateDispatcher.TryTransition(CurrentState, ev, out var updatedState))
            {
                // Cleanup previous state
                var previousState = CurrentState;

                if (previousState.GetType() != updatedState.GetType())
                {
                    stateDispatcher.OnLeave(previousState);

                    // Initialize new state
                    var newStateDispatcher = this.machineDispatcher.FindStateDispatcher(updatedState);
                    var stateType          = newStateDispatcher.OnEnter(updatedState, out var actionTask);
                    StateMachineUtilities.SetupStateState(
                        stateType,
                        actionTask,
                        ref this.currentOperation,
                        Process,
                        CompletedActionTask);
                }

                // Change state
                this.CurrentState = updatedState;
                NotifyStateChanged(CurrentState, previousState);
            }
        }
示例#2
0
 public BlockStatement Process(DecompilationContext context, BlockStatement body)
 {
     this.moveNextMethodContext = context.get_MethodContext();
     this.theCFG = this.moveNextMethodContext.get_ControlFlowGraph();
     this.moveNextMethodContext.set_IsMethodBodyChanged(true);
     StateMachineUtilities.FixInstructionConnections(this.theCFG.get_Blocks());
     if (!this.ProcessCFG())
     {
         context.StopPipeline();
     }
     return(body);
 }
示例#3
0
        public Ast.Statements.BlockStatement Process(DecompilationContext context, Ast.Statements.BlockStatement body)
        {
            this.moveNextMethodContext = context.MethodContext;
            this.theCFG = this.moveNextMethodContext.ControlFlowGraph;
            moveNextMethodContext.IsMethodBodyChanged = true;

            StateMachineUtilities.FixInstructionConnections(theCFG.Blocks);

            if (!ProcessCFG())
            {
                context.StopPipeline();
            }
            return(body);
        }
 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);
 }
示例#5
0
        /// <summary>
        /// Checks whether the specified block contains a call of the get_IsCompleted method.
        /// </summary>
        /// <remarks>
        /// Saves the target variable of the call.
        /// </remarks>
        /// <param name="theBlock"></param>
        /// <returns></returns>
        private bool CheckForIsCompletedCall(InstructionBlock theBlock)
        {
            for (Instruction current = theBlock.First; current != theBlock.Last; current = current.Next)
            {
                if ((current.OpCode.Code == Code.Call || current.OpCode.Code == Code.Callvirt) &&
                    ((MethodReference)current.Operand).Name == "get_IsCompleted")
                {
                    VariableReference awaiterVariable;
                    if (StateMachineUtilities.TryGetVariableFromInstruction(current.Previous, moveNextMethodContext.Body.Variables, out awaiterVariable))
                    {
                        awaiterVariables.Add(awaiterVariable);
                        return(true);
                    }
                    return(false);
                }
            }

            return(false);
        }