1#ifndef INTERNAL_IMEMO_H
2#define INTERNAL_IMEMO_H
11#include "ruby/internal/config.h"
13#include "internal/array.h"
17#define IMEMO_MASK 0x0f
20#define IMEMO_FL_USHIFT (FL_USHIFT + 4)
21#define IMEMO_FL_USER0 FL_USER4
22#define IMEMO_FL_USER1 FL_USER5
23#define IMEMO_FL_USER2 FL_USER6
24#define IMEMO_FL_USER3 FL_USER7
25#define IMEMO_FL_USER4 FL_USER8
26#define IMEMO_FL_USER5 FL_USER9
39 imemo_parser_strterm = 10,
42 imemo_constcache = 13,
60 const VALUE throw_obj;
65#define THROW_DATA_CONSUMED IMEMO_FL_USER0
70#if SIZEOF_INT * 2 > SIZEOF_VALUE
91#define IFUNC_YIELD_OPTIMIZABLE IMEMO_FL_USER0
118#define IMEMO_NEW(T, type, v0) ((T *)rb_imemo_new((type), (v0), sizeof(T)))
122#define THROW_DATA_P(err) imemo_throw_data_p((VALUE)err)
123#define MEMO_CAST(m) ((struct MEMO *)(m))
124#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
125#define NEW_MEMO_FOR(type, value) \
126 ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), MEMO_FOR(type, value))
127#define NEW_PARTIAL_MEMO_FOR(type, value, member) \
128 ((value) = rb_ary_hidden_new_fill(type_roomof(type, VALUE)), \
129 rb_ary_set_len((value), offsetof(type, member) / sizeof(VALUE)), \
130 MEMO_FOR(type, value))
132#ifndef RUBY_RUBYPARSER_H
137static inline enum imemo_type imemo_type(
VALUE imemo);
138static inline int imemo_type_p(
VALUE imemo,
enum imemo_type imemo_type);
139static inline bool imemo_throw_data_p(
VALUE imemo);
141static inline VALUE rb_imemo_tmpbuf_auto_free_pointer(
void);
142static inline void *RB_IMEMO_TMPBUF_PTR(
VALUE v);
143static inline void *rb_imemo_tmpbuf_set_ptr(
VALUE v,
void *ptr);
144static inline VALUE rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(
VALUE str);
145static inline void MEMO_V1_SET(
struct MEMO *m,
VALUE v);
146static inline void MEMO_V2_SET(
struct MEMO *m,
VALUE v);
148size_t rb_imemo_memsize(
VALUE obj);
149void rb_cc_table_mark(
VALUE klass);
150void rb_imemo_mark_and_move(
VALUE obj,
bool reference_updating);
151void rb_cc_table_free(
VALUE klass);
152void rb_imemo_free(
VALUE obj);
154RUBY_SYMBOL_EXPORT_BEGIN
156const char *rb_imemo_name(
enum imemo_type
type);
157RUBY_SYMBOL_EXPORT_END
159static inline struct MEMO *
162 struct MEMO *memo = IMEMO_NEW(
struct MEMO, imemo_memo, 0);
163 *((
VALUE *)&memo->v1) = a;
164 *((
VALUE *)&memo->v2) = b;
165 *((
VALUE *)&memo->u3.value) = c;
170static inline enum imemo_type
171imemo_type(
VALUE imemo)
177imemo_type_p(
VALUE imemo,
enum imemo_type imemo_type)
184 return expected_type == (
RBASIC(imemo)->flags & mask);
191#define IMEMO_TYPE_P(v, t) imemo_type_p((VALUE)(v), t)
194imemo_throw_data_p(
VALUE imemo)
206rb_imemo_tmpbuf_auto_free_pointer(
void)
212RB_IMEMO_TMPBUF_PTR(
VALUE v)
219rb_imemo_tmpbuf_set_ptr(
VALUE v,
void *ptr)
225rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(
VALUE str)
235 imemo = rb_imemo_tmpbuf_auto_free_pointer();
237 len = RSTRING_LEN(str);
238 src = RSTRING_PTR(str);
239 dst = ruby_xmalloc(
len);
240 memcpy(dst, src,
len);
#define T_IMEMO
Old name of RUBY_T_IMEMO.
#define FL_USHIFT
Old name of RUBY_FL_USHIFT.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
#define UNLIMITED_ARGUMENTS
This macro is used in conjunction with rb_check_arity().
int len
Length of the buffer.
rb_block_call_func * rb_block_call_func_t
Shorthand type that represents an iterator-written-in-C function pointer.
VALUE type(ANYARGS)
ANYARGS-ed function type.
#define RBASIC(obj)
Convenient casting macro.
#define StringValue(v)
Ensures that the parameter object is a String.
static bool RB_SPECIAL_CONST_P(VALUE obj)
Checks if the given object is of enum ruby_special_consts.
IFUNC (Internal FUNCtion)
const VALUE cref_or_me
class reference or rb_method_entry_t
#define SIZEOF_VALUE
Identical to sizeof(VALUE), except it is a macro that can also be used inside of preprocessor directi...
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.
@ RUBY_T_MASK
Bitmask of ruby_value_type.