summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--eval.c51
-rw-r--r--parse.y3
3 files changed, 37 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 79982fc..ebe6ddd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 10:09:51 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (yield_under_i): should not pass self as an argument to
diff --git a/eval.c b/eval.c
index 17e07ad..7cfd826 100644
--- a/eval.c
+++ b/eval.c
@@ -2212,7 +2212,7 @@ copy_node_scope(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;\
@@ -2239,12 +2239,12 @@ copy_node_scope(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 BEGIN_CALLARGS do {\
struct BLOCK *tmp_block = ruby_block;\
@@ -3533,28 +3533,29 @@ rb_eval(self, 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;
@@ -3562,22 +3563,22 @@ rb_eval(self, 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);
diff --git a/parse.y b/parse.y
index 56232fa..220c0a7 100644
--- a/parse.y
+++ b/parse.y
@@ -1013,9 +1013,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;