diff --git a/src/compiler/irgen.js b/src/compiler/irgen.js index c3679fb41a7..880aaa82eaf 100644 --- a/src/compiler/irgen.js +++ b/src/compiler/irgen.js @@ -663,7 +663,7 @@ class ScriptTreeGenerator { const blockInfo = this.getBlockInfo(block.opcode); if (blockInfo) { const type = blockInfo.info.blockType; - if (type === BlockType.REPORTER || type === BlockType.BOOLEAN) { + if (type === BlockType.REPORTER || type === BlockType.BOOLEAN || type === BlockType.INLINE) { return this.descendCompatLayer(block); } } @@ -1415,7 +1415,7 @@ class ScriptTreeGenerator { const blockInfo = this.getBlockInfo(block.opcode); const blockType = (blockInfo && blockInfo.info && blockInfo.info.blockType) || BlockType.COMMAND; const substacks = {}; - if (blockType === BlockType.CONDITIONAL || blockType === BlockType.LOOP) { + if (blockType === BlockType.CONDITIONAL || blockType === BlockType.LOOP || blockType === BlockType.INLINE) { for (const inputName in block.inputs) { if (!inputName.startsWith('SUBSTACK')) continue; const branchNum = inputName === 'SUBSTACK' ? 1 : +inputName.substring('SUBSTACK'.length); diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 6fc794268f7..448bf8e1ea1 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -1414,6 +1414,11 @@ class Runtime extends EventEmitter { blockJSON.nextStatement = null; // null = available connection; undefined = terminal } break; + case BlockType.INLINE: + blockInfo.branchCount = blockInfo.branchCount || 1; + blockJSON.output = blockInfo.allowDropAnywhere ? null : 'String'; // TODO: distinguish number & string here? + blockJSON.outputShape = ScratchBlocksConstants.OUTPUT_SHAPE_SQUARE; + break; } const blockText = Array.isArray(blockInfo.text) ? blockInfo.text : [blockInfo.text]; diff --git a/src/extension-support/block-type.js b/src/extension-support/block-type.js index ecaf70754dc..4680ef4af10 100644 --- a/src/extension-support/block-type.js +++ b/src/extension-support/block-type.js @@ -54,7 +54,13 @@ const BlockType = { /** * Arbitrary scratch-blocks XML. */ - XML: 'xml' + XML: 'xml', + + /** + * Specialized reporter block that allows for the insertion and evaluation + * of a substack. + */ + INLINE: 'inline' }; module.exports = BlockType;