1#ifndef RUBY_EVAL_INTERN_H
2#define RUBY_EVAL_INTERN_H
10 vm_block_handler_verify(block_handler);
11 ec->passed_block_handler = block_handler;
17 VALUE block_handler = rb_vm_frame_block_handler(ec->cfp);
18 vm_passed_block_handler_set(ec, block_handler);
19 VM_ENV_FLAGS_SET(ec->cfp->ep, VM_FRAME_FLAG_PASSED);
22#define PASS_PASSED_BLOCK_HANDLER_EC(ec) pass_passed_block_handler(ec)
23#define PASS_PASSED_BLOCK_HANDLER() pass_passed_block_handler(GET_EC())
36#if defined(__wasm__) && !defined(__EMSCRIPTEN__)
37# include "wasm/setjmp.h"
43# ifdef HAVE_CRT_EXTERNS_H
44# include <crt_externs.h>
46# include "missing/crt_externs.h"
51char *strrchr(
const char *,
const char);
58#ifdef HAVE_NET_SOCKET_H
59#include <net/socket.h>
62#define ruby_setjmp(env) RUBY_SETJMP(env)
63#define ruby_longjmp(env,val) RUBY_LONGJMP((env),(val))
69NORETURN(
void _longjmp(
jmp_buf,
int));
77#ifdef HAVE_SYS_SELECT_H
78#include <sys/select.h>
87#ifdef HAVE_SELECT_LARGE_FDSET
88#define select(n, r, w, e, t) select_large_fdset((n), (r), (w), (e), (t))
89extern int select_large_fdset(
int, fd_set *, fd_set *, fd_set *,
struct timeval *);
92#ifdef HAVE_SYS_PARAM_H
98#define EC_PUSH_TAG(ec) do { \
99 rb_execution_context_t * const _ec = (ec); \
100 struct rb_vm_tag _tag; \
101 _tag.state = TAG_NONE; \
103 _tag.prev = _ec->tag; \
104 _tag.lock_rec = rb_ec_vm_lock_rec(_ec); \
105 rb_vm_tag_jmpbuf_init(&_tag.buf); \
107#define EC_POP_TAG() \
108 _ec->tag = _tag.prev; \
109 rb_vm_tag_jmpbuf_deinit(&_tag.buf); \
112#define EC_TMPPOP_TAG() \
115#define EC_REPUSH_TAG() (void)(_ec->tag = &_tag)
117#if defined __GNUC__ && __GNUC__ == 4 && (__GNUC_MINOR__ >= 6 && __GNUC_MINOR__ <= 8) || defined __clang__
122# define VAR_FROM_MEMORY(var) __extension__(*(__typeof__(var) volatile *)&(var))
123# define VAR_INITIALIZED(var) ((var) = VAR_FROM_MEMORY(var))
124# define VAR_NOCLOBBERED(var) volatile var
126# define VAR_FROM_MEMORY(var) (var)
127# define VAR_INITIALIZED(var) ((void)&(var))
128# define VAR_NOCLOBBERED(var) var
134 unsigned int current_lock_rec = rb_ec_vm_lock_rec(ec);
135 if (current_lock_rec != recorded_lock_rec) {
136 rb_ec_vm_lock_rec_release(ec, recorded_lock_rec, current_lock_rec);
145 enum ruby_tag_type state = tag->state;
146 tag->state = TAG_NONE;
147 rb_ec_vm_lock_rec_check(ec, tag->lock_rec);
157 RUBY_ASSERT(st > TAG_NONE && st <= TAG_FATAL,
": Invalid tag jump: %d", (
int)st);
159 ruby_longjmp(RB_VM_TAG_JMPBUF_GET(ec->tag->buf), 1);
166#define EC_EXEC_TAG() \
167 (UNLIKELY(ruby_setjmp(RB_VM_TAG_JMPBUF_GET(_tag.buf))) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
169#define EC_JUMP_TAG(ec, st) rb_ec_tag_jump(ec, st)
171#define INTERNAL_EXCEPTION_P(exc) FIXNUM_P(exc)
175#define CREF_FL_PUSHED_BY_EVAL IMEMO_FL_USER1
176#define CREF_FL_OMOD_SHARED IMEMO_FL_USER2
177#define CREF_FL_SINGLETON IMEMO_FL_USER3
179static inline int CREF_SINGLETON(
const rb_cref_t *cref);
184 if (CREF_SINGLETON(cref)) {
185 return CLASS_OF(cref->klass_or_self);
188 return cref->klass_or_self;
193CREF_CLASS_FOR_DEFINITION(
const rb_cref_t *cref)
195 if (CREF_SINGLETON(cref)) {
199 return cref->klass_or_self;
212 return &cref->scope_visi;
218 return cref->refinements;
228CREF_PUSHED_BY_EVAL(
const rb_cref_t *cref)
230 return cref->flags & CREF_FL_PUSHED_BY_EVAL;
236 cref->flags |= CREF_FL_PUSHED_BY_EVAL;
242 return cref->flags & CREF_FL_SINGLETON;
248 cref->flags |= CREF_FL_SINGLETON;
254 return cref->flags & CREF_FL_OMOD_SHARED;
260 cref->flags |= CREF_FL_OMOD_SHARED;
266 cref->flags &= ~CREF_FL_OMOD_SHARED;
270 RAISED_EXCEPTION = 1,
271 RAISED_STACKOVERFLOW = 2,
274#define rb_ec_raised_set(ec, f) ((ec)->raised_flag |= (f))
275#define rb_ec_raised_reset(ec, f) ((ec)->raised_flag &= ~(f))
276#define rb_ec_raised_p(ec, f) (((ec)->raised_flag & (f)) != 0)
277#define rb_ec_raised_clear(ec) ((ec)->raised_flag = 0)
283VALUE rb_make_exception(
int argc,
const VALUE *argv);
285NORETURN(
void rb_method_name_error(
VALUE,
VALUE));
289NORETURN(
void rb_print_undef(
VALUE,
ID, rb_method_visibility_t));
290NORETURN(
void rb_print_undef_str(
VALUE,
VALUE));
291NORETURN(
void rb_print_inaccessible(
VALUE,
ID, rb_method_visibility_t));
292NORETURN(
void rb_vm_localjump_error(
const char *,
VALUE,
int));
293NORETURN(
void rb_vm_jump_tag_but_local_jump(
enum ruby_tag_type));
295VALUE rb_vm_make_jump_tag_but_local_jump(
enum ruby_tag_type state,
VALUE val);
297rb_cref_t *rb_vm_cref_replace_with_duplicated_cref(
void);
299void rb_vm_set_progname(
VALUE filename);
300VALUE rb_vm_cbase(
void);
309# define CharNext(p) rb_char_next(p)
311rb_char_next(
const char *p)
314 int len = mblen(p, RUBY_MBCHAR_MAXSIZE);
320# define CharNext(p) ((p) + 1)
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
VALUE rb_singleton_class(VALUE obj)
Finds or creates the singleton class of the passed object.
#define CLASS_OF
Old name of rb_class_of.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
int len
Length of the buffer.
#define RBIMPL_ASSUME(_)
Wraps (or simulates) __builtin_unreachable.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.