[macruby-changes] [1165] MacRuby/branches/experimental/roxor.cpp

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 26 04:43:50 PDT 2009


Revision: 1165
          http://trac.macosforge.org/projects/ruby/changeset/1165
Author:   vincent.isambart at gmail.com
Date:     2009-03-26 04:43:50 -0700 (Thu, 26 Mar 2009)
Log Message:
-----------
fixed a bug in the compilation of the optional arguments
(and also removed a useless loop)

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

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-03-26 11:20:16 UTC (rev 1164)
+++ MacRuby/branches/experimental/roxor.cpp	2009-03-26 11:43:50 UTC (rev 1165)
@@ -2287,7 +2287,7 @@
 		     ++iter) {
 
 		    ID id = iter->first;
-		    assert(iter->second == NULL);	
+		    assert(iter->second == NULL);
 	
 		    Value *val = arg++;
 		    val->setName(std::string("dyna_") + rb_id2name(id));
@@ -2342,11 +2342,11 @@
 			lvars[id] = store;
 		    }
 
-		    // compile multiple assignment arguments (def f((a, b, v)))
-		    // (this must also be done after the creation of local variables)
-		    NODE *n = node->nd_args;
-		    if (n != NULL) {
-			NODE *rest_node = n->nd_next;
+		    NODE *args_node = node->nd_args;
+		    if (args_node != NULL) {
+			// compile multiple assignment arguments (def f((a, b, v)))
+			// (this must also be done after the creation of local variables)
+			NODE *rest_node = args_node->nd_next;
 			if (rest_node != NULL) {
 			    NODE *right_req_node = rest_node->nd_next;
 			    if (right_req_node != NULL) {
@@ -2364,22 +2364,19 @@
 				}
 			    }
 			}
-		    }
 
-		    // Compile optional arguments.
-		    Function::ArgumentListType::iterator iter = f->arg_begin();
-		    ++iter; // skip self
-		    ++iter; // skip sel
-		    while (n != NULL) {
-			if (nd_type(n) == NODE_ARGS) {
-			    for (i = 0; i < n->nd_frml; i++) {
-				++iter;  // skip mandatory argument
+			// Compile optional arguments.
+			Function::ArgumentListType::iterator iter = f->arg_begin();
+			++iter; // skip self
+			++iter; // skip sel
+			NODE *opt_node = args_node->nd_opt;
+			if (opt_node != NULL) {
+			    int to_skip = dvars.size() + args_node->nd_frml;
+			    for (i = 0; i < to_skip; i++) {
+				++iter;  // skip dvars and args required on the left-side
 			    }
-			    if (n->nd_head != NULL) {
-				iter = compile_optional_arguments(iter, n->nd_head);
-			    }
+			    iter = compile_optional_arguments(iter, opt_node);
 			}
-			n = n->nd_next;
 		    }
 		}
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090326/99f21f07/attachment.html>


More information about the macruby-changes mailing list