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.
This commit is contained in:
Michael "Z" Goddard 2018-09-13 12:42:54 -04:00
parent d8309e9d24
commit ea55b3ed55
No known key found for this signature in database
GPG key ID: 762CD40DD5349872
2 changed files with 27 additions and 8 deletions

View file

@ -70,6 +70,8 @@ const parseProcedureArgMap = function (procCode) {
arg.inputOp = 'math_number'; arg.inputOp = 'math_number';
} else if (argType === 's') { } else if (argType === 's') {
arg.inputOp = 'text'; arg.inputOp = 'text';
} else if (argType === 'b') {
arg.inputOp = 'boolean';
} }
argMap.push(arg); argMap.push(arg);
} }
@ -865,6 +867,11 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension
} }
// 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.
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. // No editable shadow input; e.g., for a boolean.
continue; continue;
} }
@ -1082,14 +1089,7 @@ const parseBlock = function (sb2block, addBroadcastMsg, getVariableId, extension
let returnCode = sb2block[2]; let returnCode = sb2block[2];
// Ensure the returnCode is "b" if used in a boolean input. // Ensure the returnCode is "b" if used in a boolean input.
if (parentExpectedArg && ( if (parentExpectedArg && parentExpectedArg.inputOp === 'boolean' && returnCode !== 'b') {
// 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') {
returnCode = 'b'; returnCode = 'b';
} }

View file

@ -803,6 +803,7 @@ const specMap = {
}, },
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
} }
] ]
@ -812,6 +813,7 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
} }
] ]
@ -821,10 +823,12 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'CONDITION' inputName: 'CONDITION'
}, },
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
} }
] ]
@ -834,14 +838,17 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'CONDITION' inputName: 'CONDITION'
}, },
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
}, },
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK2' inputName: 'SUBSTACK2'
} }
] ]
@ -851,6 +858,7 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'CONDITION' inputName: 'CONDITION'
} }
] ]
@ -860,10 +868,12 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'CONDITION' inputName: 'CONDITION'
}, },
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
} }
] ]
@ -873,10 +883,12 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'CONDITION' inputName: 'CONDITION'
}, },
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
} }
] ]
@ -895,6 +907,7 @@ const specMap = {
}, },
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
} }
] ]
@ -948,6 +961,7 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'substack',
inputName: 'SUBSTACK' inputName: 'SUBSTACK'
} }
] ]
@ -1255,10 +1269,12 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'OPERAND1' inputName: 'OPERAND1'
}, },
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'OPERAND2' inputName: 'OPERAND2'
} }
] ]
@ -1268,10 +1284,12 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'OPERAND1' inputName: 'OPERAND1'
}, },
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'OPERAND2' inputName: 'OPERAND2'
} }
] ]
@ -1281,6 +1299,7 @@ const specMap = {
argMap: [ argMap: [
{ {
type: 'input', type: 'input',
inputOp: 'boolean',
inputName: 'OPERAND' inputName: 'OPERAND'
} }
] ]