[前][次][番号順一覧][スレッド一覧][生データ]

yarv-diff:100

From: ko1 atdot.net
Date: 15 Sep 2005 07:55:25 -0000
Subject: [yarv-diff:100] r256 - in trunk: . yarvtest

Author: ko1
Date: 2005-09-15 16:55:24 +0900 (Thu, 15 Sep 2005)
New Revision: 256

Modified:
   trunk/ChangeLog
   trunk/compile.c
   trunk/test.rb
   trunk/yarvcore.h
   trunk/yarvtest/test_block.rb
Log:
	* compile.c, yarvcore.h : fix "for" scope

	* yarvtest/test_block.rb : add tests for above



Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-09-13 21:14:09 UTC (rev 255)
+++ trunk/ChangeLog	2005-09-15 07:55:24 UTC (rev 256)
@@ -4,6 +4,13 @@
 #  from Mon, 03 May 2004 01:24:19 +0900
 #
 
+2005-09-15(Thu) 16:51:06 +0900  Koichi Sasada  <ko1 atdot.net>
+
+	* compile.c, yarvcore.h : fix "for" scope
+
+	* yarvtest/test_block.rb : add tests for above
+
+
 2005-09-14(Wed) 06:11:43 +0900  Koichi Sasada  <ko1 atdot.net>
 
 	* yarvcore.h, vm_evalbody.h, vm.h, vm_dump.c,

Modified: trunk/compile.c
===================================================================
--- trunk/compile.c	2005-09-13 21:14:09 UTC (rev 255)
+++ trunk/compile.c	2005-09-15 07:55:24 UTC (rev 256)
@@ -938,6 +938,9 @@
     }
   }
 
+  if(nd_type(node) == NODE_FOR){
+    iseqobj->compile_data->for_iseq = 1;
+  }
   return rnode;
 }
 
@@ -2674,7 +2677,9 @@
     if(nd_type(node) == NODE_DASGN_CURR &&
        lv > 0 &&
        iseqobj->type != ISEQ_TYPE_RESCUE){
-      rb_bug("NODE_DASGN_CURR, but lv == %d (line: %d)", lv, nd_line(node));
+      if(iseqobj->compile_data->for_iseq == 1 && lv != 1){
+        rb_bug("NODE_DASGN_CURR, but lv == %d (line: %d)", lv, nd_line(node));
+      }
     }
     
     if(idx < 0){

Modified: trunk/test.rb
===================================================================
--- trunk/test.rb	2005-09-13 21:14:09 UTC (rev 255)
+++ trunk/test.rb	2005-09-15 07:55:24 UTC (rev 256)
@@ -1,12 +1,5 @@
-
-def fib n
-  if n < 2
-    1
-  else
-    fib(n-1) + fib(n-2)
-  end
-end
-
-fib(36)
-
-
+1.times{
+  for n in 1..5
+    a = 1
+  end
+}

Modified: trunk/yarvcore.h
===================================================================
--- trunk/yarvcore.h	2005-09-13 21:14:09 UTC (rev 255)
+++ trunk/yarvcore.h	2005-09-15 07:55:24 UTC (rev 256)
@@ -152,6 +152,7 @@
   VALUE loopval_popped;  /* used by NODE_BREAK */
   VALUE in_ensure;       /* used by NODE_RETURN */
   VALUE ensure_node;
+  VALUE for_iseq;
   struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
   int   cached_const;
 

Modified: trunk/yarvtest/test_block.rb
===================================================================
--- trunk/yarvtest/test_block.rb	2005-09-13 21:14:09 UTC (rev 255)
+++ trunk/yarvtest/test_block.rb	2005-09-15 07:55:24 UTC (rev 256)
@@ -272,8 +272,26 @@
       end
       sum
     }
+    ae %q{
+      ans = []
+      1.times{
+        for n in 1..3
+          a = n
+          ans << a
+        end
+      }
+    }
+    ae %q{
+      ans = []
+      for m in 1..3
+        for n in 1..3
+          a = [m, n]
+          ans << a
+        end
+      end
+    }
   end
-
+  
   def test_unmatched_params
     ae %q{
       def iter


--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧][生データ]