[macruby-changes] [2621] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Wed Sep 23 05:40:50 PDT 2009
Revision: 2621
http://trac.macosforge.org/projects/ruby/changeset/2621
Author: vincent.isambart at gmail.com
Date: 2009-09-23 05:40:47 -0700 (Wed, 23 Sep 2009)
Log Message:
-----------
Fixed the return value of while/until loops
(yet another bug found by verifyModule)
Modified Paths:
--------------
MacRuby/trunk/compiler.cpp
MacRuby/trunk/compiler.h
Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp 2009-09-23 06:29:20 UTC (rev 2620)
+++ MacRuby/trunk/compiler.cpp 2009-09-23 12:40:47 UTC (rev 2621)
@@ -1710,8 +1710,8 @@
case NODE_BREAK:
if (within_loop) {
- current_loop_exit_val = val;
BranchInst::Create(current_loop_end_bb, bb);
+ current_loop_exit_val->addIncoming(val, bb);
}
else if (within_block) {
compile_break_val(val);
@@ -4831,6 +4831,7 @@
BasicBlock *loopBB = BasicBlock::Create("loop", f);
BasicBlock *bodyBB = BasicBlock::Create("body", f);
+ BasicBlock *exitBB = BasicBlock::Create("loop_exit", f);
BasicBlock *afterBB = BasicBlock::Create("after", f);
const bool first_pass_free = node->nd_state == 0;
@@ -4841,21 +4842,23 @@
Value *condVal = compile_node(node->nd_cond);
if (nd_type(node) == NODE_WHILE) {
- compile_boolean_test(condVal, bodyBB, afterBB);
+ compile_boolean_test(condVal, bodyBB, exitBB);
}
else {
- compile_boolean_test(condVal, afterBB, bodyBB);
+ compile_boolean_test(condVal, exitBB, bodyBB);
}
+ BranchInst::Create(afterBB, exitBB);
BasicBlock *old_current_loop_begin_bb = current_loop_begin_bb;
BasicBlock *old_current_loop_body_bb = current_loop_body_bb;
BasicBlock *old_current_loop_end_bb = current_loop_end_bb;
- Value *old_current_loop_exit_val = current_loop_exit_val;
+ PHINode *old_current_loop_exit_val = current_loop_exit_val;
current_loop_begin_bb = loopBB;
current_loop_body_bb = bodyBB;
current_loop_end_bb = afterBB;
- current_loop_exit_val = NULL;
+ current_loop_exit_val = PHINode::Create(RubyObjTy, "loop_exit", afterBB);
+ current_loop_exit_val->addIncoming(nilVal, exitBB);
bb = bodyBB;
compile_node(node->nd_body);
@@ -4866,9 +4869,6 @@
bb = afterBB;
Value *retval = current_loop_exit_val;
- if (retval == NULL) {
- retval = nilVal;
- }
current_loop_begin_bb = old_current_loop_begin_bb;
current_loop_body_bb = old_current_loop_body_bb;
Modified: MacRuby/trunk/compiler.h
===================================================================
--- MacRuby/trunk/compiler.h 2009-09-23 06:29:20 UTC (rev 2620)
+++ MacRuby/trunk/compiler.h 2009-09-23 12:40:47 UTC (rev 2621)
@@ -125,7 +125,7 @@
BasicBlock *current_loop_begin_bb;
BasicBlock *current_loop_body_bb;
BasicBlock *current_loop_end_bb;
- Value *current_loop_exit_val;
+ PHINode *current_loop_exit_val;
int return_from_block;
int return_from_block_ids;
PHINode *ensure_pn;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090923/2b27240d/attachment.html>
More information about the macruby-changes
mailing list