8 #include "internal/parse.h"
12 #include "internal/compilers.h"
13 #include "ruby/backward/2/inttypes.h"
16 #define LIKELY(x) RB_LIKELY(x)
17 #define UNLIKELY(x) RB_UNLIKELY(x)
25 #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
26 #define rb_strlen_lit(str) (sizeof(str "") - 1)
28 #define FIXNUM_MAX (LONG_MAX / 2)
30 #define RSTRING_GETMEM(str, ptrvar, lenvar) \
31 ((ptrvar) = RSTRING_PTR(str), \
32 (lenvar) = RSTRING_LEN(str))
33 #if defined(USE_FLONUM)
35 #elif SIZEOF_VALUE >= SIZEOF_DOUBLE
42 #define st_table parser_st_table
43 #define st_data_t parser_st_data_t
44 #define st_hash_type parser_st_hash_type
45 #define ST_CONTINUE ST2_CONTINUE
46 #define ST_STOP ST2_STOP
47 #define ST_DELETE ST2_DELETE
48 #define ST_CHECK ST2_CHECK
49 #define ST_REPLACE ST2_REPLACE
50 #undef st_init_numtable
51 #define st_init_numtable rb_parser_st_init_numtable
53 #define st_free_table rb_parser_st_free_table
54 #undef st_init_table_with_size
55 #define st_init_table_with_size rb_parser_st_init_table_with_size
57 #define st_insert rb_parser_st_insert
59 #define st_foreach rb_parser_st_foreach
61 #define st_delete rb_parser_st_delete
63 #define st_is_member parser_st_is_member
65 #define rb_encoding void
76 #define T_COMPLEX 0x0e
78 #define T_RATIONAL 0x0f
80 struct rb_imemo_tmpbuf_struct
{
83 VALUE
*ptr
; /* malloc'ed buffer */
84 struct rb_imemo_tmpbuf_struct
*next
; /* next imemo */
85 size_t cnt
; /* buffer size in VALUE */
89 #define xmalloc p->config->malloc
91 #define xcalloc p->config->calloc
93 #define xrealloc p->config->realloc
95 #define ALLOC_N(type,n) ((type *)p->config->alloc_n((n), sizeof(type)))
97 #define ALLOC(type) ((type *)p->config->alloc(sizeof(type)))
99 #define xfree p->config->free
101 // alloca(rbimpl_size_mul_or_raise(x, y));
102 #define ALLOCA_N(type,n) ((type *)alloca(sizeof(type) * (n)))
104 #define REALLOC_N(var,type,n) ((var) = (type *)p->config->realloc_n((void *)var, n, sizeof(type)))
106 #define ZALLOC(type) ((type *)p->config->zalloc(sizeof(type)))
108 #define MEMMOVE(p1,p2,type,n) (p->config->rb_memmove((p1), (p2), sizeof(type), (n)))
110 #define MEMCPY(p1,p2,type,n) (p->config->nonempty_memcpy((p1), (p2), sizeof(type), (n)))
112 #define new_strterm p->config->new_strterm
113 #define strterm_is_heredoc p->config->strterm_is_heredoc
114 #define rb_imemo_tmpbuf_auto_free_pointer p->config->tmpbuf_auto_free_pointer
115 #define rb_imemo_tmpbuf_set_ptr p->config->tmpbuf_set_ptr
116 #define rb_imemo_tmpbuf_parser_heap p->config->tmpbuf_parser_heap
118 #define compile_callback p->config->compile_callback
119 #define reg_named_capture_assign p->config->reg_named_capture_assign
120 #define script_lines_defined p->config->script_lines_defined
121 #define script_lines_get p->config->script_lines_get
123 #define rb_obj_freeze p->config->obj_freeze
124 #define rb_obj_hide p->config->obj_hide
126 #define RB_OBJ_FROZEN p->config->obj_frozen
128 #define RB_TYPE_P p->config->type_p
129 #undef OBJ_FREEZE_RAW
130 #define OBJ_FREEZE_RAW p->config->obj_freeze_raw