mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 15:32:40 -05:00
33 lines
894 B
JavaScript
33 lines
894 B
JavaScript
|
function Scratch3ProcedureBlocks(runtime) {
|
||
|
/**
|
||
|
* The runtime instantiating this block package.
|
||
|
* @type {Runtime}
|
||
|
*/
|
||
|
this.runtime = runtime;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Retrieve the block primitives implemented by this package.
|
||
|
* @return {Object.<string, Function>} Mapping of opcode to Function.
|
||
|
*/
|
||
|
Scratch3ProcedureBlocks.prototype.getPrimitives = function() {
|
||
|
return {
|
||
|
'procedures_defnoreturn': this.defNoReturn,
|
||
|
'procedures_callnoreturn': this.callNoReturn
|
||
|
};
|
||
|
};
|
||
|
|
||
|
Scratch3ProcedureBlocks.prototype.defNoReturn = function () {
|
||
|
// No-op: execute the blocks.
|
||
|
};
|
||
|
|
||
|
Scratch3ProcedureBlocks.prototype.callNoReturn = function (args, util) {
|
||
|
if (!util.stackFrame.executed) {
|
||
|
var procedureName = args.mutation.name;
|
||
|
util.stackFrame.executed = true;
|
||
|
util.startProcedure(procedureName);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = Scratch3ProcedureBlocks;
|