Problem with ArduBlockly development

How is that C code being generated?

I have tried editing this section of index.html so as to use the uncompressed versions of all the .js files.

 <!-- Ardublockly - These three files contain the compress version -->
  
  <script src="../blockly/blockly_compressed.js"></script>
  <script src="../blockly/blocks_compressed.js"></script>
  <script src="../blockly/arduino_compressed.js"></script>
  
  <!-- To use the uncompressed version comment out the above and comment in the ones below -->
  <!--
  <script src="../blockly/blockly_uncompressed.js"></script>
  <script src="../blockly/blocks/logic.js"></script>
  <script src="../blockly/blocks/loops.js"></script>
  <script src="../blockly/blocks/math.js"></script>
  <script src="../blockly/blocks/text.js"></script>
  <script src="../blockly/blocks/lists.js"></script>
  <script src="../blockly/blocks/colour.js"></script>
  <script src="../blockly/blocks/variables.js"></script>
  <script src="../blockly/blocks/procedures.js"></script>
  <script src="../blockly/blocks/arduino/io.js"></script>
  <script src="../blockly/blocks/arduino/map.js"></script>
  <script src="../blockly/blocks/arduino/procedures.js"></script>
  <script src="../blockly/blocks/arduino/serial.js"></script>
  <script src="../blockly/blocks/arduino/servo.js"></script>
  <script src="../blockly/blocks/arduino/spi.js"></script>
  <script src="../blockly/blocks/arduino/stepper.js"></script>
  <script src="../blockly/blocks/arduino/time.js"></script>
  <script src="../blockly/blocks/arduino/tone.js"></script>
  <script src="../blockly/blocks/arduino/variables.js"></script>
  <script src="../blockly/generators/arduino.js"></script>
  <script src="../blockly/generators/arduino/boards.js"></script>
  <script src="../blockly/generators/arduino/io.js"></script>
  <script src="../blockly/generators/arduino/lists.js"></script>
  <script src="../blockly/generators/arduino/logic.js"></script>
  <script src="../blockly/generators/arduino/loops.js"></script>
  <script src="../blockly/generators/arduino/map.js"></script>
  <script src="../blockly/generators/arduino/math.js"></script>
  <script src="../blockly/generators/arduino/procedures.js"></script>
  <script src="../blockly/generators/arduino/serial.js"></script>
  <script src="../blockly/generators/arduino/servo.js"></script>
  <script src="../blockly/generators/arduino/spi.js"></script>
  <script src="../blockly/generators/arduino/stepper.js"></script>
  <script src="../blockly/generators/arduino/text.js"></script>
  <script src="../blockly/generators/arduino/time.js"></script>
  <script src="../blockly/generators/arduino/tone.js"></script>
  <script src="../blockly/generators/arduino/variables.js"></script>
  -->

And I have modified this section of loop.js to see if I can get a change in the code generated when I place a repeat until loop block

Blockly.Arduino['controls_whileUntil'] = function(block) {
  // Do while/until loop.
  var until = block.getFieldValue('MODE') == 'UNTIL';
  var argument0 = Blockly.Arduino.valueToCode(block, 'BOOL',
      until ? Blockly.Arduino.ORDER_LOGICAL_OR :
      Blockly.Arduino.ORDER_NONE) || 'false';
  var branch = Blockly.Arduino.statementToCode(block, 'DO');
  branch = Blockly.Arduino.addLoopTrap(branch, block.id);
  if (until) {
    if (!argument0.match(/^\w+$/)) {
      argument0 = '(' + argument0 + ')';
    }
    argument0 = '!' + argument0;
  }
  return 'while XXXXXXXXX(' + argument0 + ') {\n' + branch + '}\n';
};

But it makes no difference and I still see this:



void setup() {
}

void loop() {
  while (!false) {
  }

}

So where is the code generator that is actually being used in this haystack?

Don’t double post

1 Like

Threads merged.

The source code is here: GitHub - carlosperate/ardublockly: Visual programming for Arduino. Based on blockly, implements Arduino code generation and facilitates program uploading.

And you also need this: GitHub - google/closure-library: Google's common JavaScript library