<commit_before>#ifndef _IV_LV5_GLOBAL_DATA_H_
#define _IV_LV5_GLOBAL_DATA_H_
#include <tr1/array>
#include <tr1/cstdio>
#include <boost/random.hpp>
#include "dtoa.h"
#include "conversions.h"
#include "stringpiece.h"
#include "ustringpiece.h"
#include "ustring.h"
#include "lv5/gc_template.h"
#include "lv5/xorshift.h"
#include "lv5/jsstring.h"
#include "lv5/jsfunction.h"
#include "lv5/symboltable.h"
namespace iv {
namespace lv5 {
namespace detail {

static const char* kLengthString = "length";
static const char* kEvalString = "eval";
static const char* kArgumentsString = "arguments";
static const char* kCallerString = "caller";
static const char* kCalleeString = "callee";
static const char* kToStringString = "toString";
static const char* kValueOfString = "valueOf";
static const char* kPrototypeString = "prototype";
static const char* kConstructorString = "constructor";
static const char* kArrayString = "Array";

}  // namespace iv::lv5::detail

class SymbolChecker;
class JSRegExpImpl;

// GlobalData has symboltable, global object
class GlobalData {
 public:
  friend class SymbolChecker;
  typedef Xor128 random_engine_type;
  typedef boost::uniform_real<double> random_distribution_type;
  typedef boost::variate_generator<
      random_engine_type, random_distribution_type> random_generator;

  GlobalData()
    : random_engine_(random_engine_type(),
                     random_distribution_type(0, 1)),
      global_obj_(),
      regs_(),
      builtins_(),
      table_(),
      length_symbol_(Intern(detail::kLengthString)),
      eval_symbol_(Intern(detail::kEvalString)),
      arguments_symbol_(Intern(detail::kArgumentsString)),
      caller_symbol_(Intern(detail::kCallerString)),
      callee_symbol_(Intern(detail::kCalleeString)),
      toString_symbol_(Intern(detail::kToStringString)),
      valueOf_symbol_(Intern(detail::kValueOfString)),
      prototype_symbol_(Intern(detail::kPrototypeString)),
      constructor_symbol_(Intern(detail::kConstructorString)),
      Array_symbol_(Intern(detail::kArrayString)) {
    // discard random
    for (std::size_t i = 0; i < 20; ++i) {
      Random();
    }
  }

  Symbol Intern(const core::StringPiece& str) {
    return table_.Lookup(str);
  }

  Symbol Intern(const core::UStringPiece& str) {
    return table_.Lookup(str);
  }

  Symbol InternIndex(uint32_t index) {
    std::tr1::array<char, 15> buf;<commit_msg>refine global_data.h<commit_after>#ifndef _IV_LV5_GLOBAL_DATA_H_
#define _IV_LV5_GLOBAL_DATA_H_
#include <tr1/array>
#include <tr1/cstdio>
#include <boost/random.hpp>
#include "dtoa.h"
#include "conversions.h"
#include "stringpiece.h"
#include "ustringpiece.h"
#include "ustring.h"
#include "lv5/gc_template.h"
#include "lv5/xorshift.h"
#include "lv5/jsstring.h"
#include "lv5/jsfunction.h"
#include "lv5/symboltable.h"
namespace iv {
namespace lv5 {

class SymbolChecker;
class JSRegExpImpl;

// GlobalData has symboltable, global object
class GlobalData {
 public:
  friend class SymbolChecker;
  typedef Xor128 random_engine_type;
  typedef boost::uniform_real<double> random_distribution_type;
  typedef boost::variate_generator<
      random_engine_type, random_distribution_type> random_generator;

  GlobalData()
    : random_engine_(random_engine_type(),
                     random_distribution_type(0, 1)),
      global_obj_(),
      regs_(),
      builtins_(),
      table_(),
      length_symbol_(Intern("length")),
      eval_symbol_(Intern("eval")),
      arguments_symbol_(Intern("arguments")),
      caller_symbol_(Intern("caller")),
      callee_symbol_(Intern("callee")),
      toString_symbol_(Intern("toString")),
      valueOf_symbol_(Intern("valueOf")),
      prototype_symbol_(Intern("prototype")),
      constructor_symbol_(Intern("constructor")),
      Array_symbol_(Intern("Array")) {
    // discard random
    for (std::size_t i = 0; i < 20; ++i) {
      Random();
    }
  }

  Symbol Intern(const core::StringPiece& str) {
    return table_.Lookup(str);
  }

  Symbol Intern(const core::UStringPiece& str) {
    return table_.Lookup(str);
  }

  Symbol InternIndex(uint32_t index) {
    std::tr1::array<char, 15> buf;
{'fraction_non_alphanumeric': 0.12542290961817304, 'fraction_numerical': 0.011358144030932818, 'mean_word_length': 4.772663877266388, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '6776308', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1323, 'n_words': 266}