mirror of
https://github.com/google/blockly.git
synced 2026-01-11 02:47:09 +01:00
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:
@@ -642,12 +642,6 @@ Blockly.Blocks['procedures_callnoreturn'] = {
|
||||
this.previousEnabledState_ = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Don't automatically add STATEMENT_PREFIX and STATEMENT_SUFFIX to generated
|
||||
* code. These will be handled manually in this block's generators.
|
||||
*/
|
||||
suppressPrefixSuffix: true,
|
||||
|
||||
/**
|
||||
* Returns the name of the procedure this block calls.
|
||||
* @return {string} Procedure name.
|
||||
|
||||
@@ -93,20 +93,10 @@ Blockly.Dart['procedures_callreturn'] = function(block) {
|
||||
|
||||
Blockly.Dart['procedures_callnoreturn'] = function(block) {
|
||||
// Call a procedure with no return value.
|
||||
var code = '';
|
||||
if (Blockly.Dart.STATEMENT_PREFIX) {
|
||||
// Automatic prefix insertion is switched off for this block. Add manually.
|
||||
code += Blockly.Dart.injectId(Blockly.Dart.STATEMENT_PREFIX, block);
|
||||
}
|
||||
if (Blockly.Dart.STATEMENT_SUFFIX) {
|
||||
// Suffix needs to be added before the function call.
|
||||
code += Blockly.Dart.injectId(Blockly.Dart.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.Dart['procedures_callreturn'](block);
|
||||
code += tuple[0] + ';\n';
|
||||
return code;
|
||||
return tuple[0] + ';\n';
|
||||
};
|
||||
|
||||
Blockly.Dart['procedures_ifreturn'] = function(block) {
|
||||
|
||||
@@ -95,22 +95,10 @@ Blockly.JavaScript['procedures_callreturn'] = function(block) {
|
||||
|
||||
Blockly.JavaScript['procedures_callnoreturn'] = function(block) {
|
||||
// Call a procedure with no return value.
|
||||
var code = '';
|
||||
if (Blockly.JavaScript.STATEMENT_PREFIX) {
|
||||
// Automatic prefix insertion is switched off for this block. Add manually.
|
||||
code += Blockly.JavaScript.injectId(Blockly.JavaScript.STATEMENT_PREFIX,
|
||||
block);
|
||||
}
|
||||
if (Blockly.JavaScript.STATEMENT_SUFFIX) {
|
||||
// Suffix needs to be added before the function call.
|
||||
code += Blockly.JavaScript.injectId(Blockly.JavaScript.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.JavaScript['procedures_callreturn'](block);
|
||||
code += tuple[0] + ';\n';
|
||||
return code;
|
||||
return tuple[0] + ';\n';
|
||||
};
|
||||
|
||||
Blockly.JavaScript['procedures_ifreturn'] = function(block) {
|
||||
|
||||
@@ -95,20 +95,10 @@ Blockly.Lua['procedures_callreturn'] = function(block) {
|
||||
|
||||
Blockly.Lua['procedures_callnoreturn'] = function(block) {
|
||||
// Call a procedure with no return value.
|
||||
var code = '';
|
||||
if (Blockly.Lua.STATEMENT_PREFIX) {
|
||||
// Automatic prefix insertion is switched off for this block. Add manually.
|
||||
code += Blockly.Lua.injectId(Blockly.Lua.STATEMENT_PREFIX, block);
|
||||
}
|
||||
if (Blockly.Lua.STATEMENT_SUFFIX) {
|
||||
// Suffix needs to be added before the function call.
|
||||
code += Blockly.Lua.injectId(Blockly.Lua.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.Lua['procedures_callreturn'](block);
|
||||
code += tuple[0] + '\n';
|
||||
return code;
|
||||
return tuple[0] + '\n';
|
||||
};
|
||||
|
||||
Blockly.Lua['procedures_ifreturn'] = function(block) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -117,20 +117,10 @@ Blockly.Python['procedures_callreturn'] = function(block) {
|
||||
|
||||
Blockly.Python['procedures_callnoreturn'] = function(block) {
|
||||
// Call a procedure with no return value.
|
||||
var code = '';
|
||||
if (Blockly.Python.STATEMENT_PREFIX) {
|
||||
// Automatic prefix insertion is switched off for this block. Add manually.
|
||||
code += Blockly.Python.injectId(Blockly.Python.STATEMENT_PREFIX, block);
|
||||
}
|
||||
if (Blockly.Python.STATEMENT_SUFFIX) {
|
||||
// Suffix needs to be added before the function call.
|
||||
code += Blockly.Python.injectId(Blockly.Python.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.Python['procedures_callreturn'](block);
|
||||
code += tuple[0] + '\n';
|
||||
return code;
|
||||
return tuple[0] + '\n';
|
||||
};
|
||||
|
||||
Blockly.Python['procedures_ifreturn'] = function(block) {
|
||||
|
||||
Reference in New Issue
Block a user