<commit_before>/*
 * Project:     libFIRM
 * File name:   ir/ir/irargs.c
 * Purpose:     Support for libcore IR object output.
 * Author:      <NAME>
 * Modified by:
 * Created:
 * CVS-ID:      $Id$
 * Copyright:   (c) 1998-2005 Universitt Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <ctype.h>
#include <libcore/xprintf.h>

#include "firm_common.h"
#include "irnode.h"
#include "entity.h"
#include "irloop.h"
#include "tv.h"

/**
 * identify a firm object type
 */
static int firm_get_arg_type(const arg_occ_t *occ) {
  /* Firm objects are always pointer */
  return arg_type_ptr;
}

static int firm_get_arg_type_int(const arg_occ_t *occ) {
  return arg_type_int;
}

/**
 * emit a Firm object
 */
static int firm_emit(appendable_t *app, const arg_occ_t *occ, const arg_value_t *arg)
{
#define A(s)    occ->flag_hash ? s " ": ""

  void *X = arg->v_ptr;
  firm_kind *obj = X;

  int i, n;
  ir_node *block;
  char buf[256];
  char tv[256];

  buf[0] = '\0';

  if (! X)
    strncpy(buf, "(null)", sizeof(buf));
  else {
    switch (*obj) {
    case k_BAD:
      snprintf(buf, sizeof(buf), "BAD[%p]", X);
      break;
    case k_entity:
      snprintf(buf, sizeof(buf), "%s%s[%ld]", A("ent"),
          isupper(occ->conversion) ? get_entity_ld_name(X): get_entity_name(X),
          get_entity_nr(X));
      break;
    case k_type:
      snprintf(buf, sizeof(buf), "%s%s:%s[%ld]", A("type"), get_type_tpop_name(X), get_type_name(X), get_type_nr(X));
      break;
    case k_ir_graph:
      snprintf(buf, sizeof(buf), "%s%s[%ld]", A("irg"), get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X));
      break;
    case k_ir_node:
      switch (occ->conversion) {
      case 'B':
        block = is_no_Block(X) ? get_nodes_block(X) : X;
        snprintf(buf, sizeof(buf), "%s%s%s[%ld]", A("irn"), get_irn_opname(block),
            get_mode_name(get_irn_mode(block)), get_irn_node_nr(block));
        break;
      case 'N':
        snprintf(buf, sizeof(buf), "%ld", get_irn_node_nr(X));
        break;
      default:
        snprintf(buf, sizeof(buf), "%s%s%s[%ld]", A("irn"), get_irn_opname(X),
            get_mode_name(get_irn_mode(X)), get_irn_node_nr(X));
      }
      break;
    case k_ir_mode:
      snprintf(buf, sizeof(buf), "%s%s", A("mode"), get_mode_name(X));
      break;
    case k_tarval:
      tarval_snprintf(tv, sizeof(tv), X);
      snprintf(buf, sizeof(buf), "%s%s", A("tv"), tv);
      break;
    case k_ir_loop:
      snprintf(buf, sizeof(buf), "ldepth[%d]", get_loop_depth(X));
      break;
    case k_ir_op:
      snprintf(buf, sizeof(buf), "%s%s", A("op"), get_op_name(X));
      break;
    case k_ir_compound_graph_path:
      strncat(buf, A("cgp"), sizeof(buf));

      n = get_compound_graph_path_length(X);
      for (i = 0; i < n; ++i) {
        entity *ent = get_compound_graph_path_node(X, i);
        strncat(buf, get_entity_name(ent), sizeof(buf));
        if (i < n - 1)
          strncat(buf, ".", sizeof(buf));
      }
      break;
    default:
      snprintf(buf, sizeof(buf), "UNKWN[%p]", X);
    }
  }
  return arg_append(app, occ, buf, strlen(buf));<commit_msg>You must now add + to the format options to get the node number. Like in %+F<commit_after>/*
 * Project:     libFIRM
 * File name:   ir/ir/irargs.c
 * Purpose:     Support for libcore IR object output.
 * Author:      <NAME>
 * Modified by:
 * Created:
 * CVS-ID:      $Id$
 * Copyright:   (c) 1998-2005 Universit�t Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <ctype.h>
#include <libcore/xprintf.h>

#include "firm_common.h"
#include "irnode.h"
#include "entity.h"
#include "irloop.h"
#include "tv.h"

/**
 * identify a firm object type
 */
static int firm_get_arg_type(const arg_occ_t *occ) {
  /* Firm objects are always pointer */
  return arg_type_ptr;
}

static int firm_get_arg_type_int(const arg_occ_t *occ) {
  return arg_type_int;
}

/**
 * emit a Firm object
 */
static int firm_emit(appendable_t *app, const arg_occ_t *occ, const arg_value_t *arg)
{
#define A(s)    occ->flag_hash ? s " ": ""

  void *X = arg->v_ptr;
  firm_kind *obj = X;
  int i, n;
  ir_node *block;
	char add[64];
  char buf[256];
  char tv[256];

  buf[0] = '\0';
  add[0] = '\0';

  if (! X)
    strncpy(buf, "(null)", sizeof(buf));
  else {
    switch (*obj) {
    case k_BAD:
      snprintf(buf, sizeof(buf), "BAD");
      snprintf(add, sizeof(add), "[%p]", X);
      break;
    case k_entity:
      snprintf(buf, sizeof(buf), "%s%s", A("ent"),
          isupper(occ->conversion) ? get_entity_ld_name(X): get_entity_name(X));
      snprintf(add, sizeof(add), "[%ld]", get_entity_nr(X));
      break;
    case k_type:
      snprintf(buf, sizeof(buf), "%s%s:%s", A("type"), get_type_tpop_name(X), get_type_name(X));
      snprintf(add, sizeof(add), "[%ld]", get_type_nr(X));
      break;
    case k_ir_graph:
      snprintf(buf, sizeof(buf), "%s%s", A("irg"), get_entity_name(get_irg_entity(X)));
      snprintf(add, sizeof(add), "[%ld]", get_irg_graph_nr(X));
      break;
    case k_ir_node:
      switch (occ->conversion) {
      case 'B':
        block = is_no_Block(X) ? get_nodes_block(X) : X;
        snprintf(buf, sizeof(buf), "%s%s%s", A("irn"), get_irn_opname(block),
            get_mode_name(get_irn_mode(block)));
        snprintf(add, sizeof(add), "[%ld]", get_irn_node_nr(block));
        break;
      case 'N':
        snprintf(buf, sizeof(buf), "%ld", get_irn_node_nr(X));
        break;
      default:
        snprintf(buf, sizeof(buf), "%s%s%s", A("irn"), get_irn_opname(X),
            get_mode_name(get_irn_mode(X)));
        snprintf(add, sizeof(add), "[%ld]", get_irn_node_nr(X));
      }
      break;
    case k_ir_mode:
      snprintf(buf, sizeof(buf), "%s%s", A("mode"), get_mode_name(X));
      break;
    case k_tarval:
      tarval_snprintf(tv, sizeof(tv), X);
      snprintf(buf, sizeof(buf), "%s%s", A("tv"), tv);
      break;
    case k_ir_loop:
      snprintf(buf, sizeof(buf), "ldepth[%d]", get_loop_depth(X));
      break;
    case k_ir_op:
      snprintf(buf, sizeof(buf), "%s%s", A("op"), get_op_name(X));
      break;
    case k_ir_compound_graph_path:
      strncat(buf, A("cgp"), sizeof(buf));

      n = get_compound_graph_path_length(X);
      for (i = 0; i < n; ++i) {
        entity *ent = get_compound_graph_path_node(X, i);
        strncat(buf, get_entity_name(ent), sizeof(buf));
        if (i < n - 1)
          strncat(buf, ".", sizeof(buf));
      }
      break;
    default:
      snprintf(buf, sizeof(buf), "UNKWN");
      snprintf(add, sizeof(add), "[%p]", X);
    }
  }

  if(occ->flag_plus)
  	strncat(buf, add, sizeof(buf));

  return arg_append(app, occ, buf, strlen(buf));
{'fraction_non_alphanumeric': 0.17162538472812547, 'fraction_numerical': 0.005862523816503005, 'mean_word_length': 3.0984984984984987, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7608918', 'n_tokens_mistral': 2706, 'n_tokens_neox': 2647, 'n_words': 569}