mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-27 22:50:22 -04:00
Improve block primitive lookup and execution
Slightly simplify export of block primitives from a block package. Catch and report exceptions from block functions.
This commit is contained in:
parent
27c06ce476
commit
4a3276d026
4 changed files with 94 additions and 13 deletions
src/engine
|
@ -60,18 +60,23 @@ Sequencer.prototype.stepThreads = function (threads) {
|
|||
Sequencer.prototype.stepThread = function (thread) {
|
||||
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);
|
||||
if (!opcode) {
|
||||
console.warn('Could not get opcode for block: ' + thread.nextBlock);
|
||||
}
|
||||
else {
|
||||
blockFunction();
|
||||
var blockFunction = this.runtime.getOpcodeFunction(opcode);
|
||||
if (!blockFunction) {
|
||||
console.warn('Could not get implementation for opcode: ' + opcode);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
blockFunction();
|
||||
}
|
||||
catch(e) {
|
||||
console.error('Exception calling block function', {opcode: opcode, exception: e});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thread.nextBlock = this.runtime._getNextBlock(thread.nextBlock);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue