/*----- Utility functions and classes -------------------------------------*/
+DEP.DEBUG = false;
+function blather(msg) {
+ /* Report MSG to the log if we're debugging. */
+ if (DEP.DEBUG) console.log(";; " + msg);
+}
+function show(what, value) {
+ /* Report that WHAT has the value VALUE, if we're debugging; and,
+ * regardless, return VALUE.
+ */
+ blather(what + " = " + value);
+ return value;
+}
+
function dolist(list, func) {
/* Apply FUNC to each element of LIST, discarding the results.
*
this._dependencies = { }; // Set of objects we depend on.
// If we have a recomputation function then exercise it.
+ blather("new dep " + me);
if (func !== null) {
with_frozen(function () {
PENDING.push(me);
+ blather("push new dep " + me);
});
}
}
* function which doesn't handle propagation or anything like that.
*/
+ blather("_update " + this + ": " + value);
if (value === BAD ?
this._value === BAD :
(this._value !== BAD &&
this._dependencies = { };
return try_finally(function () {
EVALUATING = me;
- return orelse(function () { return me._value_function(); },
- function () { return BAD; });
+ return show("_new_value for " + me,
+ orelse(function () { return me._value_function(); },
+ function () { return show("ret", BAD); }));
}, function() {
EVALUATING = old;
});
}
}
val = this._value;
+ blather("value " + this + ": " + val);
if (val === BAD) throw BAD;
return val;
},
var d, f;
var old_state = STATE;
STATE = 'recomputing';
+ blather("STATE <- :recomputing");
try_finally(function () {
while (PENDING.length) {
d = PENDING.shift();
while (PENDING.length) {
d = PENDING.shift();
d._value = BAD;
+ blather("recompute_pending mark " + d);
}
STATE = old_state;
+ blather("STATE <- :" + old_state);
});
}
old_pending = PENDING;
old_state = STATE;
STATE = "frozen";
+ blather("STATE <- :frozen");
try_finally(function () {
DELAYED = [];
PENDING = [];
DELAYED = old_delayed;
PENDING = old_pending;
STATE = old_state;
+ blather("STATE <- :" + old_state);
});
break;
}