* compile.c (iseq_compile_each): support v[&b]= type method call.

[ruby-dev:31094]
* bootstraptest/test_method.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-07-03 18:58:42 +00:00
Родитель d82f3e7d5c
Коммит 1d8ce92a37
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Wed Jul 4 03:52:55 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (iseq_compile_each): support v[&b]= type method call.
[ruby-dev:31094]
* bootstraptest/test_method.rb: add a test for above.
Wed Jul 4 03:43:29 2007 Koichi Sasada <ko1@atdot.net>
* compile.c (compile_massign): fix massign compilation

Просмотреть файл

@ -318,6 +318,25 @@ assert_equal '1', %q( class C; def m() 7 end; private :m end
assert_equal '1', %q( class C; def m() 1 end; private :m end
C.new.funcall(:m) )
# with block
assert_equal '[[:ok1, :foo], [:ok2, :foo, :bar]]',
%q{
class C
def [](a)
$ary << [yield, a]
end
def []=(a, b)
$ary << [yield, a, b]
end
end
$ary = []
C.new[:foo, &lambda{:ok1}]
C.new[:foo, &lambda{:ok2}] = :bar
$ary
}
# splat and block arguments
assert_equal %q{[[[:x, :y, :z], NilClass], [[1, :x, :y, :z], NilClass], [[1, 2, :x, :y, :z], NilClass], [[:obj], NilClass], [[1, :obj], NilClass], [[1, 2, :obj], NilClass], [[], Proc], [[1], Proc], [[1, 2], Proc], [[], Proc], [[1], Proc], [[1, 2], Proc], [[:x, :y, :z], Proc], [[1, :x, :y, :z], Proc], [[1, 2, :x, :y, :z], Proc]]}, %q{
def m(*args, &b)

Просмотреть файл

@ -4285,8 +4285,16 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN(ret, nd_line(node), putnil);
ADD_SEQ(ret, recv);
ADD_SEQ(ret, args);
if (flag & VM_CALL_ARGS_BLOCKARG_BIT) {
ADD_INSN1(ret, nd_line(node), topn, INT2FIX(1));
ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 3));
ADD_INSN (ret, nd_line(node), pop);
}
else {
ADD_INSN1(ret, nd_line(node), setn, INT2FIX(FIX2INT(argc) + 1));
}
}
else {
ADD_SEQ(ret, recv);
ADD_SEQ(ret, args);