[macruby-changes] [2934] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 30 22:49:52 PDT 2009
Revision: 2934
http://trac.macosforge.org/projects/ruby/changeset/2934
Author: lsansonetti at apple.com
Date: 2009-10-30 22:49:51 -0700 (Fri, 30 Oct 2009)
Log Message:
-----------
return-from-block is now active for further dispatch calls inside the same method + do not return-from-block from lambdas (to mimic MRI 1.9)
Modified Paths:
--------------
MacRuby/trunk/compiler.cpp
MacRuby/trunk/vm.cpp
Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp 2009-10-31 05:48:34 UTC (rev 2933)
+++ MacRuby/trunk/compiler.cpp 2009-10-31 05:49:51 UTC (rev 2934)
@@ -1628,14 +1628,17 @@
RoxorCompiler::compile_return_from_block(Value *val, int id)
{
if (returnFromBlockFunc == NULL) {
- // void rb_vm_return_from_block(VALUE val, int id);
+ // void rb_vm_return_from_block(VALUE val, int id,
+ // rb_vm_block_t *current_block);
returnFromBlockFunc = cast<Function>(
module->getOrInsertFunction("rb_vm_return_from_block",
- VoidTy, RubyObjTy, Int32Ty, NULL));
+ VoidTy, RubyObjTy, Int32Ty, PtrTy, NULL));
}
std::vector<Value *> params;
params.push_back(val);
params.push_back(ConstantInt::get(Int32Ty, id));
+ params.push_back(running_block);
+
compile_protected_call(returnFromBlockFunc, params);
}
@@ -4948,8 +4951,6 @@
bool old_current_block = current_block;
bool old_current_block_chain = current_block_chain;
int old_return_from_block = return_from_block;
- BasicBlock *old_rescue_invoke_bb = rescue_invoke_bb;
- BasicBlock *old_rescue_rethrow_bb = rescue_rethrow_bb;
bool old_dynamic_class = dynamic_class;
current_mid = 0;
@@ -5015,9 +5016,7 @@
if (return_from_block_bb != NULL) {
BasicBlock *old_bb = bb;
bb = return_from_block_bb;
- compile_return_from_block_handler(return_from_block);
- rescue_rethrow_bb = old_rescue_rethrow_bb;
- rescue_invoke_bb = old_rescue_invoke_bb;
+ compile_return_from_block_handler(return_from_block);
bb = old_bb;
return_from_block = old_return_from_block;
}
Modified: MacRuby/trunk/vm.cpp
===================================================================
--- MacRuby/trunk/vm.cpp 2009-10-31 05:48:34 UTC (rev 2933)
+++ MacRuby/trunk/vm.cpp 2009-10-31 05:49:51 UTC (rev 2934)
@@ -3098,14 +3098,17 @@
extern "C"
void
-rb_vm_return_from_block(VALUE val, int id)
+rb_vm_return_from_block(VALUE val, int id, rb_vm_block_t *running_block)
{
- RoxorReturnFromBlockException *exc = new RoxorReturnFromBlockException();
-
- exc->val = val;
- exc->id = id;
-
- throw exc;
+ // Do not trigger a return from the calling scope if the running block
+ // is a lambda, to conform to the ruby 1.9 specifications.
+ if (!(running_block->flags & VM_BLOCK_LAMBDA)) {
+ RoxorReturnFromBlockException *exc =
+ new RoxorReturnFromBlockException();
+ exc->val = val;
+ exc->id = id;
+ throw exc;
+ }
}
extern "C" std::type_info *__cxa_current_exception_type(void);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091030/f5af6720/attachment-0001.html>
More information about the macruby-changes
mailing list