diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-06-22 09:12:24 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-06-22 09:12:24 +0000 |
commit | def42c9a0cd274202da56531c19e0a4bee3364e3 (patch) | |
tree | b100f68b08e5f1ae5338055ae798320a4a339e01 /eval.c | |
parent | ef8e0b4dffaec6789a1582d841ddb563cac2115d (diff) |
* eval.c (rb_yield_0): no mvalue_to_svalue conversion here.
* eval.c (massign): takes svalue, convert it to mvalue inside.
* eval.c (rb_eval): parameters for yield/return are always
svalues now.
* eval.c (svalue_to_mvalue): more strict conversion.
* eval.c (mvalue_to_svalue): ditto.
* st.c (new_size): prime hash size enabled.
* ext/socket/socket.c (Init_socket): SO_* constants added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 59 |
1 files changed, 22 insertions, 37 deletions
@@ -2005,7 +2005,11 @@ svalue_to_mvalue(v) VALUE v; { if (NIL_P(v)) return rb_ary_new2(0); - if (TYPE(v) != T_ARRAY) { + if (TYPE(v) == T_ARRAY) { + if (RARRAY(v)->len > 1) return v; + return rb_ary_new3(1, v); + } + else { v = rb_ary_to_ary(v); } return v; @@ -2021,9 +2025,7 @@ mvalue_to_svalue(v) if (RARRAY(v)->len == 0) { return Qnil; } - if (RARRAY(v)->len == 1 && - !NIL_P(RARRAY(v)->ptr[0]) && - TYPE(RARRAY(v)->ptr[0]) != T_ARRAY) { + if (RARRAY(v)->len == 1) { return RARRAY(v)->ptr[0]; } return v; @@ -2374,16 +2376,20 @@ rb_eval(self, n) case NODE_RESTARGS: case NODE_RESTARY: - result = svalue_to_mvalue(rb_eval(self, node->nd_head)); + result = rb_ary_to_ary(rb_eval(self, node->nd_head)); break; - case NODE_REXPAND: + case NODE_SVALUE: result = mvalue_to_svalue(rb_eval(self, node->nd_head)); break; + case NODE_MVALUE: + result = svalue_to_mvalue(rb_eval(self, node->nd_head)); + break; + case NODE_YIELD: if (node->nd_stts) { - result = rb_eval(self, node->nd_stts); + result = mvalue_to_svalue(rb_eval(self, node->nd_stts)); } else { result = Qnil; @@ -2526,7 +2532,7 @@ rb_eval(self, n) case NODE_RETURN: if (node->nd_stts) { - return_value(rb_eval(self, node->nd_stts)); + return_value(mvalue_to_svalue(rb_eval(self, node->nd_stts))); } else { return_value(Qnil); @@ -2537,7 +2543,7 @@ rb_eval(self, n) case NODE_ARGSCAT: result = rb_ary_concat(rb_eval(self, node->nd_head), - svalue_to_mvalue(rb_eval(self, node->nd_body))); + rb_eval(self, node->nd_body)); break; case NODE_ARGSPUSH: @@ -3620,18 +3626,10 @@ rb_yield_0(val, self, klass, pcall) } } else { - if (nd_type(block->var) == NODE_MASGN) + if (nd_type(block->var) == NODE_MASGN) { massign(self, block->var, val, pcall); + } else { - /* argument adjust for proc_call etc. */ - if (pcall) { - if (RARRAY(val)->len == 1) { - val = RARRAY(val)->ptr[0]; - } - else { - val = mvalue_to_svalue(val); - } - } assign(self, block->var, val, pcall); } } @@ -3639,10 +3637,6 @@ rb_yield_0(val, self, klass, pcall) POP_TAG(); if (state) goto pop_state; } - else if (pcall) { - /* argument adjust for proc_call etc. */ - val = mvalue_to_svalue(val); - } PUSH_ITER(block->iter); PUSH_TAG(PROT_NONE); @@ -3744,9 +3738,7 @@ massign(self, node, val, pcall) NODE *list; int i = 0, len; - if (!pcall) { - val = svalue_to_mvalue(val); - } + val = svalue_to_mvalue(val); len = RARRAY(val)->len; list = node->nd_head; for (i=0; list && i<len; i++) { @@ -6347,9 +6339,7 @@ proc_invoke(proc, args, pcall) PUSH_ITER(ITER_CUR); ruby_frame->iter = ITER_CUR; - if (!pcall) { - args = mvalue_to_svalue(args); - } + args = mvalue_to_svalue(args); PUSH_TAG(PROT_NONE); state = EXEC_TAG(); if (state == 0) { @@ -6821,20 +6811,15 @@ static VALUE bmcall(args, method) VALUE args, method; { - if (TYPE(args) == T_ARRAY) { - return method_call(RARRAY(args)->len, RARRAY(args)->ptr, method); - } - return method_call(1, &args, method); + args = svalue_to_mvalue(args); + return method_call(RARRAY(args)->len, RARRAY(args)->ptr, method); } static VALUE umcall(args, method) VALUE args, method; { - if (TYPE(args) == T_ARRAY) { - return umethod_call(RARRAY(args)->len, RARRAY(args)->ptr, method); - } - return umethod_call(1, &args, method); + return umethod_call(0, 0, method); } static VALUE |