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

* eval.c (rb_eval): NODE_OP_ASGN1 should allow splat in its

argument list.  [ruby-core:07366]

* parse.y (arg): avoid unnecessary extra argument.
  [ruby-core:07366]

* eval.c (rb_eval): honor visibility on OP_ASGN1 and
  OP_ASGN2. [ruby-core:07366]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2006-02-15 08:46:55 +00:00
parent a95a1eff20
commit 8f5278b525
3 changed files with 37 additions and 28 deletions

View file

@ -1,3 +1,14 @@
Wed Feb 15 16:52:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): NODE_OP_ASGN1 should allow splat in its
argument list. [ruby-core:07366]
* parse.y (arg): avoid unnecessary extra argument.
[ruby-core:07366]
* eval.c (rb_eval): honor visibility on OP_ASGN1 and
OP_ASGN2. [ruby-core:07366]
Wed Feb 15 15:20:23 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (error_line): remove void control path. [ruby-dev:28335]

51
eval.c
View file

@ -2124,7 +2124,7 @@ copy_node_scope(NODE *node, NODE *rval)
# define TMP_ALLOC(n) ALLOCA_N(VALUE,n)
#endif
#define SETUP_ARGS0(anode,alen) do {\
#define SETUP_ARGS0(anode,alen,extra) do {\
NODE *n = anode;\
if (!n) {\
argc = 0;\
@ -2151,12 +2151,12 @@ copy_node_scope(NODE *node, NODE *rval)
if (TYPE(args) != T_ARRAY)\
args = rb_ary_to_ary(args);\
argc = RARRAY(args)->len;\
argv = ALLOCA_N(VALUE, argc);\
argv = TMP_ALLOC(argc+extra);\
MEMCPY(argv, RARRAY(args)->ptr, VALUE, argc);\
}\
} while (0)
#define SETUP_ARGS(anode) SETUP_ARGS0(anode, anode->nd_alen)
#define SETUP_ARGS(anode) SETUP_ARGS0(anode, anode->nd_alen,0)
#define ZSUPER_ARGS() do {\
argc = ruby_frame->argc;\
@ -3477,28 +3477,29 @@ rb_eval(VALUE self, NODE *n)
case NODE_OP_ASGN1:
{
int argc; VALUE *argv; /* used in SETUP_ARGS */
VALUE recv, val;
VALUE recv, val, tmp;
NODE *rval;
TMP_PROTECT;
recv = rb_eval(self, node->nd_recv);
rval = node->nd_args->nd_head;
SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen - 1);
val = rb_funcall2(recv, aref, argc-1, argv);
SETUP_ARGS0(node->nd_args->nd_next, node->nd_args->nd_alen-1,1);
val = rb_funcall3(recv, aref, argc, argv);
switch (node->nd_mid) {
case 0: /* OR */
if (RTEST(val)) RETURN(val);
val = rb_eval(self, rval);
break;
if (RTEST(val)) RETURN(val);
val = rb_eval(self, rval);
break;
case 1: /* AND */
if (!RTEST(val)) RETURN(val);
val = rb_eval(self, rval);
break;
if (!RTEST(val)) RETURN(val);
val = rb_eval(self, rval);
break;
default:
val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
tmp = rb_eval(self, rval);
val = rb_funcall3(val, node->nd_mid, 1, &tmp);
}
argv[argc-1] = val;
rb_funcall2(recv, aset, argc, argv);
argv[argc] = val;
rb_funcall2(recv, aset, argc+1, argv);
result = val;
}
break;
@ -3506,22 +3507,22 @@ rb_eval(VALUE self, NODE *n)
case NODE_OP_ASGN2:
{
ID id = node->nd_next->nd_vid;
VALUE recv, val;
VALUE recv, val, tmp;
recv = rb_eval(self, node->nd_recv);
val = rb_funcall(recv, id, 0);
val = rb_funcall3(recv, id, 0, 0);
switch (node->nd_next->nd_mid) {
case 0: /* OR */
if (RTEST(val)) RETURN(val);
val = rb_eval(self, node->nd_value);
break;
if (RTEST(val)) RETURN(val);
val = rb_eval(self, node->nd_value);
break;
case 1: /* AND */
if (!RTEST(val)) RETURN(val);
val = rb_eval(self, node->nd_value);
break;
if (!RTEST(val)) RETURN(val);
val = rb_eval(self, node->nd_value);
break;
default:
val = rb_funcall(val, node->nd_next->nd_mid, 1,
rb_eval(self, node->nd_value));
tmp = rb_eval(self, node->nd_value);
val = rb_funcall3(val, node->nd_next->nd_mid, 1, &tmp);
}
rb_funcall2(recv, node->nd_next->nd_aid, 1, &val);

View file

@ -1684,9 +1684,6 @@ arg : lhs '=' arg
value_expr($6);
args = NEW_LIST($6);
if ($3 && nd_type($3) != NODE_ARRAY)
$3 = NEW_LIST($3);
$3 = list_append($3, NEW_NIL());
list_concat(args, $3);
if ($5 == tOROP) {
$5 = 0;