summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-13 07:18:45 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-13 07:18:45 +0000
commit31c55301e4c3c84803186d28d2764363b457532f (patch)
tree5f3558168cba03413c22fb5a9b3a7d64e0519df2 /eval.c
parent976692f8ae8377af944f09177c8e79cb94809fe9 (diff)
downloadruby-31c55301e4c3c84803186d28d2764363b457532f.tar.gz
2000-03-13
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/eval.c b/eval.c
index 30c0758ec2..08e0509b08 100644
--- a/eval.c
+++ b/eval.c
@@ -3222,6 +3222,8 @@ rb_f_raise(argc, argv)
VALUE *argv;
{
VALUE mesg;
+ ID exception;
+ int n;
mesg = Qnil;
switch (argc) {
@@ -3234,17 +3236,24 @@ rb_f_raise(argc, argv)
mesg = rb_exc_new3(rb_eRuntimeError, argv[0]);
break;
}
- mesg = rb_funcall(argv[0], rb_intern("exception"), 0, 0);
- break;
- case 3:
+ n = 0;
+ goto exception_call;
+
case 2:
- mesg = rb_funcall(argv[0], rb_intern("exception"), 1, argv[1]);
+ case 3:
+ n = 1;
+ exception_call:
+ exception = rb_intern("exception");
+ if (!rb_respond_to(argv[0], exception)) {
+ rb_raise(rb_eTypeError, "exception class/object expected");
+ }
+ mesg = rb_funcall(argv[0], exception, n, argv[1]);
break;
default:
rb_raise(rb_eArgError, "wrong # of arguments");
break;
}
- if (!NIL_P(mesg)) {
+ if (argc > 0) {
if (!rb_obj_is_kind_of(mesg, rb_eException))
rb_raise(rb_eTypeError, "exception object expected");
set_backtrace(mesg, (argc>2)?argv[2]:Qnil);
@@ -3739,9 +3748,11 @@ rb_f_missing(argc, argv, obj)
char *file = ruby_sourcefile;
int line = ruby_sourceline;
- if (argc == 0) rb_raise(rb_eArgError, "no id given");
+ if (argc == 0 || !SYMBOL_P(argv[0])) {
+ rb_raise(rb_eArgError, "no id given");
+ }
- id = NUM2INT(argv[0]);
+ id = SYM2ID(argv[0]);
argc--; argv++;
switch (TYPE(obj)) {
@@ -5892,25 +5903,35 @@ block_pass(self, node)
POP_TAG();
POP_ITER();
if (_block.tag->dst == state) {
- state &= TAG_MASK;
- orphan = 2;
+ if (orphan) {
+ state &= TAG_MASK;
+ }
+ else {
+ struct BLOCK *ptr = old_block;
+
+ while (ptr) {
+ if (ptr->scope == _block.scope) {
+ ptr->tag->dst = state;
+ break;
+ }
+ ptr = ptr->prev;
+ }
+ }
}
ruby_block = old_block;
ruby_safe_level = safe;
if (state) {
- if (orphan == 2) {/* escape from orphan procedure */
- switch (state) {
- case TAG_BREAK:
- rb_raise(rb_eLocalJumpError, "break from proc-closure");
- break;
- case TAG_RETRY:
- rb_raise(rb_eLocalJumpError, "retry from proc-closure");
- break;
- case TAG_RETURN:
- rb_raise(rb_eLocalJumpError, "return from proc-closure");
- break;
- }
+ switch (state) {/* escape from orphan procedure */
+ case TAG_BREAK:
+ rb_raise(rb_eLocalJumpError, "break from proc-closure");
+ break;
+ case TAG_RETRY:
+ rb_raise(rb_eLocalJumpError, "retry from proc-closure");
+ break;
+ case TAG_RETURN:
+ rb_raise(rb_eLocalJumpError, "return from proc-closure");
+ break;
}
JUMP_TAG(state);
}