<commit_before>// This contains all the structures for lorito

#ifndef LORITO_LORITO_H_GUARD
#define LORITO_LORITO_H_GUARD

#include "config.h"

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>

struct lorito_interp_t;
struct lorito_opcode_t;
struct lorito_reg_t;
struct lorito_pmc_t;

struct lorito_str_t;
struct lorito_file_t;
struct lorito_codeseg_t;
struct lorito_constseg_t;
struct lorito_ctx_t;
struct lorito_c_method_t;

struct lorito_interp_t
{
  struct lorito_ctx_t* ctx;
  int next_fileid;

  unsigned short magic;

  // Files
  int allocated_file;
  struct lorito_file_t **files;
  //
  struct lorito_codeseg_t *last_seg;

  //Intern Strings (Symbols)
  int symbol_len;
  struct lorito_str_t **symbols;

  // Special PMCs
  struct lorito_pmc_t *default_lookup;
  struct lorito_pmc_t *null_pmc;

  // Errors
  struct lorito_str_t *last_error;
};
typedef struct lorito_interp_t Lorito_Interp;

struct lorito_opcode_t
{
  unsigned char opcode;
  unsigned char dest;
  unsigned char src1;
  unsigned char src2;
  union
  {
    int immediate;
    int jumploc;
    int offset;
  };
};
typedef struct lorito_opcode_t Lorito_Opcode;

struct lorito_reg_t
{
  int regs_i[REGNUM];
  double regs_n[REGNUM];
  struct lorito_str_t *regs_s[REGNUM];
  struct lorito_pmc_t *regs_p[REGNUM];
};
typedef struct lorito_reg_t Lorito_Reg;

struct lorito_str_t
{
  int length;
  const char *original;
};
typedef struct lorito_str_t Lorito_Str;

// The enum of internal PMCs
enum INTERNAL_PMC_ENUM {
  NOT_INTERNAL = 0,

  BOX_INT      = 1,
  BOX_NUM      = 2,
  BOX_STR      = 3,

  FILE_BLOCK   = 4,
  CODE_BLOCK   = 5,
  CONST_BLOCK   = 6,
 
  CONTEXT      = 7,
  LOOKUP       = 8,
  C_METHOD     = 9
};
typedef enum INTERNAL_PMC_ENUM Lorito_Internal;

struct lorito_pmc_t
{
  unsigned short magic;  // Magic identifier, changes per interp.
  Lorito_Internal internal_type;

  int size;
  unsigned char *data;

  int ptr_count;
  int ptr_last;
  struct lorito_pmc_t *ptrs;

  // Lookup method
  struct lorito_pmc_t *lookup;
  // VTable PMC for lookup
  struct lorito_pmc_t *vtable;

  // The data for the internal types
  /*
  union {
    int boxed_int;
    double boxed_num;
    struct lorito_str_t *boxed_str;
    struct lorito_file_t *file;
    struct lorito_codeseg_t *code;
    struct lorito_constseg_t *const;
    struct lorito_ctx_t *ctx;
  };
  */
};
typedef struct lorito_pmc_t Lorito_PMC;

// Macros for Internal PMCs.
#define IS_INTERNAL(p)   (p->internal_type != NOT_INTERNAL)
#define IS_BOX_INT(p)    (p->internal_type == BOX_INT     )
#define IS_BOX_NUM(p)    (p->internal_type == BOX_NUM     )
#define IS_BOX_STR(p)    (p->internal_type == BOX_STR     )
#define IS_FILE_BLOCK(p) (p->internal_type == FILE_BLOCK  )
#define IS_CODE_BLOCK(p) (p->internal_type == CODE_BLOCK  )
#define IS_CONST_BLOCK(p)(p->internal_type == CONST_BLOCK )
#define IS_CONTEXT(p)    (p->internal_type == CONTEXT     )
#define IS_LOOKUP(p)     (p->internal_type == LOOKUP      )
#define IS_C_METHOD(p)   (p->internal_type == C_METHOD    )

#define IS_CODE(p)       (p->internal_type == CODE_BLOCK   \
                       || p->internal_type == C_METHOD    )

#define IS_CALLABLE(p)   (p->internal_type == CODE_BLOCK   \
                       || p->internal_type == C_METHOD     \
                       || p->internal_type == CONTEXT     )

#define IS_CTX(p)        (p->internal_type == LOOKUP       \
                       || p->internal_type == CONTEXT     )

#define IS_BOXED(p)      (p->internal_type == BOX_INT      \
                       || p->internal_type == BOX_NUM      \
                       || p->internal_type == BOX_STR     )


// Internal PMCs

struct lorito_box_str_t
{
  struct lorito_pmc_t pmc;
  struct lorito_str_t *data;<commit_msg>Add DATA_BLOCK constant and macros.<commit_after>// This contains all the structures for lorito

#ifndef LORITO_LORITO_H_GUARD
#define LORITO_LORITO_H_GUARD

#include "config.h"

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>

struct lorito_interp_t;
struct lorito_opcode_t;
struct lorito_reg_t;
struct lorito_pmc_t;

struct lorito_str_t;
struct lorito_file_t;
struct lorito_codeseg_t;
struct lorito_constseg_t;
struct lorito_ctx_t;
struct lorito_c_method_t;

struct lorito_interp_t
{
  struct lorito_ctx_t* ctx;
  int next_fileid;

  unsigned short magic;

  // Files
  int allocated_file;
  struct lorito_file_t **files;
  //
  struct lorito_codeseg_t *last_seg;

  //Intern Strings (Symbols)
  int symbol_len;
  struct lorito_str_t **symbols;

  // Special PMCs
  struct lorito_pmc_t *default_lookup;
  struct lorito_pmc_t *null_pmc;

  // Errors
  struct lorito_str_t *last_error;
};
typedef struct lorito_interp_t Lorito_Interp;

struct lorito_opcode_t
{
  unsigned char opcode;
  unsigned char dest;
  unsigned char src1;
  unsigned char src2;
  union
  {
    int immediate;
    int jumploc;
    int offset;
  };
};
typedef struct lorito_opcode_t Lorito_Opcode;

struct lorito_reg_t
{
  int regs_i[REGNUM];
  double regs_n[REGNUM];
  struct lorito_str_t *regs_s[REGNUM];
  struct lorito_pmc_t *regs_p[REGNUM];
};
typedef struct lorito_reg_t Lorito_Reg;

struct lorito_str_t
{
  int length;
  const char *original;
};
typedef struct lorito_str_t Lorito_Str;

// The enum of internal PMCs
enum INTERNAL_PMC_ENUM {
  NOT_INTERNAL = 0,

  BOX_INT      = 1,
  BOX_NUM      = 2,
  BOX_STR      = 3,

  FILE_BLOCK   = 4,
  CODE_BLOCK   = 5,
  CONST_BLOCK  = 6,
  DATA_BLOCK   = 7,
 
  CONTEXT      = 8,
  LOOKUP       = 9,
  C_METHOD     = 10
};
typedef enum INTERNAL_PMC_ENUM Lorito_Internal;

struct lorito_pmc_t
{
  unsigned short magic;  // Magic identifier, changes per interp.
  Lorito_Internal internal_type;

  int size;
  unsigned char *data;

  int ptr_count;
  int ptr_last;
  struct lorito_pmc_t *ptrs;

  // Lookup method
  struct lorito_pmc_t *lookup;
  // VTable PMC for lookup
  struct lorito_pmc_t *vtable;

  // The data for the internal types
  /*
  union {
    int boxed_int;
    double boxed_num;
    struct lorito_str_t *boxed_str;
    struct lorito_file_t *file;
    struct lorito_codeseg_t *code;
    struct lorito_constseg_t *const;
    struct lorito_ctx_t *ctx;
  };
  */
};
typedef struct lorito_pmc_t Lorito_PMC;

// Macros for Internal PMCs.
#define IS_INTERNAL(p)   (p->internal_type != NOT_INTERNAL)
#define IS_BOX_INT(p)    (p->internal_type == BOX_INT     )
#define IS_BOX_NUM(p)    (p->internal_type == BOX_NUM     )
#define IS_BOX_STR(p)    (p->internal_type == BOX_STR     )
#define IS_FILE_BLOCK(p) (p->internal_type == FILE_BLOCK  )
#define IS_CODE_BLOCK(p) (p->internal_type == CODE_BLOCK  )
#define IS_CONST_BLOCK(p)(p->internal_type == CONST_BLOCK )
#define IS_DATA_BLOCK(p) (p->internal_type == DATA_BLOCK )
#define IS_CONTEXT(p)    (p->internal_type == CONTEXT     )
#define IS_LOOKUP(p)     (p->internal_type == LOOKUP      )
#define IS_C_METHOD(p)   (p->internal_type == C_METHOD    )

#define IS_CODE(p)       (p->internal_type == CODE_BLOCK   \
                       || p->internal_type == C_METHOD    )

#define IS_CALLABLE(p)   (p->internal_type == CODE_BLOCK   \
                       || p->internal_type == C_METHOD     \
                       || p->internal_type == CONTEXT     )

#define IS_CTX(p)        (p->internal_type == LOOKUP       \
                       || p->internal_type == CONTEXT     )

#define IS_BOXED(p)      (p->internal_type == BOX_INT      \
                       || p->internal_type == BOX_NUM      \
                       || p->internal_type == BOX_STR     )


// Internal PMCs

struct lorito_box_str_t
{
  struct lorito_pmc_t pmc;
  struct lorito_str_t *data;
{'fraction_non_alphanumeric': 0.09690374400829123, 'fraction_numerical': 0.0033683119575074493, 'mean_word_length': 3.0998406797663303, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 56, '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': '1099217', 'n_tokens_mistral': 3099, 'n_tokens_neox': 2992, 'n_words': 647}