on master help sign in
renamed for clarity
commitefdb99f32a45a81c7a77c422ed4572bf897b4133 authorMichael James <michael@michaelbjames.com> dateWed 23 Jul 2014, 15:12 (12 years ago) parentb72ec5e
1 file changed+28−28
runtime/Debugger.js+28−28
runtime/Debugger.js+28−28
@@ -16,7 +16,7 @@ Elm.debuggerAttach = function(module, hotSwapState /* =undefined */) {
1616 var wrappedModule = debugModule(module, runtime);
1717 Elm.Debugger = debuggerInit(wrappedModule, runtime, hotSwapState);
1818 dispatchElmDebuggerInit();
19− return wrappedModule.moduleInstance;
19+ return wrappedModule.debuggedModule;
2020 }
2121 };
2222};
@@ -40,7 +40,7 @@ function debugModule(module, runtime) {
4040 var recordedEvents = [];
4141 var asyncCallbacks = [];
4242 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
43− var now = 0;
43+ var pauseTime = 0;
4444
4545 function wrapNotify(id, v) {
4646 var timestep = runtime.timer.now();
@@ -113,11 +113,11 @@ function debugModule(module, runtime) {
113113 programPaused = true;
114114 clearAsyncCallbacks();
115115 tracePath.stopRecording();
116− now = Date.now();
116+ pauseTime = Date.now();
117117 }
118118
119119 function setContinue(position) {
120− var timerDelay = Date.now() - now;
120+ var timerDelay = Date.now() - pauseTime;
121121 runtime.timer.addDelay(timerDelay);
122122 programPaused = false;
123123 if (position > 0) {
@@ -140,11 +140,11 @@ function debugModule(module, runtime) {
140140 wrappedRuntime.runDelayed = wrapRunDelayed;
141141
142142 var assignedPropTracker = Object.create(wrappedRuntime);
143− var moduleInstance = module.make(assignedPropTracker);
143+ var debuggedModule = module.make(assignedPropTracker);
144144
145145 // make sure the signal graph is actually a signal & extract the visual model
146− if ( !('recv' in moduleInstance.main) ) {
147− moduleInstance.main = Elm.Signal.make(runtime).constant(moduleInstance.main);
146+ if ( !('recv' in debuggedModule.main) ) {
147+ debuggedModule.main = Elm.Signal.make(runtime).constant(debuggedModule.main);
148148 }
149149
150150 // The main module stores imported modules onto the runtime.
@@ -154,13 +154,13 @@ function debugModule(module, runtime) {
154154 runtime[key] = assignedPropTracker[key];
155155 });
156156
157− var moduleNodes = flattenNodes(wrappedRuntime.inputs);
158− var tracePath = tracePathInit(runtime, moduleInstance.main);
157+ var signalGraphNodes = flattenSignalGraph(wrappedRuntime.inputs);
158+ var tracePath = tracePathInit(runtime, debuggedModule.main);
159159
160160 return {
161− moduleInstance: moduleInstance,
162− moduleNodes: moduleNodes,
163− initialNodeValues: saveNodeValues(moduleNodes),
161+ debuggedModule: debuggedModule,
162+ signalGraphNodes: signalGraphNodes,
163+ initialSnapshot: snapshotSignalGraph(signalGraphNodes),
164164 initialAsyncCallbacks: asyncCallbacks.slice(),
165165 // API functions
166166 clearAsyncCallbacks: clearAsyncCallbacks,
@@ -182,7 +182,7 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
182182
183183 function resetProgram() {
184184 debugModule.clearAsyncCallbacks();
185− restoreNodeValues(debugModule.moduleNodes, debugModule.initialNodeValues);
185+ restoreSnapshot(debugModule.signalGraphNodes, debugModule.initialSnapshot);
186186 redrawGraphics();
187187 }
188188
@@ -208,11 +208,11 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
208208 return;
209209 }
210210 resetProgram();
211− var index = eventCounter;
211+ var continueIndex = eventCounter;
212212 eventCounter = 0;
213213 debugModule.tracePath.clearTraces();
214214 debugModule.tracePath.startRecording();
215− stepTo(index);
215+ stepTo(continueIndex);
216216 debugModule.setContinue(eventCounter);
217217 }
218218 }
@@ -258,20 +258,20 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
258258 }
259259
260260 function redrawGraphics() {
261− var main = debugModule.moduleInstance.main
261+ var main = debugModule.debuggedModule.main
262262 for (var i = main.kids.length ; i-- ; ) {
263263 main.kids[i].recv(runtime.timer.now(), true, main.id);
264264 }
265265 }
266266
267267 function getHotSwapState() {
268− var counter = eventCounter;
268+ var continueIndex = eventCounter;
269269 if (!debugModule.getPaused()) {
270− counter = getMaxSteps();
270+ continueIndex = getMaxSteps();
271271 }
272272 return {
273273 recordedEvents: debugModule.copyRecordedEvents(),
274− eventCounter: counter
274+ eventCounter: continueIndex
275275 };
276276 }
277277
@@ -315,9 +315,9 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
315315 getPaused: debugModule.getPaused,
316316 getHotSwapState: getHotSwapState,
317317 dispose: dispose,
318− allNodes: debugModule.moduleNodes,
318+ allNodes: debugModule.signalGraphNodes,
319319 watchTracker: debugModule.watchTracker,
320− mainNode: debugModule.moduleInstance.main
320+ mainSignalNode: debugModule.debuggedModule.main
321321 };
322322
323323 return elmDebugger;
@@ -336,10 +336,10 @@ function Point(x, y) {
336336 }
337337}
338338
339−function tracePathInit(runtime, mainNode) {
339+function tracePathInit(runtime, mainSignalNode) {
340340 var List = Elm.List.make(runtime);
341341 var Signal = Elm.Signal.make(runtime);
342− var tracePathNode = A2(Signal.lift, graphicsUpdate, mainNode);
342+ var tracePathNode = A2(Signal.lift, graphicsUpdate, mainSignalNode);
343343 var tracePathCanvas = createCanvas();
344344 var tracePositions = {};
345345 var recordingTraces = true;
@@ -474,7 +474,7 @@ function assert(bool, msg) {
474474 }
475475}
476476
477−function saveNodeValues(allNodes) {
477+function snapshotSignalGraph(allNodes) {
478478 var nodeValues = [];
479479
480480 allNodes.forEach(function(node) {
@@ -485,18 +485,18 @@ function saveNodeValues(allNodes) {
485485};
486486
487487
488−function restoreNodeValues(allNodes, nodeStates) {
489− assert(allNodes.length == nodeStates.length, "saved program state has wrong length");
488+function restoreSnapshot(allNodes, snapshot) {
489+ assert(allNodes.length == snapshot.length, "saved program state has wrong length");
490490 for (var i=0; i < allNodes.length; i++) {
491491 var node = allNodes[i];
492− var state = nodeStates[i];
492+ var state = snapshot[i];
493493 assert(node.id == state.id, "the nodes moved position");
494494
495495 node.value = state.value;
496496 }
497497}
498498
499−function flattenNodes(nodes) {
499+function flattenSignalGraph(nodes) {
500500 var nodesById = {};
501501
502502 function addAllToDict(node) {