mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-13 15:00:06 -04:00
Move stepping logic for reporters to sequencer
This commit is contained in:
parent
f802faa461
commit
c63747e61b
2 changed files with 33 additions and 17 deletions
src/engine
|
@ -48,24 +48,13 @@ var execute = function (sequencer, thread) {
|
|||
// Is there no value for this input waiting in the stack frame?
|
||||
if (typeof currentStackFrame.reported[inputName] === 'undefined') {
|
||||
// If there's not, we need to evaluate the block.
|
||||
// Push to the stack to evaluate this input.
|
||||
thread.pushStack(inputBlockId);
|
||||
if (DEBUG_BLOCK_CALLS) {
|
||||
console.time('Reporter evaluation');
|
||||
}
|
||||
runtime.glowBlock(inputBlockId, true);
|
||||
// Save name of input for `Thread.pushReportedValue`.
|
||||
currentStackFrame.waitingReporter = inputName;
|
||||
execute(sequencer, thread);
|
||||
if (thread.status === Thread.STATUS_YIELD) {
|
||||
// Reporter yielded; don't pop stack and wait for it to unyield.
|
||||
// The value will be populated once the reporter unyields,
|
||||
// and passed up to the currentStackFrame on next execution.
|
||||
var reporterYielded = (
|
||||
sequencer.stepToReporter(thread, inputBlockId, inputName)
|
||||
);
|
||||
// If the reporter yielded, return immediately;
|
||||
// it needs time to finish and report its value.
|
||||
if (reporterYielded) {
|
||||
return;
|
||||
} else {
|
||||
// Reporter finished right away; pop the stack.
|
||||
runtime.glowBlock(inputBlockId, false);
|
||||
thread.popStack();
|
||||
}
|
||||
}
|
||||
argValues[inputName] = currentStackFrame.reported[inputName];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue