@@ -16,7 +16,7 @@ Elm.debuggerAttach = function(module, hotSwapState /* =undefined */) {
16 var wrappedModule = debugModule(module, runtime);
16 var wrappedModule = debugModule(module, runtime);
17 Elm.Debugger = debuggerInit(wrappedModule, runtime, hotSwapState);
17 Elm.Debugger = debuggerInit(wrappedModule, runtime, hotSwapState);
18 dispatchElmDebuggerInit();
18 dispatchElmDebuggerInit();
19− return wrappedModule.moduleInstance;
19+ return wrappedModule.debuggedModule;
@@ -40,7 +40,7 @@ function debugModule(module, runtime) {
40 var recordedEvents = [];
40 var recordedEvents = [];
41 var asyncCallbacks = [];
41 var asyncCallbacks = [];
42 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
42 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
43− var now = 0;
43+ var pauseTime = 0;
45 function wrapNotify(id, v) {
45 function wrapNotify(id, v) {
46 var timestep = runtime.timer.now();
46 var timestep = runtime.timer.now();
@@ -113,11 +113,11 @@ function debugModule(module, runtime) {
113 programPaused = true;
113 programPaused = true;
114 clearAsyncCallbacks();
114 clearAsyncCallbacks();
115 tracePath.stopRecording();
115 tracePath.stopRecording();
116− now = Date.now();
116+ pauseTime = Date.now();
119 function setContinue(position) {
119 function setContinue(position) {
120− var timerDelay = Date.now() - now;
120+ var timerDelay = Date.now() - pauseTime;
121 runtime.timer.addDelay(timerDelay);
121 runtime.timer.addDelay(timerDelay);
122 programPaused = false;
122 programPaused = false;
123 if (position > 0) {
123 if (position > 0) {
@@ -140,11 +140,11 @@ function debugModule(module, runtime) {
140 wrappedRuntime.runDelayed = wrapRunDelayed;
140 wrappedRuntime.runDelayed = wrapRunDelayed;
142 var assignedPropTracker = Object.create(wrappedRuntime);
142 var assignedPropTracker = Object.create(wrappedRuntime);
143− var moduleInstance = module.make(assignedPropTracker);
143+ var debuggedModule = module.make(assignedPropTracker);
145 // make sure the signal graph is actually a signal & extract the visual model
145 // make sure the signal graph is actually a signal & extract the visual model
146− if ( !('recv' in moduleInstance.main) ) {
146+ if ( !('recv' in debuggedModule.main) ) {
147− moduleInstance.main = Elm.Signal.make(runtime).constant(moduleInstance.main);
147+ debuggedModule.main = Elm.Signal.make(runtime).constant(debuggedModule.main);
150 // The main module stores imported modules onto the runtime.
150 // The main module stores imported modules onto the runtime.
@@ -154,13 +154,13 @@ function debugModule(module, runtime) {
154 runtime[key] = assignedPropTracker[key];
154 runtime[key] = assignedPropTracker[key];
157− var moduleNodes = flattenNodes(wrappedRuntime.inputs);
157+ var signalGraphNodes = flattenSignalGraph(wrappedRuntime.inputs);
158− var tracePath = tracePathInit(runtime, moduleInstance.main);
158+ var tracePath = tracePathInit(runtime, debuggedModule.main);
161− moduleInstance: moduleInstance,
161+ debuggedModule: debuggedModule,
162− moduleNodes: moduleNodes,
162+ signalGraphNodes: signalGraphNodes,
163− initialNodeValues: saveNodeValues(moduleNodes),
163+ initialSnapshot: snapshotSignalGraph(signalGraphNodes),
164 initialAsyncCallbacks: asyncCallbacks.slice(),
164 initialAsyncCallbacks: asyncCallbacks.slice(),
165 // API functions
165 // API functions
166 clearAsyncCallbacks: clearAsyncCallbacks,
166 clearAsyncCallbacks: clearAsyncCallbacks,
@@ -182,7 +182,7 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
183 function resetProgram() {
183 function resetProgram() {
184 debugModule.clearAsyncCallbacks();
184 debugModule.clearAsyncCallbacks();
185− restoreNodeValues(debugModule.moduleNodes, debugModule.initialNodeValues);
185+ restoreSnapshot(debugModule.signalGraphNodes, debugModule.initialSnapshot);
186 redrawGraphics();
186 redrawGraphics();
@@ -208,11 +208,11 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
210 resetProgram();
210 resetProgram();
211− var index = eventCounter;
211+ var continueIndex = eventCounter;
212 eventCounter = 0;
212 eventCounter = 0;
213 debugModule.tracePath.clearTraces();
213 debugModule.tracePath.clearTraces();
214 debugModule.tracePath.startRecording();
214 debugModule.tracePath.startRecording();
215− stepTo(index);
215+ stepTo(continueIndex);
216 debugModule.setContinue(eventCounter);
216 debugModule.setContinue(eventCounter);
@@ -258,20 +258,20 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
260 function redrawGraphics() {
260 function redrawGraphics() {
261− var main = debugModule.moduleInstance.main
261+ var main = debugModule.debuggedModule.main
262 for (var i = main.kids.length ; i-- ; ) {
262 for (var i = main.kids.length ; i-- ; ) {
263 main.kids[i].recv(runtime.timer.now(), true, main.id);
263 main.kids[i].recv(runtime.timer.now(), true, main.id);
267 function getHotSwapState() {
267 function getHotSwapState() {
268− var counter = eventCounter;
268+ var continueIndex = eventCounter;
269 if (!debugModule.getPaused()) {
269 if (!debugModule.getPaused()) {
270− counter = getMaxSteps();
270+ continueIndex = getMaxSteps();
273 recordedEvents: debugModule.copyRecordedEvents(),
273 recordedEvents: debugModule.copyRecordedEvents(),
274− eventCounter: counter
274+ eventCounter: continueIndex
@@ -315,9 +315,9 @@ function debuggerInit(debugModule, runtime, hotSwapState /* =undefined */) {
315 getPaused: debugModule.getPaused,
315 getPaused: debugModule.getPaused,
316 getHotSwapState: getHotSwapState,
316 getHotSwapState: getHotSwapState,
317 dispose: dispose,
317 dispose: dispose,
318− allNodes: debugModule.moduleNodes,
318+ allNodes: debugModule.signalGraphNodes,
319 watchTracker: debugModule.watchTracker,
319 watchTracker: debugModule.watchTracker,
320− mainNode: debugModule.moduleInstance.main
320+ mainSignalNode: debugModule.debuggedModule.main
323 return elmDebugger;
323 return elmDebugger;
@@ -336,10 +336,10 @@ function Point(x, y) {
339−function tracePathInit(runtime, mainNode) {
339+function tracePathInit(runtime, mainSignalNode) {
340 var List = Elm.List.make(runtime);
340 var List = Elm.List.make(runtime);
341 var Signal = Elm.Signal.make(runtime);
341 var Signal = Elm.Signal.make(runtime);
342− var tracePathNode = A2(Signal.lift, graphicsUpdate, mainNode);
342+ var tracePathNode = A2(Signal.lift, graphicsUpdate, mainSignalNode);
343 var tracePathCanvas = createCanvas();
343 var tracePathCanvas = createCanvas();
344 var tracePositions = {};
344 var tracePositions = {};
345 var recordingTraces = true;
345 var recordingTraces = true;
@@ -474,7 +474,7 @@ function assert(bool, msg) {
477−function saveNodeValues(allNodes) {
477+function snapshotSignalGraph(allNodes) {
478 var nodeValues = [];
478 var nodeValues = [];
480 allNodes.forEach(function(node) {
480 allNodes.forEach(function(node) {
@@ -485,18 +485,18 @@ function saveNodeValues(allNodes) {
488−function restoreNodeValues(allNodes, nodeStates) {
488+function restoreSnapshot(allNodes, snapshot) {
489− assert(allNodes.length == nodeStates.length, "saved program state has wrong length");
489+ assert(allNodes.length == snapshot.length, "saved program state has wrong length");
490 for (var i=0; i < allNodes.length; i++) {
490 for (var i=0; i < allNodes.length; i++) {
491 var node = allNodes[i];
491 var node = allNodes[i];
492− var state = nodeStates[i];
492+ var state = snapshot[i];
493 assert(node.id == state.id, "the nodes moved position");
493 assert(node.id == state.id, "the nodes moved position");
495 node.value = state.value;
495 node.value = state.value;
499−function flattenNodes(nodes) {
499+function flattenSignalGraph(nodes) {
500 var nodesById = {};
500 var nodesById = {};
502 function addAllToDict(node) {
502 function addAllToDict(node) {