Remove uneeded int2big property for Universal Parser
[ruby.git] / universal_parser.c
blobfa3520eaeba6798fea52b37c644a8c41ba41436b
1 #include <alloca.h>
2 #include <string.h>
3 #include <stdarg.h>
4 #include <stdbool.h>
5 #include <stddef.h>
7 /* Dependency */
8 #include "internal/parse.h"
9 #include "node.h"
10 #include "id.h"
12 #include "internal/compilers.h"
13 #include "ruby/backward/2/inttypes.h"
14 #include "probes.h"
16 #define LIKELY(x) RB_LIKELY(x)
17 #define UNLIKELY(x) RB_UNLIKELY(x)
18 #ifndef TRUE
19 # define TRUE 1
20 #endif
22 #ifndef FALSE
23 # define FALSE 0
24 #endif
25 #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
26 #define rb_strlen_lit(str) (sizeof(str "") - 1)
27 #undef FIXNUM_MAX
28 #define FIXNUM_MAX (LONG_MAX / 2)
29 #undef RSTRING_GETMEM
30 #define RSTRING_GETMEM(str, ptrvar, lenvar) \
31 ((ptrvar) = RSTRING_PTR(str), \
32 (lenvar) = RSTRING_LEN(str))
33 #if defined(USE_FLONUM)
34 # /* Take that. */
35 #elif SIZEOF_VALUE >= SIZEOF_DOUBLE
36 # define USE_FLONUM 1
37 #else
38 # define USE_FLONUM 0
39 #endif
41 /* parser_st */
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
52 #undef st_free_table
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
56 #undef st_insert
57 #define st_insert rb_parser_st_insert
58 #undef st_foreach
59 #define st_foreach rb_parser_st_foreach
60 #undef st_delete
61 #define st_delete rb_parser_st_delete
62 #undef st_is_member
63 #define st_is_member parser_st_is_member
65 #define rb_encoding void
67 #undef T_FLOAT
68 #define T_FLOAT 0x04
69 #undef T_REGEXP
70 #define T_REGEXP 0x06
71 #undef T_HASH
72 #define T_HASH 0x08
73 #undef T_BIGNUM
74 #define T_BIGNUM 0x0a
75 #undef T_COMPLEX
76 #define T_COMPLEX 0x0e
77 #undef T_RATIONAL
78 #define T_RATIONAL 0x0f
80 struct rb_imemo_tmpbuf_struct {
81 VALUE flags;
82 VALUE reserved;
83 VALUE *ptr; /* malloc'ed buffer */
84 struct rb_imemo_tmpbuf_struct *next; /* next imemo */
85 size_t cnt; /* buffer size in VALUE */
88 #undef xmalloc
89 #define xmalloc p->config->malloc
90 #undef xcalloc
91 #define xcalloc p->config->calloc
92 #undef xrealloc
93 #define xrealloc p->config->realloc
94 #undef ALLOC_N
95 #define ALLOC_N(type,n) ((type *)p->config->alloc_n((n), sizeof(type)))
96 #undef ALLOC
97 #define ALLOC(type) ((type *)p->config->alloc(sizeof(type)))
98 #undef xfree
99 #define xfree p->config->free
100 #undef ALLOCA_N
101 // alloca(rbimpl_size_mul_or_raise(x, y));
102 #define ALLOCA_N(type,n) ((type *)alloca(sizeof(type) * (n)))
103 #undef REALLOC_N
104 #define REALLOC_N(var,type,n) ((var) = (type *)p->config->realloc_n((void *)var, n, sizeof(type)))
105 #undef ZALLOC
106 #define ZALLOC(type) ((type *)p->config->zalloc(sizeof(type)))
107 #undef MEMMOVE
108 #define MEMMOVE(p1,p2,type,n) (p->config->rb_memmove((p1), (p2), sizeof(type), (n)))
109 #undef MEMCPY
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
125 #undef RB_OBJ_FROZEN
126 #define RB_OBJ_FROZEN p->config->obj_frozen
127 #undef RB_TYPE_P
128 #define RB_TYPE_P p->config->type_p
129 #undef OBJ_FREEZE_RAW
130 #define OBJ_FREEZE_RAW p->config->obj_freeze_raw
132 #undef FIXNUM_P
133 #define FIXNUM_P p->config->fixnum_p
134 #undef SYMBOL_P
135 #define SYMBOL_P p->config->symbol_p
137 #define rb_attr_get p->config->attr_get
139 #define rb_ary_new p->config->ary_new
140 #define rb_ary_push p->config->ary_push
141 #undef rb_ary_new_from_args
142 #define rb_ary_new_from_args p->config->ary_new_from_args
143 #define rb_ary_pop p->config->ary_pop
144 #define rb_ary_last p->config->ary_last
145 #define rb_ary_unshift p->config->ary_unshift
146 #undef rb_ary_new2
147 #define rb_ary_new2 p->config->ary_new2
148 #define rb_ary_entry p->config->ary_entry
149 #define rb_ary_join p->config->ary_join
150 #define rb_ary_reverse p->config->ary_reverse
151 #define rb_ary_clear p->config->ary_clear
152 #undef RARRAY_LEN
153 #define RARRAY_LEN p->config->array_len
154 #define RARRAY_AREF p->config->array_aref
156 #undef rb_sym_intern_ascii_cstr
157 #define rb_sym_intern_ascii_cstr p->config->sym_intern_ascii_cstr
158 #define rb_make_temporary_id p->config->make_temporary_id
159 #define is_local_id p->config->is_local_id
160 #define is_attrset_id p->config->is_attrset_id
161 #define is_global_name_punct p->config->is_global_name_punct
162 #define id_type p->config->id_type
163 #define rb_id_attrset p->config->id_attrset
164 #undef rb_intern
165 #define rb_intern p->config->intern
166 #define rb_intern2 p->config->intern2
167 #define rb_intern3 p->config->intern3
168 #define rb_intern_str p->config->intern_str
169 #define is_notop_id p->config->is_notop_id
170 #define rb_enc_symname_type p->config->enc_symname_type
171 #define rb_str_intern p->config->str_intern
172 #define rb_id2name p->config->id2name
173 #define rb_id2str p->config->id2str
174 #define rb_id2sym p->config->id2sym
175 #undef ID2SYM
176 #define ID2SYM p->config->id2sym
177 #undef SYM2ID
178 #define SYM2ID p->config->sym2id
180 #define rb_str_catf p->config->str_catf
181 #undef rb_str_cat_cstr
182 #define rb_str_cat_cstr p->config->str_cat_cstr
183 #define rb_str_subseq p->config->str_subseq
184 #define rb_str_dup p->config->str_dup
185 #define rb_str_new_frozen p->config->str_new_frozen
186 #define rb_str_buf_new p->config->str_buf_new
187 #undef rb_str_buf_cat
188 #define rb_str_buf_cat p->config->str_buf_cat
189 #define rb_str_modify p->config->str_modify
190 #define rb_str_set_len p->config->str_set_len
191 #define rb_str_cat p->config->str_cat
192 #define rb_str_resize p->config->str_resize
193 #undef rb_str_new
194 #define rb_str_new p->config->str_new
195 #undef rb_str_new_cstr
196 #define rb_str_new_cstr p->config->str_new_cstr
197 #define rb_fstring p->config->fstring
198 #define is_ascii_string p->config->is_ascii_string
199 #define rb_enc_str_new p->config->enc_str_new
200 #define rb_enc_str_buf_cat p->config->enc_str_buf_cat
201 #define rb_str_buf_append p->config->str_buf_append
202 #define rb_str_vcatf p->config->str_vcatf
203 #undef StringValueCStr
204 #define StringValueCStr(v) p->config->string_value_cstr(&(v))
205 #define rb_sprintf p->config->rb_sprintf
206 #undef RSTRING_PTR
207 #define RSTRING_PTR p->config->rstring_ptr
208 #undef RSTRING_END
209 #define RSTRING_END p->config->rstring_end
210 #undef RSTRING_LEN
211 #define RSTRING_LEN p->config->rstring_len
212 #define rb_filesystem_str_new_cstr p->config->filesystem_str_new_cstr
213 #define rb_obj_as_string p->config->obj_as_string
215 #define rb_hash_clear p->config->hash_clear
216 #define rb_hash_new p->config->hash_new
217 #define rb_hash_aset p->config->hash_aset
218 #define rb_hash_lookup p->config->hash_lookup
219 #define rb_ident_hash_new p->config->ident_hash_new
221 #undef INT2FIX
222 #define INT2FIX p->config->int2fix
223 #undef LONG2FIX
224 #define LONG2FIX p->config->int2fix
226 #define bignum_negate p->config->bignum_negate
227 #define rb_big_norm p->config->big_norm
228 #define rb_cstr_to_inum p->config->cstr_to_inum
230 #define rb_float_new p->config->float_new
231 #undef RFLOAT_VALUE
232 #define RFLOAT_VALUE p->config->float_value
233 #undef DBL2NUM
234 #define DBL2NUM p->config->float_new
236 #define rb_fix2int p->config->fix2int
237 #undef NUM2INT
238 #define NUM2INT p->config->num2int
239 #define rb_int_positive_pow p->config->int_positive_pow
240 #undef INT2NUM
241 #define INT2NUM p->config->int2num
242 #undef FIX2LONG
243 #define FIX2LONG p->config->fix2long
245 #define rb_rational_new p->config->rational_new
246 #define rb_rational_raw p->config->rational_raw
247 #undef rb_rational_raw1
248 #define rb_rational_raw1 p->config->rational_raw1
249 #define rational_set_num p->config->rational_set_num
250 #define rational_get_num p->config->rational_get_num