1 /**********************************************************************
6 created at: Thu Jun 10 14:22:17 JST 1993
8 Copyright (C) 1993-2007 Yukihiro Matsumoto
9 Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
10 Copyright (C) 2000 Information-technology Promotion Agency, Japan
12 **********************************************************************/
14 #include "eval_intern.h"
16 VALUE
proc_invoke(VALUE
, VALUE
, VALUE
, VALUE
);
17 VALUE
rb_binding_new(void);
18 NORETURN(void rb_raise_jump(VALUE
));
20 ID
rb_frame_callee(void);
21 VALUE rb_eLocalJumpError
;
22 VALUE rb_eSysStackError
;
24 #define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
26 #include "eval_error.c"
27 #include "eval_safe.c"
28 #include "eval_jump.c"
32 #if defined(__APPLE__)
33 #define environ (*_NSGetEnviron())
34 #elif !defined(_WIN32) && !defined(__MACOS__) || defined(_WIN32_WCE)
35 extern char **environ
;
37 char **rb_origenviron
;
39 void rb_clear_trace_func(void);
40 void rb_thread_stop_timer_thread(void);
42 void rb_call_inits(void);
45 void Init_BareVM(void);
50 static int initialized
= 0;
60 rb_origenviron
= environ
;
63 Init_stack((void *)&state
);
68 if ((state
= EXEC_TAG()) == 0) {
86 GET_VM()->running
= 1;
89 extern void rb_clear_trace_func(void);
92 ruby_options(int argc
, char **argv
)
97 Init_stack((void *)&state
);
99 if ((state
= EXEC_TAG()) == 0) {
100 SAVE_ROOT_JMPBUF(GET_THREAD(), tree
= ruby_process_options(argc
, argv
));
103 rb_clear_trace_func();
104 state
= error_handle(state
);
105 tree
= (void *)INT2FIX(state
);
112 ruby_finalize_0(void)
115 if (EXEC_TAG() == 0) {
120 rb_clear_trace_func();
124 ruby_finalize_1(void)
127 GET_THREAD()->errinfo
= Qnil
;
128 rb_gc_call_finalizer_at_exit();
138 void rb_thread_stop_timer_thread(void);
144 volatile VALUE errs
[2];
145 rb_thread_t
*th
= GET_THREAD();
148 errs
[1] = th
->errinfo
;
150 Init_stack((void *)&state
);
153 if ((state
= EXEC_TAG()) == 0) {
154 SAVE_ROOT_JMPBUF(th
, ruby_finalize_0());
158 errs
[0] = th
->errinfo
;
160 if ((state
= EXEC_TAG()) == 0) {
161 SAVE_ROOT_JMPBUF(th
, rb_thread_terminate_all());
166 th
->errinfo
= errs
[1];
167 ex
= error_handle(ex
);
170 rb_thread_stop_timer_thread();
172 for (nerr
= 0; nerr
< sizeof(errs
) / sizeof(errs
[0]); ++nerr
) {
173 VALUE err
= errs
[nerr
];
175 if (!RTEST(err
)) continue;
177 /* th->errinfo contains a NODE while break'ing */
178 if (TYPE(err
) == T_NODE
) continue;
180 if (rb_obj_is_kind_of(err
, rb_eSystemExit
)) {
181 return sysexit_status(err
);
183 else if (rb_obj_is_kind_of(err
, rb_eSignal
)) {
184 VALUE sig
= rb_iv_get(err
, "signo");
185 ruby_default_signal(NUM2INT(sig
));
192 #if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
194 #if EXIT_SUCCESS != 0
195 case 0: return EXIT_SUCCESS
;
197 #if EXIT_FAILURE != 1
198 case 1: return EXIT_FAILURE
;
207 ruby_exec_node(void *n
, const char *file
)
210 VALUE iseq
= (VALUE
)n
;
211 rb_thread_t
*th
= GET_THREAD();
216 if ((state
= EXEC_TAG()) == 0) {
217 SAVE_ROOT_JMPBUF(th
, {
229 exit(ruby_cleanup(ex
));
233 ruby_run_node(void *n
)
238 case Qtrue
: return EXIT_SUCCESS
;
239 case Qfalse
: return EXIT_FAILURE
;
244 Init_stack((void *)&n
);
245 return ruby_cleanup(ruby_exec_node(n
, 0));
250 * Module.nesting => array
252 * Returns the list of +Modules+ nested at the point of call.
256 * $a = Module.nesting
259 * $a #=> [M1::M2, M1]
260 * $a[0].name #=> "M1::M2"
266 VALUE ary
= rb_ary_new();
267 const NODE
*cref
= vm_cref();
269 while (cref
&& cref
->nd_next
) {
270 VALUE klass
= cref
->nd_clss
;
272 rb_ary_push(ary
, klass
);
274 cref
= cref
->nd_next
;
281 * Module.constants => array
283 * Returns an array of the names of all constants defined in the
284 * system. This list includes the names of all modules and classes.
286 * p Module.constants.sort[1..5]
290 * ["ARGV", "ArgumentError", "Array", "Bignum", "Binding"]
294 rb_mod_s_constants(int argc
, VALUE
*argv
, VALUE mod
)
296 const NODE
*cref
= vm_cref();
302 return rb_mod_constants(argc
, argv
, rb_cModule
);
306 klass
= cref
->nd_clss
;
308 data
= rb_mod_const_at(cref
->nd_clss
, data
);
313 cref
= cref
->nd_next
;
317 data
= rb_mod_const_of(cbase
, data
);
319 return rb_const_list(data
);
323 rb_frozen_class_p(VALUE klass
)
325 const char *desc
= "something(?!)";
327 if (OBJ_FROZEN(klass
)) {
328 if (FL_TEST(klass
, FL_SINGLETON
))
331 switch (TYPE(klass
)) {
341 rb_error_frozen(desc
);
345 NORETURN(static void rb_longjmp(int, VALUE
));
346 VALUE
rb_make_backtrace(void);
349 rb_longjmp(int tag
, VALUE mesg
)
353 rb_thread_t
*th
= GET_THREAD();
357 if (rb_thread_set_raised(th
)) {
358 th
->errinfo
= exception_error
;
365 mesg
= rb_exc_new(rb_eRuntimeError
, 0, 0);
368 file
= rb_sourcefile();
369 if (file
) line
= rb_sourceline();
370 if (file
&& !NIL_P(mesg
)) {
371 at
= get_backtrace(mesg
);
373 at
= rb_make_backtrace();
374 if (OBJ_FROZEN(mesg
)) {
375 mesg
= rb_obj_dup(mesg
);
377 set_backtrace(mesg
, at
);
384 if (RTEST(ruby_debug
) && !NIL_P(e
= th
->errinfo
) &&
385 !rb_obj_is_kind_of(e
, rb_eSystemExit
)) {
389 if ((status
= EXEC_TAG()) == 0) {
390 RB_GC_GUARD(e
) = rb_obj_as_string(e
);
392 warn_printf("Exception `%s' at %s:%d - %s\n",
393 rb_obj_classname(th
->errinfo
),
394 file
, line
, RSTRING_PTR(e
));
397 warn_printf("Exception `%s' - %s\n",
398 rb_obj_classname(th
->errinfo
),
403 if (status
== TAG_FATAL
&& th
->errinfo
== exception_error
) {
407 rb_thread_reset_raised(th
);
412 rb_trap_restore_mask();
414 if (tag
!= TAG_FATAL
) {
415 EXEC_EVENT_HOOK(th
, RUBY_EVENT_RAISE
, th
->cfp
->self
,
416 0 /* TODO: id */, 0 /* TODO: klass */);
419 rb_thread_raised_clear(th
);
424 rb_exc_raise(VALUE mesg
)
426 rb_longjmp(TAG_RAISE
, mesg
);
430 rb_exc_fatal(VALUE mesg
)
432 rb_longjmp(TAG_FATAL
, mesg
);
438 rb_raise(rb_eInterrupt
, "%s", "");
441 static VALUE
get_errinfo(void);
447 * raise(exception [, string [, array]])
450 * fail(exception [, string [, array]])
452 * With no arguments, raises the exception in <code>$!</code> or raises
453 * a <code>RuntimeError</code> if <code>$!</code> is +nil+.
454 * With a single +String+ argument, raises a
455 * +RuntimeError+ with the string as a message. Otherwise,
456 * the first parameter should be the name of an +Exception+
457 * class (or an object that returns an +Exception+ object when sent
458 * an +exception+ message). The optional second parameter sets the
459 * message associated with the exception, and the third parameter is an
460 * array of callback information. Exceptions are caught by the
461 * +rescue+ clause of <code>begin...end</code> blocks.
463 * raise "Failed to create socket"
464 * raise ArgumentError, "No parameters", caller
468 rb_f_raise(int argc
, VALUE
*argv
)
478 rb_raise_jump(rb_make_exception(argc
, argv
));
479 return Qnil
; /* not reached */
483 rb_make_exception(int argc
, VALUE
*argv
)
497 if (TYPE(argv
[0]) == T_STRING
) {
498 mesg
= rb_exc_new3(rb_eRuntimeError
, argv
[0]);
508 CONST_ID(exception
, "exception");
509 if (!rb_respond_to(argv
[0], exception
)) {
510 rb_raise(rb_eTypeError
, "exception class/object expected");
512 mesg
= rb_funcall(argv
[0], exception
, n
, argv
[1]);
515 rb_raise(rb_eArgError
, "wrong number of arguments");
519 if (!rb_obj_is_kind_of(mesg
, rb_eException
))
520 rb_raise(rb_eTypeError
, "exception object expected");
522 set_backtrace(mesg
, argv
[2]);
529 rb_raise_jump(VALUE mesg
)
531 rb_thread_t
*th
= GET_THREAD();
532 th
->cfp
= RUBY_VM_PREVIOUS_CONTROL_FRAME(th
->cfp
);
534 rb_longjmp(TAG_RAISE
, mesg
);
544 rb_block_given_p(void)
546 rb_thread_t
*th
= GET_THREAD();
548 if ((th
->cfp
->lfp
[0] & 0x02) == 0 &&
549 GC_GUARDED_PTR_REF(th
->cfp
->lfp
[0])) {
560 return rb_block_given_p();
565 * block_given? => true or false
566 * iterator? => true or false
568 * Returns <code>true</code> if <code>yield</code> would execute a
569 * block in the current context. The <code>iterator?</code> form
570 * is mildly deprecated.
580 * try { "hello" } #=> "hello"
581 * try do "hello" end #=> "hello"
586 rb_f_block_given_p(void)
588 rb_thread_t
*th
= GET_THREAD();
589 rb_control_frame_t
*cfp
= th
->cfp
;
590 cfp
= vm_get_ruby_level_caller_cfp(th
, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp
));
593 (cfp
->lfp
[0] & 0x02) == 0 &&
594 GC_GUARDED_PTR_REF(cfp
->lfp
[0])) {
602 VALUE rb_eThreadError
;
607 if (!rb_block_given_p()) {
608 vm_localjump_error("no block given", Qnil
, 0);
613 rb_rescue2(VALUE (* b_proc
) (ANYARGS
), VALUE data1
,
614 VALUE (* r_proc
) (ANYARGS
), VALUE data2
, ...)
617 rb_thread_t
*th
= GET_THREAD();
618 rb_control_frame_t
*cfp
= th
->cfp
;
619 volatile VALUE result
;
620 volatile VALUE e_info
= th
->errinfo
;
624 if ((state
= EXEC_TAG()) == 0) {
626 result
= (*b_proc
) (data1
);
629 th
->cfp
= cfp
; /* restore */
631 if (state
== TAG_RAISE
) {
635 va_init_list(args
, data2
);
636 while ((eclass
= va_arg(args
, VALUE
)) != 0) {
637 if (rb_obj_is_kind_of(th
->errinfo
, eclass
)) {
647 if ((state
= EXEC_TAG()) == 0) {
648 result
= (*r_proc
) (data2
, th
->errinfo
);
651 if (state
== TAG_RETRY
) {
662 th
->errinfo
= e_info
;
675 rb_rescue(VALUE (* b_proc
)(ANYARGS
), VALUE data1
,
676 VALUE (* r_proc
)(ANYARGS
), VALUE data2
)
678 return rb_rescue2(b_proc
, data1
, r_proc
, data2
, rb_eStandardError
,
683 rb_protect(VALUE (* proc
) (VALUE
), VALUE data
, int * state
)
685 VALUE result
= Qnil
; /* OK */
687 rb_thread_t
*th
= GET_THREAD();
688 rb_control_frame_t
*cfp
= th
->cfp
;
689 struct rb_vm_trap_tag trap_tag
;
690 rb_jmpbuf_t org_jmpbuf
;
692 trap_tag
.prev
= th
->trap_tag
;
695 th
->trap_tag
= &trap_tag
;
696 MEMCPY(&org_jmpbuf
, &(th
)->root_jmpbuf
, rb_jmpbuf_t
, 1);
697 if ((status
= EXEC_TAG()) == 0) {
698 SAVE_ROOT_JMPBUF(th
, result
= (*proc
) (data
));
700 MEMCPY(&(th
)->root_jmpbuf
, &org_jmpbuf
, rb_jmpbuf_t
, 1);
701 th
->trap_tag
= trap_tag
.prev
;
716 rb_ensure(VALUE (*b_proc
)(ANYARGS
), VALUE data1
, VALUE (*e_proc
)(ANYARGS
), VALUE data2
)
719 volatile VALUE result
= Qnil
;
722 if ((state
= EXEC_TAG()) == 0) {
723 result
= (*b_proc
) (data1
);
727 /* retval = prot_tag ? prot_tag->retval : Qnil; */ /* save retval */
735 rb_with_disable_interrupt(VALUE (*proc
)(ANYARGS
), VALUE data
)
737 VALUE result
= Qnil
; /* OK */
742 int thr_critical
= rb_thread_critical
;
744 rb_thread_critical
= Qtrue
;
746 if ((status
= EXEC_TAG()) == 0) {
747 result
= (*proc
) (data
);
750 rb_thread_critical
= thr_critical
;
760 frame_func_id(rb_control_frame_t
*cfp
)
762 rb_iseq_t
*iseq
= cfp
->iseq
;
764 return cfp
->method_id
;
767 if (RUBY_VM_IFUNC_P(iseq
)) {
768 return rb_intern("<ifunc>");
770 if (iseq
->defined_method_id
) {
771 return iseq
->defined_method_id
;
773 if (iseq
->local_iseq
== iseq
) {
776 iseq
= iseq
->parent_iseq
;
782 rb_frame_this_func(void)
784 return frame_func_id(GET_THREAD()->cfp
);
788 rb_frame_callee(void)
790 rb_thread_t
*th
= GET_THREAD();
791 rb_control_frame_t
*prev_cfp
= RUBY_VM_PREVIOUS_CONTROL_FRAME(th
->cfp
);
792 /* check if prev_cfp can be accessible */
793 if ((void *)(th
->stack
+ th
->stack_size
) == (void *)(prev_cfp
)) {
796 return frame_func_id(prev_cfp
);
802 rb_thread_t
*th
= GET_THREAD();
803 th
->cfp
= RUBY_VM_PREVIOUS_CONTROL_FRAME(th
->cfp
);
808 * append_features(mod) => mod
810 * When this module is included in another, Ruby calls
811 * <code>append_features</code> in this module, passing it the
812 * receiving module in _mod_. Ruby's default implementation is
813 * to add the constants, methods, and module variables of this module
814 * to _mod_ if this module has not already been added to
815 * _mod_ or one of its ancestors. See also <code>Module#include</code>.
819 rb_mod_append_features(VALUE module
, VALUE include
)
821 switch (TYPE(include
)) {
826 Check_Type(include
, T_CLASS
);
829 rb_include_module(include
, module
);
836 * include(module, ...) => self
838 * Invokes <code>Module.append_features</code> on each parameter in turn.
842 rb_mod_include(int argc
, VALUE
*argv
, VALUE module
)
846 for (i
= 0; i
< argc
; i
++)
847 Check_Type(argv
[i
], T_MODULE
);
849 rb_funcall(argv
[argc
], rb_intern("append_features"), 1, module
);
850 rb_funcall(argv
[argc
], rb_intern("included"), 1, module
);
856 rb_obj_call_init(VALUE obj
, int argc
, VALUE
*argv
)
859 rb_funcall2(obj
, idInitialize
, argc
, argv
);
863 rb_extend_object(VALUE obj
, VALUE module
)
865 rb_include_module(rb_singleton_class(obj
), module
);
870 * extend_object(obj) => obj
872 * Extends the specified object by adding this module's constants and
873 * methods (which are added as singleton methods). This is the callback
874 * method used by <code>Object#extend</code>.
877 * def Picky.extend_object(o)
879 * puts "Can't add Picky to a String"
881 * puts "Picky added to #{o.class}"
886 * (s = Array.new).extend Picky # Call Object.extend
887 * (s = "quick brown fox").extend Picky
891 * Picky added to Array
892 * Can't add Picky to a String
896 rb_mod_extend_object(VALUE mod
, VALUE obj
)
898 rb_extend_object(obj
, mod
);
904 * obj.extend(module, ...) => obj
906 * Adds to _obj_ the instance methods from each module given as a
911 * "Hello from Mod.\n"
917 * "Hello from Klass.\n"
922 * k.hello #=> "Hello from Klass.\n"
923 * k.extend(Mod) #=> #<Klass:0x401b3bc8>
924 * k.hello #=> "Hello from Mod.\n"
928 rb_obj_extend(int argc
, VALUE
*argv
, VALUE obj
)
933 rb_raise(rb_eArgError
, "wrong number of arguments (0 for 1)");
935 for (i
= 0; i
< argc
; i
++)
936 Check_Type(argv
[i
], T_MODULE
);
938 rb_funcall(argv
[argc
], rb_intern("extend_object"), 1, obj
);
939 rb_funcall(argv
[argc
], rb_intern("extended"), 1, obj
);
946 * include(module, ...) => self
948 * Invokes <code>Module.append_features</code>
949 * on each parameter in turn. Effectively adds the methods and constants
950 * in each module to the receiver.
954 top_include(int argc
, VALUE
*argv
, VALUE self
)
956 rb_thread_t
*th
= GET_THREAD();
959 if (th
->top_wrapper
) {
961 ("main#include in the wrapped load is effective only in wrapper module");
962 return rb_mod_include(argc
, argv
, th
->top_wrapper
);
964 return rb_mod_include(argc
, argv
, rb_cObject
);
967 VALUE
rb_f_trace_var();
968 VALUE
rb_f_untrace_var();
973 rb_thread_t
*th
= GET_THREAD();
974 rb_control_frame_t
*cfp
= th
->cfp
;
975 rb_control_frame_t
*end_cfp
= RUBY_VM_END_CONTROL_FRAME(th
);
977 while (RUBY_VM_VALID_CONTROL_FRAME_P(cfp
, end_cfp
)) {
978 if (RUBY_VM_NORMAL_ISEQ_P(cfp
->iseq
)) {
979 if (cfp
->iseq
->type
== ISEQ_TYPE_RESCUE
) {
980 return &cfp
->dfp
[-2];
982 else if (cfp
->iseq
->type
== ISEQ_TYPE_ENSURE
&&
983 TYPE(cfp
->dfp
[-2]) != T_NODE
&&
984 !FIXNUM_P(cfp
->dfp
[-2])) {
985 return &cfp
->dfp
[-2];
988 cfp
= RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp
);
996 VALUE
*ptr
= errinfo_place();
1006 errinfo_getter(ID id
)
1008 return get_errinfo();
1013 errinfo_setter(VALUE val
, ID id
, VALUE
*var
)
1015 if (!NIL_P(val
) && !rb_obj_is_kind_of(val
, rb_eException
)) {
1016 rb_raise(rb_eTypeError
, "assigning non-exception to $!");
1019 VALUE
*ptr
= errinfo_place();
1024 rb_raise(rb_eRuntimeError
, "errinfo_setter: not in rescue clause.");
1033 rb_thread_t
*th
= GET_THREAD();
1038 rb_set_errinfo(VALUE err
)
1040 if (!NIL_P(err
) && !rb_obj_is_kind_of(err
, rb_eException
)) {
1041 rb_raise(rb_eTypeError
, "assigning non-exception to $!");
1043 GET_THREAD()->errinfo
= err
;
1047 rb_rubylevel_errinfo(void)
1049 return get_errinfo();
1055 VALUE err
= get_errinfo();
1057 return get_backtrace(err
);
1065 errat_setter(VALUE val
, ID id
, VALUE
*var
)
1067 VALUE err
= get_errinfo();
1069 rb_raise(rb_eArgError
, "$! not set");
1071 set_backtrace(err
, val
);
1074 int vm_collect_local_variables_in_heap(rb_thread_t
*th
, VALUE
*dfp
, VALUE ary
);
1078 * local_variables => array
1080 * Returns the names of the current local variables.
1086 * local_variables #=> ["fred", "i"]
1090 rb_f_local_variables(void)
1092 VALUE ary
= rb_ary_new();
1093 rb_thread_t
*th
= GET_THREAD();
1094 rb_control_frame_t
*cfp
=
1095 vm_get_ruby_level_caller_cfp(th
, RUBY_VM_PREVIOUS_CONTROL_FRAME(th
->cfp
));
1100 for (i
= 0; i
< cfp
->iseq
->local_table_size
; i
++) {
1101 ID lid
= cfp
->iseq
->local_table
[i
];
1103 const char *vname
= rb_id2name(lid
);
1104 /* should skip temporary variable */
1106 rb_ary_push(ary
, ID2SYM(lid
));
1111 if (cfp
->lfp
!= cfp
->dfp
) {
1113 VALUE
*dfp
= GC_GUARDED_PTR_REF(cfp
->dfp
[0]);
1115 if (vm_collect_local_variables_in_heap(th
, dfp
, ary
)) {
1119 while (cfp
->dfp
!= dfp
) {
1120 cfp
= RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp
);
1134 * __method__ => symbol
1135 * __callee__ => symbol
1137 * Returns the name of the current method as a Symbol.
1138 * If called outside of a method, it returns <code>nil</code>.
1143 rb_f_method_name(void)
1145 ID fname
= rb_frame_callee();
1148 return ID2SYM(fname
);
1158 /* TODO: fix position */
1159 GET_THREAD()->vm
->mark_object_ary
= rb_ary_new();
1161 rb_define_virtual_variable("$@", errat_getter
, errat_setter
);
1162 rb_define_virtual_variable("$!", errinfo_getter
, 0);
1164 rb_define_global_function("eval", rb_f_eval
, -1);
1165 rb_define_global_function("iterator?", rb_f_block_given_p
, 0);
1166 rb_define_global_function("block_given?", rb_f_block_given_p
, 0);
1168 rb_define_global_function("raise", rb_f_raise
, -1);
1169 rb_define_global_function("fail", rb_f_raise
, -1);
1171 rb_define_global_function("global_variables", rb_f_global_variables
, 0); /* in variable.c */
1172 rb_define_global_function("local_variables", rb_f_local_variables
, 0);
1174 rb_define_global_function("__method__", rb_f_method_name
, 0);
1175 rb_define_global_function("__callee__", rb_f_method_name
, 0);
1177 rb_define_private_method(rb_cModule
, "append_features", rb_mod_append_features
, 1);
1178 rb_define_private_method(rb_cModule
, "extend_object", rb_mod_extend_object
, 1);
1179 rb_define_private_method(rb_cModule
, "include", rb_mod_include
, -1);
1180 rb_define_method(rb_cModule
, "module_eval", rb_mod_module_eval
, -1);
1181 rb_define_method(rb_cModule
, "class_eval", rb_mod_module_eval
, -1);
1183 rb_undef_method(rb_cClass
, "module_function");
1186 extern void Init_vm_eval(void);
1187 extern void Init_eval_method(void);
1192 rb_define_singleton_method(rb_cModule
, "nesting", rb_mod_nesting
, 0);
1193 rb_define_singleton_method(rb_cModule
, "constants", rb_mod_s_constants
, -1);
1195 rb_define_singleton_method(rb_vm_top_self(), "include", top_include
, -1);
1197 rb_define_method(rb_mKernel
, "extend", rb_obj_extend
, -1);
1199 rb_define_global_function("trace_var", rb_f_trace_var
, -1); /* in variable.c */
1200 rb_define_global_function("untrace_var", rb_f_untrace_var
, -1); /* in variable.c */
1202 rb_define_virtual_variable("$SAFE", safe_getter
, safe_setter
);
1204 exception_error
= rb_exc_new3(rb_eFatal
,
1205 rb_obj_freeze(rb_str_new2("exception reentered")));
1206 rb_ivar_set(exception_error
, idThrowState
, INT2FIX(TAG_FATAL
));
1207 OBJ_TAINT(exception_error
);
1208 OBJ_FREEZE(exception_error
);
1215 rb_dvar_defined(ID id
)
1217 rb_thread_t
*th
= GET_THREAD();
1219 if (th
->base_block
&& (iseq
= th
->base_block
->iseq
)) {
1220 while (iseq
->type
== ISEQ_TYPE_BLOCK
||
1221 iseq
->type
== ISEQ_TYPE_RESCUE
||
1222 iseq
->type
== ISEQ_TYPE_ENSURE
||
1223 iseq
->type
== ISEQ_TYPE_EVAL
) {
1226 for (i
= 0; i
< iseq
->local_table_size
; i
++) {
1227 if (iseq
->local_table
[i
] == id
) {
1231 iseq
= iseq
->parent_iseq
;
1238 rb_local_defined(ID id
)
1240 rb_thread_t
*th
= GET_THREAD();
1243 if (th
->base_block
&& th
->base_block
->iseq
) {
1245 iseq
= th
->base_block
->iseq
->local_iseq
;
1247 for (i
=0; i
<iseq
->local_table_size
; i
++) {
1248 if (iseq
->local_table
[i
] == id
) {
1257 rb_parse_in_eval(void)
1259 return GET_THREAD()->parse_in_eval
!= 0;