From ea55b3ed5558dcf57e0de99006ed7726eb6f8124 Mon Sep 17 00:00:00 2001 From: "Michael \"Z\" Goddard" Date: Thu, 13 Sep 2018 12:42:54 -0400 Subject: [PATCH] add inputOp to every input arg in the sb2 specmap Add missing meta information in the inputOp value for some arguments. `boolean` and `substack`, the new inputOp values, are not considered to be shadowed values. --- src/serialization/sb2.js | 16 ++++++++-------- src/serialization/sb2_specmap.js | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/serialization/sb2.js b/src/serialization/sb2.js index 63944d21e..b1498c771 100644 --- a/src/serialization/sb2.js +++ b/src/serialization/sb2.js @@ -70,6 +70,8 @@ const parseProcedureArgMap = function (procCode) { arg.inputOp = 'math_number'; } else if (argType === 's') { arg.inputOp = 'text'; + } else if (argType === 'b') { + arg.inputOp = 'boolean'; } argMap.push(arg); } @@ -865,6 +867,11 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension } // Generate a shadow block to occupy the input. if (!expectedArg.inputOp) { + // Undefined inputOp. inputOp should always be defined for inputs. + log.warn(`Unknown input operation for input ${expectedArg.inputName} of opcode ${activeBlock.opcode}.`); + continue; + } + if (expectedArg.inputOp === 'boolean' || expectedArg.inputOp === 'substack') { // No editable shadow input; e.g., for a boolean. continue; } @@ -1082,14 +1089,7 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension let returnCode = sb2block[2]; // Ensure the returnCode is "b" if used in a boolean input. - if (parentExpectedArg && ( - // Used as a CONDITION input like for control_if. - parentExpectedArg.inputName === 'CONDITION' || - // Used as a procedure call boolean input. - ( - parentExpectedArg.inputName.startsWith('input') && !parentExpectedArg.inputOp - ) - ) && returnCode !== 'b') { + if (parentExpectedArg && parentExpectedArg.inputOp === 'boolean' && returnCode !== 'b') { returnCode = 'b'; } diff --git a/src/serialization/sb2_specmap.js b/src/serialization/sb2_specmap.js index c05cde2bd..bb4ed0132 100644 --- a/src/serialization/sb2_specmap.js +++ b/src/serialization/sb2_specmap.js @@ -803,6 +803,7 @@ const specMap = { }, { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' } ] @@ -812,6 +813,7 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' } ] @@ -821,10 +823,12 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'CONDITION' }, { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' } ] @@ -834,14 +838,17 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'CONDITION' }, { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' }, { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK2' } ] @@ -851,6 +858,7 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'CONDITION' } ] @@ -860,10 +868,12 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'CONDITION' }, { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' } ] @@ -873,10 +883,12 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'CONDITION' }, { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' } ] @@ -895,6 +907,7 @@ const specMap = { }, { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' } ] @@ -948,6 +961,7 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'substack', inputName: 'SUBSTACK' } ] @@ -1255,10 +1269,12 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'OPERAND1' }, { type: 'input', + inputOp: 'boolean', inputName: 'OPERAND2' } ] @@ -1268,10 +1284,12 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'OPERAND1' }, { type: 'input', + inputOp: 'boolean', inputName: 'OPERAND2' } ] @@ -1281,6 +1299,7 @@ const specMap = { argMap: [ { type: 'input', + inputOp: 'boolean', inputName: 'OPERAND' } ]