<commit_before>module Rubinius
  class CompilerNG
    attr_accessor :parser, :generator, :encoder, :packager, :writer

    # Temporary
    def self.enable
      Compiler.module_eval do
        class << self
          alias_method :old_compile_file, :compile_file
          alias_method :old_compile_string, :compile_string

          define_method :compile_file, CompilerNG.method(:compile_file)
          define_method :compile_string, CompilerNG.method(:compile_eval)
        end
      end
    end

    def self.compile(file, line=1, output=nil)
      compiler = new :file, :compiled_file

      parser = compiler.parser
      parser.root AST::Script
      parser.input file, line

      writer = compiler.writer
      writer.name = output

      compiler.run
    end

    def self.compile_file(file, line=1)
      compiler = new :file, :compiled_method

      parser = compiler.parser
      parser.root AST::Script
      parser.default_transforms
      parser.input file, line

      compiler.run
    end

    def self.compile_string(string, file="(eval)", line=1)
      compiler = new :string, :compiled_method

      parser = compiler.parser
      parser.root AST::Script
      parser.default_transforms
      parser.input string, file, line

      compiler.run
    end

    def self.compile_eval(string, binding, file="(eval)", line=1)<commit_msg>Ensure temp c-ng adapter sends right line number to parser.<commit_after>module Rubinius
  class CompilerNG
    attr_accessor :parser, :generator, :encoder, :packager, :writer

    # Temporary
    def self.enable
      Compiler.module_eval do
        class << self
          alias_method :old_compile_file, :compile_file
          alias_method :old_compile_string, :compile_string

          define_method :compile_file, CompilerNG.method(:compile_file_old)
          define_method :compile_string, CompilerNG.method(:compile_eval)
        end
      end
    end

    def self.compile(file, line=1, output=nil)
      compiler = new :file, :compiled_file

      parser = compiler.parser
      parser.root AST::Script
      parser.input file, line

      writer = compiler.writer
      writer.name = output

      compiler.run
    end

    # Match old compiler's signature
    def self.compile_file_old(file, flags=nil)
      compile_file file, 1
    end

    def self.compile_file(file, line=1)
      compiler = new :file, :compiled_method

      parser = compiler.parser
      parser.root AST::Script
      parser.default_transforms
      parser.input file, line

      compiler.run
    end

    def self.compile_string(string, file="(eval)", line=1)
      compiler = new :string, :compiled_method

      parser = compiler.parser
      parser.root AST::Script
      parser.default_transforms
      parser.input string, file, line

      compiler.run
    end

    def self.compile_eval(string, binding, file="(eval)", line=1)
{'fraction_non_alphanumeric': 0.08205841446453407, 'fraction_numerical': 0.003129346314325452, 'mean_word_length': 2.6884615384615387, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '6858274', 'n_tokens_mistral': 852, 'n_tokens_neox': 808, 'n_words': 207}