yarv-diff:413
From: ko1 atdot.net
Date: 10 Nov 2006 21:08:22 +0900
Subject: [yarv-diff:413] r581 - in trunk: . sample yarvtest
Author: ko1
Date: 2006-11-10 21:08:21 +0900 (Fri, 10 Nov 2006)
New Revision: 581
Modified:
trunk/ChangeLog
trunk/compile.c
trunk/insns.def
trunk/sample/test.rb
trunk/yarvtest/test_bin.rb
Log:
* compile.c : fix to compile arguments
* insns.def : fix to duplicate first array value on concatarray
instruction
* yarvtest/test_bin.rb : add a test for above change
* sample/test.rb : fix to catch up Ruby HEAD (fix to remove test about
module duplicate)
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-11-10 03:51:05 UTC (rev 580)
+++ trunk/ChangeLog 2006-11-10 12:08:21 UTC (rev 581)
@@ -4,6 +4,19 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2006-11-10(Fri) 21:29:13 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * compile.c : fix to compile arguments
+
+ * insns.def : fix to duplicate first array value on concatarray
+ instruction
+
+ * yarvtest/test_bin.rb : add a test for above change
+
+ * sample/test.rb : fix to catch up Ruby HEAD (fix to remove test about
+ module duplicate)
+
+
2006-11-10(Fri) 12:49:11 +0900 Koichi Sasada <ko1 atdot.net>
* vm_macro.def : fix to inherit visibility on
Modified: trunk/compile.c
===================================================================
--- trunk/compile.c 2006-11-10 03:51:05 UTC (rev 580)
+++ trunk/compile.c 2006-11-10 12:08:21 UTC (rev 581)
@@ -361,7 +361,8 @@
plist = list;
list = list->next;
}
- if (anchor->last != plist) {
+
+ if (anchor->last != plist && anchor->last != 0) {
flag |= 0x70000;
}
@@ -515,6 +516,32 @@
verify_list("append", anc1);
}
+/*
+ * anc1: e1, e2, e3
+ * anc2: e4, e5
+ *#=>
+ * anc1: e4, e5, e1, e2, e3
+ * anc2: e4, e5 (broken)
+ */
+static void
+INSERT_LIST(LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
+{
+ if (anc2->anchor.next) {
+ LINK_ELEMENT *first = anc1->anchor.next;
+ anc1->anchor.next = anc2->anchor.next;
+ anc1->anchor.next->prev = &anc1->anchor;
+ anc2->last->next = first;
+ if (first) {
+ first->prev = anc2->last;
+ }
+ else {
+ anc1->last = anc2->last;
+ }
+ }
+
+ verify_list("append", anc1);
+}
+
#if 0
/*
* anc1: e1, e2, e3
@@ -527,8 +554,11 @@
SWAP_LIST(LINK_ANCHOR *anc1, LINK_ANCHOR *anc2)
{
LINK_ANCHOR tmp = *anc2;
+
+ /* it has bug */
*anc2 = *anc1;
*anc1 = tmp;
+
verify_list("swap1", anc1);
verify_list("swap2", anc2);
}
@@ -2502,18 +2532,21 @@
{
VALUE argc = INT2FIX(0);
NODE *argn = node->nd_args;
+ NODE *argp = 0;
DECL_ANCHOR(arg_block);
-
+ DECL_ANCHOR(args_push);
+
if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
COMPILE(arg_block, "block", argn->nd_body);
*flag |= VM_CALL_ARGS_BLOCKARG_BIT;
argn = argn->nd_head;
}
+ setup_argn:
if (argn) {
switch (nd_type(argn)) {
case NODE_SPLAT: {
- COMPILE(args, "args(splat)", argn->nd_head);
+ COMPILE(args, "args (splat)", argn->nd_head);
argc = INT2FIX(1);
*flag |= VM_CALL_ARGS_SPLAT_BIT;
break;
@@ -2521,10 +2554,18 @@
case NODE_ARGSCAT: {
argc = INT2FIX(compile_array(iseq, args, argn->nd_head, Qfalse) + 1);
POP_ELEMENT(args);
- COMPILE(args, "args(cat: splat)", argn->nd_body);
+ COMPILE(args, "args (cat: splat)", argn->nd_body);
*flag |= VM_CALL_ARGS_SPLAT_BIT;
break;
}
+ case NODE_ARGSPUSH: {
+ DECL_ANCHOR(args_push_e);
+ COMPILE(args_push_e, "argspush (cdr)", argn->nd_body);
+ ADD_INSN(args_push_e, nd_line(node), concatarray);
+ INSERT_LIST(args_push, args_push_e);
+ argn = argn->nd_head;
+ goto setup_argn;
+ }
default: {
argc = INT2FIX(compile_array(iseq, args, argn, Qfalse));
POP_ELEMENT(args);
@@ -2533,6 +2574,10 @@
}
}
+ if (!LIST_SIZE_ZERO(args_push)) {
+ ADD_SEQ(args, args_push);
+ }
+
if (*flag & VM_CALL_ARGS_BLOCKARG_BIT) {
ADD_SEQ(args, arg_block);
}
@@ -4037,7 +4082,7 @@
break;
}
case NODE_ARGSCAT:{
- COMPILE(ret, "argscat body", node->nd_head);
+ COMPILE(ret, "argscat head", node->nd_head);
COMPILE(ret, "argscat body", node->nd_body);
ADD_INSN(ret, nd_line(node), concatarray);
break;
@@ -4415,15 +4460,10 @@
case NODE_ATTRASGN:{
DECL_ANCHOR(recv);
DECL_ANCHOR(args);
- int argc;
+ VALUE flag = 0;
+ VALUE argc;
- if (node->nd_args) {
- compile_array(iseq, args, node->nd_args, Qfalse);
- argc = FIX2INT(OPERAND_AT(POP_ELEMENT(args), 0));
- }
- else {
- argc = 0; /* massign */
- }
+ argc = setup_arg(iseq, args, node, &flag);
if (node->nd_recv == (NODE *) 1) {
ADD_INSN(recv, nd_line(node), putself);
@@ -4439,13 +4479,13 @@
ADD_INSN(ret, nd_line(node), putnil);
ADD_SEQ(ret, recv);
ADD_SEQ(ret, args);
- ADD_INSN1(ret, nd_line(node), setn, INT2FIX(argc + 1));
+ ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 1));
}
else {
ADD_SEQ(ret, recv);
ADD_SEQ(ret, args);
}
- ADD_SEND(ret, nd_line(node), ID2SYM(node->nd_mid), INT2FIX(argc));
+ ADD_SEND_R(ret, nd_line(node), ID2SYM(node->nd_mid), argc, 0, INT2FIX(flag));
ADD_INSN(ret, nd_line(node), pop);
break;
Modified: trunk/insns.def
===================================================================
--- trunk/insns.def 2006-11-10 03:51:05 UTC (rev 580)
+++ trunk/insns.def 2006-11-10 12:08:21 UTC (rev 581)
@@ -546,11 +546,21 @@
ary = ary1;
}
else {
- VALUE tmp = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_splat");
- if (NIL_P(tmp)) {
- tmp = rb_ary_new3(1, ary2);
+ VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_splat");
+ VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_splat");
+
+ if (NIL_P(tmp1)) {
+ tmp1 = rb_ary_new3(1, ary1);
}
- ary = rb_ary_concat(ary1, tmp);
+
+ if (NIL_P(tmp2)) {
+ tmp2 = rb_ary_new3(1, ary2);
+ }
+
+ if (tmp1 == ary1) {
+ tmp1 = rb_ary_dup(ary1);
+ }
+ ary = rb_ary_concat(tmp1, tmp2);
}
}
Modified: trunk/sample/test.rb
===================================================================
--- trunk/sample/test.rb 2006-11-10 03:51:05 UTC (rev 580)
+++ trunk/sample/test.rb 2006-11-10 12:08:21 UTC (rev 581)
@@ -1952,7 +1952,7 @@
module M002; include M001; end
module M003; include M002; end
-test_ok(M003.ancestors == [M003, M002, M001, M002])
+test_ok(M003.ancestors == [M003, M002, M001])
test_check "marshal"
$x = [1,2,3,[4,5,"foo"],{1=>"bar"},2.5,fact(30)]
Modified: trunk/yarvtest/test_bin.rb
===================================================================
--- trunk/yarvtest/test_bin.rb 2006-11-10 03:51:05 UTC (rev 580)
+++ trunk/yarvtest/test_bin.rb 2006-11-10 12:08:21 UTC (rev 581)
@@ -508,6 +508,28 @@
end
o.foo = :x
}
+ ae %q{
+ $r = []
+ class C
+ def [](*args)
+ $r << [:ref, args]
+ args.size
+ end
+
+ def []=(*args)
+ $r << [:set, args]
+ args.size
+ end
+ end
+
+ o = C.new
+ ary = [:x, :y]
+ o[1] = 2
+ o[1, 2] = 3
+ o[1, 2, *ary] = 3
+ o[1, 2, *ary, 3] = 4
+ $r
+ }
end
def test_aref_aset
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml