w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dump.c File Reference
#include <string.h>
#include <limits.h>
#include <math.h>
#include <mruby/dump.h>
#include <mruby/irep.h>
#include <mruby/debug.h>
#include <mruby/endian.h>
Include dependency graph for dump.c:

Go to the source code of this file.

Classes

struct  operator_symbol
 

Macros

#define MRB_FLOAT_FMT   "%.17g"
 
#define OPERATOR_SYMBOL(sym_name, name)   {name, sym_name, sizeof(sym_name)-1}
 

Functions

static size_t get_irep_record_size_1 (mrb_state *mrb, const mrb_irep *irep)
 
static size_t get_irep_header_size (mrb_state *mrb)
 
static ptrdiff_t write_irep_header (mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
 
static size_t get_iseq_block_size (mrb_state *mrb, const mrb_irep *irep)
 
static ptrdiff_t write_iseq_block (mrb_state *mrb, const mrb_irep *irep, uint8_t *buf, uint8_t flags)
 
static void dump_float (mrb_state *mrb, uint8_t *buf, mrb_float f)
 
static size_t get_pool_block_size (mrb_state *mrb, const mrb_irep *irep)
 
static ptrdiff_t write_pool_block (mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
 
static size_t get_syms_block_size (mrb_state *mrb, const mrb_irep *irep)
 
static ptrdiff_t write_syms_block (mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
 
static size_t get_irep_record_size (mrb_state *mrb, const mrb_irep *irep)
 
static int write_irep_record (mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, size_t *irep_record_size, uint8_t flags)
 
static uint32_t write_footer (mrb_state *mrb, uint8_t *bin)
 
static int write_section_irep_header (mrb_state *mrb, size_t section_size, uint8_t *bin)
 
static int write_section_irep (mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, size_t *len_p, uint8_t flags)
 
static size_t get_debug_record_size (mrb_state *mrb, const mrb_irep *irep)
 
static int find_filename_index (const mrb_sym *ary, int ary_len, mrb_sym s)
 
static size_t get_filename_table_size (mrb_state *mrb, const mrb_irep *irep, mrb_sym **fp, uint16_t *lp)
 
static size_t write_debug_record_1 (mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, mrb_sym const *filenames, uint16_t filenames_len)
 
static size_t write_debug_record (mrb_state *mrb, const mrb_irep *irep, uint8_t *bin, mrb_sym const *filenames, uint16_t filenames_len)
 
static int write_section_debug (mrb_state *mrb, const mrb_irep *irep, uint8_t *cur, mrb_sym const *filenames, uint16_t filenames_len)
 
static void create_lv_sym_table (mrb_state *mrb, const mrb_irep *irep, mrb_sym **syms, uint32_t *syms_len)
 
static int write_lv_sym_table (mrb_state *mrb, uint8_t **start, mrb_sym const *syms, uint32_t syms_len)
 
static int write_lv_record (mrb_state *mrb, const mrb_irep *irep, uint8_t **start, mrb_sym const *syms, uint32_t syms_len)
 
static size_t get_lv_record_size (mrb_state *mrb, const mrb_irep *irep)
 
static size_t get_lv_section_size (mrb_state *mrb, const mrb_irep *irep, mrb_sym const *syms, uint32_t syms_len)
 
static int write_section_lv (mrb_state *mrb, const mrb_irep *irep, uint8_t *start, mrb_sym const *syms, uint32_t const syms_len)
 
static int write_rite_binary_header (mrb_state *mrb, size_t binary_size, uint8_t *bin, uint8_t flags)
 
static mrb_bool debug_info_defined_p (const mrb_irep *irep)
 
static mrb_bool lv_defined_p (const mrb_irep *irep)
 
static int dump_irep (mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
 
int mrb_dump_irep (mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size)
 
int mrb_dump_irep_binary (mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp)
 
int mrb_dump_irep_cfunc (mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname)
 
static int dump_pool (mrb_state *mrb, const mrb_pool_value *p, FILE *fp)
 
static mrb_bool sym_name_word_p (const char *name, mrb_int len)
 
static mrb_bool sym_name_with_equal_p (const char *name, mrb_int len)
 
static mrb_bool sym_name_with_question_mark_p (const char *name, mrb_int len)
 
static mrb_bool sym_name_with_bang_p (const char *name, mrb_int len)
 
static mrb_bool sym_name_ivar_p (const char *name, mrb_int len)
 
static mrb_bool sym_name_cvar_p (const char *name, mrb_int len)
 
static const char * sym_operator_name (const char *sym_name, mrb_int len)
 
static const char * sym_var_name (mrb_state *mrb, const char *initname, const char *key, int n)
 
static int dump_sym (mrb_state *mrb, mrb_sym sym, const char *var_name, int idx, mrb_value init_syms_code, FILE *fp)
 
static int dump_syms (mrb_state *mrb, const char *name, const char *key, int n, int syms_len, const mrb_sym *syms, mrb_value init_syms_code, FILE *fp)
 
static int dump_irep_struct (mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, const char *name, int n, mrb_value init_syms_code, int *mp)
 
int mrb_dump_irep_cstruct (mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, const char *initname)
 

Variables

static const struct operator_symbol operator_table []
 

Macro Definition Documentation

◆ MRB_FLOAT_FMT

#define MRB_FLOAT_FMT   "%.17g"

Definition at line 17 of file dump.c.

◆ OPERATOR_SYMBOL

#define OPERATOR_SYMBOL (   sym_name,
  name 
)    {name, sym_name, sizeof(sym_name)-1}

Definition at line 26 of file dump.c.

Function Documentation

◆ create_lv_sym_table()

static void create_lv_sym_table ( mrb_state mrb,
const mrb_irep irep,
mrb_sym **  syms,
uint32_t syms_len 
)
static

◆ debug_info_defined_p()

static mrb_bool debug_info_defined_p ( const mrb_irep irep)
static

Definition at line 763 of file dump.c.

References mrb_irep::debug_info, FALSE, i, mrb_irep::reps, mrb_irep::rlen, and TRUE.

Referenced by dump_irep().

◆ dump_float()

static void dump_float ( mrb_state mrb,
uint8_t buf,
mrb_float  f 
)
static

Definition at line 119 of file dump.c.

References buf, f, i, littleendian, memcpy, s, and u.

Referenced by write_pool_block().

◆ dump_irep()

◆ dump_irep_struct()

◆ dump_pool()

static int dump_pool ( mrb_state mrb,
const mrb_pool_value p,
FILE fp 
)
static

◆ dump_sym()

◆ dump_syms()

static int dump_syms ( mrb_state mrb,
const char *  name,
const char *  key,
int  n,
int  syms_len,
const mrb_sym syms,
mrb_value  init_syms_code,
FILE fp 
)
static

◆ find_filename_index()

static int find_filename_index ( const mrb_sym ary,
int  ary_len,
mrb_sym  s 
)
static

Definition at line 451 of file dump.c.

References i, and s.

Referenced by create_lv_sym_table(), get_filename_table_size(), write_debug_record_1(), and write_lv_record().

◆ get_debug_record_size()

◆ get_filename_table_size()

static size_t get_filename_table_size ( mrb_state mrb,
const mrb_irep irep,
mrb_sym **  fp,
uint16_t lp 
)
static

◆ get_irep_header_size()

static size_t get_irep_header_size ( mrb_state mrb)
static

Definition at line 66 of file dump.c.

References size, uint16_t, and uint32_t.

Referenced by get_irep_record_size_1().

◆ get_irep_record_size()

static size_t get_irep_record_size ( mrb_state mrb,
const mrb_irep irep 
)
static

Definition at line 320 of file dump.c.

References get_irep_record_size_1(), mrb_irep::reps, mrb_irep::rlen, and size.

Referenced by dump_irep(), and write_section_irep().

◆ get_irep_record_size_1()

static size_t get_irep_record_size_1 ( mrb_state mrb,
const mrb_irep irep 
)
static

◆ get_iseq_block_size()

static size_t get_iseq_block_size ( mrb_state mrb,
const mrb_irep irep 
)
static

Definition at line 90 of file dump.c.

References mrb_irep::clen, mrb_irep::ilen, size, and uint16_t.

Referenced by get_irep_record_size_1().

◆ get_lv_record_size()

static size_t get_lv_record_size ( mrb_state mrb,
const mrb_irep irep 
)
static

Definition at line 679 of file dump.c.

References i, mrb_irep::nlocals, mrb_irep::reps, ret, mrb_irep::rlen, and uint16_t.

Referenced by get_lv_section_size().

◆ get_lv_section_size()

static size_t get_lv_section_size ( mrb_state mrb,
const mrb_irep irep,
mrb_sym const syms,
uint32_t  syms_len 
)
static

Definition at line 694 of file dump.c.

References get_lv_record_size(), i, mrb_sym_name_len(), ret, str_len(), uint16_t, and uint32_t.

Referenced by dump_irep().

◆ get_pool_block_size()

◆ get_syms_block_size()

static size_t get_syms_block_size ( mrb_state mrb,
const mrb_irep irep 
)
static

Definition at line 260 of file dump.c.

References len, mrb_sym_name_len(), size, mrb_irep::slen, mrb_irep::syms, and uint16_t.

Referenced by get_irep_record_size_1().

◆ lv_defined_p()

static mrb_bool lv_defined_p ( const mrb_irep irep)
static

Definition at line 775 of file dump.c.

References FALSE, i, mrb_irep::lv, mrb_irep::reps, mrb_irep::rlen, and TRUE.

Referenced by dump_irep().

◆ mrb_dump_irep()

int mrb_dump_irep ( mrb_state mrb,
const mrb_irep irep,
uint8_t  flags,
uint8_t **  bin,
size_t bin_size 
)

Definition at line 877 of file dump.c.

References dump_irep(), and flags.

◆ mrb_dump_irep_binary()

int mrb_dump_irep_binary ( mrb_state mrb,
const mrb_irep irep,
uint8_t  flags,
FILE fp 
)

◆ mrb_dump_irep_cfunc()

int mrb_dump_irep_cfunc ( mrb_state mrb,
const mrb_irep irep,
uint8_t  flags,
FILE fp,
const char *  initname 
)

◆ mrb_dump_irep_cstruct()

int mrb_dump_irep_cstruct ( mrb_state mrb,
const mrb_irep irep,
uint8_t  flags,
FILE fp,
const char *  initname 
)

◆ sym_name_cvar_p()

static mrb_bool sym_name_cvar_p ( const char *  name,
mrb_int  len 
)
static

Definition at line 1031 of file dump.c.

References len, name, and sym_name_ivar_p().

Referenced by dump_sym().

◆ sym_name_ivar_p()

static mrb_bool sym_name_ivar_p ( const char *  name,
mrb_int  len 
)
static

Definition at line 1025 of file dump.c.

References len, name, and sym_name_word_p().

Referenced by dump_sym(), and sym_name_cvar_p().

◆ sym_name_with_bang_p()

static mrb_bool sym_name_with_bang_p ( const char *  name,
mrb_int  len 
)
static

Definition at line 1019 of file dump.c.

References len, name, and sym_name_word_p().

Referenced by dump_sym().

◆ sym_name_with_equal_p()

static mrb_bool sym_name_with_equal_p ( const char *  name,
mrb_int  len 
)
static

Definition at line 1007 of file dump.c.

References len, name, and sym_name_word_p().

Referenced by dump_sym().

◆ sym_name_with_question_mark_p()

static mrb_bool sym_name_with_question_mark_p ( const char *  name,
mrb_int  len 
)
static

Definition at line 1013 of file dump.c.

References len, name, and sym_name_word_p().

Referenced by dump_sym().

◆ sym_name_word_p()

static mrb_bool sym_name_word_p ( const char *  name,
mrb_int  len 
)
static

◆ sym_operator_name()

static const char* sym_operator_name ( const char *  sym_name,
mrb_int  len 
)
static

◆ sym_var_name()

static const char* sym_var_name ( mrb_state mrb,
const char *  initname,
const char *  key,
int  n 
)
static

Definition at line 1062 of file dump.c.

References buf, key, mrb_str_cat_cstr(), mrb_str_cat_lit, mrb_str_new_cstr(), n, RSTRING_PTR, s, and snprintf.

Referenced by dump_syms().

◆ write_debug_record()

static size_t write_debug_record ( mrb_state mrb,
const mrb_irep irep,
uint8_t bin,
mrb_sym const filenames,
uint16_t  filenames_len 
)
static

◆ write_debug_record_1()

◆ write_footer()

static uint32_t write_footer ( mrb_state mrb,
uint8_t bin 
)
static

◆ write_irep_header()

static ptrdiff_t write_irep_header ( mrb_state mrb,
const mrb_irep irep,
uint8_t buf 
)
static

◆ write_irep_record()

static int write_irep_record ( mrb_state mrb,
const mrb_irep irep,
uint8_t bin,
size_t irep_record_size,
uint8_t  flags 
)
static

◆ write_iseq_block()

static ptrdiff_t write_iseq_block ( mrb_state mrb,
const mrb_irep irep,
uint8_t buf,
uint8_t  flags 
)
static

Definition at line 103 of file dump.c.

References buf, mrb_irep::clen, cur, mrb_irep::ilen, mrb_irep::iseq, memcpy, and uint16_to_bin().

Referenced by write_irep_record().

◆ write_lv_record()

static int write_lv_record ( mrb_state mrb,
const mrb_irep irep,
uint8_t **  start,
mrb_sym const syms,
uint32_t  syms_len 
)
static

◆ write_lv_sym_table()

static int write_lv_sym_table ( mrb_state mrb,
uint8_t **  start,
mrb_sym const syms,
uint32_t  syms_len 
)
static

Definition at line 630 of file dump.c.

References cur, i, memcpy, MRB_DUMP_OK, mrb_sym_name_len(), start, str, str_len(), uint16_to_bin(), and uint32_to_bin().

Referenced by write_section_lv().

◆ write_pool_block()

◆ write_rite_binary_header()

static int write_rite_binary_header ( mrb_state mrb,
size_t  binary_size,
uint8_t bin,
uint8_t  flags 
)
static

◆ write_section_debug()

◆ write_section_irep()

static int write_section_irep ( mrb_state mrb,
const mrb_irep irep,
uint8_t bin,
size_t len_p,
uint8_t  flags 
)
static

◆ write_section_irep_header()

static int write_section_irep_header ( mrb_state mrb,
size_t  section_size,
uint8_t bin 
)
static

◆ write_section_lv()

static int write_section_lv ( mrb_state mrb,
const mrb_irep irep,
uint8_t start,
mrb_sym const syms,
uint32_t const  syms_len 
)
static

◆ write_syms_block()

static ptrdiff_t write_syms_block ( mrb_state mrb,
const mrb_irep irep,
uint8_t buf 
)
static

Variable Documentation

◆ operator_table

const struct operator_symbol operator_table[]
static

Definition at line 20 of file dump.c.

Referenced by sym_operator_name().