mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-13 14:33:59 -04:00
Handle unknown opcode in input
This commit is contained in:
parent
5cf10b1af1
commit
26c928d10b
1 changed files with 24 additions and 20 deletions
|
@ -843,6 +843,7 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension
|
||||||
for (let i = 0; i < blockMetadata.argMap.length; i++) {
|
for (let i = 0; i < blockMetadata.argMap.length; i++) {
|
||||||
const expectedArg = blockMetadata.argMap[i];
|
const expectedArg = blockMetadata.argMap[i];
|
||||||
const providedArg = sb2block[i + 1]; // (i = 0 is opcode)
|
const providedArg = sb2block[i + 1]; // (i = 0 is opcode)
|
||||||
|
|
||||||
// Whether the input is obscuring a shadow.
|
// Whether the input is obscuring a shadow.
|
||||||
let shadowObscured = false;
|
let shadowObscured = false;
|
||||||
// Positional argument is an input.
|
// Positional argument is an input.
|
||||||
|
@ -866,15 +867,19 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension
|
||||||
// Single block occupies the input.
|
// Single block occupies the input.
|
||||||
const parsedBlockDesc = parseBlock(providedArg, addBroadcastMsg, getVariableId, extensions,
|
const parsedBlockDesc = parseBlock(providedArg, addBroadcastMsg, getVariableId, extensions,
|
||||||
parseState, comments, commentIndex);
|
parseState, comments, commentIndex);
|
||||||
innerBlocks = [parsedBlockDesc[0]];
|
innerBlocks = parsedBlockDesc[0] ? [parsedBlockDesc[0]] : [];
|
||||||
// Update commentIndex
|
// Update commentIndex
|
||||||
commentIndex = parsedBlockDesc[1];
|
commentIndex = parsedBlockDesc[1];
|
||||||
}
|
}
|
||||||
parseState.expectedArg = parentExpectedArg;
|
parseState.expectedArg = parentExpectedArg;
|
||||||
// Check if innerBlocks is an empty list.
|
|
||||||
// This indicates that all the inner blocks from the sb2 have
|
// Obscures any shadow.
|
||||||
|
shadowObscured = true;
|
||||||
|
|
||||||
|
// Check if innerBlocks is not an empty list.
|
||||||
|
// An empty list indicates that all the inner blocks from the sb2 have
|
||||||
// unknown opcodes and have been skipped.
|
// unknown opcodes and have been skipped.
|
||||||
if (innerBlocks.length === 0) continue;
|
if (innerBlocks.length > 0) {
|
||||||
let previousBlock = null;
|
let previousBlock = null;
|
||||||
for (let j = 0; j < innerBlocks.length; j++) {
|
for (let j = 0; j < innerBlocks.length; j++) {
|
||||||
if (j === 0) {
|
if (j === 0) {
|
||||||
|
@ -884,8 +889,6 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension
|
||||||
}
|
}
|
||||||
previousBlock = innerBlocks[j].id;
|
previousBlock = innerBlocks[j].id;
|
||||||
}
|
}
|
||||||
// Obscures any shadow.
|
|
||||||
shadowObscured = true;
|
|
||||||
activeBlock.inputs[expectedArg.inputName].block = (
|
activeBlock.inputs[expectedArg.inputName].block = (
|
||||||
innerBlocks[0].id
|
innerBlocks[0].id
|
||||||
);
|
);
|
||||||
|
@ -893,6 +896,7 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension
|
||||||
activeBlock.children.concat(innerBlocks)
|
activeBlock.children.concat(innerBlocks)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Generate a shadow block to occupy the input.
|
// Generate a shadow block to occupy the input.
|
||||||
if (!expectedArg.inputOp) {
|
if (!expectedArg.inputOp) {
|
||||||
// Undefined inputOp. inputOp should always be defined for inputs.
|
// Undefined inputOp. inputOp should always be defined for inputs.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue