From 976bfae03be67236543367aef7b8a22df02cd37b Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 5 Jul 2007 18:16:54 +0000 Subject: * insns.def: remove unused code. * compile.c (compile_massign): fix to invoke to_splat on splat rhs (example: *a = *nil). [ruby-dev:31136] * bootstraptest/test_massign.rb: add tests for above. * compile.c (iseq_compile_each): disable excess optimization. [ruby-dev:31126] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ bootstraptest/test_massign.rb | 3 +++ compile.c | 21 ++++++++++----------- insns.def | 44 ++++++++++++++----------------------------- 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1a9659339..f9c2fda602 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Fri Jul 6 03:06:58 2007 Koichi Sasada + + * insns.def: remove unused code. + + * compile.c (compile_massign): fix to invoke to_splat on + splat rhs (example: *a = *nil). [ruby-dev:31136] + + * bootstraptest/test_massign.rb: add tests for above. + + * compile.c (iseq_compile_each): disable excess optimization. + [ruby-dev:31126] + Fri Jul 6 02:08:25 2007 Koichi Sasada * insns.def: fix to invoke nil.to_splat on NODE_ARGSCAT. diff --git a/bootstraptest/test_massign.rb b/bootstraptest/test_massign.rb index d4fa5931d6..71b53452b9 100644 --- a/bootstraptest/test_massign.rb +++ b/bootstraptest/test_massign.rb @@ -1,6 +1,9 @@ assert_equal '[[1], 2, 3]', '*v1, (a, b) = [1,[2, 3]]; [v1, a, b]' assert_equal '[[1], 2, 3]', '*v1,(*), (a, b) = [1,:x,[2, 3]]; [v1, a, b]' +assert_equal '[]', '*a = *nil; a' +assert_equal '[nil]', '*a = nil; a' + =begin # generated by this script: diff --git a/compile.c b/compile.c index 6ac0e61f0e..4bcc6cdf47 100644 --- a/compile.c +++ b/compile.c @@ -2044,21 +2044,18 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret, break; case NODE_SPLAT: - COMPILE(ret, "rhs to ary (splat)", rhsn->nd_head); - ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), - INT2FIX(lhs_splat)); + COMPILE(ret, "rhs to ary (splat)", rhsn); + ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), INT2FIX(lhs_splat)); break; case NODE_ARGSCAT: COMPILE(ret, "rhs to argscat", rhsn); - ADD_INSN2(ret, nd_line(rhsn), expandarray, - INT2FIX(llen), INT2FIX(lhs_splat)); + ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), INT2FIX(lhs_splat)); break; + default: COMPILE(ret, "rhs to ary (splat/default)", rhsn); - ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), - INT2FIX(lhs_splat)); - /* rb_compile_error(ERROR_ARGS "unknown rhs: %s", ruby_node_name(nd_type(rhsn))); */ + ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), INT2FIX(lhs_splat)); } } else { @@ -3974,9 +3971,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) break; } case NODE_SPLAT:{ - COMPILE_(ret, "splat", node->nd_head, poped); - if (!poped) { - ADD_INSN1(ret, nd_line(node), splatarray, Qfalse); + COMPILE(ret, "splat", node->nd_head); + ADD_INSN1(ret, nd_line(node), splatarray, Qfalse); + + if (poped) { + ADD_INSN(ret, nd_line(node), pop); } break; } diff --git a/insns.def b/insns.def index 51e5272ee9..59c924f166 100644 --- a/insns.def +++ b/insns.def @@ -505,40 +505,24 @@ expandarray } } else { - if ((long)num >= 0) { - int len; - if (TYPE(ary) != T_ARRAY) { - ary = rb_ary_to_ary(ary); - } - len = RARRAY_LEN(ary); - for (i = 0; i < len && i < num; i++) { - PUSH(RARRAY_PTR(ary)[i]); - } - for (; i < num; i++) { - PUSH(Qnil); - } - if (flag) { - if (len > num) { - PUSH(rb_ary_new4(len - num, &RARRAY_PTR(ary)[num])); - } - else { - PUSH(rb_ary_new()); - } - } + int len; + if (TYPE(ary) != T_ARRAY) { + ary = rb_ary_to_ary(ary); } - else { - long holdnum = -num; - VALUE val; - - val = rb_ary_new4(holdnum, STACK_ADDR_FROM_TOP(holdnum)); - if (CLASS_OF(ary) == rb_cArray) { - val = rb_ary_concat(val, ary); + len = RARRAY_LEN(ary); + for (i = 0; i < len && i < num; i++) { + PUSH(RARRAY_PTR(ary)[i]); + } + for (; i < num; i++) { + PUSH(Qnil); + } + if (flag) { + if (len > num) { + PUSH(rb_ary_new4(len - num, &RARRAY_PTR(ary)[num])); } else { - rb_ary_push(val, ary); + PUSH(rb_ary_new()); } - POPN(holdnum); - PUSH(val); } } } -- cgit v1.2.3