From c5eb8ece1628cf0d142b27d76238a8551f6f40de Mon Sep 17 00:00:00 2001 From: griffpatch Date: Mon, 20 Feb 2017 09:40:32 +0000 Subject: [PATCH] Handle actual looping cases And it starts to get a little less elegant :/ Wondering if this should not be handled better in another part of the codebase? We don't want to be duplicating existing code stepping functionality locally at the end of the promise script really... What do you think? --- src/engine/execute.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/engine/execute.js b/src/engine/execute.js index 5d2734dde..7ff0203ec 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -241,7 +241,15 @@ var execute = function (sequencer, thread) { return; } var nextBlockId = thread.target.blocks.getNextBlock(popped); - } while (nextBlockId === null); + if (nextBlockId !== null) { + // A next block exists so break out this loop + break; + } + // Investigate the next block and if not in a loop, + // then repeat and pop the next item off the stack frame + var stackFrame = thread.peekStackFrame(); + } while (stackFrame !== null && !stackFrame.isLoop); + thread.pushStack(nextBlockId); } else { thread.popStack();