function rewrite_element_as_argument_passing (element_hash) {
  var coordinating_elements_metadata = determine_element_as_argument_coordinators(element_hash);

  var has_no_element_as_argument_usages = !coordinating_elements_metadata.length;
  if (has_no_element_as_argument_usages) {
    return;
  }

  var elements_with_element_as_arg_params = {};

  coordinating_elements_metadata.forEach(function (coordinating_element_metadata) {
    var coordination_cases = coordinating_element_metadata.cases;
    var coordinating_element = element_hash[coordinating_element_metadata.name];
    var coordinating_element_local_refs_hash = coordinating_element.localRefsHash;

    for (var i = 0; i !== coordination_cases.length; ++i) {
      var coordinating_case = coordination_cases[i];
      var element_as_arg_ref = coordinating_element_local_refs_hash[coordinating_case.arg];

      if (element_as_arg_ref.type === 'elements') {
        element_as_arg_ref.value.args.__placement = VIRTUAL_PLACEMENT_REF_NAME;
      } else if (element_as_arg_ref.type === 'dynamicElementLists') {
        var options = element_as_arg_ref.value.options;
        for (var option_key in options) {
          var option_args = options[option_key].args;
          option_args.__placement = VIRTUAL_PLACEMENT_REF_NAME;
        }
      }

      var element_params_seen = elements_with_element_as_arg_params[coordinating_case.element_passed_to_type] || {};

      element_params_seen[coordinating_case.arg_name] = true;

      elements_with_element_as_arg_params[coordinating_case.element_passed_to_type] = element_params_seen;
    }
  });

  mark_element_as_arg_parameters(elements_with_element_as_arg_params, element_hash);
}
/**
 * Detects and restructures situations where we have elements or dynamic element lists getting passed as arguments to an element.
 *
 * Elements by default just output a placement that represents a spot after its contents.  Given that knowledge, it is clear that there is no opportunity without restructuring the element that wants to insert an element created in the context of another element into itself to do so.
 *
 * The restructuring will find these spots where it is clear that an element or dynamic element list is being passed as an arg, and rewrite from the target TripleVariable to remove the TripleVariable and have the input of the TripleVariable become an output and the output of the element or dynamic element list to become an input and have every step of the path handle that change.
 *
 * @param {Object} element_hash
 */
Detects and restructures situations where we have elements or dynamic element lists getting passed as arguments to an element.
Elements by default just output a placement that represents a spot after its contents.  Given that knowledge, it is clear that there is no opportunity without restructuring the element that wants to insert an element created in the context of another element into itself to do so.

The restructuring will find these spots where it is clear that an element or dynamic element list is being passed as an arg, and rewrite from the target TripleVariable to remove the TripleVariable and have the input of the TripleVariable become an output and the output of the element or dynamic element list to become an input and have every step of the path handle that change.


Detects and restructures situations where we have elements or dynamic element lists getting passed as arguments to an element . Elements by default just output a placement that represents a spot after its contents . Given that knowledge it is clear that there is no opportunity without restructuring the element that wants to insert an element created in the context of another element into itself to do so . The restructuring will find these spots where it is clear that an element or dynamic element list is being passed as an arg and rewrite from the target TripleVariable to remove the TripleVariable and have the input of the TripleVariable become an output and the output of the element or dynamic element list to become an input and have every step of the path handle that change .
function rewrite_element_as_argument_passing (element_hash) {
  var coordinating_elements_metadata = determine_element_as_argument_coordinators(element_hash);
  var has_no_element_as_argument_usages = !coordinating_elements_metadata.length;
  if (has_no_element_as_argument_usages) {
    return;
  }
  var elements_with_element_as_arg_params = {};
  coordinating_elements_metadata.forEach(function (coordinating_element_metadata) {
    var coordination_cases = coordinating_element_metadata.cases;
    var coordinating_element = element_hash[coordinating_element_metadata.name];
    var coordinating_element_local_refs_hash = coordinating_element.localRefsHash;
    for (var i = 0; i !== coordination_cases.length; ++i) {
      var coordinating_case = coordination_cases[i];
      var element_as_arg_ref = coordinating_element_local_refs_hash[coordinating_case.arg];
      if (element_as_arg_ref.type === 'elements') {
        element_as_arg_ref.value.args.__placement = VIRTUAL_PLACEMENT_REF_NAME;
      } else if (element_as_arg_ref.type === 'dynamicElementLists') {
        var options = element_as_arg_ref.value.options;
        for (var option_key in options) {
          var option_args = options[option_key].args;
          option_args.__placement = VIRTUAL_PLACEMENT_REF_NAME;
        }
      }
      var element_params_seen = elements_with_element_as_arg_params[coordinating_case.element_passed_to_type] || {};
      element_params_seen[coordinating_case.arg_name] = true;
      elements_with_element_as_arg_params[coordinating_case.element_passed_to_type] = element_params_seen;
    }
  });
  mark_element_as_arg_parameters(elements_with_element_as_arg_params, element_hash);
}
function rewrite_element_as_argument_passing ( element_hash ) { var coordinating_elements_metadata = determine_element_as_argument_coordinators ( element_hash ) ; var has_no_element_as_argument_usages = ! coordinating_elements_metadata . length ; if ( has_no_element_as_argument_usages ) { return ; } var elements_with_element_as_arg_params = { } ; coordinating_elements_metadata . forEach ( function ( coordinating_element_metadata ) { var coordination_cases = coordinating_element_metadata . cases ; var coordinating_element = element_hash [ coordinating_element_metadata . name ] ; var coordinating_element_local_refs_hash = coordinating_element . localRefsHash ; for ( var i = 0 ; i !== coordination_cases . length ; ++ i ) { var coordinating_case = coordination_cases [ i ] ; var element_as_arg_ref = coordinating_element_local_refs_hash [ coordinating_case . arg ] ; if ( element_as_arg_ref . type === 'elements' ) { element_as_arg_ref . value . args . __placement = VIRTUAL_PLACEMENT_REF_NAME ; } else if ( element_as_arg_ref . type === 'dynamicElementLists' ) { var options = element_as_arg_ref . value . options ; for ( var option_key in options ) { var option_args = options [ option_key ] . args ; option_args . __placement = VIRTUAL_PLACEMENT_REF_NAME ; } } var element_params_seen = elements_with_element_as_arg_params [ coordinating_case . element_passed_to_type ] || { } ; element_params_seen [ coordinating_case . arg_name ] = true ; elements_with_element_as_arg_params [ coordinating_case . element_passed_to_type ] = element_params_seen ; } } ) ; mark_element_as_arg_parameters ( elements_with_element_as_arg_params , element_hash ) ; }
Detects and restructures situations where we have elements or dynamic element lists getting passed as arguments to an element.
Detects and restructures situations where we have elements or dynamic element lists getting passed as arguments to an element .