yarv-diff:278
From: ko1 atdot.net
Date: 18 Feb 2006 16:46:25 -0000
Subject: [yarv-diff:278] r442 - in trunk: . test/ruby
Author: ko1
Date: 2006-02-19 01:46:24 +0900 (Sun, 19 Feb 2006)
New Revision: 442
Modified:
trunk/
trunk/ChangeLog
trunk/eval.c
trunk/test.rb
trunk/test/ruby/test_eval.rb
trunk/vm.c
trunk/yarvcore.c
Log:
r670@lermite: ko1 | 2006-02-19 01:44:32 +0900
* vm.c : "return" from lambda{} break block
* eval.c : Unsupport Proc as Binding
* test/ruby/test_eval.rb : apply above changes
* yarvcore.c : remove unused function yarv_yield_values()
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:669
+ 81cd9672-7512-7e48-ae48-6936450e977d:/local/yarv/trunk:670
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-02-18 16:46:06 UTC (rev 441)
+++ trunk/ChangeLog 2006-02-18 16:46:24 UTC (rev 442)
@@ -3,7 +3,17 @@
# YARV ChangeLog
# from Mon, 03 May 2004 01:24:19 +0900
#
+2006-02-19(Sun) 01:27:08 +0900 Koichi Sasada <ko1 atdot.net>
+ * vm.c : "return" from lambda{} break block
+
+ * eval.c : Unsupport Proc as Binding
+
+ * test/ruby/test_eval.rb : apply above changes
+
+ * yarvcore.c : remove unused function yarv_yield_values()
+
+
2006-02-18(Sat) 03:19:36 +0900 Koichi Sasada <ko1 atdot.net>
* thread.c, insns.def : fix passing value when thread killed
@@ -5295,6 +5305,7 @@
* 0.0.0.d : imported
+
Local variables:
add-log-time-format: (lambda ()
(let* ((time (current-time))
Modified: trunk/eval.c
===================================================================
--- trunk/eval.c 2006-02-18 16:46:06 UTC (rev 441)
+++ trunk/eval.c 2006-02-18 16:46:24 UTC (rev 442)
@@ -1183,13 +1183,7 @@
}
VALUE
-#ifdef HAVE_STDARG_PROTOTYPES
rb_yield_values(int n, ...)
-#else
-rb_yield_values(n, va_alist)
- int n;
- va_dcl
-#endif
{
int i;
va_list args;
@@ -1209,8 +1203,7 @@
}
VALUE
-rb_yield_splat(values)
- VALUE values;
+rb_yield_splat(VALUE values)
{
int avalue = Qfalse;
@@ -1920,17 +1913,9 @@
envval = bind->env;
stored_cref_stack = bind->cref_stack;
}
- else if (CLASS_OF(scope) == cYarvProc) {
- yarv_proc_t *proc;
- GetProcVal(scope, proc);
- envval = proc->envval;
- if (proc->special_cref_stack) {
- stored_cref_stack = proc->special_cref_stack;
- }
- }
else {
rb_raise(rb_eTypeError,
- "wrong argument type %s (expected Proc/Binding)",
+ "wrong argument type %s (expected Binding)",
rb_obj_classname(scope));
}
GetEnvVal(envval, env);
Modified: trunk/test/ruby/test_eval.rb
===================================================================
--- trunk/test/ruby/test_eval.rb 2006-02-18 16:46:06 UTC (rev 441)
+++ trunk/test/ruby/test_eval.rb 2006-02-18 16:46:24 UTC (rev 442)
@@ -281,16 +281,19 @@
end
assert(!$bad)
- x = proc{}
- eval "i4 = 1", x
- assert_equal(1, eval("i4", x))
- x = proc{proc{}}.call
- eval "i4 = 22", x
- assert_equal(22, eval("i4", x))
- $x = []
- x = proc{proc{}}.call
- eval "(0..9).each{|i5| $x[i5] = proc{i5*2}}", x
- assert_equal(8, $x[4].call)
+ if false
+ # Ruby 2.0 doesn't see Proc as Binding
+ x = proc{}
+ eval "i4 = 1", x
+ assert_equal(1, eval("i4", x))
+ x = proc{proc{}}.call
+ eval "i4 = 22", x
+ assert_equal(22, eval("i4", x))
+ $x = []
+ x = proc{proc{}}.call
+ eval "(0..9).each{|i5| $x[i5] = proc{i5*2}}", x
+ assert_equal(8, $x[4].call)
+ end
x = binding
eval "i = 1", x
@@ -313,26 +316,32 @@
foo22 = 5
proc{foo11=22}.call
proc{foo22=55}.call
- assert_equal(eval("foo11"), eval("foo11", p))
- assert_equal(1, eval("foo11"))
+ # assert_equal(eval("foo11"), eval("foo11", p))
+ # assert_equal(1, eval("foo11"))
assert_equal(eval("foo22"), eval("foo22", p))
assert_equal(55, eval("foo22"))
}.call
- p1 = proc{i7 = 0; proc{i7}}.call
- assert_equal(0, p1.call)
- eval "i7=5", p1
- assert_equal(5, p1.call)
- assert(!defined?(i7))
+ if false
+ # Ruby 2.0 doesn't see Proc as Binding
+ p1 = proc{i7 = 0; proc{i7}}.call
+ assert_equal(0, p1.call)
+ eval "i7=5", p1
+ assert_equal(5, p1.call)
+ assert(!defined?(i7))
+ end
- p1 = proc{i7 = 0; proc{i7}}.call
- i7 = nil
- assert_equal(0, p1.call)
- eval "i7=1", p1
- assert_equal(1, p1.call)
- eval "i7=5", p1
- assert_equal(5, p1.call)
- assert_nil(i7)
+ if false
+ # Ruby 2.0 doesn't see Proc as Binding
+ p1 = proc{i7 = 0; proc{i7}}.call
+ i7 = nil
+ assert_equal(0, p1.call)
+ eval "i7=1", p1
+ assert_equal(1, p1.call)
+ eval "i7=5", p1
+ assert_equal(5, p1.call)
+ assert_nil(i7)
+ end
end
def test_nil_instance_eval_cvar # [ruby-dev:24103]
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2006-02-18 16:46:06 UTC (rev 441)
+++ trunk/test.rb 2006-02-18 16:46:24 UTC (rev 442)
@@ -1,3 +1,68 @@
+
+class TrueClass
+ @@cvar = :TrueCvar
+end
+
+class FalseClass
+ @@cvar = :FalseCvar
+end
+
+class FalseClass
+ p true.instance_eval('@@cvar')
+end
+
+__END__
+
+
+obj = true
+obj.class.class_variable_set :@@cvar , 1
+p obj.instance_eval('@@cvar')
+
+__END__
+[[[1, 2], 3]].each{|a, b|
+ p [a, b]
+}
+
+def f; yield []; end; f {|a,| p a}
+
+a, = []
+p a
+
+{1=>2}.each{|*e| p e}
+
+def f
+ yield([1,2])
+end
+f{|*a| p a}
+
+__END__
+f = lambda {|r,| p r}
+f.call([], *[])
+
+f = lambda {|r| p r}
+f.call([])
+
+
+__END__
+
+
+def m
+ proc{
+ return :ng
+ }
+end
+
+def call pr
+ pr.call
+end
+
+pr = m()
+
+call pr
+
+p :exit
+
+__END__
a = 1
th = Thread.new{
begin
Modified: trunk/vm.c
===================================================================
--- trunk/vm.c 2006-02-18 16:46:06 UTC (rev 441)
+++ trunk/vm.c 2006-02-18 16:46:24 UTC (rev 442)
@@ -546,10 +546,16 @@
int i;
if (0) { // for debug
+ int i;
+ GET_THREAD()->cfp->sp += argc;
+ for(i=0; i<argc; i++){
+ dp(argv[i]);
+ }
printf(" argc: %d\n", argc);
printf("iseq argc: %d\n", iseq->argc);
printf("iseq rest: %d\n", iseq->arg_rest);
printf("iseq blck: %d\n", iseq->arg_block);
+ GET_THREAD()->cfp->sp -= argc;
}
if (iseq->argc == 1 && iseq->arg_rest != -1) {
@@ -563,7 +569,7 @@
}
}
else {
- if (argc == 1 && TYPE(argv[0]) == T_ARRAY) {
+ if (argc == 1 && TYPE(argv[0]) == T_ARRAY) {// && iseq->arg_rest == 0) {
VALUE ary = argv[0];
argc = RARRAY(ary)->len;
@@ -687,10 +693,13 @@
}
}
else {
- if (state == TAG_BREAK) {
+
+ if (state == TAG_BREAK ||
+ (state == TAG_RETURN && proc->is_lambda)) {
VALUE err = th->errinfo;
VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
VALUE *cdfp = proc->block.dfp;
+
if (escape_dfp == cdfp) {
state = 0;
th->errinfo = Qnil;
Modified: trunk/yarvcore.c
===================================================================
--- trunk/yarvcore.c 2006-02-18 16:46:06 UTC (rev 441)
+++ trunk/yarvcore.c 2006-02-18 16:46:24 UTC (rev 442)
@@ -127,22 +127,6 @@
yarv_vm_t *theYarvVM = 0;
static VALUE yarvVMArray = Qnil;
-VALUE th_invoke_yield(yarv_thread_t *th, int argc, VALUE *argv);
-
-/* rb_yield_values */
-VALUE
-yarv_yield_values(int argc, VALUE *argv)
-{
- yarv_thread_t *th = GET_THREAD();
-
- if (argc == 1 && CLASS_OF(argv[0]) == rb_cValues) {
- argc = RARRAY(argv[0])->len;
- argv = RARRAY(argv[0])->ptr;
- }
-
- return th_invoke_yield(th, argc, argv);
-}
-
VALUE thread_call0(VALUE self, VALUE klass, VALUE recv, VALUE id, ID oid,
int argc, VALUE *argv, NODE * body, int nosuper);
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml