Source:
<code>public KDebugOpResult step(int steps) { K currentK = activeState.getCurrentK(); int activeStateCheckpoint = activeState.getActiveStateId(); int lastCheckpoint = activeState.getlastMapCheckpoint(); if (activeStateCheckpoint + steps < activeState.getlastMapCheckpoint() + checkpointInterval) { currentK = rewriter.execute(currentK, Optional.of(new Integer(steps))); activeStateCheckpoint += steps; <START> activeState.setActiveStateId(activeStateCheckpoint); <END> activeState.setCurrentK(currentK); return new KDebugOpResult(currentK, null); } currentK = rewriter.execute(currentK, Optional.of(new Integer(lastCheckpoint + checkpointInterval - activeStateCheckpoint))); steps -= lastCheckpoint + checkpointInterval - activeStateCheckpoint; activeStateCheckpoint = lastCheckpoint + checkpointInterval; activeState.addCheckpoint(new Checkpoint(currentK, activeStateCheckpoint), activeStateCheckpoint); while (steps >= checkpointInterval) { activeStateCheckpoint += checkpointInterval; Checkpoint newCheckpoint = new Checkpoint(rewriter.execute(currentK, Optional.of(new Integer(checkpointInterval))), activeStateCheckpoint); steps -= checkpointInterval; activeState.addCheckpoint(newCheckpoint, activeStateCheckpoint); currentK = newCheckpoint.getCheckpointK(); } currentK = rewriter.execute(currentK, Optional.of(new Integer(steps))); activeStateCheckpoint += steps; activeState.setCurrentK(currentK); activeState.setActiveStateId(activeStateCheckpoint); return new KDebugOpResult(currentK, null); }</code><technical_language>I State class immutable for now... adjust if a serious performance issue</technical_language>

Target:
public DebuggerState step(int steps) { K currentK = activeState.getCurrentK(); int activeStateCheckpoint = activeState.getStepNum(); int lastCheckpoint = activeState.getlastMapCheckpoint(); DebuggerState nextActiveState; stateList.remove(activeState); if (activeStateCheckpoint + steps < lastCheckpoint + checkpointInterval) { currentK = rewriter.execute(currentK, Optional.of(new Integer(steps))); activeStateCheckpoint += steps; NavigableMap<Integer, RewriterCheckpoint> checkpointMap = activeState.getCheckpointMap(); nextActiveState = new DebuggerState(currentK, activeStateCheckpoint, checkpointMap); stateList.add(nextActiveState); activeState = nextActiveState; return nextActiveState; } if (lastCheckpoint + checkpointInterval - activeStateCheckpoint < 0) { lastCheckpoint = (activeStateCheckpoint / checkpointInterval) * checkpointInterval; } currentK = rewriter.execute(currentK, Optional.of(new Integer(lastCheckpoint + checkpointInterval - activeStateCheckpoint))); NavigableMap<Integer, RewriterCheckpoint> checkpointMap = activeState.getCheckpointMap(); steps -= lastCheckpoint + checkpointInterval - activeStateCheckpoint; activeStateCheckpoint = lastCheckpoint + checkpointInterval; checkpointMap.put(new Integer(activeStateCheckpoint), new RewriterCheckpoint(currentK)); while (steps >= checkpointInterval) { activeStateCheckpoint += checkpointInterval; RewriterCheckpoint newCheckpoint = new RewriterCheckpoint(rewriter.execute(currentK, Optional.of(new Integer(checkpointInterval)))); steps -= checkpointInterval; checkpointMap.put(new Integer(activeStateCheckpoint), newCheckpoint); currentK = newCheckpoint.getCheckpointK(); } currentK = rewriter.execute(currentK, Optional.of(new Integer(steps))); activeStateCheckpoint += steps; nextActiveState = new DebuggerState(currentK, activeStateCheckpoint, checkpointMap); activeState = nextActiveState; stateList.add(activeState); return nextActiveState; }