예제 #1
0
        /// <summary>
        /// Set the value of the <see cref="_traced_var"/> (traced <see cref="Variable"/>) to be 'n' steps in the past ('n' <see cref="Alteration"/>s)
        /// </summary>
        /// <param name="n"> number of times to rewind the value of <see cref="_traced_var"/> once</param>
        public void rewind(int n = 1)
        {
            last_stack_count -= n;
            Debugging.assert(events.Count > 1); // 1 is for variable creation
            Debugging.assert(n < events.Count); // didn't rewind before creation of variable ?

            dynamic dyn_value;

            for (int i = 0; i < n; i++)
            {
                printTrace("rewind: ", i, "/", n);
                Event popped = events.Pop();
                printTrace("popped event: " + popped);
                dyn_value = popped.alter.main_value;
                printTrace("loop dyn_value: ", StringUtils.dynamic2Str(dyn_value));
            }

            Event new_ = peekEvent();

            printTrace("latest event after rewind: " + new_);
            dyn_value = peekValue();
            printTrace("final rewind value: " + StringUtils.dynamic2Str(dyn_value));
            _traced_var.forceSetValue(dyn_value);
        }