[macruby-changes] [956] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 17 14:10:49 PDT 2009


Revision: 956
          http://trac.macosforge.org/projects/ruby/changeset/956
Author:   lsansonetti at apple.com
Date:     2009-03-17 14:10:48 -0700 (Tue, 17 Mar 2009)
Log Message:
-----------
fixed a bug in recursive method dispatch within a block + added a new test

Modified Paths:
--------------
    MacRuby/branches/experimental/roxor.cpp
    MacRuby/branches/experimental/test_roxor.rb

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-03-17 20:53:09 UTC (rev 955)
+++ MacRuby/branches/experimental/roxor.cpp	2009-03-17 21:10:48 UTC (rev 956)
@@ -2848,8 +2848,8 @@
 		}
 
 		// Recursive method call optimization.
-		if (!block_given && !super_call && !splat_args 
-		    && mid == current_mid && recv == NULL) {
+		if (!block_given && !super_call && !splat_args
+		    && positive_arity && mid == current_mid && recv == NULL) {
 
 		    // TODO check if both functions have the same arity (paranoid?)
 
@@ -3567,6 +3567,8 @@
 		BasicBlock *old_current_loop_begin_bb = current_loop_begin_bb;
 		BasicBlock *old_current_loop_end_bb = current_loop_end_bb;
 		current_loop_begin_bb = current_loop_end_bb = NULL;
+		ID old_current_mid = current_mid;
+		current_mid = 0;
 
 		assert(node->nd_body != NULL);
 		Value *block = compile_node(node->nd_body);	
@@ -3575,6 +3577,7 @@
 		current_loop_begin_bb = old_current_loop_begin_bb;
 		current_loop_end_bb = old_current_loop_end_bb;
 		current_block = false;
+		current_mid = old_current_mid;
 
 		current_block_func = cast<Function>(block);
 		current_block_node = node->nd_body;

Modified: MacRuby/branches/experimental/test_roxor.rb
===================================================================
--- MacRuby/branches/experimental/test_roxor.rb	2009-03-17 20:53:09 UTC (rev 955)
+++ MacRuby/branches/experimental/test_roxor.rb	2009-03-17 21:10:48 UTC (rev 956)
@@ -638,6 +638,19 @@
     end
     p :ok
   }
+
+  assert "1\n2\n2", %q{
+    def func
+      p 1
+      def func
+        p 2
+      end
+      func
+    end
+    func
+    func
+  }
+
 end
 
 test "blocks" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090317/ea9aa0e2/attachment.html>


More information about the macruby-changes mailing list