Ruby: eval_intern.h File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Macros | Enumerations | Functions
eval_intern.h File Reference
`#include "ruby/ruby.h"`
`#include "vm_core.h"`
`#include <stdio.h>`
`#include <setjmp.h>`
`#include <sys/types.h>`
`#include <signal.h>`
`#include <errno.h>`
`#include <sys/stat.h>`

Go to the source code of this file.

## Macros
#define | PASS_PASSED_BLOCK_HANDLER_EC(ec) pass_passed_block_handler(ec)
#define | PASS_PASSED_BLOCK_HANDLER() pass_passed_block_handler(GET_EC())
#define | EXIT_SUCCESS 0
#define | EXIT_FAILURE 1
#define | ruby_setjmp(env) RUBY_SETJMP(env)
#define | ruby_longjmp(env, val) RUBY_LONGJMP((env),(val))
#define | SAVE_ROOT_JMPBUF_BEFORE_STMT __try {
#define | SAVE_ROOT_JMPBUF_AFTER_STMT
#define | SAVE_ROOT_JMPBUF(th, stmt)
#define | EC_PUSH_TAG(ec)
#define | EC_POP_TAG()
#define | EC_TMPPOP_TAG() _ec->tag = _tag.prev
#define | EC_REPUSH_TAG() (void)(_ec->tag = &_tag)
#define | VAR_FROM_MEMORY(var) __extension__(*(__typeof__(var) volatile *)&(var))
#define | VAR_INITIALIZED(var) ((var) = VAR_FROM_MEMORY(var))
#define | VAR_NOCLOBBERED(var) volatile var
#define | EC_EXEC_TAG() (ruby_setjmp(_tag.buf) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
#define | EC_JUMP_TAG(ec, st) rb_ec_tag_jump(ec, st)
#define | INTERNAL_EXCEPTION_P(exc) FIXNUM_P(exc)
#define | CREF_FL_PUSHED_BY_EVAL IMEMO_FL_USER1
#define | CREF_FL_OMOD_SHARED IMEMO_FL_USER2
#define | rb_ec_raised_set(ec, f) ((ec)->raised_flag |= (f))
#define | rb_ec_raised_reset(ec, f) ((ec)->raised_flag &= ~(f))
#define | rb_ec_raised_p(ec, f) (((ec)->raised_flag & (f)) != 0)
#define | rb_ec_raised_clear(ec) ((ec)->raised_flag = 0)
#define | CharNext(p) ((p) + 1)

## Enumerations
enum | { RAISED_EXCEPTION = 1 , RAISED_STACKOVERFLOW = 2 , RAISED_NOMEMORY = 4 }

## Functions
char * | strrchr (const char *, const char)
int | rb_ec_set_raised (rb_execution_context_t *ec)
int | rb_ec_reset_raised (rb_execution_context_t *ec)
int | rb_ec_stack_check (rb_execution_context_t *ec)
VALUE | rb_f_eval (int argc, const VALUE *argv, VALUE self)
VALUE | rb_make_exception (int argc, const VALUE *argv)
| Make an `Exception` object from the list of arguments in a manner similar to `Kernel#raise`. More...
void | rb_method_name_error (VALUE, VALUE)
void | rb_fiber_start (void)
void | rb_print_undef (VALUE, ID, rb_method_visibility_t)
void | rb_print_undef_str (VALUE, VALUE)
void | rb_print_inaccessible (VALUE, ID, rb_method_visibility_t)
void | rb_vm_localjump_error (const char *, VALUE, int)
void | rb_vm_jump_tag_but_local_jump (int)
VALUE | rb_vm_make_jump_tag_but_local_jump (int state, VALUE val)
rb_cref_t * | rb_vm_cref (void)
rb_cref_t * | rb_vm_cref_replace_with_duplicated_cref (void)
VALUE | rb_vm_call_cfunc (VALUE recv, VALUE(*func)(VALUE), VALUE arg, VALUE block_handler, VALUE filename)
void | rb_vm_set_progname (VALUE filename)
VALUE | rb_vm_cbase (void)
VALUE | rb_ec_backtrace_object (const rb_execution_context_t *ec)
VALUE | rb_ec_backtrace_str_ary (const rb_execution_context_t *ec, long lev, long n)
VALUE | rb_ec_backtrace_location_ary (const rb_execution_context_t *ec, long lev, long n, bool skip_internal)

## Macro Definition Documentation

## ◆ CharNext

#define CharNext | ( |  | p | ) | ((p) + 1)

Definition at line 316 of file eval_intern.h.

## ◆ CREF_FL_OMOD_SHARED

#define CREF_FL_OMOD_SHARED IMEMO_FL_USER2

Definition at line 203 of file eval_intern.h.

## ◆ CREF_FL_PUSHED_BY_EVAL

#define CREF_FL_PUSHED_BY_EVAL IMEMO_FL_USER1

Definition at line 202 of file eval_intern.h.

## ◆ EC_EXEC_TAG

#define EC_EXEC_TAG | ( |  | ) | (ruby_setjmp(_tag.buf) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))

Definition at line 193 of file eval_intern.h.

## ◆ EC_JUMP_TAG

#define EC_JUMP_TAG | ( |  | ec,
|  |  | st
| ) |  | rb_ec_tag_jump(ec, st)

Definition at line 196 of file eval_intern.h.

## ◆ EC_POP_TAG

#define EC_POP_TAG | ( |  | ) |

Value:
_ec->tag = _tag.prev; \
} while (0)

Definition at line 138 of file eval_intern.h.

## ◆ EC_PUSH_TAG

#define EC_PUSH_TAG | ( |  | ec | ) |

Value:
do { \
rb_execution_context_t * const _ec = (ec); \
struct rb_vm_tag _tag; \
_tag.state = TAG_NONE; \
_tag.tag = Qundef; \
_tag.prev = _ec->tag; \
_tag.lock_rec = rb_ec_vm_lock_rec(_ec); \
Qundef
#define Qundef
Definition: special_consts.h:53
rb_execution_context_struct
Definition: vm_core.h:854
rb_execution_context_struct::tag
struct rb_vm_tag * tag
Definition: vm_core.h:860
rb_vm_tag
Definition: vm_core.h:808
rb_vm_tag::state
enum ruby_tag_type state
Definition: vm_core.h:813
rb_vm_tag::lock_rec
unsigned int lock_rec
Definition: vm_core.h:814
TAG_NONE
#define TAG_NONE
Definition: vm_core.h:198

Definition at line 130 of file eval_intern.h.

## ◆ EC_REPUSH_TAG

#define EC_REPUSH_TAG | ( |  | ) | (void)(_ec->tag = &_tag)

Definition at line 145 of file eval_intern.h.

## ◆ EC_TMPPOP_TAG

#define EC_TMPPOP_TAG | ( |  | ) | _ec->tag = _tag.prev

Definition at line 142 of file eval_intern.h.

## ◆ EXIT_FAILURE

#define EXIT_FAILURE 1

Definition at line 32 of file eval_intern.h.

## ◆ EXIT_SUCCESS

#define EXIT_SUCCESS 0

Definition at line 29 of file eval_intern.h.

## ◆ INTERNAL_EXCEPTION_P

#define INTERNAL_EXCEPTION_P | ( |  | exc | ) | FIXNUM_P(exc)

Definition at line 198 of file eval_intern.h.

## ◆ PASS_PASSED_BLOCK_HANDLER

#define PASS_PASSED_BLOCK_HANDLER | ( |  | ) | pass_passed_block_handler(GET_EC())

Definition at line 23 of file eval_intern.h.

## ◆ PASS_PASSED_BLOCK_HANDLER_EC

#define PASS_PASSED_BLOCK_HANDLER_EC | ( |  | ec | ) | pass_passed_block_handler(ec)

Definition at line 22 of file eval_intern.h.

## ◆ rb_ec_raised_clear

#define rb_ec_raised_clear | ( |  | ec | ) | ((ec)->raised_flag = 0)

Definition at line 273 of file eval_intern.h.

## ◆ rb_ec_raised_p

#define rb_ec_raised_p | ( |  | ec,
|  |  | f
| ) |  | (((ec)->raised_flag & (f)) != 0)

Definition at line 272 of file eval_intern.h.

## ◆ rb_ec_raised_reset

#define rb_ec_raised_reset | ( |  | ec,
|  |  | f
| ) |  | ((ec)->raised_flag &= ~(f))

Definition at line 271 of file eval_intern.h.

## ◆ rb_ec_raised_set

#define rb_ec_raised_set | ( |  | ec,
|  |  | f
| ) |  | ((ec)->raised_flag |= (f))

Definition at line 270 of file eval_intern.h.

## ◆ ruby_longjmp

#define ruby_longjmp | ( |  | env,
|  |  | val
| ) |  | RUBY_LONGJMP((env),(val))

Definition at line 59 of file eval_intern.h.

## ◆ ruby_setjmp

#define ruby_setjmp | ( |  | env | ) | RUBY_SETJMP(env)

Definition at line 58 of file eval_intern.h.

## ◆ SAVE_ROOT_JMPBUF

#define SAVE_ROOT_JMPBUF | ( |  | th,
|  |  | stmt
| ) |  |

Value:
do \
if (ruby_setjmp((th)->root_jmpbuf) == 0) { \
SAVE_ROOT_JMPBUF_BEFORE_STMT \
stmt; \
SAVE_ROOT_JMPBUF_AFTER_STMT \
} \
else { \
rb_fiber_start(); \
} while (0)
SAVE_ROOT_JMPBUF_AFTER_STMT
#define SAVE_ROOT_JMPBUF_AFTER_STMT
Definition: eval_intern.h:97
ruby_setjmp
#define ruby_setjmp(env)
Definition: eval_intern.h:58

Definition at line 120 of file eval_intern.h.

## ◆ SAVE_ROOT_JMPBUF_AFTER_STMT

#define SAVE_ROOT_JMPBUF_AFTER_STMT

Value:
} \
__except (GetExceptionCode() == EXCEPTION_STACK_OVERFLOW ? \
(rb_ec_raised_set(GET_EC(), RAISED_STACKOVERFLOW), \
raise(SIGSEGV), \
EXCEPTION_EXECUTE_HANDLER) : \
EXCEPTION_CONTINUE_SEARCH) { \
/* never reaches here */ \
}
rb_ec_raised_set
#define rb_ec_raised_set(ec, f)
Definition: eval_intern.h:270
RAISED_STACKOVERFLOW
@ RAISED_STACKOVERFLOW
Definition: eval_intern.h:267

Definition at line 97 of file eval_intern.h.

## ◆ SAVE_ROOT_JMPBUF_BEFORE_STMT

#define SAVE_ROOT_JMPBUF_BEFORE_STMT __try {

Definition at line 95 of file eval_intern.h.

## ◆ VAR_FROM_MEMORY

#define VAR_FROM_MEMORY | ( |  | var | ) | __extension__(*(__typeof__(var) volatile *)&(var))

Definition at line 152 of file eval_intern.h.

## ◆ VAR_INITIALIZED

#define VAR_INITIALIZED | ( |  | var | ) | ((var) = VAR_FROM_MEMORY(var))

Definition at line 153 of file eval_intern.h.

## ◆ VAR_NOCLOBBERED

#define VAR_NOCLOBBERED | ( |  | var | ) | volatile var

Definition at line 154 of file eval_intern.h.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
RAISED_EXCEPTION |
RAISED_STACKOVERFLOW |
RAISED_NOMEMORY |

Definition at line 265 of file eval_intern.h.

## Function Documentation

## ◆ rb_ec_backtrace_object()

VALUE rb_ec_backtrace_object | ( | const rb_execution_context_t * | ec | ) |

Definition at line 770 of file vm_backtrace.c.

References ALL_BACKTRACE_LINES, BACKTRACE_START, FALSE, and NULL.

## ◆ rb_ec_backtrace_str_ary()

VALUE rb_ec_backtrace_str_ary | ( | const rb_execution_context_t * | ec,
|  | long | lev,
|  | long | n
| ) |  |

Definition at line 892 of file vm_backtrace.c.

References FALSE, and NULL.

Referenced by rb_make_backtrace().

## ◆ rb_ec_reset_raised()

int rb_ec_reset_raised | ( | rb_execution_context_t * | ec | ) |

Definition at line 2597 of file thread.c.

References RAISED_EXCEPTION, and rb_execution_context_struct::raised_flag.

Referenced by rb_suppress_tracing().

## ◆ rb_ec_set_raised()

int rb_ec_set_raised | ( | rb_execution_context_t * | ec | ) |

Definition at line 2587 of file thread.c.

References RAISED_EXCEPTION, and rb_execution_context_struct::raised_flag.

## ◆ rb_ec_stack_check()

int rb_ec_stack_check | ( | rb_execution_context_t * | ec | ) |

Definition at line 5546 of file gc.c.

References stack_check, and STACKFRAME_FOR_CALL_CFUNC.

## ◆ rb_f_eval()

VALUE rb_f_eval | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | self
| ) |  |

Definition at line 1778 of file vm_eval.c.

References argc, argv, NIL_P, NULL, NUM2INT, Qundef, rb_scan_args(), SafeStringValue, and StringValue.

Referenced by Init_vm_eval().

## ◆ rb_fiber_start()

void rb_fiber_start | ( | void |  | ) |

Definition at line 2014 of file cont.c.

References rb_context_struct::argc, argc, argv, rb_fiber_struct::blocking, rb_thread_struct::blocking, rb_thread_struct::ec, EC_EXEC_TAG, EC_POP_TAG, EC_PUSH_TAG, err, rb_execution_context_struct::errinfo, EXEC_EVENT_HOOK, rb_execution_context_struct::fiber_ptr, FIBER_RESUMED_P, rb_fiber_struct::first_proc, GetProcPtr, rb_context_struct::kw_splat, NIL_P, Qfalse, Qnil, RARRAY_CONST_PTR, rb_fiber_start(), rb_threadptr_pending_interrupt_enque(), rb_vm_invoke_proc(), rb_vm_make_jump_tag_but_local_jump(), rb_vm_proc_local_ep(), rb_execution_context_struct::root_lep, rb_execution_context_struct::root_svar, RUBY_EVENT_FIBER_SWITCH, rb_thread_struct::self, TAG_FATAL, TAG_NONE, TAG_RAISE, TRUE, rb_context_struct::value, VAR_FROM_MEMORY, VM_ASSERT, VM_BLOCK_HANDLER_NONE, and VM_UNREACHABLE.

Referenced by rb_fiber_start().

## ◆ rb_method_name_error()

void rb_method_name_error | ( | VALUE | klass,
|  | VALUE | str
| ) |  |

Definition at line 1909 of file proc.c.

References attached, BUILTIN_TYPE, FL_SINGLETON, FL_TEST, METHOD::klass, MSG, Qundef, rb_ivar_get(), str, T_CLASS, and T_MODULE.

Referenced by rb_undef().

## ◆ rb_print_inaccessible()

void rb_print_inaccessible | ( | VALUE | klass,
|  | ID | id,
|  | rb_method_visibility_t | visi
| ) |  |

Definition at line 425 of file eval_error.c.

References ID2SYM, inaccessible_mesg, METHOD_VISI_MASK, METHOD_VISI_PRIVATE, METHOD_VISI_PROTECTED, METHOD_VISI_PUBLIC, METHOD_VISI_UNDEF, T_MODULE, and UNREACHABLE.

## ◆ rb_print_undef()

void rb_print_undef | ( | VALUE | klass,
|  | ID | id,
|  | rb_method_visibility_t | visi
| ) |  |

Definition at line 397 of file eval_error.c.

References ID2SYM, METHOD_VISI_MASK, METHOD_VISI_PRIVATE, METHOD_VISI_PROTECTED, METHOD_VISI_PUBLIC, METHOD_VISI_UNDEF, T_MODULE, undef_mesg, and UNREACHABLE.

Referenced by rb_alias().

## ◆ rb_print_undef_str()

void rb_print_undef_str | ( | VALUE | klass,
|  | VALUE | name
| ) |  |

Definition at line 412 of file eval_error.c.

References name, T_MODULE, and undef_mesg.

## ◆ rb_vm_call_cfunc()

VALUE rb_vm_call_cfunc | ( | VALUE | recv,
|  | VALUE(*)(VALUE) | func,
|  | VALUE | arg,
|  | VALUE | block_handler,
|  | VALUE | filename
| ) |  |

Definition at line 2452 of file vm.c.

References rb_execution_context_struct::cfp, Qnil, rb_iseq_new(), rb_vm_pop_frame(), rb_control_frame_struct::sp, VM_ENV_FLAG_LOCAL, VM_FRAME_FLAG_FINISH, and VM_FRAME_MAGIC_TOP.

## ◆ rb_vm_cbase()

VALUE rb_vm_cbase | ( | void |  | ) |

Definition at line 1665 of file vm.c.

References rb_execution_context_struct::cfp, rb_control_frame_struct::ep, rb_eRuntimeError, rb_raise(), and rb_vm_get_ruby_level_next_cfp().

## ◆ rb_vm_cref()

rb_cref_t * rb_vm_cref | ( | void |  | ) |

Definition at line 1624 of file vm.c.

## ◆ rb_vm_cref_replace_with_duplicated_cref()

rb_cref_t * rb_vm_cref_replace_with_duplicated_cref | ( | void |  | ) |

Definition at line 1631 of file vm.c.

References rb_execution_context_struct::cfp, rb_control_frame_struct::ep, and rb_vm_get_ruby_level_next_cfp().

## ◆ rb_vm_jump_tag_but_local_jump()

void rb_vm_jump_tag_but_local_jump | ( | int | state | ) |

Definition at line 1750 of file vm.c.

References EC_JUMP_TAG, NIL_P, Qundef, rb_exc_raise(), and rb_vm_make_jump_tag_but_local_jump().

## ◆ rb_vm_localjump_error()

void rb_vm_localjump_error | ( | const char * | mesg,
|  | VALUE | value,
|  | int | reason
| ) |  |

Definition at line 1711 of file vm.c.

References rb_exc_raise().

Referenced by rb_need_block().

## ◆ rb_vm_make_jump_tag_but_local_jump()

VALUE rb_vm_make_jump_tag_but_local_jump | ( | int | state,
|  | VALUE | val
| ) |  |

Definition at line 1718 of file vm.c.

References Qnil, Qundef, TAG_BREAK, TAG_NEXT, TAG_REDO, TAG_RETRY, and TAG_RETURN.

Referenced by rb_fiber_start(), and rb_vm_jump_tag_but_local_jump().

## ◆ rb_vm_set_progname()

void rb_vm_set_progname | ( | VALUE | filename | ) |

Definition at line 3690 of file vm.c.

References rb_thread_struct::ec, rb_control_frame_struct::iseq, rb_thread_struct::ractor, rb_iseq_pathobj_set(), rb_iseq_realpath(), rb_str_dup(), rb_execution_context_struct::vm_stack, and rb_execution_context_struct::vm_stack_size.

Referenced by ruby_script(), and ruby_set_script_name().

## ◆ strrchr()

char * strrchr | ( | const char * | ,
|  | const char |
| ) |  |

Referenced by main(), rb_feature_provided(), ruby_init_loadpath(), and tar().