Remove debug calls from execute

This commit is contained in:
Tim Mickel 2016-06-30 17:13:43 -04:00
parent ec4567aa8a
commit 1c24770f8c

View file

@ -1,11 +1,5 @@
var Thread = require('./thread'); var Thread = require('./thread');
/**
* If set, block calls, args, and return values will be logged to the console.
* @const {boolean}
*/
var DEBUG_BLOCK_CALLS = true;
/** /**
* Execute a block. * Execute a block.
* @param {!Sequencer} sequencer Which sequencer is executing. * @param {!Sequencer} sequencer Which sequencer is executing.
@ -66,11 +60,6 @@ var execute = function (sequencer, thread) {
// (e.g., on return from a substack) gets fresh inputs. // (e.g., on return from a substack) gets fresh inputs.
currentStackFrame.reported = {}; currentStackFrame.reported = {};
if (DEBUG_BLOCK_CALLS) {
console.groupCollapsed('Executing: ' + opcode);
console.log('with arguments: ', argValues);
console.log('and stack frame: ', currentStackFrame);
}
var primitiveReportedValue = null; var primitiveReportedValue = null;
primitiveReportedValue = blockFunction(argValues, { primitiveReportedValue = blockFunction(argValues, {
yield: thread.yield.bind(thread), yield: thread.yield.bind(thread),
@ -98,29 +87,17 @@ var execute = function (sequencer, thread) {
// Promise handlers // Promise handlers
primitiveReportedValue.then(function(resolvedValue) { primitiveReportedValue.then(function(resolvedValue) {
// Promise resolved: the primitive reported a value. // Promise resolved: the primitive reported a value.
if (DEBUG_BLOCK_CALLS) {
console.log('reporting value: ', resolvedValue);
}
thread.pushReportedValue(resolvedValue); thread.pushReportedValue(resolvedValue);
sequencer.proceedThread(thread); sequencer.proceedThread(thread);
}, function(rejectionReason) { }, function(rejectionReason) {
// Promise rejected: the primitive had some error. // Promise rejected: the primitive had some error.
// Log it and proceed. // Log it and proceed.
if (DEBUG_BLOCK_CALLS) { console.warn('Primitive rejected promise: ', rejectionReason);
console.warn('primitive rejected promise: ', rejectionReason);
}
sequencer.proceedThread(thread); sequencer.proceedThread(thread);
}); });
} else if (thread.status === Thread.STATUS_RUNNING) { } else if (thread.status === Thread.STATUS_RUNNING) {
if (DEBUG_BLOCK_CALLS) {
console.log('reporting value: ', primitiveReportedValue);
}
thread.pushReportedValue(primitiveReportedValue); thread.pushReportedValue(primitiveReportedValue);
} }
if (DEBUG_BLOCK_CALLS) {
console.log('ending stack frame: ', currentStackFrame);
console.groupEnd();
}
}; };
module.exports = execute; module.exports = execute;