on master help sign in
elm.DebugStatus.eventCounter
bb9ffcfMichael James
runtime/Debugger.js+10−9
@@ -44,7 +44,8 @@ function debugModule(module, runtime) {
44 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
44 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
45 var pauseTime = 0;
45 var pauseTime = 0;
46 var eventsUntilSnapshot = EVENTS_PER_SAVE;
46 var eventsUntilSnapshot = EVENTS_PER_SAVE;
47+ runtime.DebugStatus = runtime.DebugStatus || {};
47− runtime.eventCounter = runtime.eventCounter || 0;
48+ runtime.DebugStatus.eventCounter = runtime.DebugStatus.eventCounter || 0;
48
49
49 // runtime is the prototype of wrappedRuntime
50 // runtime is the prototype of wrappedRuntime
50 // so we can access all runtime properties too
51 // so we can access all runtime properties too
@@ -111,7 +112,7 @@ function debugModule(module, runtime) {
111 function recordEvent(id, v, timestep) {
112 function recordEvent(id, v, timestep) {
112 watchTracker.pushFrame();
113 watchTracker.pushFrame();
113 recordedEvents.push({ id:id, value:v, timestep:timestep });
114 recordedEvents.push({ id:id, value:v, timestep:timestep });
114− runtime.eventCounter += 1;
115+ runtime.DebugStatus.eventCounter += 1;
115 }
116 }
116
117
117 function clearAsyncCallbacks() {
118 function clearAsyncCallbacks() {
@@ -124,7 +125,7 @@ function debugModule(module, runtime) {
124
125
125 function clearRecordedEvents() {
126 function clearRecordedEvents() {
126 recordedEvents = [];
127 recordedEvents = [];
127− runtime.eventCounter = 0;
128+ runtime.DebugStatus.eventCounter = 0;
128 }
129 }
129
130
130 function getRecordedEventsLength() {
131 function getRecordedEventsLength() {
@@ -182,7 +183,7 @@ function debugModule(module, runtime) {
182 snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
183 snapshots = snapshots.slice(0, lastSnapshotPosition + 1);
183 recordedEvents = recordedEvents.slice(0, position);
184 recordedEvents = recordedEvents.slice(0, position);
184 tracePath.clearTracesAfter(position);
185 tracePath.clearTracesAfter(position);
185− runtime.eventCounter = position;
186+ runtime.DebugStatus.eventCounter = position;
186 executeCallbacks(asyncCallbacks, false);
187 executeCallbacks(asyncCallbacks, false);
187 }
188 }
188 tracePath.startRecording();
189 tracePath.startRecording();
@@ -320,14 +321,14 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
320 debugModule.setPaused();
321 debugModule.setPaused();
321 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
322 debugModule.loadRecordedEvents(hotSwapState.recordedEvents);
322 var index = getMaxSteps();
323 var index = getMaxSteps();
323− runtime.eventCounter = 0;
324+ runtime.DebugStatus.eventCounter = 0;
324 debugModule.tracePath.clearTraces();
325 debugModule.tracePath.clearTraces();
325
326
326 // draw new trace path
327 // draw new trace path
327 debugModule.tracePath.startRecording();
328 debugModule.tracePath.startRecording();
328 while(currentEventIndex < index) {
329 while(currentEventIndex < index) {
329 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
330 var nextEvent = debugModule.getRecordedEventAt(currentEventIndex);
330− runtime.eventCounter += 1;
331+ runtime.DebugStatus.eventCounter += 1;
331 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
332 runtime.notify(nextEvent.id, nextEvent.value, nextEvent.timestep);
332 debugModule.snapshotOnCheckpoint();
333 debugModule.snapshotOnCheckpoint();
333 currentEventIndex += 1;
334 currentEventIndex += 1;
@@ -412,14 +413,14 @@ function tracePathInit(runtime, signalGraphMain) {
412 else {
413 else {
413 tracePositions[id] = [pos];
414 tracePositions[id] = [pos];
414 }
415 }
415− if (tracePositions[id].length < runtime.eventCounter) {
416+ if (tracePositions[id].length < runtime.DebugStatus.eventCounter) {
416− var padCount = runtime.eventCounter - tracePositions[id].length;
417+ var padCount = runtime.DebugStatus.eventCounter - tracePositions[id].length;
417 var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
418 var lastTracePosition = tracePositions[id][tracePositions[id].length - 1];
418 for (var i = padCount; i--;) {
419 for (var i = padCount; i--;) {
419 tracePositions[id].push(lastTracePosition)
420 tracePositions[id].push(lastTracePosition)
420 }
421 }
421 }
422 }
422− assert(tracePositions[id].length === runtime.eventCounter,
423+ assert(tracePositions[id].length === runtime.DebugStatus.eventCounter,
423 "We don't have a 1-1 mapping of trace positions to events");
424 "We don't have a 1-1 mapping of trace positions to events");
424 }
425 }
425 }
426 }