Commit 159220dd authored by carlospamg's avatar carlospamg

Fix issue where procedure "if_return" did not generate arduino code.

parent a601e56f
...@@ -30,9 +30,14 @@ goog.require('Blockly.Arduino'); ...@@ -30,9 +30,14 @@ goog.require('Blockly.Arduino');
Blockly.Arduino['procedures_defreturn'] = function(block) { Blockly.Arduino['procedures_defreturn'] = function(block) {
// Define a procedure with a return value. // Define a procedure with a return value.
var funcName = Blockly.Arduino.variableDB_.getName(block.getTitleValue('NAME'), var funcName = Blockly.Arduino.variableDB_.getName(
Blockly.Procedures.NAME_TYPE); block.getFieldValue('NAME'), Blockly.Procedures.NAME_TYPE);
var branch = Blockly.Arduino.statementToCode(block, 'STACK'); var branch = Blockly.Arduino.statementToCode(block, 'STACK');
if (Blockly.Arduino.STATEMENT_PREFIX) {
branch = Blockly.Arduino.prefixLines(
Blockly.Arduino.STATEMENT_PREFIX.replace(/%1/g,
'\'' + block.id + '\''), Blockly.Arduino.INDENT) + branch;
}
if (Blockly.Arduino.INFINITE_LOOP_TRAP) { if (Blockly.Arduino.INFINITE_LOOP_TRAP) {
branch = Blockly.Arduino.INFINITE_LOOP_TRAP.replace(/%1/g, branch = Blockly.Arduino.INFINITE_LOOP_TRAP.replace(/%1/g,
'\'' + block.id + '\'') + branch; '\'' + block.id + '\'') + branch;
...@@ -61,8 +66,8 @@ Blockly.Arduino['procedures_defnoreturn'] = Blockly.Arduino['procedures_defretur ...@@ -61,8 +66,8 @@ Blockly.Arduino['procedures_defnoreturn'] = Blockly.Arduino['procedures_defretur
Blockly.Arduino['procedures_callreturn'] = function(block) { Blockly.Arduino['procedures_callreturn'] = function(block) {
// Call a procedure with a return value. // Call a procedure with a return value.
var funcName = Blockly.Arduino.variableDB_.getName(block.getTitleValue('NAME'), var funcName = Blockly.Arduino.variableDB_.getName(
Blockly.Procedures.NAME_TYPE); block.getFieldValue('NAME'), Blockly.Procedures.NAME_TYPE);
var args = []; var args = [];
for (var x = 0; x < block.arguments_.length; x++) { for (var x = 0; x < block.arguments_.length; x++) {
args[x] = Blockly.Arduino.valueToCode(block, 'ARG' + x, args[x] = Blockly.Arduino.valueToCode(block, 'ARG' + x,
...@@ -74,8 +79,8 @@ Blockly.Arduino['procedures_callreturn'] = function(block) { ...@@ -74,8 +79,8 @@ Blockly.Arduino['procedures_callreturn'] = function(block) {
Blockly.Arduino['procedures_callnoreturn'] = function(block) { Blockly.Arduino['procedures_callnoreturn'] = function(block) {
// Call a procedure with no return value. // Call a procedure with no return value.
var funcName = Blockly.Arduino.variableDB_.getName(block.getTitleValue('NAME'), var funcName = Blockly.Arduino.variableDB_.getName(
Blockly.Procedures.NAME_TYPE); block.getFieldValue('NAME'), Blockly.Procedures.NAME_TYPE);
var args = []; var args = [];
for (var x = 0; x < block.arguments_.length; x++) { for (var x = 0; x < block.arguments_.length; x++) {
args[x] = Blockly.Arduino.valueToCode(block, 'ARG' + x, args[x] = Blockly.Arduino.valueToCode(block, 'ARG' + x,
...@@ -85,7 +90,7 @@ Blockly.Arduino['procedures_callnoreturn'] = function(block) { ...@@ -85,7 +90,7 @@ Blockly.Arduino['procedures_callnoreturn'] = function(block) {
return code; return code;
}; };
Blockly.Arduino.procedures_ifreturn = function() { Blockly.Arduino['procedures_ifreturn'] = function(block) {
// Conditionally return value from a procedure. // Conditionally return value from a procedure.
var condition = Blockly.Arduino.valueToCode(block, 'CONDITION', var condition = Blockly.Arduino.valueToCode(block, 'CONDITION',
Blockly.Arduino.ORDER_NONE) || 'false'; Blockly.Arduino.ORDER_NONE) || 'false';
......
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