remove empty procedure_definetion block

The engine supports blocks that do not have defined functions.
This commit is contained in:
Michael "Z" Goddard 2019-04-25 10:17:29 -04:00
parent 11b52c4e60
commit ffcd0e6518
No known key found for this signature in database
GPG key ID: 762CD40DD5349872
3 changed files with 6 additions and 7 deletions

View file

@ -13,17 +13,16 @@ class Scratch3ProcedureBlocks {
*/
getPrimitives () {
return {
procedures_definition: this.definition,
// procedures_definition is the top block of a procedure but has no
// effect of its own.
procedures_definition: null,
procedures_call: this.call,
argument_reporter_string_number: this.argumentReporterStringNumber,
argument_reporter_boolean: this.argumentReporterBoolean
};
}
definition () {
// No-op: execute the blocks.
}
call (args, util) {
if (!util.stackFrame.executed) {
const procedureCode = args.mutation.proccode;

View file

@ -279,7 +279,7 @@ class BlockCached {
// Assign opcode isHat and blockFunction data to avoid dynamic lookups.
this._isHat = runtime.getIsHat(opcode);
this._blockFunction = runtime.getOpcodeFunction(opcode);
this._definedBlockFunction = typeof this._blockFunction !== 'undefined';
this._definedBlockFunction = typeof this._blockFunction === 'function';
// Store the current shadow value if there is a shadow value.
const fieldKeys = Object.keys(fields);

View file

@ -713,7 +713,7 @@ class Runtime extends EventEmitter {
if (packageObject.getPrimitives) {
const packagePrimitives = packageObject.getPrimitives();
for (const op in packagePrimitives) {
if (packagePrimitives.hasOwnProperty(op)) {
if (typeof packagePrimitives[op] === 'function') {
this._primitives[op] =
packagePrimitives[op].bind(packageObject);
}