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

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 25 05:14:56 PDT 2009


Revision: 1147
          http://trac.macosforge.org/projects/ruby/changeset/1147
Author:   vincent.isambart at gmail.com
Date:     2009-03-25 05:14:55 -0700 (Wed, 25 Mar 2009)
Log Message:
-----------
added basic code for supporting def f(a=b=c=1)

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

Modified: MacRuby/branches/experimental/roxor.cpp
===================================================================
--- MacRuby/branches/experimental/roxor.cpp	2009-03-25 12:14:50 UTC (rev 1146)
+++ MacRuby/branches/experimental/roxor.cpp	2009-03-25 12:14:55 UTC (rev 1147)
@@ -710,13 +710,43 @@
 
 Function::ArgumentListType::iterator
 RoxorCompiler::compile_optional_arguments(Function::ArgumentListType::iterator iter,
-					  NODE *node)
+					  NODE *start_node)
 {
+    NODE *node = start_node;
     assert(nd_type(node) == NODE_OPT_ARG);
 
+    // we have to handle the case def f(a = b = c = 1) and create those b and c
+    // and this before we compile the assignments themselves
     do {
 	assert(node->nd_value != NULL);
 
+	assert(nd_type(node->nd_value) == NODE_LASGN || nd_type(node->nd_value) == NODE_DASGN_CURR);
+	NODE *assign_node = node->nd_value->nd_value;
+	while (assign_node != NULL) {
+	    switch (nd_type(assign_node)) {
+		case NODE_LASGN:
+		case NODE_DASGN_CURR:
+		    Value *slot = new AllocaInst(RubyObjTy, "", bb);
+		    new StoreInst(nilVal, slot, bb);
+		    lvars[assign_node->nd_vid] = slot;
+		case NODE_IASGN:
+		case NODE_GASGN:
+		    assign_node = assign_node->nd_value;
+		    break;
+
+		// TODO: NODE_ATTRASGN
+
+		default:
+		    assign_node = NULL;
+	    }
+	}
+    }
+    while ((node = node->nd_next) != NULL);
+
+    node = start_node;
+    do {
+	assert(node->nd_value != NULL);
+
 	Value *isUndefInst = new ICmpInst(ICmpInst::ICMP_EQ, iter, undefVal, "", bb);
 
 	Function *f = bb->getParent();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090325/4f862138/attachment.html>


More information about the macruby-changes mailing list