mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Add STATEMENT_SUFFIX
Also remove need to manually indent INFINITE_LOOP_TRAP. This is a breaking change for Python users of this property. However, very few users of this property exist, given that the existing code breaks if the block ID has a $ in it (also fixed in this PR).
This commit is contained in:
@@ -34,15 +34,21 @@ Blockly.Lua['procedures_defreturn'] = function(block) {
|
||||
var funcName = Blockly.Lua.variableDB_.getName(
|
||||
block.getFieldValue('NAME'), Blockly.Procedures.NAME_TYPE);
|
||||
var branch = Blockly.Lua.statementToCode(block, 'STACK');
|
||||
if (Blockly.Lua.STATEMENT_PREFIX) {
|
||||
var id = block.id.replace(/\$/g, '$$$$'); // Issue 251.
|
||||
var id = block.id.replace(/\$/g, '$$$$'); // Issue 251.
|
||||
if (Blockly.Lua.STATEMENT_SUFFIX) {
|
||||
branch = Blockly.Lua.prefixLines(
|
||||
Blockly.Lua.STATEMENT_PREFIX.replace(/%1/g,
|
||||
'\'' + id + '\''), Blockly.Lua.INDENT) + branch;
|
||||
Blockly.Lua.STATEMENT_SUFFIX.replace(/%1/g, '\'' + id + '\''),
|
||||
Blockly.Lua.INDENT) + branch;
|
||||
}
|
||||
if (Blockly.Lua.INFINITE_LOOP_TRAP) {
|
||||
branch = Blockly.Lua.INFINITE_LOOP_TRAP.replace(/%1/g,
|
||||
'\'' + block.id + '\'') + branch;
|
||||
branch = Blockly.Lua.prefixLines(
|
||||
Blockly.Lua.INFINITE_LOOP_TRAP.replace(/%1/g, '\'' + id + '\''),
|
||||
Blockly.Lua.INDENT) + branch;
|
||||
}
|
||||
if (Blockly.Lua.STATEMENT_PREFIX) {
|
||||
branch = Blockly.Lua.prefixLines(
|
||||
Blockly.Lua.STATEMENT_PREFIX.replace(/%1/g, '\'' + id + '\''),
|
||||
Blockly.Lua.INDENT) + branch;
|
||||
}
|
||||
var returnValue = Blockly.Lua.valueToCode(block, 'RETURN',
|
||||
Blockly.Lua.ORDER_NONE) || '';
|
||||
|
||||
Reference in New Issue
Block a user