mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-20 10:21:12 -04:00
Fix for empty substacks
This commit is contained in:
parent
47545e7109
commit
852b11519a
3 changed files with 26 additions and 7 deletions
|
@ -64,7 +64,7 @@ Sequencer.prototype.stepThreads = function (threads) {
|
|||
&& activeThread.nextBlock === null) {
|
||||
activeThread.nextBlock = activeThread.stack.pop();
|
||||
// Don't pop stack frame - we need the data.
|
||||
// A new one won't be created when we execute.
|
||||
// A new one won't be created when we execute.
|
||||
}
|
||||
if (activeThread.nextBlock === null) {
|
||||
// No more on the stack
|
||||
|
@ -96,6 +96,10 @@ Sequencer.prototype.stepThread = function (thread) {
|
|||
// If the primitive would like to do control flow,
|
||||
// it can overwrite nextBlock.
|
||||
var currentBlock = thread.nextBlock;
|
||||
if (!currentBlock) {
|
||||
thread.status = Thread.STATUS_DONE;
|
||||
return;
|
||||
}
|
||||
thread.nextBlock = this.runtime._getNextBlock(currentBlock);
|
||||
|
||||
var opcode = this.runtime._getOpcode(currentBlock);
|
||||
|
@ -144,7 +148,12 @@ Sequencer.prototype.stepThread = function (thread) {
|
|||
*/
|
||||
var threadStartSubstack = function () {
|
||||
// Set nextBlock to the start of the substack
|
||||
thread.nextBlock = instance.runtime._getSubstack(currentBlock).value;
|
||||
var substack = instance.runtime._getSubstack(currentBlock);
|
||||
if (substack && substack.value) {
|
||||
thread.nextBlock = substack.value;
|
||||
} else {
|
||||
thread.nextBlock = null;
|
||||
}
|
||||
instance.runtime.glowBlock(currentBlock, false);
|
||||
switchedStack = true;
|
||||
};
|
||||
|
|
14
vm.js
14
vm.js
|
@ -1628,7 +1628,7 @@
|
|||
&& activeThread.nextBlock === null) {
|
||||
activeThread.nextBlock = activeThread.stack.pop();
|
||||
// Don't pop stack frame - we need the data.
|
||||
// A new one won't be created when we execute.
|
||||
// A new one won't be created when we execute.
|
||||
}
|
||||
if (activeThread.nextBlock === null) {
|
||||
// No more on the stack
|
||||
|
@ -1660,6 +1660,10 @@
|
|||
// If the primitive would like to do control flow,
|
||||
// it can overwrite nextBlock.
|
||||
var currentBlock = thread.nextBlock;
|
||||
if (!currentBlock) {
|
||||
thread.status = Thread.STATUS_DONE;
|
||||
return;
|
||||
}
|
||||
thread.nextBlock = this.runtime._getNextBlock(currentBlock);
|
||||
|
||||
var opcode = this.runtime._getOpcode(currentBlock);
|
||||
|
@ -1708,7 +1712,12 @@
|
|||
*/
|
||||
var threadStartSubstack = function () {
|
||||
// Set nextBlock to the start of the substack
|
||||
thread.nextBlock = instance.runtime._getSubstack(currentBlock).value;
|
||||
var substack = instance.runtime._getSubstack(currentBlock);
|
||||
if (substack && substack.value) {
|
||||
thread.nextBlock = substack.value;
|
||||
} else {
|
||||
thread.nextBlock = null;
|
||||
}
|
||||
instance.runtime.glowBlock(currentBlock, false);
|
||||
switchedStack = true;
|
||||
};
|
||||
|
@ -1980,6 +1989,7 @@
|
|||
};
|
||||
|
||||
Scratch3Blocks.prototype.repeat = function(argValues, util) {
|
||||
console.log('Running: control_repeat');
|
||||
// Initialize loop
|
||||
if (util.stackFrame.loopCounter === undefined) {
|
||||
util.stackFrame.loopCounter = 4; // @todo arg
|
||||
|
|
6
vm.min.js
vendored
6
vm.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue