scratch-vm/src/blocks/scratch3_procedures.js
Tim Mickel 0a66c62f6a Mutations in block representation; an unfeatured procedure call (#212)
* Add scratch3_procedures and no-op for defnoreturn

* Add mutation adapter to parse mutations in CREATE/CHANGE events

* Add mutation-to-XML

* Update spec map for Blockly procedure names

* Placeholder for procedure special cases

* Basic stepping to procedures

* Remove extra case

* Validation for changeBlock
2016-10-03 17:43:24 -04:00

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