<commit_before>/*
Ruby 1.9 version: (7/20/2009, <NAME>, <EMAIL>)

   Now works with Ruby-1.9.1. Tested with p129 and p243.

   This does not (and can not) function identically to the 1.8 version. 
   Line numbers are ordered differently. But ruby-debug doesn't seem 
   to mind the difference.

   Also, 1.9 does not number lines with a "begin" statement.

   All this 1.9 version does is compile into bytecode, disassemble it
   using rb_iseq_disasm(), and parse the text output. This isn't a
   great solution; it will break if the disassembly format changes.
   Walking the iseq tree and decoding each instruction is pretty hairy,
   though, so until I have a really compelling reason to go that route, 
   I'll leave it at this.
*/
#include <ruby.h>
#include <version.h>
#include <vm_core.h>
#include "trace_nums.h"

VALUE mTraceLineNumbers;

/* Return a list of trace hook line numbers for the string in Ruby source src*/
static VALUE 
lnums_for_str(VALUE self, VALUE src)
{
  VALUE result = rb_ary_new(); /* The returned array of line numbers. */<commit_msg>updated for Ruby 1.9.3<commit_after>/*
Ruby 1.9 version: (7/20/2009, <NAME>, <EMAIL>)

   Now works with Ruby-1.9.1. Tested with p129 and p243.

   This does not (and can not) function identically to the 1.8 version. 
   Line numbers are ordered differently. But ruby-debug doesn't seem 
   to mind the difference.

   Also, 1.9 does not number lines with a "begin" statement.

   All this 1.9 version does is compile into bytecode, disassemble it
   using rb_iseq_disasm(), and parse the text output. This isn't a
   great solution; it will break if the disassembly format changes.
   Walking the iseq tree and decoding each instruction is pretty hairy,
   though, so until I have a really compelling reason to go that route, 
   I'll leave it at this.
*/
#include <ruby.h>
#include <version.h>
#include <vm_core.h>
#include "trace_nums.h"

VALUE mTraceLineNumbers;

static inline const rb_data_type_t *
threadptr_data_type(void)
{
        static const rb_data_type_t *thread_data_type;
        if (!thread_data_type)
        {
                VALUE current_thread = rb_thread_current();
                thread_data_type = RTYPEDDATA_TYPE(current_thread);
        }
        return thread_data_type;
}

#define ruby_threadptr_data_type *threadptr_data_type()
#define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))

/* Return a list of trace hook line numbers for the string in Ruby source src*/
static VALUE 
lnums_for_str(VALUE self, VALUE src)
{
  VALUE result = rb_ary_new(); /* The returned array of line numbers. */
{'fraction_non_alphanumeric': 0.07927996936039831, 'fraction_numerical': 0.019532746074301034, 'mean_word_length': 3.5505226480836236, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6689631', 'n_tokens_mistral': 860, 'n_tokens_neox': 793, 'n_words': 330}