From 29887e24c9f96f95df89afe550f0fa9cfbbbb3c0 Mon Sep 17 00:00:00 2001 From: Tim Mickel Date: Wed, 24 Aug 2016 11:04:23 -0400 Subject: [PATCH] Simplify `execute` hat check. In case a reporter has side-effects, we'd probably like to run hat predicates even if there is no next block. --- src/engine/execute.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/engine/execute.js b/src/engine/execute.js index 3ab78752..1d4ec614 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -35,23 +35,13 @@ var execute = function (sequencer, thread) { // Hats are implemented slightly differently from regular blocks. // If they have an associated block function, it's treated as a predicate; // if not, execution will proceed right through it (as a no-op). - if (isHat) { - var nextBlock = target.blocks.getNextBlock(currentBlockId); - if (!nextBlock) { - // Hat with no next block - don't try to evaluate it. - sequencer.retireThread(thread); - return; - } - if (!blockFunction) { - // No predicate for the hat - just continue to next block. - sequencer.proceedThread(thread); - return; - } - } else { - if (!blockFunction) { + if (!blockFunction) { + if (!isHat) { console.warn('Could not get implementation for opcode: ' + opcode); - return; } + // Skip through the block. + // (either hat with no predicate, or missing op). + return; } // Generate values for arguments (inputs).