From 85533a02bf3a28dc5ec2279283e16b0cade49d44 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 24 Jan 2024 02:11:07 +0000 Subject: [PATCH 1/3] Add BlockType.INLINE --- src/extension-support/block-type.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; From 7b10180c9f1c716437b32134b6ee7c6a1cfd4f90 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 24 Jan 2024 02:14:38 +0000 Subject: [PATCH 2/3] Add BlockType.INLINE --- src/engine/runtime.js | 5 +++++ 1 file changed, 5 insertions(+) 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]; From 8b325bc8579d905946de28055e14c00608010148 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 24 Jan 2024 21:25:57 +0000 Subject: [PATCH 3/3] Update irgen.js --- src/compiler/irgen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/irgen.js b/src/compiler/irgen.js index 40f007a75d4..b5c4fd3bfdf 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);