summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-20 08:33:49 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-20 08:33:49 +0000
commit6eb98c5ebe264eb0be6488c7db875137a44d8279 (patch)
tree8c8b6e6962798bc57a9519a6f140b79c009ee050 /eval.c
parent8405551e6d05c08c4e6a25672e009d349d888aa1 (diff)
* eval.c (PUSH_FRAME): generate unique number to be TAG_JUMP()
destination. * eval.c (localjump_destination): use unique number in ruby_frame for localjump destination. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/eval.c b/eval.c
index 45d2cda05a..c7a778716d 100644
--- a/eval.c
+++ b/eval.c
@@ -604,6 +604,8 @@ struct SCOPE *ruby_scope;
static struct FRAME *top_frame;
static struct SCOPE *top_scope;
+static unsigned long frame_unique = 0;
+
#define PUSH_FRAME() do { \
struct FRAME _frame; \
_frame.prev = ruby_frame; \
@@ -613,6 +615,7 @@ static struct SCOPE *top_scope;
_frame.argc = 0; \
_frame.argv = 0; \
_frame.flags = FRAME_ALLOCA; \
+ _frame.uniq = frame_unique++; \
ruby_frame = &_frame
#define POP_FRAME() \
@@ -875,7 +878,7 @@ static struct tag *prot_tag;
prot_tag = _tag.prev; \
} while (0)
-#define TAG_DST() (_tag.dst == (VALUE)_tag.scope)
+#define TAG_DST() (_tag.dst == (VALUE)ruby_frame->uniq)
#define TAG_RETURN 0x1
#define TAG_BREAK 0x2
@@ -2448,7 +2451,7 @@ class_prefix(self, cpath)
}\
} while (0)
-NORETURN(static void localjump_destination _((int, struct SCOPE*, VALUE)));
+NORETURN(static void localjump_destination _((int, VALUE)));
static VALUE
rb_eval(self, n)
@@ -2771,7 +2774,7 @@ rb_eval(self, n)
break;
case NODE_BREAK:
- localjump_destination(TAG_BREAK, ruby_scope, rb_eval(self, node->nd_stts));
+ localjump_destination(TAG_BREAK, rb_eval(self, node->nd_stts));
break;
case NODE_NEXT:
@@ -2952,7 +2955,7 @@ rb_eval(self, n)
break;
case NODE_RETURN:
- localjump_destination(TAG_RETURN, ruby_scope, rb_eval(self, node->nd_stts));
+ localjump_destination(TAG_RETURN, rb_eval(self, node->nd_stts));
break;
case NODE_ARGSCAT:
@@ -3106,7 +3109,7 @@ rb_eval(self, n)
break;
case TAG_RETURN:
case TAG_BREAK:
- localjump_destination(state, ruby_scope, result);
+ localjump_destination(state, result);
default:
JUMP_TAG(state);
}
@@ -3882,7 +3885,7 @@ rb_f_abort(argc, argv)
void
rb_iter_break()
{
- localjump_destination(TAG_BREAK, ruby_scope, Qnil);
+ localjump_destination(TAG_BREAK, Qnil);
}
NORETURN(static void rb_longjmp _((int, VALUE)));
@@ -4056,9 +4059,8 @@ rb_f_block_given_p()
static VALUE rb_eThreadError;
static void
-localjump_destination(state, scope, retval)
+localjump_destination(state, retval)
int state;
- struct SCOPE *scope;
VALUE retval;
{
struct tag *tt = prot_tag;
@@ -4067,12 +4069,12 @@ localjump_destination(state, scope, retval)
if (retval == Qundef) retval = Qnil;
while (tt) {
if (tt->tag == PROT_PCALL || (tt->tag == PROT_THREAD && state == TAG_BREAK) ||
- (tt->tag == PROT_CALL || tt->tag == tag) && tt->scope == scope) {
- tt->dst = (VALUE)scope;
+ (tt->tag == PROT_CALL || tt->tag == tag) && tt->frame->uniq == ruby_frame->uniq) {
+ tt->dst = (VALUE)ruby_frame->uniq;
tt->retval = retval;
JUMP_TAG(state);
}
- if (tt->tag == PROT_FUNC && tt->scope == scope) break;
+ if (tt->tag == PROT_FUNC && tt->frame->uniq == ruby_frame->uniq) break;
if (tt->tag == PROT_THREAD) {
rb_raise(rb_eThreadError, "return jump can't across threads");
}
@@ -7087,7 +7089,7 @@ proc_invoke(proc, args, self, klass)
localjump_error(mesg, result, state);
}
if (result != Qundef) {
- localjump_destination(state, ruby_scope, result);
+ localjump_destination(state, result);
}
default:
JUMP_TAG(state);