mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-26 22:20:41 -04:00
Add framework for block execution
The runtime now stores a mapping of opcode to function. The `wedo2` and `scratch3` packages are currently stubs.
This commit is contained in:
parent
f90fccb0d1
commit
27c06ce476
4 changed files with 98 additions and 4 deletions
src/engine
|
@ -58,10 +58,22 @@ Sequencer.prototype.stepThreads = function (threads) {
|
|||
* @param {!Thread} thread Thread object to step
|
||||
*/
|
||||
Sequencer.prototype.stepThread = function (thread) {
|
||||
// @todo Actually run the blocks
|
||||
// Currently goes to the next block in the sequence.
|
||||
var nextBlock = this.runtime._getNextBlock(thread.nextBlock);
|
||||
thread.nextBlock = nextBlock;
|
||||
var opcode = this.runtime._getOpcode(thread.nextBlock);
|
||||
|
||||
if (!opcode) {
|
||||
console.log('Could not get opcode for block: ' + thread.nextBlock);
|
||||
}
|
||||
else {
|
||||
var blockFunction = this.runtime.getOpcodeFunction(opcode);
|
||||
if (!blockFunction) {
|
||||
console.log('Could not get implementation for opcode: ' + opcode);
|
||||
}
|
||||
else {
|
||||
blockFunction();
|
||||
}
|
||||
}
|
||||
|
||||
thread.nextBlock = this.runtime._getNextBlock(thread.nextBlock);
|
||||
};
|
||||
|
||||
module.exports = Sequencer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue