Automatic commit Wed Jan 15 03:00:09 PST 2014

This commit is contained in:
ellen.spertus
2014-01-15 03:00:09 -08:00
parent ce63f70b37
commit bd778cdfea
183 changed files with 2213 additions and 2072 deletions

View File

@@ -166,25 +166,12 @@ Blockly.JavaScript['controls_forEach'] = function(block) {
branch = Blockly.JavaScript.INFINITE_LOOP_TRAP.replace(/%1/g,
'\'' + block.id + '\'') + branch;
}
var code;
var indexVar = Blockly.JavaScript.variableDB_.getDistinctName(
variable0 + '_index', Blockly.Variables.NAME_TYPE);
if (argument0.match(/^\w+$/)) {
branch = ' ' + variable0 + ' = ' + argument0 + '[' + indexVar + '];\n' +
branch;
code = 'for (var ' + indexVar + ' in ' + argument0 + ') {\n' +
branch + '}\n';
} else {
// The list appears to be more complicated than a simple variable.
// Cache it to a variable to prevent repeated look-ups.
var listVar = Blockly.JavaScript.variableDB_.getDistinctName(
variable0 + '_list', Blockly.Variables.NAME_TYPE);
branch = ' ' + variable0 + ' = ' + listVar + '[' + indexVar + '];\n' +
branch;
code = 'var ' + listVar + ' = ' + argument0 + ';\n' +
'for (var ' + indexVar + ' in ' + listVar + ') {\n' +
branch + '}\n';
}
branch = ' ' + variable0 + ' = ' + argument0 + '[' + indexVar + '];\n' +
branch;
var code = 'for (var ' + indexVar + ' in ' + argument0 + ') {\n' +
branch + '}\n';
return code;
};