Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Data Structures | Macros | Typedefs | Enumerations | Functions
vm_eval.c File Reference

Go to the source code of this file.

Data Structures

struct  local_var_list
 
struct  rescue_funcall_args
 
struct  iter_method_arg
 
struct  eval_string_wrap_arg
 

Macros

#define id_mesg   idMesg
 
#define type_case(t)   t: return #t
 

Typedefs

typedef enum call_type call_type
 

Enumerations

enum  call_type {
  CALL_PUBLIC , CALL_FCALL , CALL_VCALL , CALL_PUBLIC_KW ,
  CALL_FCALL_KW , CALL_TYPE_MAX
}
 

Functions

VALUE vm_exec (rb_execution_context_t *ec, bool mjit_enable_p)
 
VALUE rb_vm_call0 (rb_execution_context_t *ec, VALUE recv, ID id, int argc, const VALUE *argv, const rb_callable_method_entry_t *cme, int kw_splat)
 
VALUE rb_vm_call_kw (rb_execution_context_t *ec, VALUE recv, VALUE id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me, int kw_splat)
 
VALUE rb_call_super_kw (int argc, const VALUE *argv, int kw_splat)
 
VALUE rb_call_super (int argc, const VALUE *argv)
 
VALUE rb_current_receiver (void)
 
void rb_check_stack_overflow (void)
 
VALUE rb_check_funcall_kw (VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
 
VALUE rb_check_funcall (VALUE recv, ID mid, int argc, const VALUE *argv)
 
VALUE rb_check_funcall_default (VALUE recv, ID mid, int argc, const VALUE *argv, VALUE def)
 
VALUE rb_check_funcall_with_hook_kw (VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg, int kw_splat)
 
VALUE rb_check_funcall_with_hook (VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg)
 
const char * rb_type_str (enum ruby_value_type type)
 
VALUE rb_make_no_method_exception (VALUE exc, VALUE format, VALUE obj, int argc, const VALUE *argv, int priv)
 
VALUE rb_funcallv (VALUE recv, ID mid, int argc, const VALUE *argv)
 Calls a method. More...
 
VALUE rb_funcallv_kw (VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
 
VALUE rb_apply (VALUE recv, ID mid, VALUE args)
 Calls a method. More...
 
VALUE rb_funcall (VALUE recv, ID mid, int n,...)
 Calls a method. More...
 
VALUE rb_check_funcall_basic_kw (VALUE recv, ID mid, VALUE ancestor, int argc, const VALUE *argv, int kw_splat)
 Calls a method only if it is the basic method of ancestor otherwise returns Qundef;. More...
 
VALUE rb_funcallv_public (VALUE recv, ID mid, int argc, const VALUE *argv)
 Calls a method. More...
 
VALUE rb_funcallv_public_kw (VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
 
VALUE rb_funcall_passing_block (VALUE recv, ID mid, int argc, const VALUE *argv)
 
VALUE rb_funcall_passing_block_kw (VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
 
VALUE rb_funcall_with_block (VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval)
 
VALUE rb_funcall_with_block_kw (VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval, int kw_splat)
 
VALUE rb_f_send (int argc, VALUE *argv, VALUE recv)
 
VALUE rb_yield_1 (VALUE val)
 
VALUE rb_yield (VALUE val)
 
VALUE rb_yield_values (int n,...)
 
VALUE rb_yield_values2 (int argc, const VALUE *argv)
 
VALUE rb_yield_values_kw (int argc, const VALUE *argv, int kw_splat)
 
VALUE rb_yield_splat (VALUE values)
 
VALUE rb_yield_splat_kw (VALUE values, int kw_splat)
 
VALUE rb_yield_force_blockarg (VALUE values)
 
VALUE rb_yield_block (RB_BLOCK_CALL_FUNC_ARGLIST(val, arg))
 
VALUE rb_iterate (VALUE(*it_proc)(VALUE), VALUE data1, rb_block_call_func_t bl_proc, VALUE data2)
 
VALUE rb_block_call (VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2)
 
VALUE rb_block_call_kw (VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2, int kw_splat)
 
VALUE rb_lambda_call (VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, int min_argc, int max_argc, VALUE data2)
 
VALUE rb_check_block_call (VALUE obj, ID mid, int argc, const VALUE *argv, rb_block_call_func_t bl_proc, VALUE data2)
 
VALUE rb_each (VALUE obj)
 
void rb_parser_warn_location (VALUE, int)
 
VALUE rb_f_eval (int argc, const VALUE *argv, VALUE self)
 
VALUE ruby_eval_string_from_file (const char *str, const char *filename)
 
VALUE rb_eval_string (const char *str)
 Evaluates the given string in an isolated binding. More...
 
VALUE rb_eval_string_protect (const char *str, int *pstate)
 Evaluates the given string in an isolated binding. More...
 
VALUE rb_eval_string_wrap (const char *str, int *pstate)
 Evaluates the given string under a module binding in an isolated binding. More...
 
VALUE rb_eval_cmd_kw (VALUE cmd, VALUE arg, int kw_splat)
 
VALUE rb_yield_refine_block (VALUE refinement, VALUE refinements)
 
VALUE rb_obj_instance_eval (int argc, const VALUE *argv, VALUE self)
 
VALUE rb_obj_instance_exec (int argc, const VALUE *argv, VALUE self)
 
VALUE rb_mod_module_eval (int argc, const VALUE *argv, VALUE mod)
 
VALUE rb_mod_module_exec (int argc, const VALUE *argv, VALUE mod)
 
void rb_throw_obj (VALUE tag, VALUE value)
 
void rb_throw (const char *tag, VALUE val)
 
VALUE rb_catch (const char *tag, rb_block_call_func_t func, VALUE data)
 
VALUE rb_catch_protect (VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr)
 
VALUE rb_catch_obj (VALUE t, rb_block_call_func_t func, VALUE data)
 
VALUE rb_current_realfilepath (void)
 
void Init_vm_eval (void)
 

Macro Definition Documentation

◆ id_mesg

#define id_mesg   idMesg

Definition at line 29 of file vm_eval.c.

◆ type_case

#define type_case (   t)    t: return #t

Typedef Documentation

◆ call_type

typedef enum call_type call_type

Enumeration Type Documentation

◆ call_type

enum call_type
Enumerator
CALL_PUBLIC 
CALL_FCALL 
CALL_VCALL 
CALL_PUBLIC_KW 
CALL_FCALL_KW 
CALL_TYPE_MAX 

Definition at line 31 of file vm_eval.c.

Function Documentation

◆ Init_vm_eval()

void Init_vm_eval ( void  )

◆ rb_apply()

VALUE rb_apply ( VALUE  recv,
ID  mid,
VALUE  args 
)

Calls a method.

Parameters
recvreceiver of the method
midan ID that represents the name of the method
argsan Array object which contains method arguments
Precondition
args must refer an Array object.

Definition at line 1044 of file vm_eval.c.

References ALLOCA_N, argc, argv, CALL_FCALL, MEMCPY, OBJ_FREEZE, RARRAY_CONST_PTR, RARRAY_CONST_PTR_TRANSIENT, rb_ary_subseq, rb_funcallv, and RB_GC_GUARD.

◆ rb_block_call()

VALUE rb_block_call ( VALUE  obj,
ID  mid,
int  argc,
const VALUE argv,
rb_block_call_func_t  bl_proc,
VALUE  data2 
)

◆ rb_block_call_kw()

VALUE rb_block_call_kw ( VALUE  obj,
ID  mid,
int  argc,
const VALUE argv,
rb_block_call_func_t  bl_proc,
VALUE  data2,
int  kw_splat 
)

◆ rb_call_super()

VALUE rb_call_super ( int  argc,
const VALUE argv 
)

Definition at line 298 of file vm_eval.c.

References argc, argv, PASS_PASSED_BLOCK_HANDLER_EC, and RB_NO_KEYWORDS.

◆ rb_call_super_kw()

VALUE rb_call_super_kw ( int  argc,
const VALUE argv,
int  kw_splat 
)

Definition at line 290 of file vm_eval.c.

References argc, argv, and PASS_PASSED_BLOCK_HANDLER_EC.

◆ rb_catch()

VALUE rb_catch ( const char *  tag,
rb_block_call_func_t  func,
VALUE  data 
)

◆ rb_catch_obj()

VALUE rb_catch_obj ( VALUE  t,
rb_block_call_func_t  func,
VALUE  data 
)

Definition at line 2427 of file vm_eval.c.

References EC_JUMP_TAG, rb_vm_tag::state, and t.

Referenced by rb_catch().

◆ rb_catch_protect()

VALUE rb_catch_protect ( VALUE  t,
rb_block_call_func func,
VALUE  data,
enum ruby_tag_type stateptr 
)

Definition at line 2421 of file vm_eval.c.

References t.

◆ rb_check_block_call()

VALUE rb_check_block_call ( VALUE  obj,
ID  mid,
int  argc,
const VALUE argv,
rb_block_call_func_t  bl_proc,
VALUE  data2 
)

◆ rb_check_funcall()

VALUE rb_check_funcall ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv 
)

◆ rb_check_funcall_basic_kw()

VALUE rb_check_funcall_basic_kw ( VALUE  recv,
ID  mid,
VALUE  ancestor,
int  argc,
const VALUE argv,
int  kw_splat 
)

Calls a method only if it is the basic method of ancestor otherwise returns Qundef;.

Parameters
recvreceiver of the method
midan ID that represents the name of the method
ancestorthe Class that defined the basic method
argcthe number of arguments
argvpointer to an array of method arguments
kw_splatbool

Definition at line 1111 of file vm_eval.c.

References argc, argv, CLASS_OF, rb_callable_method_entry_struct::defined_class, rb_callcache::klass, METHOD_ENTRY_BASIC, Qundef, rb_callable_method_entry(), rb_vm_call0(), and RBASIC_CLASS.

Referenced by rb_hash().

◆ rb_check_funcall_default()

VALUE rb_check_funcall_default ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
VALUE  def 
)

◆ rb_check_funcall_kw()

VALUE rb_check_funcall_kw ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
int  kw_splat 
)

◆ rb_check_funcall_with_hook()

VALUE rb_check_funcall_with_hook ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
rb_check_funcall_hook hook,
VALUE  arg 
)

◆ rb_check_funcall_with_hook_kw()

VALUE rb_check_funcall_with_hook_kw ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
rb_check_funcall_hook hook,
VALUE  arg,
int  kw_splat 
)

◆ rb_check_stack_overflow()

void rb_check_stack_overflow ( void  )

Definition at line 331 of file vm_eval.c.

References ruby_current_ec_key, and stack_check.

◆ rb_current_realfilepath()

VALUE rb_current_realfilepath ( void  )

◆ rb_current_receiver()

VALUE rb_current_receiver ( void  )

◆ rb_each()

VALUE rb_each ( VALUE  obj)

Definition at line 1639 of file vm_eval.c.

References CALL_FCALL, and iter_method_arg::obj.

◆ rb_eval_cmd_kw()

VALUE rb_eval_cmd_kw ( VALUE  cmd,
VALUE  arg,
int  kw_splat 
)

◆ rb_eval_string()

VALUE rb_eval_string ( const char *  str)

Evaluates the given string in an isolated binding.

Here "isolated" means the binding does not inherit any other binding. This behaves same as the binding for required libraries.

FILE will be "(eval)", and LINE starts from 1 in the evaluation.

Parameters
strRuby code to evaluate.
Returns
The evaluated result.
Exceptions
ExceptionRaises an exception on error.

Definition at line 1823 of file vm_eval.c.

References ruby_eval_string_from_file(), and str.

◆ rb_eval_string_protect()

VALUE rb_eval_string_protect ( const char *  str,
int pstate 
)

Evaluates the given string in an isolated binding.

FILE will be "(eval)", and LINE starts from 1 in the evaluation.

See also
rb_eval_string
Parameters
strRuby code to evaluate.
stateBeing set to zero if succeeded. Nonzero if an error occurred.
Returns
The evaluated result if succeeded, an undefined value if otherwise.

Definition at line 1845 of file vm_eval.c.

References rb_protect(), and str.

◆ rb_eval_string_wrap()

VALUE rb_eval_string_wrap ( const char *  str,
int pstate 
)

Evaluates the given string under a module binding in an isolated binding.

This is same as the binding for loaded libraries on "load('foo', true)".

FILE will be "(eval)", and LINE starts from 1 in the evaluation.

See also
rb_eval_string
Parameters
strRuby code to evaluate.
stateBeing set to zero if succeeded. Nonzero if an error occurred.
Returns
The evaluated result if succeeded, an undefined value if otherwise.

Definition at line 1877 of file vm_eval.c.

References rb_thread_struct::ec, EC_JUMP_TAG, eval_string_wrap_arg::klass, rb_extend_object(), rb_module_new(), rb_obj_clone(), rb_protect(), rb_vm_top_self(), str, eval_string_wrap_arg::str, TAG_NONE, rb_thread_struct::top_self, eval_string_wrap_arg::top_self, and rb_thread_struct::top_wrapper.

◆ 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_f_send()

VALUE rb_f_send ( int  argc,
VALUE argv,
VALUE  recv 
)

Definition at line 1295 of file vm_eval.c.

References argc, argv, and CALL_FCALL.

Referenced by Init_vm_eval().

◆ rb_funcall()

VALUE rb_funcall ( VALUE  recv,
ID  mid,
int  n,
  ... 
)

◆ rb_funcall_passing_block()

VALUE rb_funcall_passing_block ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv 
)

Definition at line 1149 of file vm_eval.c.

References argc, argv, PASS_PASSED_BLOCK_HANDLER, and rb_funcallv_public().

◆ rb_funcall_passing_block_kw()

VALUE rb_funcall_passing_block_kw ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
int  kw_splat 
)

Definition at line 1156 of file vm_eval.c.

References argc, argv, CALL_PUBLIC, CALL_PUBLIC_KW, and PASS_PASSED_BLOCK_HANDLER.

◆ rb_funcall_with_block()

VALUE rb_funcall_with_block ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
VALUE  passed_procval 
)

Definition at line 1163 of file vm_eval.c.

References argc, argv, NIL_P, and rb_funcallv_public().

◆ rb_funcall_with_block_kw()

VALUE rb_funcall_with_block_kw ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
VALUE  passed_procval,
int  kw_splat 
)

Definition at line 1173 of file vm_eval.c.

References argc, argv, CALL_PUBLIC, CALL_PUBLIC_KW, and NIL_P.

Referenced by rb_sym_proc_call().

◆ rb_funcallv()

VALUE rb_funcallv ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv 
)

Calls a method.

Parameters
recvreceiver of the method
midan ID that represents the name of the method
argcthe number of arguments
argvpointer to an array of method arguments

Definition at line 1024 of file vm_eval.c.

References argc, argv, and CALL_FCALL.

◆ rb_funcallv_kw()

VALUE rb_funcallv_kw ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
int  kw_splat 
)

Definition at line 1030 of file vm_eval.c.

References argc, argv, CALL_FCALL, and CALL_FCALL_KW.

Referenced by rb_eval_cmd_kw(), rb_obj_call_init(), and rb_obj_call_init_kw().

◆ rb_funcallv_public()

VALUE rb_funcallv_public ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv 
)

Calls a method.

Same as rb_funcallv but this function can call only public methods.

Parameters
recvreceiver of the method
midan ID that represents the name of the method
argcthe number of arguments
argvpointer to an array of method arguments

Definition at line 1137 of file vm_eval.c.

References argc, argv, and CALL_PUBLIC.

Referenced by rb_funcall_passing_block(), rb_funcall_with_block(), and rb_random_ulong_limited().

◆ rb_funcallv_public_kw()

VALUE rb_funcallv_public_kw ( VALUE  recv,
ID  mid,
int  argc,
const VALUE argv,
int  kw_splat 
)

Definition at line 1143 of file vm_eval.c.

References argc, argv, CALL_PUBLIC, and CALL_PUBLIC_KW.

◆ rb_iterate()

VALUE rb_iterate ( VALUE(*)(VALUE it_proc,
VALUE  data1,
rb_block_call_func_t  bl_proc,
VALUE  data2 
)

Definition at line 1544 of file vm_eval.c.

Referenced by rb_block_call(), rb_block_call_kw(), and rb_check_block_call().

◆ rb_lambda_call()

VALUE rb_lambda_call ( VALUE  obj,
ID  mid,
int  argc,
const VALUE argv,
rb_block_call_func_t  bl_proc,
int  min_argc,
int  max_argc,
VALUE  data2 
)

◆ rb_make_no_method_exception()

VALUE rb_make_no_method_exception ( VALUE  exc,
VALUE  format,
VALUE  obj,
int  argc,
const VALUE argv,
int  priv 
)

◆ rb_mod_module_eval()

VALUE rb_mod_module_eval ( int  argc,
const VALUE argv,
VALUE  mod 
)

Definition at line 2164 of file vm_eval.c.

References argc, argv, mod, and RB_NO_KEYWORDS.

◆ rb_mod_module_exec()

VALUE rb_mod_module_exec ( int  argc,
const VALUE argv,
VALUE  mod 
)

Definition at line 2198 of file vm_eval.c.

References argc, argv, mod, and RB_NO_KEYWORDS.

◆ rb_obj_instance_eval()

VALUE rb_obj_instance_eval ( int  argc,
const VALUE argv,
VALUE  self 
)

Definition at line 2092 of file vm_eval.c.

References argc, argv, RB_NO_KEYWORDS, and rb_captured_block::self.

◆ rb_obj_instance_exec()

VALUE rb_obj_instance_exec ( int  argc,
const VALUE argv,
VALUE  self 
)

Definition at line 2124 of file vm_eval.c.

References argc, argv, RB_NO_KEYWORDS, and rb_captured_block::self.

◆ rb_parser_warn_location()

void rb_parser_warn_location ( VALUE  ,
int   
)

◆ rb_throw()

void rb_throw ( const char *  tag,
VALUE  val 
)

Definition at line 2315 of file vm_eval.c.

References rb_sym_intern_ascii_cstr, rb_throw_obj(), and rb_vm_tag::tag.

◆ rb_throw_obj()

void rb_throw_obj ( VALUE  tag,
VALUE  value 
)

◆ rb_type_str()

const char * rb_type_str ( enum ruby_value_type  type)

◆ rb_vm_call0()

VALUE rb_vm_call0 ( rb_execution_context_t ec,
VALUE  recv,
ID  id,
int  argc,
const VALUE argv,
const rb_callable_method_entry_t cme,
int  kw_splat 
)

◆ rb_vm_call_kw()

VALUE rb_vm_call_kw ( rb_execution_context_t ec,
VALUE  recv,
VALUE  id,
int  argc,
const VALUE argv,
const rb_callable_method_entry_t me,
int  kw_splat 
)

Definition at line 260 of file vm_eval.c.

References argc, argv, and rb_vm_call0().

Referenced by rb_check_funcall_with_hook_kw().

◆ rb_yield()

VALUE rb_yield ( VALUE  val)

Definition at line 1341 of file vm_eval.c.

References NULL, and Qundef.

Referenced by ossl_generate_cb_2(), rb_ary_delete(), rb_ary_each(), and ruby_float_step().

◆ rb_yield_1()

VALUE rb_yield_1 ( VALUE  val)

Definition at line 1335 of file vm_eval.c.

◆ rb_yield_block()

VALUE rb_yield_block ( RB_BLOCK_CALL_FUNC_ARGLIST(val, arg)  )

Definition at line 1419 of file vm_eval.c.

References argc, argv, NIL_P, rb_keyword_given_p(), and VM_BLOCK_HANDLER_NONE.

◆ rb_yield_force_blockarg()

VALUE rb_yield_force_blockarg ( VALUE  values)

Definition at line 1413 of file vm_eval.c.

◆ rb_yield_refine_block()

VALUE rb_yield_refine_block ( VALUE  refinement,
VALUE  refinements 
)

◆ rb_yield_splat()

VALUE rb_yield_splat ( VALUE  values)

◆ rb_yield_splat_kw()

VALUE rb_yield_splat_kw ( VALUE  values,
int  kw_splat 
)

◆ rb_yield_values()

VALUE rb_yield_values ( int  n,
  ... 
)

Definition at line 1353 of file vm_eval.c.

References ALLOCA_N, and argv.

◆ rb_yield_values2()

VALUE rb_yield_values2 ( int  argc,
const VALUE argv 
)

Definition at line 1375 of file vm_eval.c.

References argc, and argv.

◆ rb_yield_values_kw()

VALUE rb_yield_values_kw ( int  argc,
const VALUE argv,
int  kw_splat 
)

Definition at line 1381 of file vm_eval.c.

References argc, and argv.

◆ ruby_eval_string_from_file()

VALUE ruby_eval_string_from_file ( const char *  str,
const char *  filename 
)
Note
This function name is not stable.

Definition at line 1804 of file vm_eval.c.

References NULL, rb_str_new2, rb_str_new_cstr, rb_vm_top_self(), and str.

Referenced by rb_eval_string().

◆ vm_exec()

VALUE vm_exec ( rb_execution_context_t ec,
bool  mjit_enable_p 
)

Definition at line 2151 of file vm.c.