yarv-diff:236
From: ko1 atdot.net
Date: 13 Feb 2006 14:59:42 -0000
Subject: [yarv-diff:236] r397 - in trunk: . yarvtest
Author: ko1
Date: 2006-02-13 23:59:41 +0900 (Mon, 13 Feb 2006)
New Revision: 397
Modified:
trunk/
trunk/ChangeLog
trunk/insns.def
trunk/test.rb
trunk/vm_macro.def
trunk/yarvcore.h
trunk/yarvtest/test_method.rb
Log:
r587@leremita: ko1 | 2006-02-13 23:58:49 +0900
* insns.def, vm_macro.def : fix NODE_ZSUPER dispatch and
fix error message when super without suitable method ([yarv-dev:846])
* yarvcore.h : add VM_CALL_SUPER definition
* yarvtest/test_method.rb : add a test of Module#private_class_method
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:585
+ 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:587
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-02-13 14:09:39 UTC (rev 396)
+++ trunk/ChangeLog 2006-02-13 14:59:41 UTC (rev 397)
@@ -4,6 +4,16 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2006-02-13(Mon) 23:53:27 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * insns.def, vm_macro.def : fix NODE_ZSUPER dispatch and
+ fix error message when super without suitable method ([yarv-dev:846])
+
+ * yarvcore.h : add VM_CALL_SUPER definition
+
+ * yarvtest/test_method.rb : add a test of Module#private_class_method
+
+
2006-02-13(Mon) 22:49:42 +0900 Koichi Sasada <ko1 atdot.net>
* insns.def : traverse all iseq to find super method ([yarv-dev:859])
Modified: trunk/insns.def
===================================================================
--- trunk/insns.def 2006-02-13 14:09:39 UTC (rev 396)
+++ trunk/insns.def 2006-02-13 14:59:41 UTC (rev 397)
@@ -1235,7 +1235,7 @@
*/
DEFINE_INSN
send
-(ID id, num_t op_argc, BLOCKISEQ blockiseq, num_t flag, IC ic)
+(ID id, num_t op_argc, BLOCKISEQ blockiseq, num_t op_flag, IC ic)
(...)
(VALUE val) // inc += - op_argc;
{
@@ -1244,12 +1244,12 @@
VALUE klass;
yarv_block_t *blockptr = 0;
num_t num = op_argc;
+ num_t flag = op_flag;
macro_eval_setup_send_arguments(num, blockptr, flag, blockiseq);
recv = TOPN(num);
klass = CLASS_OF(recv);
- LABEL_IS_SC(start_method_dispatch):
mn = eval_method_search(id, klass, ic);
#if CURRENT_INSN_send || CURRENT_INSN_send_SC_xx_ax
@@ -1265,6 +1265,7 @@
num = 2;
recv = TOPN(2);
}
+ flag = 0;
id = tmp_id;
klass = CLASS_OF(recv);
blockptr = 0;
@@ -1283,6 +1284,7 @@
while (ip && !ip->defined_method_id) {
ip = ip->parent_iseq;
}
+
if (ip == 0) {
rb_raise(rb_eNoMethodError, "super called outside of method");
}
@@ -1312,11 +1314,13 @@
}
}
}
+ flag = VM_CALL_SUPER;
blockptr = tmp_blockptr;
mn = rb_method_node(klass, id);
}
#endif
#endif
+ LABEL_IS_SC(start_method_dispatch):
macro_eval_invoke_method(recv, klass, id, num, mn, blockptr);
YARV_CHECK_INTS();
}
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2006-02-13 14:09:39 UTC (rev 396)
+++ trunk/test.rb 2006-02-13 14:59:41 UTC (rev 397)
@@ -1,3 +1,16 @@
+class A
+end
+
+class B
+ def hoge
+ super
+ end
+end
+
+B.new.hoge
+
+__END__
+
super
__END__
class C
Modified: trunk/vm_macro.def
===================================================================
--- trunk/vm_macro.def 2006-02-13 14:09:39 UTC (rev 396)
+++ trunk/vm_macro.def 2006-02-13 14:59:41 UTC (rev 397)
@@ -256,6 +256,9 @@
if (flag & VM_CALL_VCALL_BIT) {
stat |= NOEX_VCALL;
}
+ if (flag & VM_CALL_SUPER) {
+ stat |= NOEX_SUPER;
+ }
val = eval_method_missing(th, id, recv, num, blockptr, stat);
}
}
@@ -313,6 +316,11 @@
NEXT_INSN();
break;
}
+ case NODE_ZSUPER:{
+ klass = RCLASS(mn->nd_clss)->super;
+ mn = rb_method_node(klass, id);
+ goto LABEL_IS_SC(start_method_dispatch);
+ }
case NODE_SCOPE:{
dpi(id);
SDR();
@@ -320,10 +328,6 @@
/* unreachable */
break;
}
- case NODE_ZSUPER:{
- klass = RCLASS(mn->nd_clss)->super;
- goto LABEL_IS_SC(start_method_dispatch);
- }
default:{
printf("node: %s\n", node_name(nd_type(node)));
rb_bug("eval_invoke_method: unreachable");
Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h 2006-02-13 14:09:39 UTC (rev 396)
+++ trunk/yarvcore.h 2006-02-13 14:59:41 UTC (rev 397)
@@ -477,6 +477,7 @@
#define VM_CALL_VCALL_BIT 0x08
#define VM_CALL_TAILCALL_BIT 0x10
#define VM_CALL_TAILRECURSION_BIT 0x20
+#define VM_CALL_SUPER 0x40
VALUE thread_eval_body(VALUE self);
VALUE iseq_inspect(VALUE self);
Modified: trunk/yarvtest/test_method.rb
===================================================================
--- trunk/yarvtest/test_method.rb 2006-02-13 14:09:39 UTC (rev 396)
+++ trunk/yarvtest/test_method.rb 2006-02-13 14:59:41 UTC (rev 397)
@@ -475,5 +475,20 @@
instance_eval('A.new.m')
}
end
+
+ def test_private_class_method
+ ae %q{
+ class C
+ def self.m
+ :ok
+ end
+ def self.test
+ m
+ end
+ private_class_method :m
+ end
+ C.test
+ }
+ end
end
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml