Commit 91842be8 authored by carlosperate's avatar carlosperate

Adding static type to the logic blocks.

parent eb20dc15
......@@ -327,6 +327,13 @@ Blockly.Blocks['logic_compare'] = {
}
this.prevBlocks_[0] = blockA;
this.prevBlocks_[1] = blockB;
},
/**
* Assigns a type to the block, comparison operations result in booleans.
* @this Blockly.Block
*/
getType: function() {
return 'boolean';
}
};
......@@ -358,6 +365,13 @@ Blockly.Blocks['logic_operation'] = {
};
return TOOLTIPS[op];
});
},
/**
* Assigns a type to the block, logic comparison operations result in bools.
* @this Blockly.Block
*/
getType: function() {
return 'boolean';
}
};
......@@ -374,6 +388,14 @@ Blockly.Blocks['logic_negate'] = {
['BOOL', 'Boolean', Blockly.ALIGN_RIGHT],
Blockly.ALIGN_RIGHT);
this.setTooltip(Blockly.Msg.LOGIC_NEGATE_TOOLTIP);
},
/**
* Assigns a type to the block, not input is meant to be a booleans, so it
* should return the same.
* @this Blockly.Block
*/
getType: function() {
return 'boolean';
}
};
......@@ -392,6 +414,13 @@ Blockly.Blocks['logic_boolean'] = {
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(BOOLEANS), 'BOOL');
this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP);
},
/**
* Assigns a type to the boolean block.
* @this Blockly.Block
*/
getType: function() {
return 'boolean';
}
};
......@@ -408,6 +437,7 @@ Blockly.Blocks['logic_null'] = {
.appendField(Blockly.Msg.LOGIC_NULL);
this.setTooltip(Blockly.Msg.LOGIC_NULL_TOOLTIP);
}
// Null does not have a type, so no getType.
};
Blockly.Blocks['logic_ternary'] = {
......@@ -428,4 +458,5 @@ Blockly.Blocks['logic_ternary'] = {
this.setOutput(true);
this.setTooltip(Blockly.Msg.LOGIC_TERNARY_TOOLTIP);
}
//TODO: getType that uses the type of the given inputs
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment