Ruby  2.5.0dev(2017-10-22revision60238)
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_from_file_arg
 

Macros

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

Typedefs

typedef enum call_type call_type
 

Enumerations

enum  call_type { CALL_PUBLIC, CALL_FCALL, CALL_VCALL, CALL_TYPE_MAX }
 

Functions

VALUE rb_vm_call (rb_thread_t *th, VALUE recv, VALUE id, int argc, const VALUE *argv, const rb_callable_method_entry_t *me)
 
VALUE rb_call_super (int argc, const VALUE *argv)
 
VALUE rb_current_receiver (void)
 
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 (VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg)
 
 NORETURN (static void raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj, enum method_missing_reason call_status))
 
void rb_raise_method_missing (rb_thread_t *th, int argc, const VALUE *argv, VALUE obj, int call_status)
 
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_funcallv (VALUE recv, ID mid, int argc, const VALUE *argv)
 Calls a method. More...
 
VALUE rb_funcallv_public (VALUE recv, ID mid, int argc, const VALUE *argv)
 Calls a method. More...
 
VALUE rb_funcall_passing_block (VALUE recv, ID mid, int argc, const VALUE *argv)
 
VALUE rb_funcall_with_block (VALUE recv, ID mid, int argc, const VALUE *argv, VALUE passed_procval)
 
VALUE rb_f_send (int argc, VALUE *argv, VALUE recv)
 
VALUE rb_f_public_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_splat (VALUE values)
 
VALUE rb_yield_force_blockarg (VALUE values)
 
VALUE rb_yield_block (VALUE val, VALUE arg, int argc, const VALUE *argv, VALUE blockarg)
 
VALUE rb_iterate (VALUE(*it_proc)(VALUE), VALUE data1, VALUE(*bl_proc)(ANYARGS), VALUE data2)
 
VALUE rb_block_call (VALUE obj, ID mid, int argc, const VALUE *argv, VALUE(*bl_proc)(ANYARGS), VALUE data2)
 
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, VALUE(*bl_proc)(ANYARGS), VALUE data2)
 
VALUE rb_each (VALUE obj)
 
VALUE rb_f_eval (int argc, const VALUE *argv, VALUE self)
 
VALUE ruby_eval_string_from_file (const char *str, const char *filename)
 
VALUE ruby_eval_string_from_file_protect (const char *str, const char *filename, int *state)
 
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 (VALUE cmd, VALUE arg, int level)
 
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, VALUE(*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, VALUE(*func)(), VALUE data)
 
VALUE rb_f_block_given_p (void)
 
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)    case 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_TYPE_MAX 

Definition at line 31 of file vm_eval.c.

Function Documentation

◆ Init_vm_eval()

void Init_vm_eval ( void  )

Definition at line 2155 of file vm_eval.c.

References rb_define_global_function(), and rb_f_eval().

◆ NORETURN()

NORETURN ( static void   raise_method_missingrb_thread_t *th, int argc, const VALUE *argv, VALUE obj, enum method_missing_reason call_status)

◆ 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 744 of file vm_eval.c.

References argc, argv, OBJ_FREEZE, RARRAY_LENINT, rb_ary_subseq(), and RBASIC_CLEAR_CLASS.

◆ rb_block_call()

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

◆ rb_call_super()

VALUE rb_call_super ( int  argc,
const VALUE argv 
)

Definition at line 238 of file vm_eval.c.

References GET_THREAD, and PASS_PASSED_BLOCK_HANDLER_TH.

◆ rb_catch()

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

Definition at line 1970 of file vm_eval.c.

References rb_catch_obj(), rb_cObject, rb_obj_alloc(), and rb_sym_intern_ascii_cstr().

◆ rb_catch_obj()

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

Definition at line 2012 of file vm_eval.c.

References GET_THREAD, and rb_vm_tag::state.

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 2006 of file vm_eval.c.

◆ rb_check_block_call()

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

◆ rb_check_funcall()

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

Definition at line 389 of file vm_eval.c.

References Qundef, and rb_check_funcall_default().

Referenced by rb_iseq_load_iseq(), and rb_threadptr_error_print().

◆ rb_check_funcall_default()

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

Definition at line 395 of file vm_eval.c.

References CLASS_OF, GET_THREAD, and rescue_funcall_args::me.

Referenced by rb_check_funcall(), and rb_get_path_check_to_string().

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

Definition at line 417 of file vm_eval.c.

References CLASS_OF, GET_THREAD, and rescue_funcall_args::me.

◆ rb_current_realfilepath()

VALUE rb_current_realfilepath ( void  )

Definition at line 2145 of file vm_eval.c.

References rb_execution_context_struct::cfp, rb_thread_struct::ec, and GET_THREAD.

Referenced by rb_f_require_relative().

◆ rb_current_receiver()

VALUE rb_current_receiver ( void  )

◆ rb_each()

VALUE rb_each ( VALUE  obj)

Definition at line 1233 of file vm_eval.c.

◆ rb_eval_cmd()

VALUE rb_eval_cmd ( VALUE  cmd,
VALUE  arg,
int  level 
)

◆ 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 1447 of file vm_eval.c.

References ruby_eval_string_from_file().

Referenced by rb_eval_string_protect().

◆ 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 1463 of file vm_eval.c.

References rb_eval_string(), and rb_protect().

Referenced by rb_eval_string_wrap().

◆ 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 1480 of file vm_eval.c.

References GET_THREAD, rb_eval_string_protect(), rb_extend_object(), rb_module_new(), rb_obj_clone(), rb_vm_top_self(), TAG_NONE, TH_JUMP_TAG, rb_thread_struct::top_self, rb_thread_struct::top_wrapper, and val.

◆ rb_f_block_given_p()

VALUE rb_f_block_given_p ( void  )

Definition at line 2130 of file vm_eval.c.

References rb_execution_context_struct::cfp, rb_thread_struct::ec, and GET_THREAD.

◆ rb_f_eval()

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

Definition at line 1385 of file vm_eval.c.

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

Referenced by Init_vm_eval().

◆ rb_f_public_send()

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

Definition at line 953 of file vm_eval.c.

◆ rb_f_send()

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

Definition at line 933 of file vm_eval.c.

◆ rb_funcall()

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

Calls a method.

Parameters
recvreceiver of the method
midan ID that represents the name of the method
nthe number of arguments
...arbitrary number of method arguments
Precondition
each of arguments after n must be a VALUE.

Definition at line 774 of file vm_eval.c.

References ALLOCA_N, argv, and va_init_list.

Referenced by default_inspect(), DupConfigPtr(), fun1(), generic_to_value(), ossl_time_split(), ossl_to_der(), rb_big_pow(), rb_class_inherited(), rb_cmpint(), rb_exc_new(), rb_exc_new_str(), rb_io_flush_raw(), rb_numeric_quo(), rb_obj_as_string(), and rb_obj_init_dup_clone().

◆ rb_funcall_passing_block()

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

Definition at line 826 of file vm_eval.c.

References 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 833 of file vm_eval.c.

References GET_THREAD, 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 805 of file vm_eval.c.

Referenced by rb_eval_cmd().

◆ 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 820 of file vm_eval.c.

◆ rb_iterate()

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

Definition at line 1156 of file vm_eval.c.

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

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

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

Definition at line 1748 of file vm_eval.c.

◆ rb_mod_module_exec()

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

Definition at line 1776 of file vm_eval.c.

◆ rb_obj_instance_eval()

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

Definition at line 1689 of file vm_eval.c.

◆ rb_obj_instance_exec()

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

Definition at line 1714 of file vm_eval.c.

◆ rb_raise_method_missing()

void rb_raise_method_missing ( rb_thread_t th,
int  argc,
const VALUE argv,
VALUE  obj,
int  call_status 
)

Definition at line 728 of file vm_eval.c.

◆ rb_throw()

void rb_throw ( const char *  tag,
VALUE  val 
)

Definition at line 1893 of file vm_eval.c.

References rb_sym_intern_ascii_cstr(), and rb_throw_obj().

◆ rb_throw_obj()

void rb_throw_obj ( VALUE  tag,
VALUE  value 
)

◆ rb_vm_call()

VALUE rb_vm_call ( rb_thread_t th,
VALUE  recv,
VALUE  id,
int  argc,
const VALUE argv,
const rb_callable_method_entry_t me 
)

Definition at line 206 of file vm_eval.c.

◆ rb_yield()

VALUE rb_yield ( VALUE  val)

Definition at line 973 of file vm_eval.c.

References Qundef.

Referenced by ossl_generate_cb_2(), and rb_ary_delete().

◆ rb_yield_1()

VALUE rb_yield_1 ( VALUE  val)

Definition at line 967 of file vm_eval.c.

◆ rb_yield_block()

VALUE rb_yield_block ( VALUE  val,
VALUE  arg,
int  argc,
const VALUE argv,
VALUE  blockarg 
)

Definition at line 1032 of file vm_eval.c.

◆ rb_yield_force_blockarg()

VALUE rb_yield_force_blockarg ( VALUE  values)

Definition at line 1026 of file vm_eval.c.

◆ rb_yield_refine_block()

VALUE rb_yield_refine_block ( VALUE  refinement,
VALUE  refinements 
)

Definition at line 1584 of file vm_eval.c.

References GET_THREAD.

◆ rb_yield_splat()

VALUE rb_yield_splat ( VALUE  values)

Definition at line 1013 of file vm_eval.c.

References NIL_P, rb_check_array_type(), rb_eArgError, and rb_raise().

◆ rb_yield_values()

VALUE rb_yield_values ( int  n,
  ... 
)

Definition at line 985 of file vm_eval.c.

◆ rb_yield_values2()

VALUE rb_yield_values2 ( int  argc,
const VALUE argv 
)

Definition at line 1007 of file vm_eval.c.

◆ 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 1407 of file vm_eval.c.

References rb_str_new_cstr().

Referenced by rb_eval_string().

◆ ruby_eval_string_from_file_protect()

VALUE ruby_eval_string_from_file_protect ( const char *  str,
const char *  filename,
int *  state 
)