From f7ac4f227d4705b2bd5370e0ba8bb8984039f94f Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 3 Jul 2001 09:37:08 +0000 Subject: [PATCH] * eval.c (rb_eval_string_wrap): should push frame (and adjust cbase) before wrapped eval. * eval.c (rb_eval_cmd): ditto. * eval.c (eval): should update ruby_class always after all. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ eval.c | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2691fe4bab..5be4ba981f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Tue Jul 3 18:35:49 2001 Yukihiro Matsumoto + + * eval.c (rb_eval_string_wrap): should push frame (and adjust + cbase) before wrapped eval. + + * eval.c (rb_eval_cmd): ditto. + + * eval.c (eval): should update ruby_class always after all. + Tue Jul 3 14:56:27 2001 Shugo Maeda * eval.c (block_pass): do not change wrapper information. diff --git a/eval.c b/eval.c index 3a0c701970..2b0d75e5e4 100644 --- a/eval.c +++ b/eval.c @@ -1275,11 +1275,17 @@ rb_eval_string_wrap(str, state) PUSH_CLASS(); ruby_class = ruby_wrapper = rb_module_new(); ruby_top_self = rb_obj_clone(ruby_top_self); - rb_extend_object(ruby_top_self, ruby_class); + rb_extend_object(ruby_top_self, ruby_wrapper); + PUSH_FRAME(); + ruby_frame->last_func = 0; + ruby_frame->last_class = 0; + ruby_frame->self = self; + ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,ruby_wrapper,0,0); val = rb_eval_string_protect(str, &status); ruby_top_self = self; + POP_FRAME(); POP_CLASS(); ruby_wrapper = wrapper; if (state) { @@ -1333,16 +1339,19 @@ rb_eval_cmd(cmd, arg) RARRAY(arg)->len, RARRAY(arg)->ptr); } - PUSH_CLASS(); - PUSH_TAG(PROT_NONE); saved_scope = ruby_scope; ruby_scope = top_scope; + PUSH_FRAME(); + ruby_frame->last_func = 0; + ruby_frame->last_class = 0; + ruby_frame->self = ruby_top_self; + ruby_frame->cbase = (VALUE)rb_node_newnode(NODE_CREF,ruby_wrapper,0,0); - ruby_class = ruby_wrapper ? ruby_wrapper : rb_cObject; if (OBJ_TAINTED(cmd)) { ruby_safe_level = 4; } + PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { val = eval(ruby_top_self, cmd, Qnil, 0, 0); } @@ -1352,7 +1361,7 @@ rb_eval_cmd(cmd, arg) ruby_scope = saved_scope; ruby_safe_level = safe; POP_TAG(); - POP_CLASS(); + POP_FRAME(); jump_tag_but_local_jump(state); return val; @@ -4868,7 +4877,6 @@ eval(self, src, scope, file, line) file = ruby_sourcefile; line = ruby_sourceline; } - PUSH_CLASS(); if (!NIL_P(scope)) { if (!rb_obj_is_block(scope)) { rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Binding)", @@ -4895,13 +4903,14 @@ eval(self, src, scope, file, line) self = data->self; ruby_frame->iter = data->iter; - ruby_class = ruby_cbase; } else { if (ruby_frame->prev) { ruby_frame->iter = ruby_frame->prev->iter; } } + PUSH_CLASS(); + ruby_class = ruby_cbase; ruby_in_eval++; if (TYPE(ruby_class) == T_ICLASS) {