comprehensions.js 683 B

123456789101112131415
  1. 'use strict';
  2. goog.provide('Blockly.Python.comprehensions');
  3. goog.require('Blockly.Python');
  4. Blockly.Python['list_comprehension'] = function(block) {
  5. var value_body = Blockly.Python.valueToCode(block, 'body', Blockly.Python.ORDER_ATOMIC) || '___';
  6. var value_var = Blockly.Python.valueToCode(block, 'var', Blockly.Python.ORDER_ATOMIC) || '___';
  7. var value_list = Blockly.Python.valueToCode(block, 'list', Blockly.Python.ORDER_ATOMIC) || '___';
  8. // TODO: Assemble Python into code variable.
  9. var code = '['+value_body+' for '+value_var+' in '+value_list+']';
  10. // TODO: Change ORDER_NONE to the correct strength.
  11. return [code, Blockly.Python.ORDER_NONE];
  12. };