Ruby  2.0.0p598(2014-11-13revision48408)
Macros | Functions | Variables
eval.c File Reference
#include "eval_intern.h"
#include "iseq.h"
#include "gc.h"
#include "ruby/vm.h"
#include "ruby/encoding.h"
#include "internal.h"
#include "vm_core.h"
#include "probes_helper.h"
#include "eval_error.c"
#include "eval_jump.c"

Go to the source code of this file.

Macros

#define numberof(array)   (int)(sizeof(array) / sizeof((array)[0]))
 
#define exception_error   GET_VM()->special_exceptions[ruby_error_reenter]
 

Functions

 NORETURN (void rb_raise_jump(VALUE))
 
NODErb_vm_get_cref (const rb_iseq_t *, const VALUE *)
 
int ruby_setup (void)
 
void ruby_init (void)
 
voidruby_options (int argc, char **argv)
 Processes command line arguments and compiles the Ruby source to execute. More...
 
static void ruby_finalize_0 (void)
 
static void ruby_finalize_1 (void)
 
void ruby_finalize (void)
 Runs the VM finalization processes. More...
 
int ruby_cleanup (volatile int ex)
 Destructs the VM. More...
 
static int ruby_exec_internal (void *n)
 
void ruby_stop (int ex)
 Calls ruby_cleanup() and exits the process. More...
 
int ruby_executable_node (void *n, int *status)
 Checks the return value of ruby_options(). More...
 
int ruby_run_node (void *n)
 Runs the given compiled source and exits this process. More...
 
int ruby_exec_node (void *n)
 Runs the given compiled source. More...
 
static VALUE rb_mod_nesting (void)
 
static VALUE rb_mod_s_constants (int argc, VALUE *argv, VALUE mod)
 
void rb_frozen_class_p (VALUE klass)
 
 NORETURN (static void rb_longjmp(int, volatile VALUE))
 
static void setup_exception (rb_thread_t *th, int tag, volatile VALUE mesg)
 
static void rb_longjmp (int tag, volatile VALUE mesg)
 
static VALUE make_exception (int argc, VALUE *argv, int isstr)
 
void rb_exc_raise (VALUE mesg)
 
void rb_exc_fatal (VALUE mesg)
 
void rb_interrupt (void)
 
static VALUE get_errinfo (void)
 
static VALUE rb_f_raise (int argc, VALUE *argv)
 
VALUE rb_make_exception (int argc, VALUE *argv)
 
void rb_raise_jump (VALUE mesg)
 
void rb_jump_tag (int tag)
 
int rb_block_given_p (void)
 
int rb_iterator_p (void)
 
void rb_need_block (void)
 
VALUE rb_rescue2 (VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
 
VALUE rb_rescue (VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2)
 
VALUE rb_protect (VALUE(*proc)(VALUE), VALUE data, int *state)
 
VALUE rb_ensure (VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
 
static const rb_method_entry_tmethod_entry_of_iseq (rb_control_frame_t *cfp, rb_iseq_t *iseq)
 
static ID frame_func_id (rb_control_frame_t *cfp)
 
static ID frame_called_id (rb_control_frame_t *cfp)
 
ID rb_frame_this_func (void)
 
static rb_control_frame_tprevious_frame (rb_thread_t *th)
 
ID rb_frame_callee (void)
 
static ID rb_frame_caller (void)
 
static VALUE rb_mod_append_features (VALUE module, VALUE include)
 
static VALUE rb_mod_include (int argc, VALUE *argv, VALUE module)
 
static VALUE rb_mod_prepend_features (VALUE module, VALUE prepend)
 
static VALUE rb_mod_prepend (int argc, VALUE *argv, VALUE module)
 
static void warn_refinements_once ()
 
static VALUE hidden_identity_hash_new ()
 
void rb_using_refinement (NODE *cref, VALUE klass, VALUE module)
 
static int using_refinement (VALUE klass, VALUE module, VALUE arg)
 
void rb_using_module (NODE *cref, VALUE module)
 
VALUE rb_refinement_module_get_refined_class (VALUE module)
 
static void add_activated_refinement (VALUE activated_refinements, VALUE klass, VALUE refinement)
 
VALUE rb_yield_refine_block (VALUE refinement, VALUE refinements)
 
static VALUE rb_mod_refine (VALUE module, VALUE klass)
 
void rb_obj_call_init (VALUE obj, int argc, VALUE *argv)
 
void rb_extend_object (VALUE obj, VALUE module)
 
static VALUE rb_mod_extend_object (VALUE mod, VALUE obj)
 
static VALUE rb_obj_extend (int argc, VALUE *argv, VALUE obj)
 
static VALUE top_include (int argc, VALUE *argv, VALUE self)
 
static VALUE top_using (VALUE self, VALUE module)
 
static VALUEerrinfo_place (rb_thread_t *th)
 
static VALUE get_thread_errinfo (rb_thread_t *th)
 
static VALUE errinfo_getter (ID id)
 
VALUE rb_errinfo (void)
 
void rb_set_errinfo (VALUE err)
 
VALUE rb_rubylevel_errinfo (void)
 
static VALUE errat_getter (ID id)
 
static void errat_setter (VALUE val, ID id, VALUE *var)
 
static VALUE rb_f_method_name (void)
 
static VALUE rb_f_callee_name (void)
 
static VALUE f_current_dirname (void)
 
void Init_eval (void)
 

Variables

VALUE rb_eLocalJumpError
 
VALUE rb_eSysStackError
 
VALUE rb_eThreadError
 

Macro Definition Documentation

#define exception_error   GET_VM()->special_exceptions[ruby_error_reenter]

Definition at line 32 of file eval.c.

Referenced by Init_eval(), and setup_exception().

#define numberof (   array)    (int)(sizeof(array) / sizeof((array)[0]))

Definition at line 23 of file eval.c.

Referenced by ruby_cleanup().

Function Documentation

static void add_activated_refinement ( VALUE  activated_refinements,
VALUE  klass,
VALUE  refinement 
)
static
static VALUE errat_getter ( ID  id)
static

Definition at line 1444 of file eval.c.

References err, get_backtrace(), get_errinfo(), NIL_P(), and Qnil.

Referenced by Init_eval().

static void errat_setter ( VALUE  val,
ID  id,
VALUE var 
)
static

Definition at line 1456 of file eval.c.

References err, get_errinfo(), NIL_P(), rb_eArgError, rb_raise(), and set_backtrace().

Referenced by Init_eval().

static VALUE errinfo_getter ( ID  id)
static

Definition at line 1397 of file eval.c.

References get_errinfo().

Referenced by Init_eval().

static VALUE* errinfo_place ( rb_thread_t th)
static
static VALUE f_current_dirname ( void  )
static

Definition at line 1512 of file eval.c.

References NIL_P(), Qnil, rb_current_realfilepath(), and rb_file_dirname().

Referenced by Init_eval().

static ID frame_called_id ( rb_control_frame_t cfp)
static
static ID frame_func_id ( rb_control_frame_t cfp)
static
static VALUE get_errinfo ( void  )
static
static VALUE get_thread_errinfo ( rb_thread_t th)
static

Definition at line 1379 of file eval.c.

References rb_thread_struct::errinfo, errinfo_place(), and ptr.

Referenced by get_errinfo().

static VALUE hidden_identity_hash_new ( )
static

Definition at line 1051 of file eval.c.

References hash, rb_funcall(), rb_hash_new(), rb_intern, and RBASIC.

Referenced by rb_mod_refine(), and rb_using_refinement().

void Init_eval ( void  )
static VALUE make_exception ( int  argc,
VALUE argv,
int  isstr 
)
static
static const rb_method_entry_t* method_entry_of_iseq ( rb_control_frame_t cfp,
rb_iseq_t iseq 
)
static
NORETURN ( void   rb_raise_jumpVALUE)
NORETURN ( static void   rb_longjmpint, volatile VALUE)
static rb_control_frame_t* previous_frame ( rb_thread_t th)
static
int rb_block_given_p ( void  )

Definition at line 672 of file eval.c.

References rb_thread_struct::cfp, FALSE, GET_THREAD(), rb_vm_control_frame_block_ptr(), th, and TRUE.

Referenced by argf_bytes(), argf_chars(), argf_codepoints(), argf_lines(), dh_generate(), dir_s_chdir(), dir_s_glob(), dir_s_open(), dsa_generate(), enum_chunk(), enum_count(), enum_find_index(), enum_grep(), enum_inject(), enum_max(), enum_min(), enum_minmax(), enum_slice_before(), enum_zip(), enumerator_each(), enumerator_initialize(), env_delete_m(), env_fetch(), env_update_i(), etc_group(), etc_passwd(), fdbm_delete(), fdbm_fetch(), fdbm_fetch_m(), fdbm_s_open(), fgdbm_fetch(), fgdbm_fetch_m(), fgdbm_s_open(), fsdbm_delete(), fsdbm_fetch(), fsdbm_fetch_m(), fsdbm_s_open(), generator_initialize(), gzfile_wrap(), lazy_drop_while(), lazy_flat_map(), lazy_grep(), lazy_initialize(), lazy_map(), lazy_reject(), lazy_select(), lazy_take_while(), lazy_to_enum(), lazy_zip(), mSyslog_open(), obj_to_enum(), ossl_pem_passwd_cb(), ossl_x509store_verify(), p_gid_switch(), p_uid_switch(), pack_unpack(), path_each_line(), path_open(), path_s_glob(), path_sub(), proc_call(), pty_getpty(), pty_open(), range_max(), range_min(), rb_ary_count(), rb_ary_delete(), rb_ary_fetch(), rb_ary_fill(), rb_ary_index(), rb_ary_initialize(), rb_ary_product(), rb_ary_rindex(), rb_ary_sort_bang(), rb_ary_uniq(), rb_ary_uniq_bang(), rb_ary_zip(), rb_dlhandle_initialize(), rb_f_at_exit(), rb_f_open(), rb_fiddle_handle_initialize(), rb_gzreader_bytes(), rb_gzreader_lines(), rb_hash_delete(), rb_hash_fetch_m(), rb_hash_initialize(), rb_hash_update(), rb_io_bytes(), rb_io_chars(), rb_io_codepoints(), rb_io_lines(), rb_io_s_new(), rb_io_s_open(), rb_io_s_pipe(), rb_io_s_popen(), rb_iterator_p(), rb_method_call(), rb_mod_initialize(), rb_mutex_synchronize_m(), rb_need_block(), rb_reg_match_m(), rb_scan_args(), rb_str_enumerate_bytes(), rb_str_enumerate_chars(), rb_str_enumerate_codepoints(), rb_str_enumerate_lines(), rb_str_match_m(), rb_str_scan(), rb_str_sub_bang(), rb_struct_s_def(), rb_thread_s_handle_interrupt(), rsa_generate(), specific_eval(), strio_bytes(), strio_chars(), strio_codepoints(), strio_lines(), strio_s_open(), thread_initialize(), tracepoint_disable_m(), tracepoint_enable_m(), tracepoint_new_s(), window_attron(), zstream_detach_buffer(), zstream_expand_buffer(), and zstream_run().

VALUE rb_ensure ( VALUE(*)(ANYARGS b_proc,
VALUE  data1,
VALUE(*)(ANYARGS e_proc,
VALUE  data2 
)
VALUE rb_errinfo ( void  )

Definition at line 1422 of file eval.c.

References rb_thread_struct::errinfo, GET_THREAD(), and th.

void rb_exc_fatal ( VALUE  mesg)

Definition at line 536 of file eval.c.

References FALSE, make_exception(), NIL_P(), rb_longjmp(), and TAG_FATAL.

Referenced by rb_fatal().

void rb_exc_raise ( VALUE  mesg)
void rb_extend_object ( VALUE  obj,
VALUE  module 
)
static VALUE rb_f_callee_name ( void  )
static

Definition at line 1489 of file eval.c.

References ID2SYM, Qnil, and rb_frame_callee().

Referenced by Init_eval().

static VALUE rb_f_method_name ( void  )
static

Definition at line 1476 of file eval.c.

References ID2SYM, Qnil, and rb_frame_caller().

Referenced by Init_eval().

static VALUE rb_f_raise ( int  argc,
VALUE argv 
)
static

Definition at line 577 of file eval.c.

References err, get_errinfo(), NIL_P(), rb_make_exception(), rb_raise_jump(), and UNREACHABLE.

Referenced by Init_eval().

ID rb_frame_callee ( void  )
static ID rb_frame_caller ( void  )
static

Definition at line 927 of file eval.c.

References frame_func_id(), GET_THREAD(), and previous_frame().

Referenced by rb_f_method_name().

ID rb_frame_this_func ( void  )
void rb_frozen_class_p ( VALUE  klass)
void rb_interrupt ( void  )

Definition at line 545 of file eval.c.

References rb_eInterrupt, and rb_raise().

Referenced by rb_signal_exec().

int rb_iterator_p ( void  )

Definition at line 685 of file eval.c.

References rb_block_given_p().

void rb_jump_tag ( int  tag)
static void rb_longjmp ( int  tag,
volatile VALUE  mesg 
)
static

Definition at line 516 of file eval.c.

References GET_THREAD(), JUMP_TAG, rb_thread_raised_clear, setup_exception(), and th.

Referenced by rb_exc_fatal(), and rb_exc_raise().

VALUE rb_make_exception ( int  argc,
VALUE argv 
)

Definition at line 642 of file eval.c.

References make_exception(), and TRUE.

Referenced by parser_set_encode(), rb_f_raise(), and rb_threadptr_raise().

static VALUE rb_mod_append_features ( VALUE  module,
VALUE  include 
)
static

Definition at line 947 of file eval.c.

References Check_Type, rb_include_module(), T_CLASS, T_MODULE, and TYPE.

Referenced by Init_eval().

static VALUE rb_mod_extend_object ( VALUE  mod,
VALUE  obj 
)
static

Definition at line 1260 of file eval.c.

References obj, and rb_extend_object().

Referenced by Init_eval().

static VALUE rb_mod_include ( int  argc,
VALUE argv,
VALUE  module 
)
static

Definition at line 970 of file eval.c.

References argc, Check_Type, CONST_ID, i, rb_funcall(), and T_MODULE.

Referenced by Init_eval(), and top_include().

static VALUE rb_mod_nesting ( void  )
static

Definition at line 334 of file eval.c.

References ary, RNode::flags, klass, NIL_P(), NODE_FL_CREF_PUSHED_BY_EVAL, rb_ary_new(), rb_ary_push(), and rb_vm_cref().

Referenced by Init_eval().

static VALUE rb_mod_prepend ( int  argc,
VALUE argv,
VALUE  module 
)
static

Definition at line 1023 of file eval.c.

References argc, Check_Type, CONST_ID, i, rb_funcall(), and T_MODULE.

Referenced by Init_eval().

static VALUE rb_mod_prepend_features ( VALUE  module,
VALUE  prepend 
)
static

Definition at line 1000 of file eval.c.

References Check_Type, rb_prepend_module(), T_CLASS, T_MODULE, and TYPE.

Referenced by Init_eval().

static VALUE rb_mod_refine ( VALUE  module,
VALUE  klass 
)
static
static VALUE rb_mod_s_constants ( int  argc,
VALUE argv,
VALUE  mod 
)
static
void rb_need_block ( void  )

Definition at line 693 of file eval.c.

References Qnil, rb_block_given_p(), and rb_vm_localjump_error().

Referenced by generator_initialize(), and yielder_initialize().

void rb_obj_call_init ( VALUE  obj,
int  argc,
VALUE argv 
)
static VALUE rb_obj_extend ( int  argc,
VALUE argv,
VALUE  obj 
)
static

Definition at line 1292 of file eval.c.

References argc, Check_Type, CONST_ID, i, obj, rb_check_arity, rb_funcall(), T_MODULE, and UNLIMITED_ARGUMENTS.

Referenced by Init_eval().

VALUE rb_protect ( VALUE(*)(VALUE proc,
VALUE  data,
int state 
)
void rb_raise_jump ( VALUE  mesg)
VALUE rb_refinement_module_get_refined_class ( VALUE  module)

Definition at line 1122 of file eval.c.

References CONST_ID, and rb_attr_get().

Referenced by include_modules_at(), rb_method_entry_make(), and rb_mod_to_s().

VALUE rb_rescue ( VALUE(*)(ANYARGS b_proc,
VALUE  data1,
VALUE(*)(ANYARGS r_proc,
VALUE  data2 
)

Definition at line 763 of file eval.c.

References rb_eStandardError, and rb_rescue2().

Referenced by cmp_equal(), do_coerce(), range_init(), and time_mload().

VALUE rb_rescue2 ( VALUE(*)(ANYARGS b_proc,
VALUE  data1,
VALUE(*)(ANYARGS r_proc,
VALUE  data2,
  ... 
)
VALUE rb_rubylevel_errinfo ( void  )

Definition at line 1438 of file eval.c.

References get_errinfo().

void rb_set_errinfo ( VALUE  err)
void rb_using_module ( NODE cref,
VALUE  module 
)

Definition at line 1110 of file eval.c.

References Check_Type, CONST_ID, NIL_P(), rb_attr_get(), rb_hash_foreach(), T_MODULE, and using_refinement().

Referenced by top_using().

void rb_using_refinement ( NODE cref,
VALUE  klass,
VALUE  module 
)
NODE* rb_vm_get_cref ( const rb_iseq_t ,
const VALUE  
)
VALUE rb_yield_refine_block ( VALUE  refinement,
VALUE  refinements 
)
static int ruby_exec_internal ( void n)
static
static void ruby_finalize_0 ( void  )
static

Definition at line 111 of file eval.c.

References EXEC_TAG, POP_TAG, PUSH_TAG, rb_clear_trace_func(), rb_exec_end_proc(), and rb_trap_exit().

Referenced by ruby_cleanup(), and ruby_finalize().

static void ruby_finalize_1 ( void  )
static
void ruby_stop ( int  ex)

Calls ruby_cleanup() and exits the process.

Definition at line 261 of file eval.c.

References ruby_cleanup().

Referenced by thread_start_func_2().

static void setup_exception ( rb_thread_t th,
int  tag,
volatile VALUE  mesg 
)
static
static VALUE top_include ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 1320 of file eval.c.

References GET_THREAD(), rb_cObject, rb_mod_include(), rb_secure(), rb_warning(), th, and rb_thread_struct::top_wrapper.

Referenced by Init_eval().

static VALUE top_using ( VALUE  self,
VALUE  module 
)
static
static int using_refinement ( VALUE  klass,
VALUE  module,
VALUE  arg 
)
static

Definition at line 1101 of file eval.c.

References rb_using_refinement(), and ST_CONTINUE.

Referenced by rb_using_module().

static void warn_refinements_once ( )
static

Definition at line 1040 of file eval.c.

References rb_warn().

Referenced by rb_mod_refine(), and top_using().

Variable Documentation

VALUE rb_eLocalJumpError

Definition at line 29 of file eval.c.

Referenced by Init_Proc(), and make_localjump_error().

VALUE rb_eSysStackError

Definition at line 30 of file eval.c.

Referenced by error_print(), and Init_Proc().

VALUE rb_eThreadError