on master help sign in
redundant code moved to function
f217b7dMichael James
runtime/Debugger.js+10−16
@@ -84,12 +84,7 @@ function debugModule(module, runtime) {
84 else {
84 else {
85 recordEvent(id, v, timestep);
85 recordEvent(id, v, timestep);
86 var changed = runtime.notify(id, v, timestep);
86 var changed = runtime.notify(id, v, timestep);
87− if (eventsUntilSnapshot === 1) {
87+ snapshotOnCheckpoint();
88− saveSnapshot();
89− eventsUntilSnapshot = EVENTS_PER_SAVE;
90− } else {
91− eventsUntilSnapshot -= 1;
92− }
93 if (parent.window) {
88 if (parent.window) {
94 parent.window.postMessage("elmNotify", window.location.origin);
89 parent.window.postMessage("elmNotify", window.location.origin);
95 }
90 }
@@ -159,8 +154,13 @@ function debugModule(module, runtime) {
159 return snapshots[snapshotEvent];
154 return snapshots[snapshotEvent];
160 }
155 }
161
156
162− function saveSnapshot() {
157+ function snapshotOnCheckpoint() {
158+ if (eventsUntilSnapshot === 1) {
163− snapshots.push(snapshotSignalGraph(signalGraphNodes));
159+ snapshots.push(snapshotSignalGraph(signalGraphNodes));
160+ eventsUntilSnapshot = EVENTS_PER_SAVE;
161+ } else {
162+ eventsUntilSnapshot -= 1;
163+ }
164 }
164 }
165
165
166 function setPaused() {
166 function setPaused() {
@@ -206,7 +206,7 @@ function debugModule(module, runtime) {
206 loadRecordedEvents: loadRecordedEvents,
206 loadRecordedEvents: loadRecordedEvents,
207 clearSnapshots: clearSnapshots,
207 clearSnapshots: clearSnapshots,
208 getSnapshotAt: getSnapshotAt,
208 getSnapshotAt: getSnapshotAt,
209− saveSnapshot: saveSnapshot,
209+ snapshotOnCheckpoint: snapshotOnCheckpoint,
210 getPaused: getPaused,
210 getPaused: getPaused,
211 setPaused: setPaused,
211 setPaused: setPaused,
212 setContinue: setContinue,
212 setContinue: setContinue,
@@ -319,7 +319,6 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
319 debugModule.setPaused();
319 debugModule.setPaused();
320 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
320 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
321 var index = getMaxSteps();
321 var index = getMaxSteps();
322− var eventsUntilSnapshot = EVENTS_PER_SAVE;
323 eventCounter = 0;
322 eventCounter = 0;
324 debugModule.tracePath.clearTraces();
323 debugModule.tracePath.clearTraces();
325
324
@@ -329,12 +328,7 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
329 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
328 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
330 eventCounter += 1;
329 eventCounter += 1;
331 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
330 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
332− if (eventsUntilSnapshot === 1) {
333− debugModule.saveSnapshot();
331+ debugModule.snapshotOnCheckpoint();
334− eventsUntilSnapshot = EVENTS_PER_SAVE;
335− } else {
336− eventsUntilSnapshot -= 1;
337− }
338 currentEventIndex += 1;
332 currentEventIndex += 1;
339 }
333 }
340 debugModule.tracePath.stopRecording();
334 debugModule.tracePath.stopRecording();