components/blockly-src/generators/python/loops.js
function(arg, suffix) {
      if (Blockly.isNumber(arg)) {
        // Simple number.
        arg = parseFloat(arg);
      } else if (arg.match(/^\w+$/)) {
        // Variable.
        arg = 'float(' + arg + ')';
      } else {
        // It's complicated.
        var varName = Blockly.Python.variableDB_.getDistinctName(
            variable0 + suffix, Blockly.Variables.NAME_TYPE);
        code += varName + ' = float(' + arg + ')\n';
        arg = varName;
      }
      return arg;
    }
function(arg, suffix) {
      if (Blockly.isNumber(arg)) {
        // Simple number.
        arg = parseFloat(arg);
      } else if (arg.match(/^\w+$/)) {
        // Variable.
        arg = 'float(' + arg + ')';
      } else {
        // It's complicated.
        var varName = Blockly.Python.variableDB_.getDistinctName(
            variable0 + suffix, Blockly.Variables.NAME_TYPE);
        code += varName + ' = float(' + arg + ')\n';
        arg = varName;
      }
      return arg;
    }
function ( arg , suffix ) { if ( Blockly . isNumber ( arg ) ) { // Simple number. arg = parseFloat ( arg ) ; } else if ( arg . match ( / ^\w+$ / ) ) { // Variable. arg = 'float(' + arg + ')' ; } else { // It's complicated. var varName = Blockly . Python . variableDB_ . getDistinctName ( variable0 + suffix , Blockly . Variables . NAME_TYPE ) ; code += varName + ' = float(' + arg + ')\n' ; arg = varName ; } return arg ; }
Cache non-trivial values to variables to prevent repeated look-ups.
Cache non - trivial values to variables to prevent repeated look - ups .