* 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
This commit is contained in:
ko1 2007-07-05 18:16:54 +00:00
parent b9171a73c4
commit 976bfae03b
4 changed files with 39 additions and 41 deletions

View File

@ -1,3 +1,15 @@
Fri Jul 6 03:06:58 2007 Koichi Sasada <ko1@atdot.net>
* 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 <ko1@atdot.net> Fri Jul 6 02:08:25 2007 Koichi Sasada <ko1@atdot.net>
* insns.def: fix to invoke nil.to_splat on NODE_ARGSCAT. * insns.def: fix to invoke nil.to_splat on NODE_ARGSCAT.

View File

@ -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,[2, 3]]; [v1, a, b]'
assert_equal '[[1], 2, 3]', '*v1,(*), (a, b) = [1,:x,[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 =begin
# generated by this script: # generated by this script:

View File

@ -2044,21 +2044,18 @@ compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *ret,
break; break;
case NODE_SPLAT: case NODE_SPLAT:
COMPILE(ret, "rhs to ary (splat)", rhsn->nd_head); COMPILE(ret, "rhs to ary (splat)", rhsn);
ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), INT2FIX(lhs_splat));
INT2FIX(lhs_splat));
break; break;
case NODE_ARGSCAT: case NODE_ARGSCAT:
COMPILE(ret, "rhs to argscat", rhsn); COMPILE(ret, "rhs to argscat", rhsn);
ADD_INSN2(ret, nd_line(rhsn), expandarray, ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), INT2FIX(lhs_splat));
INT2FIX(llen), INT2FIX(lhs_splat));
break; break;
default: default:
COMPILE(ret, "rhs to ary (splat/default)", rhsn); COMPILE(ret, "rhs to ary (splat/default)", rhsn);
ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), ADD_INSN2(ret, nd_line(rhsn), expandarray, INT2FIX(llen), INT2FIX(lhs_splat));
INT2FIX(lhs_splat));
/* rb_compile_error(ERROR_ARGS "unknown rhs: %s", ruby_node_name(nd_type(rhsn))); */
} }
} }
else { else {
@ -3974,9 +3971,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
break; break;
} }
case NODE_SPLAT:{ case NODE_SPLAT:{
COMPILE_(ret, "splat", node->nd_head, poped); COMPILE(ret, "splat", node->nd_head);
if (!poped) {
ADD_INSN1(ret, nd_line(node), splatarray, Qfalse); ADD_INSN1(ret, nd_line(node), splatarray, Qfalse);
if (poped) {
ADD_INSN(ret, nd_line(node), pop);
} }
break; break;
} }

View File

@ -505,7 +505,6 @@ expandarray
} }
} }
else { else {
if ((long)num >= 0) {
int len; int len;
if (TYPE(ary) != T_ARRAY) { if (TYPE(ary) != T_ARRAY) {
ary = rb_ary_to_ary(ary); ary = rb_ary_to_ary(ary);
@ -526,21 +525,6 @@ expandarray
} }
} }
} }
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);
}
else {
rb_ary_push(val, ary);
}
POPN(holdnum);
PUSH(val);
}
}
} }
/** /**