VALUE rb_eval_cmd(VALUE cmd, VALUE arg, int level) { int state; VALUE val = Qnil; /* OK */ volatile int safe = rb_safe_level(); if (OBJ_TAINTED(cmd)) { level = 4; } if (TYPE(cmd) != T_STRING) { PUSH_TAG(); rb_set_safe_level_force(level); if ((state = EXEC_TAG()) == 0) { val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LEN(arg), RARRAY_PTR(arg)); } POP_TAG(); rb_set_safe_level_force(safe); if (state) JUMP_TAG(state); return val; } PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { val = eval_string(rb_vm_top_self(), cmd, Qnil, 0, 0); } POP_TAG(); rb_set_safe_level_force(safe); if (state) rb_vm_jump_tag_but_local_jump(state, val); return val; }
static inline void rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap) { int state; volatile VALUE wrapper = th->top_wrapper; volatile VALUE self = th->top_self; volatile int loaded = FALSE; volatile int mild_compile_error; #if !defined __GNUC__ rb_thread_t *volatile th0 = th; #endif th->errinfo = Qnil; /* ensure */ if (!wrap) { th->top_wrapper = 0; } else { /* load in anonymous module as toplevel */ th->top_self = rb_obj_clone(rb_vm_top_self()); th->top_wrapper = rb_module_new(); rb_extend_object(th->top_self, th->top_wrapper); } mild_compile_error = th->mild_compile_error; TH_PUSH_TAG(th); state = EXEC_TAG(); if (state == 0) { NODE *node; VALUE iseq; th->mild_compile_error++; node = (NODE *)rb_load_file_str(fname); loaded = TRUE; iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse); th->mild_compile_error--; rb_iseq_eval(iseq); } TH_POP_TAG(); #if !defined __GNUC__ th = th0; fname = RB_GC_GUARD(fname); #endif th->mild_compile_error = mild_compile_error; th->top_self = self; th->top_wrapper = wrapper; if (!loaded && !FIXNUM_P(th->errinfo)) { /* an error on loading don't include INT2FIX(TAG_FATAL) see r35625 */ rb_exc_raise(th->errinfo); } if (state) { rb_vm_jump_tag_but_local_jump(state); } if (!NIL_P(th->errinfo)) { /* exception during load */ rb_exc_raise(th->errinfo); } }
static void rb_load_internal(VALUE fname, int wrap) { int state; rb_thread_t *th = GET_THREAD(); volatile VALUE wrapper = th->top_wrapper; volatile VALUE self = th->top_self; volatile int loaded = FALSE; volatile int mild_compile_error; #ifndef __GNUC__ rb_thread_t *volatile th0 = th; #endif th->errinfo = Qnil; /* ensure */ if (!wrap) { rb_secure(4); /* should alter global state */ th->top_wrapper = 0; } else { /* load in anonymous module as toplevel */ th->top_self = rb_obj_clone(rb_vm_top_self()); th->top_wrapper = rb_module_new(); rb_extend_object(th->top_self, th->top_wrapper); } mild_compile_error = th->mild_compile_error; PUSH_TAG(); state = EXEC_TAG(); if (state == 0) { NODE *node; VALUE iseq; th->mild_compile_error++; node = (NODE *)rb_load_file(RSTRING_PTR(fname)); loaded = TRUE; iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse); th->mild_compile_error--; rb_iseq_eval(iseq); } POP_TAG(); #ifndef __GNUC__ th = th0; fname = RB_GC_GUARD(fname); #endif th->mild_compile_error = mild_compile_error; th->top_self = self; th->top_wrapper = wrapper; if (!loaded) { rb_exc_raise(GET_THREAD()->errinfo); } if (state) { rb_vm_jump_tag_but_local_jump(state, Qundef); } if (!NIL_P(GET_THREAD()->errinfo)) { /* exception during load */ rb_exc_raise(th->errinfo); } }