refactor: Migrate blocks/loops.js to goog.module syntax (#5755)

* refactor: Turn .getSurroundLoop into a (Block) method

  This considerably simplifies the code in the genrators, obviating
  the need for generators to import Blockly.Constants.Loops, and
  allowing the compiler to remove blocks/loops.js from the first
  (Blockly) chunk of the compilation.

  (The latter could and should have been arranged by making the
  generator chunks depend on the blocks chunk, but that is no longer
  necessary.)

* refactor: Migrate blocks/loops.js to goog.module

* refactor: Migrate blocks/loops.js named requires

* chore: clang-format blocks/loops.js
This commit is contained in:
Christopher Allen
2021-11-30 23:51:27 +00:00
committed by GitHub
parent 874bbc13c9
commit 208d2008a3
8 changed files with 266 additions and 257 deletions

View File

@@ -12,7 +12,6 @@
goog.provide('Blockly.JavaScript.loops');
goog.require('Blockly.Constants.Loops');
goog.require('Blockly.JavaScript');
goog.require('Blockly.utils.string');
@@ -167,8 +166,7 @@ Blockly.JavaScript['controls_flow_statements'] = function(block) {
block);
}
if (Blockly.JavaScript.STATEMENT_PREFIX) {
const loop = Blockly.Constants.Loops
.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.getSurroundLoop(block);
const loop = block.getSurroundLoop();
if (loop && !loop.suppressPrefixSuffix) {
// Inject loop's statement prefix here since the regular one at the end
// of the loop will not get executed if 'continue' is triggered.