mirror of
https://github.com/google/blockly.git
synced 2026-01-04 07:30:08 +01:00
Remove duplicated generators.
This commit is contained in:
@@ -28,22 +28,17 @@ goog.provide('Blockly.Python.loops');
|
||||
|
||||
goog.require('Blockly.Python');
|
||||
|
||||
Blockly.Python['controls_repeat'] = function(block) {
|
||||
// Repeat n times (internal number).
|
||||
var repeats = parseInt(block.getFieldValue('TIMES'), 10);
|
||||
var branch = Blockly.Python.statementToCode(block, 'DO');
|
||||
branch = Blockly.Python.addLoopTrap(branch, block.id) ||
|
||||
Blockly.Python.PASS;
|
||||
var loopVar = Blockly.Python.variableDB_.getDistinctName(
|
||||
'count', Blockly.Variables.NAME_TYPE);
|
||||
var code = 'for ' + loopVar + ' in range(' + repeats + '):\n' + branch;
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Python['controls_repeat_ext'] = function(block) {
|
||||
// Repeat n times (external number).
|
||||
var repeats = Blockly.Python.valueToCode(block, 'TIMES',
|
||||
Blockly.Python.ORDER_NONE) || '0';
|
||||
// Repeat n times.
|
||||
if (block.getField('TIMES')) {
|
||||
// Internal number.
|
||||
var repeats = parseInt(block.getFieldValue('TIMES'), 10);
|
||||
} else {
|
||||
// External number.
|
||||
var repeats = Blockly.Python.valueToCode(block, 'TIMES',
|
||||
Blockly.Python.ORDER_NONE) || '0';
|
||||
}
|
||||
if (Blockly.isNumber(repeats)) {
|
||||
repeats = parseInt(repeats, 10);
|
||||
} else {
|
||||
@@ -58,6 +53,8 @@ Blockly.Python['controls_repeat_ext'] = function(block) {
|
||||
return code;
|
||||
};
|
||||
|
||||
Blockly.Python['controls_repeat'] = Blockly.Python['controls_repeat_ext'];
|
||||
|
||||
Blockly.Python['controls_whileUntil'] = function(block) {
|
||||
// Do while/until loop.
|
||||
var until = block.getFieldValue('MODE') == 'UNTIL';
|
||||
|
||||
Reference in New Issue
Block a user