Add sequencer-level debug console logs

This commit is contained in:
Tim Mickel 2016-06-07 21:05:32 -04:00
parent 5767e05d56
commit c1e30cf2ee
4 changed files with 19 additions and 11 deletions
src/engine

View file

@ -24,6 +24,12 @@ function Sequencer (runtime) {
*/
Sequencer.WORK_TIME = 10;
/**
* If set, block calls, args, and return values will be logged to the console.
* @const {boolean}
*/
Sequencer.DEBUG_BLOCK_CALLS = true;
/**
* Step through all threads in `this.threads`, running them in order.
* @return {Array.<Thread>} All threads which have finished in this iteration.
@ -213,9 +219,15 @@ Sequencer.prototype.stepThread = function (thread) {
console.warn('Could not get implementation for opcode: ' + opcode);
}
else {
if (Sequencer.DEBUG_BLOCK_CALLS) {
console.groupCollapsed('Executing: ' + opcode);
console.log('with arguments: ', argValues);
console.log('and stack frame: ', currentStackFrame);
}
var blockFunctionReturnValue = null;
try {
// @todo deal with the return value
blockFunction(argValues, {
blockFunctionReturnValue = blockFunction(argValues, {
yield: threadYieldCallback,
done: threadDoneCallback,
timeout: YieldTimers.timeout,
@ -238,6 +250,11 @@ Sequencer.prototype.stepThread = function (thread) {
// Thread executed without yielding - move to done
threadDoneCallback();
}
if (Sequencer.DEBUG_BLOCK_CALLS) {
console.log('ending stack frame: ', currentStackFrame);
console.log('returned: ', blockFunctionReturnValue);
console.groupEnd();
}
}
}
}