コード例 #1
0
        /// <summary>
        ///   Replays the transition of the counter example with the zero-baesd <paramref name="transitionIndex" />.
        /// </summary>
        /// <param name="choiceResolver">The choice resolver that should be used to resolve nondeterministic choices.</param>
        /// <param name="transitionIndex">The zero-based index of the transition that should be replayed.</param>
        internal unsafe void Replay(ChoiceResolver choiceResolver, int transitionIndex)
        {
            if (StepCount == 0)
            {
                return;
            }

            choiceResolver.Clear();
            choiceResolver.PrepareNextState();
            choiceResolver.SetChoices(ReplayInfo[transitionIndex]);

            fixed(byte *state = States[transitionIndex])
            RuntimeModel.Deserialize(state);

            foreach (var fault in RuntimeModel.NondeterministicFaults)
            {
                fault.Reset();
            }

            if (transitionIndex == 0)
            {
                RuntimeModel.ExecuteInitialStep();
            }
            else
            {
                RuntimeModel.ExecuteStep();
            }

            RuntimeModel.NotifyFaultActivations();
        }
コード例 #2
0
		/// <summary>
		///   Adds a transition to the <paramref name="model" />'s current state.
		/// </summary>
		/// <param name="model">The model the transition should be added for.</param>
		public void Add(RuntimeModel model)
		{
			if (_count >= _capacity)
				throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");

			++_computedCount;

			// 1. Serialize the model's computed state; that is the successor state of the transition's source state
			//    modulo any changes resulting from notifications of fault activations
			var successorState = _targetStateMemory + _stateVectorSize * _count;
			var activatedFaults = FaultSet.FromActivatedFaults(model.NondeterministicFaults);
			model.Serialize(successorState);

			// 2. Make sure the transition we're about to add is activation-minimal
			if (!Add(successorState, activatedFaults))
				return;

			// 3. Execute fault activation notifications and serialize the updated state if necessary
			if (model.NotifyFaultActivations())
				model.Serialize(successorState);

			// 4. Store the transition
			_transitions[_count] = new CandidateTransition
			{
				TargetState = successorState,
				Formulas = new StateFormulaSet(_formulas),
				ActivatedFaults = activatedFaults,
				IsValid = true,
			};
			++_count;
		}