コード例 #1
0
        public ExecutionState GetNextState()
        {
            while (GetNumberOfStates() > 0)
            {
                var state = UnderlyingStateScheduler.GetNextState();

                if (!TerminateIfDepthExceeded(state))
                {
                    return(state);
                }
                else
                {
                    UnderlyingStateScheduler.RemoveState(state);
                }
            }

            Debug.Assert(GetNumberOfStates() == 0, "Expected no states to remain");
            return(null);
        }
コード例 #2
0
        public void RemoveState(ExecutionState toRemove)
        {
            Debug.Assert(EscapingBlocks != null, "Escaping blocks not set");

            // Fast path
            if (LoopEscapingStates.Count > 0 && LoopEscapingStates.Peek() == toRemove)
            {
                LoopEscapingStates.Pop();
                return;
            }

            // FIXME: This might be slow
            if (LoopEscapingStates.Contains(toRemove))
            {
                int initialStates = LoopEscapingStates.Count;

                // The item we want to remove is not on the top of the stack
                // pop items until we find it, remove it and then pop the items back on
                Stack <ExecutionState> statesToAddBack = new Stack <ExecutionState>();
                while (LoopEscapingStates.Peek() != toRemove)
                {
                    statesToAddBack.Push(LoopEscapingStates.Pop());
                }

                // Pop the state to remove
                var state = LoopEscapingStates.Pop();
                Debug.Assert(state == toRemove, "We removed the wrong state!");

                // but the other states back
                while (statesToAddBack.Count > 0)
                {
                    LoopEscapingStates.Push(statesToAddBack.Pop());
                }

                Debug.Assert(LoopEscapingStates.Count == (initialStates - 1), "The number of states removed was incorrect");
            }
            else
            {
                UnderlyingScheduler.RemoveState(toRemove);
            }
        }
コード例 #3
0
 public void RemoveState(ExecutionState toRemove)
 {
     StateToCurrentLoops.Remove(toRemove);
     UnderlyingScheduler.RemoveState(toRemove);
 }