1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c: backout argv copy on write changes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-07-28 04:31:20 +00:00
parent c109c50bd5
commit a99ce7f39c

8
eval.c
View file

@ -1240,6 +1240,8 @@ ruby_init()
Init_stack((void*)&state); Init_stack((void*)&state);
Init_heap(); Init_heap();
PUSH_SCOPE(); PUSH_SCOPE();
ruby_scope->local_vars = 0;
ruby_scope->local_tbl = 0;
top_scope = ruby_scope; top_scope = ruby_scope;
/* default visibility is private at toplevel */ /* default visibility is private at toplevel */
SCOPE_SET(SCOPE_PRIVATE); SCOPE_SET(SCOPE_PRIVATE);
@ -3423,7 +3425,6 @@ rb_eval(self, n)
if (ruby_scope->local_vars == 0) if (ruby_scope->local_vars == 0)
rb_bug("unexpected local variable assignment"); rb_bug("unexpected local variable assignment");
result = rb_eval(self, node->nd_value); result = rb_eval(self, node->nd_value);
if (node->nd_cnt < ruby_frame->argc + 2) scope_dup(ruby_scope);
ruby_scope->local_vars[node->nd_cnt] = result; ruby_scope->local_vars[node->nd_cnt] = result;
break; break;
@ -4962,7 +4963,6 @@ assign(self, lhs, val, pcall)
case NODE_LASGN: case NODE_LASGN:
if (ruby_scope->local_vars == 0) if (ruby_scope->local_vars == 0)
rb_bug("unexpected local variable assignment"); rb_bug("unexpected local variable assignment");
if (lhs->nd_cnt < ruby_frame->argc + 2) scope_dup(ruby_scope);
ruby_scope->local_vars[lhs->nd_cnt] = val; ruby_scope->local_vars[lhs->nd_cnt] = val;
break; break;
@ -5630,7 +5630,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
if (local_vars) { if (local_vars) {
if (i > 0) { if (i > 0) {
/* +2 for $_ and $~ */ /* +2 for $_ and $~ */
MEMCPY(local_vars+2, argv, VALUE, ruby_frame->argc); MEMCPY(local_vars+2, argv, VALUE, i);
} }
argv += i; argc -= i; argv += i; argc -= i;
if (node->nd_opt) { if (node->nd_opt) {
@ -5645,6 +5645,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
rb_eval(recv, opt); rb_eval(recv, opt);
} }
} }
local_vars = ruby_scope->local_vars;
if ((int)node->nd_rest >= 0) { if ((int)node->nd_rest >= 0) {
VALUE v; VALUE v;
@ -5654,7 +5655,6 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
v = rb_ary_new2(0); v = rb_ary_new2(0);
ruby_scope->local_vars[node->nd_rest] = v; ruby_scope->local_vars[node->nd_rest] = v;
} }
ruby_frame->argv = ruby_scope->local_vars + 2;
} }
} }