function compose(containerBlock) {
    var itemBlock = containerBlock.getInputTargetBlock('STACK'); // Count number of inputs.

    var connections = [];
    var blockTypes = [];

    while (itemBlock) {
      connections.push(itemBlock.valueConnection_);
      blockTypes.push(itemBlock.type);
      itemBlock = itemBlock.nextConnection && itemBlock.nextConnection.targetBlock();
    } // Disconnect any children that don't belong.


    for (var i = 0; i < this.parametersCount_; i++) {
      var connection = this.getInput('PARAMETER' + i).connection.targetConnection;

      if (connection && connections.indexOf(connection) === -1) {
        // Disconnect all children of this block
        var connectedBlock = connection.getSourceBlock();

        for (var j = 0; j < connectedBlock.inputList.length; j++) {
          var field = connectedBlock.inputList[j].connection;

          if (field && field.targetConnection) {
            field.targetConnection.getSourceBlock().unplug(true);
          }
        }

        connection.disconnect();
        connection.getSourceBlock().dispose();
      }
    }

    this.parametersCount_ = connections.length;
    this.updateShape_(); // Reconnect any child blocks.

    for (var _i6 = 0; _i6 < this.parametersCount_; _i6++) {
      Blockly.Mutator.reconnect(connections[_i6], this, 'PARAMETER' + _i6);

      if (!connections[_i6]) {
        var createName = 'ast_Function' + blockTypes[_i6].substring('ast_FunctionMutant'.length);

        var _itemBlock3 = this.workspace.newBlock(createName);

        _itemBlock3.setDeletable(false);

        _itemBlock3.setMovable(false);

        _itemBlock3.initSvg();

        this.getInput('PARAMETER' + _i6).connection.connect(_itemBlock3.outputConnection);

        _itemBlock3.render(); //this.get(itemBlock, 'ADD'+i)

      }
    } // Show/hide the returns annotation


    var hasReturns = containerBlock.getFieldValue('RETURNS');

    if (hasReturns !== null) {
      hasReturns = hasReturns === 'TRUE';

      if (this.hasReturn_ != hasReturns) {
        if (hasReturns) {
          this.setReturnAnnotation_(true);
          Blockly.Mutator.reconnect(this.returnConnection_, this, 'RETURNS');
          this.returnConnection_ = null;
        } else {
          var returnConnection = this.getInput('RETURNS').connection;
          this.returnConnection_ = returnConnection.targetConnection;

          if (this.returnConnection_) {
            var returnBlock = returnConnection.targetBlock();
            returnBlock.unplug();
            returnBlock.bumpNeighbours_();
          }

          this.setReturnAnnotation_(false);
        }
      }
    }
  }
/**
   * Reconfigure this block based on the mutator dialog's components.
   * @param {!Blockly.Block} containerBlock Root block in mutator.
   * @this Blockly.Block
   */
Reconfigure this block based on the mutator dialog's components.
@param {!Blockly.Block} containerBlock Root block in mutator.
Reconfigure this block based on the mutator dialog ' s components . @param { !Blockly . Block } containerBlock Root block in mutator .
function compose(containerBlock) {
    var itemBlock = containerBlock.getInputTargetBlock('STACK'); 
    var connections = [];
    var blockTypes = [];
    while (itemBlock) {
      connections.push(itemBlock.valueConnection_);
      blockTypes.push(itemBlock.type);
      itemBlock = itemBlock.nextConnection && itemBlock.nextConnection.targetBlock();
    } 
    for (var i = 0; i < this.parametersCount_; i++) {
      var connection = this.getInput('PARAMETER' + i).connection.targetConnection;
      if (connection && connections.indexOf(connection) === -1) {
        var connectedBlock = connection.getSourceBlock();
        for (var j = 0; j < connectedBlock.inputList.length; j++) {
          var field = connectedBlock.inputList[j].connection;
          if (field && field.targetConnection) {
            field.targetConnection.getSourceBlock().unplug(true);
          }
        }
        connection.disconnect();
        connection.getSourceBlock().dispose();
      }
    }
    this.parametersCount_ = connections.length;
    this.updateShape_(); 
    for (var _i6 = 0; _i6 < this.parametersCount_; _i6++) {
      Blockly.Mutator.reconnect(connections[_i6], this, 'PARAMETER' + _i6);
      if (!connections[_i6]) {
        var createName = 'ast_Function' + blockTypes[_i6].substring('ast_FunctionMutant'.length);
        var _itemBlock3 = this.workspace.newBlock(createName);
        _itemBlock3.setDeletable(false);
        _itemBlock3.setMovable(false);
        _itemBlock3.initSvg();
        this.getInput('PARAMETER' + _i6).connection.connect(_itemBlock3.outputConnection);
        _itemBlock3.render(); 
      }
    } 
    var hasReturns = containerBlock.getFieldValue('RETURNS');
    if (hasReturns !== null) {
      hasReturns = hasReturns === 'TRUE';
      if (this.hasReturn_ != hasReturns) {
        if (hasReturns) {
          this.setReturnAnnotation_(true);
          Blockly.Mutator.reconnect(this.returnConnection_, this, 'RETURNS');
          this.returnConnection_ = null;
        } else {
          var returnConnection = this.getInput('RETURNS').connection;
          this.returnConnection_ = returnConnection.targetConnection;
          if (this.returnConnection_) {
            var returnBlock = returnConnection.targetBlock();
            returnBlock.unplug();
            returnBlock.bumpNeighbours_();
          }
          this.setReturnAnnotation_(false);
        }
      }
    }
  }
function compose ( containerBlock ) { var itemBlock = containerBlock . getInputTargetBlock ( 'STACK' ) ; var connections = [ ] ; var blockTypes = [ ] ; while ( itemBlock ) { connections . push ( itemBlock . valueConnection_ ) ; blockTypes . push ( itemBlock . type ) ; itemBlock = itemBlock . nextConnection && itemBlock . nextConnection . targetBlock ( ) ; } for ( var i = 0 ; i < this . parametersCount_ ; i ++ ) { var connection = this . getInput ( 'PARAMETER' + i ) . connection . targetConnection ; if ( connection && connections . indexOf ( connection ) === - 1 ) { var connectedBlock = connection . getSourceBlock ( ) ; for ( var j = 0 ; j < connectedBlock . inputList . length ; j ++ ) { var field = connectedBlock . inputList [ j ] . connection ; if ( field && field . targetConnection ) { field . targetConnection . getSourceBlock ( ) . unplug ( true ) ; } } connection . disconnect ( ) ; connection . getSourceBlock ( ) . dispose ( ) ; } } this . parametersCount_ = connections . length ; this . updateShape_ ( ) ; for ( var _i6 = 0 ; _i6 < this . parametersCount_ ; _i6 ++ ) { Blockly . Mutator . reconnect ( connections [ _i6 ] , this , 'PARAMETER' + _i6 ) ; if ( ! connections [ _i6 ] ) { var createName = 'ast_Function' + blockTypes [ _i6 ] . substring ( 'ast_FunctionMutant' . length ) ; var _itemBlock3 = this . workspace . newBlock ( createName ) ; _itemBlock3 . setDeletable ( false ) ; _itemBlock3 . setMovable ( false ) ; _itemBlock3 . initSvg ( ) ; this . getInput ( 'PARAMETER' + _i6 ) . connection . connect ( _itemBlock3 . outputConnection ) ; _itemBlock3 . render ( ) ; } } var hasReturns = containerBlock . getFieldValue ( 'RETURNS' ) ; if ( hasReturns !== null ) { hasReturns = hasReturns === 'TRUE' ; if ( this . hasReturn_ != hasReturns ) { if ( hasReturns ) { this . setReturnAnnotation_ ( true ) ; Blockly . Mutator . reconnect ( this . returnConnection_ , this , 'RETURNS' ) ; this . returnConnection_ = null ; } else { var returnConnection = this . getInput ( 'RETURNS' ) . connection ; this . returnConnection_ = returnConnection . targetConnection ; if ( this . returnConnection_ ) { var returnBlock = returnConnection . targetBlock ( ) ; returnBlock . unplug ( ) ; returnBlock . bumpNeighbours_ ( ) ; } this . setReturnAnnotation_ ( false ) ; } } } }
Reconfigure this block based on the mutator dialog's components.
Reconfigure this block based on the mutator dialog ' s components .
// Count number of inputs. // Disconnect any children that don't belong. // Disconnect all children of this block // Reconnect any child blocks. //this.get(itemBlock, 'ADD'+i) // Show/hide the returns annotation