[macruby-changes] [1164] MacRuby/branches/experimental/roxor.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 26 04:20:17 PDT 2009
Revision: 1164
http://trac.macosforge.org/projects/ruby/changeset/1164
Author: vincent.isambart at 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:
--------------
MacRuby/branches/experimental/roxor.cpp
Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090326/9c454c9b/attachment.html>
More information about the macruby-changes
mailing list