summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-22 08:42:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-22 08:42:47 +0000
commit0d1df1cd7dde2396d1b81379b47e65e98b1b60f2 (patch)
treefa4c6633759cb9eb87ca7435a3bad901075c855f /eval.c
parent27daa53c544d2654a8fe05fad95df6bce18cdf7a (diff)
* variable.c (rb_mod_const_missing): new method. [ruby-core:00441]
* variable.c (rb_const_get_at): allow "const_missing" hook. * variable.c (rb_const_get_0): ditto. * eval.c (method_missing): rename from rb_undefined to clarify. * eval.c (ruby_finalize_0): update exit status if any of END proc raises SystemExit. [ruby-core:01256] * eval.c (rb_exec_end_proc): reduce rb_protect(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/eval.c b/eval.c
index 57260f9..f84e5f0 100644
--- a/eval.c
+++ b/eval.c
@@ -1319,22 +1319,32 @@ ruby_options(argc, argv)
void rb_exec_end_proc _((void));
-void
-ruby_finalize()
+static void
+ruby_finalize_0(exp)
+ int *exp;
{
- int state;
-
+ ruby_errinfo = 0;
PUSH_TAG(PROT_NONE);
- if ((state = EXEC_TAG()) == 0) {
+ if (EXEC_TAG() == 0) {
rb_trap_exit();
- rb_exec_end_proc();
- rb_gc_call_finalizer_at_exit();
}
POP_TAG();
+ rb_exec_end_proc();
+ rb_gc_call_finalizer_at_exit();
+ if (exp && ruby_errinfo && rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
+ VALUE st = rb_iv_get(ruby_errinfo, "status");
+ *exp = NUM2INT(st);
+ }
trace_func = 0;
tracing = 0;
}
+void
+ruby_finalize()
+{
+ ruby_finalize_0(0);
+}
+
int
ruby_cleanup(ex)
int ex;
@@ -1355,7 +1365,7 @@ ruby_cleanup(ex)
ex = error_handle(ex);
POP_TAG();
- ruby_finalize();
+ ruby_finalize_0(&ex);
return ex;
}
@@ -4712,7 +4722,7 @@ rb_f_missing(argc, argv, obj)
}
static VALUE
-rb_undefined(obj, id, argc, argv, call_status)
+method_missing(obj, id, argc, argv, call_status)
VALUE obj;
ID id;
int argc;
@@ -5077,7 +5087,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
ent = cache + EXPR1(klass, mid);
if (ent->mid == mid && ent->klass == klass) {
if (!ent->method)
- return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
+ return method_missing(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
klass = ent->origin;
id = ent->mid0;
noex = ent->noex;
@@ -5085,15 +5095,15 @@ rb_call(klass, recv, mid, argc, argv, scope)
}
else if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
if (scope == 3) {
- return rb_undefined(recv, mid, argc, argv, CSTAT_SUPER);
+ return method_missing(recv, mid, argc, argv, CSTAT_SUPER);
}
- return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
+ return method_missing(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
}
if (mid != missing) {
/* receiver specified form for private method */
if ((noex & NOEX_PRIVATE) && scope == 0)
- return rb_undefined(recv, mid, argc, argv, CSTAT_PRIV);
+ return method_missing(recv, mid, argc, argv, CSTAT_PRIV);
/* self must be kind of a specified form for protected method */
if ((noex & NOEX_PROTECTED)) {
@@ -5103,7 +5113,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
defined_class = RBASIC(defined_class)->klass;
}
if (!rb_obj_is_kind_of(ruby_frame->self, rb_class_real(defined_class)))
- return rb_undefined(recv, mid, argc, argv, CSTAT_PROT);
+ return method_missing(recv, mid, argc, argv, CSTAT_PROT);
}
}
@@ -6443,7 +6453,11 @@ rb_exec_end_proc()
save = link = end_procs;
while (link) {
- rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ (*link->func)(link->data);
+ }
+ POP_TAG();
if (status) {
error_handle(status);
}
@@ -6451,7 +6465,11 @@ rb_exec_end_proc()
}
link = end_procs;
while (link != save) {
- rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ (*link->func)(link->data);
+ }
+ POP_TAG();
if (status) {
error_handle(status);
}
@@ -6460,7 +6478,11 @@ rb_exec_end_proc()
while (ephemeral_end_procs) {
link = ephemeral_end_procs;
ephemeral_end_procs = link->next;
- rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status);
+ PUSH_TAG(PROT_NONE);
+ if ((status = EXEC_TAG()) == 0) {
+ (*link->func)(link->data);
+ }
+ POP_TAG();
if (status) {
error_handle(status);
}