mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
eval.c: static IDs
* eval.c (ruby_static_id_signo, ruby_static_id_status): add static IDs, signo and status. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
556515bf69
commit
0d20fbe3bd
5 changed files with 21 additions and 9 deletions
5
error.c
5
error.c
|
@ -646,10 +646,12 @@ VALUE rb_mErrno;
|
||||||
static VALUE rb_eNOERROR;
|
static VALUE rb_eNOERROR;
|
||||||
|
|
||||||
static ID id_new, id_cause, id_message, id_backtrace;
|
static ID id_new, id_cause, id_message, id_backtrace;
|
||||||
static ID id_status, id_name, id_args, id_Errno, id_errno, id_i_path;
|
static ID id_name, id_args, id_Errno, id_errno, id_i_path;
|
||||||
|
extern ID ruby_static_id_status;
|
||||||
#define id_bt idBt
|
#define id_bt idBt
|
||||||
#define id_bt_locations idBt_locations
|
#define id_bt_locations idBt_locations
|
||||||
#define id_mesg idMesg
|
#define id_mesg idMesg
|
||||||
|
#define id_status ruby_static_id_status
|
||||||
|
|
||||||
#undef rb_exc_new_cstr
|
#undef rb_exc_new_cstr
|
||||||
|
|
||||||
|
@ -1913,7 +1915,6 @@ Init_Exception(void)
|
||||||
id_cause = rb_intern_const("cause");
|
id_cause = rb_intern_const("cause");
|
||||||
id_message = rb_intern_const("message");
|
id_message = rb_intern_const("message");
|
||||||
id_backtrace = rb_intern_const("backtrace");
|
id_backtrace = rb_intern_const("backtrace");
|
||||||
id_status = rb_intern_const("status");
|
|
||||||
id_name = rb_intern_const("name");
|
id_name = rb_intern_const("name");
|
||||||
id_args = rb_intern_const("args");
|
id_args = rb_intern_const("args");
|
||||||
id_Errno = rb_intern_const("Errno");
|
id_Errno = rb_intern_const("Errno");
|
||||||
|
|
9
eval.c
9
eval.c
|
@ -24,6 +24,10 @@ NORETURN(void rb_raise_jump(VALUE, VALUE));
|
||||||
VALUE rb_eLocalJumpError;
|
VALUE rb_eLocalJumpError;
|
||||||
VALUE rb_eSysStackError;
|
VALUE rb_eSysStackError;
|
||||||
|
|
||||||
|
ID ruby_static_id_signo, ruby_static_id_status;
|
||||||
|
#define id_signo ruby_static_id_signo
|
||||||
|
#define id_status ruby_static_id_status
|
||||||
|
|
||||||
#define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
|
#define exception_error GET_VM()->special_exceptions[ruby_error_reenter]
|
||||||
|
|
||||||
#include "eval_error.c"
|
#include "eval_error.c"
|
||||||
|
@ -218,7 +222,7 @@ ruby_cleanup(volatile int ex)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (rb_obj_is_kind_of(err, rb_eSignal)) {
|
else if (rb_obj_is_kind_of(err, rb_eSignal)) {
|
||||||
VALUE sig = rb_iv_get(err, "signo");
|
VALUE sig = rb_ivar_get(err, id_signo);
|
||||||
state = NUM2INT(sig);
|
state = NUM2INT(sig);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1711,4 +1715,7 @@ Init_eval(void)
|
||||||
rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
|
rb_define_global_function("untrace_var", rb_f_untrace_var, -1); /* in variable.c */
|
||||||
|
|
||||||
rb_vm_register_special_exception(ruby_error_reenter, rb_eFatal, "exception reentered");
|
rb_vm_register_special_exception(ruby_error_reenter, rb_eFatal, "exception reentered");
|
||||||
|
|
||||||
|
id_signo = rb_intern_const("signo");
|
||||||
|
id_status = rb_intern_const("status");
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ rb_print_inaccessible(VALUE klass, ID id, int scope)
|
||||||
static int
|
static int
|
||||||
sysexit_status(VALUE err)
|
sysexit_status(VALUE err)
|
||||||
{
|
{
|
||||||
VALUE st = rb_iv_get(err, "status");
|
VALUE st = rb_ivar_get(err, id_status);
|
||||||
return NUM2INT(st);
|
return NUM2INT(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ error_handle(int ex)
|
||||||
status = sysexit_status(errinfo);
|
status = sysexit_status(errinfo);
|
||||||
}
|
}
|
||||||
else if (rb_obj_is_instance_of(errinfo, rb_eSignal) &&
|
else if (rb_obj_is_instance_of(errinfo, rb_eSignal) &&
|
||||||
rb_iv_get(errinfo, "signo") != INT2FIX(SIGSEGV)) {
|
rb_ivar_get(errinfo, id_signo) != INT2FIX(SIGSEGV)) {
|
||||||
/* no message when exiting by signal */
|
/* no message when exiting by signal */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -256,7 +256,7 @@ typedef unsigned LONG_LONG unsigned_clock_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ID id_in, id_out, id_err, id_pid, id_uid, id_gid;
|
static ID id_in, id_out, id_err, id_pid, id_uid, id_gid;
|
||||||
static ID id_close, id_child, id_status;
|
static ID id_close, id_child;
|
||||||
#ifdef HAVE_SETPGID
|
#ifdef HAVE_SETPGID
|
||||||
static ID id_pgroup;
|
static ID id_pgroup;
|
||||||
#endif
|
#endif
|
||||||
|
@ -279,6 +279,8 @@ static ID id_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID;
|
||||||
static ID id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC;
|
static ID id_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC;
|
||||||
#endif
|
#endif
|
||||||
static ID id_hertz;
|
static ID id_hertz;
|
||||||
|
extern ID ruby_static_id_status;
|
||||||
|
#define id_status ruby_static_id_status
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
|
@ -7820,7 +7822,6 @@ Init_process(void)
|
||||||
id_gid = rb_intern("gid");
|
id_gid = rb_intern("gid");
|
||||||
id_close = rb_intern("close");
|
id_close = rb_intern("close");
|
||||||
id_child = rb_intern("child");
|
id_child = rb_intern("child");
|
||||||
id_status = rb_intern("status");
|
|
||||||
#ifdef HAVE_SETPGID
|
#ifdef HAVE_SETPGID
|
||||||
id_pgroup = rb_intern("pgroup");
|
id_pgroup = rb_intern("pgroup");
|
||||||
#endif
|
#endif
|
||||||
|
|
7
signal.c
7
signal.c
|
@ -45,6 +45,9 @@
|
||||||
# include "nacl/signal.h"
|
# include "nacl/signal.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern ID ruby_static_id_signo;
|
||||||
|
#define id_signo ruby_static_id_signo
|
||||||
|
|
||||||
#ifdef NEED_RUBY_ATOMIC_OPS
|
#ifdef NEED_RUBY_ATOMIC_OPS
|
||||||
rb_atomic_t
|
rb_atomic_t
|
||||||
ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val)
|
ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val)
|
||||||
|
@ -326,7 +329,7 @@ esignal_init(int argc, VALUE *argv, VALUE self)
|
||||||
sig = rb_sprintf("SIG%s", signm);
|
sig = rb_sprintf("SIG%s", signm);
|
||||||
}
|
}
|
||||||
rb_call_super(1, &sig);
|
rb_call_super(1, &sig);
|
||||||
rb_iv_set(self, "signo", INT2NUM(signo));
|
rb_ivar_set(self, id_signo, INT2NUM(signo));
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +344,7 @@ esignal_init(int argc, VALUE *argv, VALUE self)
|
||||||
static VALUE
|
static VALUE
|
||||||
esignal_signo(VALUE self)
|
esignal_signo(VALUE self)
|
||||||
{
|
{
|
||||||
return rb_iv_get(self, "signo");
|
return rb_ivar_get(self, id_signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* :nodoc: */
|
/* :nodoc: */
|
||||||
|
|
Loading…
Add table
Reference in a new issue