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:
Christopher Willis-Ford 2016-05-02 09:20:27 -07:00
parent f90fccb0d1
commit 27c06ce476
4 changed files with 98 additions and 4 deletions
src/engine

View file

@ -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;