on master help sign in
moved a chunk up so functions can access the variables created
commit4786f5ef9e534f944dba97c1a8e4c571f0cf537d authorMichael James <michael@michaelbjames.com> dateWed 23 Jul 2014, 16:51 (12 years ago) parentd5168f0
1 file changed+25−24
runtime/Debugger.js+25−24
runtime/Debugger.js+25−24
@@ -41,6 +41,31 @@ function debugModule(module, runtime) {
4141 var watchTracker = Elm.Native.Debug.make(runtime).watchTracker;
4242 var pauseTime = 0;
4343
44+ // runtime is the prototype of wrappedRuntime
45+ // so we can access all runtime properties too
46+ var wrappedRuntime = Object.create(runtime);
47+ wrappedRuntime.notify = wrapNotify;
48+ wrappedRuntime.runDelayed = wrapRunDelayed;
49+
50+ // make a copy of the wrappedRuntime
51+ var assignedPropTracker = Object.create(wrappedRuntime);
52+ var debuggedModule = module.make(assignedPropTracker);
53+
54+ // make sure the signal graph is actually a signal & extract the visual model
55+ if ( !('recv' in debuggedModule.main) ) {
56+ debuggedModule.main = Elm.Signal.make(runtime).constant(debuggedModule.main);
57+ }
58+
59+ // The main module stores imported modules onto the runtime.
60+ // To ensure only one instance of each module is created,
61+ // we assign them back on the original runtime object.
62+ Object.keys(assignedPropTracker).forEach(function(key) {
63+ runtime[key] = assignedPropTracker[key];
64+ });
65+
66+ var signalGraphNodes = flattenSignalGraph(wrappedRuntime.inputs);
67+ var tracePath = tracePathInit(runtime, debuggedModule.main);
68+
4469 function wrapNotify(id, v) {
4570 var timestep = runtime.timer.now();
4671
@@ -132,30 +157,6 @@ function debugModule(module, runtime) {
132157 return programPaused;
133158 }
134159
135− // runtime is the prototype of wrappedRuntime
136− // so we can access all runtime properties too
137− var wrappedRuntime = Object.create(runtime);
138− wrappedRuntime.notify = wrapNotify;
139− wrappedRuntime.runDelayed = wrapRunDelayed;
140−
141− var assignedPropTracker = Object.create(wrappedRuntime);
142− var debuggedModule = module.make(assignedPropTracker);
143−
144− // make sure the signal graph is actually a signal & extract the visual model
145− if ( !('recv' in debuggedModule.main) ) {
146− debuggedModule.main = Elm.Signal.make(runtime).constant(debuggedModule.main);
147− }
148−
149− // The main module stores imported modules onto the runtime.
150− // To ensure only one instance of each module is created,
151− // we assign them back on the original runtime object.
152− Object.keys(assignedPropTracker).forEach(function(key) {
153− runtime[key] = assignedPropTracker[key];
154− });
155−
156− var signalGraphNodes = flattenSignalGraph(wrappedRuntime.inputs);
157− var tracePath = tracePathInit(runtime, debuggedModule.main);
158−
159160 return {
160161 debuggedModule: debuggedModule,
161162 signalGraphNodes: signalGraphNodes,