Use conventional prefix/suffix for function calls.

Previously a function call with no return value generated:

  prefix();
  suffix();
  function();

The intent was so the prefix and suffix calls in the function body wouldn’t overlap with the prefix and suffix calls of the function call.  However, this is doomed to be inconsistent with a function call with a return value:

  prefix();
  print(function());
  suffix();

Thus since overlaping must exist, both types of function calls should have consistent suffix locations.
This commit is contained in:
Neil Fraser
2019-05-15 13:43:57 -07:00
committed by Neil Fraser
parent 475d8eb71f
commit e642a77f5d
6 changed files with 5 additions and 63 deletions

View File

@@ -114,20 +114,10 @@ Blockly.PHP['procedures_callreturn'] = function(block) {
Blockly.PHP['procedures_callnoreturn'] = function(block) {
// Call a procedure with no return value.
var code = '';
if (Blockly.PHP.STATEMENT_PREFIX) {
// Automatic prefix insertion is switched off for this block. Add manually.
code += Blockly.PHP.injectId(Blockly.PHP.STATEMENT_PREFIX, block);
}
if (Blockly.PHP.STATEMENT_SUFFIX) {
// Suffix needs to be added before the function call.
code += Blockly.PHP.injectId(Blockly.PHP.STATEMENT_SUFFIX, block);
}
// Generated code is for a function call as a statement is the same as a
// function call as a value, with the addition of line ending.
var tuple = Blockly.PHP['procedures_callreturn'](block);
code += tuple[0] + ';\n';
return code;
return tuple[0] + ';\n';
};
Blockly.PHP['procedures_ifreturn'] = function(block) {