Revision
1164
Author
vincent.isambart@gmail.com
Date
2009-03-26 04:20:16 -0700 (Thu, 26 Mar 2009)

Log Message

added support for multiple assignment arguments (def f((a, b)))
Note that the tests cases not passing seem to be a bug in the normal multiple assignment code

Modified Paths

Diff

Modified: MacRuby/branches/experimental/roxor.cpp (1163 => 1164)


--- MacRuby/branches/experimental/roxor.cpp	2009-03-26 06:00:53 UTC (rev 1163)
+++ MacRuby/branches/experimental/roxor.cpp	2009-03-26 11:20:16 UTC (rev 1164)
@@ -2342,8 +2342,31 @@
 			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;
+			if (rest_node != NULL) {
+			    NODE *right_req_node = rest_node->nd_next;
+			    if (right_req_node != NULL) {
+				NODE *last_node = right_req_node->nd_next;
+				if (last_node != NULL) {
+				    assert(nd_type(last_node) == NODE_AND);
+				    // multiple assignment for the left-side required arguments
+				    if (last_node->nd_1st != NULL) {
+					compile_node(last_node->nd_1st);
+				    }
+				    // multiple assignment for the right-side required arguments
+				    if (last_node->nd_2nd != NULL) {
+					compile_node(last_node->nd_2nd);
+				    }
+				}
+			    }
+			}
+		    }
+
 		    // Compile optional arguments.
-		    NODE *n = node->nd_args;
 		    Function::ArgumentListType::iterator iter = f->arg_begin();
 		    ++iter; // skip self
 		    ++iter; // skip sel