[macruby-changes] [5253] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 4 19:05:05 PST 2011


Revision: 5253
          http://trac.macosforge.org/projects/ruby/changeset/5253
Author:   lsansonetti at apple.com
Date:     2011-03-04 19:05:02 -0800 (Fri, 04 Mar 2011)
Log Message:
-----------
fix a bug when break expressions inside hash iterations wouldn't be taken into account

Modified Paths:
--------------
    MacRuby/trunk/hash.c
    MacRuby/trunk/vm.h

Modified: MacRuby/trunk/hash.c
===================================================================
--- MacRuby/trunk/hash.c	2011-03-04 23:05:12 UTC (rev 5252)
+++ MacRuby/trunk/hash.c	2011-03-05 03:05:02 UTC (rev 5253)
@@ -760,7 +760,9 @@
 delete_if_i(VALUE key, VALUE value, VALUE ary)
 {
     if (key != Qundef) {
-	if (RTEST(rb_yield_values(2, key, value))) {
+	const bool ok = RTEST(rb_yield_values(2, key, value));
+	ST_STOP_IF_BROKEN();
+	if (ok) {
 	    rb_ary_push(ary, key);
 	}
     }
@@ -850,7 +852,9 @@
 select_i(VALUE key, VALUE value, VALUE result)
 {
     if (key != Qundef) {
-	if (RTEST(rb_yield_values(2, key, value))) {
+	const bool ok = RTEST(rb_yield_values(2, key, value));
+	ST_STOP_IF_BROKEN();
+	if (ok) {
 	    rb_hash_aset(result, key, value);
 	}
     }
@@ -1011,6 +1015,7 @@
 {
     if (key != Qundef) {
 	rb_yield(value);
+	ST_STOP_IF_BROKEN();
     }
     return ST_CONTINUE;
 }
@@ -1044,6 +1049,7 @@
 {
     if (key != Qundef) {
 	rb_yield(key);
+	ST_STOP_IF_BROKEN();
     }
     return ST_CONTINUE;
 }
@@ -1079,6 +1085,7 @@
 {
     if (key != Qundef) {
 	rb_yield(rb_assoc_new(key, value));
+	ST_STOP_IF_BROKEN();
     }
     return ST_CONTINUE;
 }
@@ -1488,6 +1495,7 @@
     if (key != Qundef) {
 	if (rhash_has_key(hash, 0, key)) {
 	    value = rb_yield_values(3, key, rhash_aref(hash, 0, key), value);
+	    ST_STOP_IF_BROKEN();
 	}
 	rhash_aset(hash, 0, key, value);
     }

Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h	2011-03-04 23:05:12 UTC (rev 5252)
+++ MacRuby/trunk/vm.h	2011-03-05 03:05:02 UTC (rev 5253)
@@ -515,6 +515,15 @@
 VALUE rb_vm_get_broken_value(void *vm);
 VALUE rb_vm_returned_from_block(void *_vm, int id);
 
+#define ST_STOP_IF_BROKEN() \
+    do { \
+	VALUE __v = rb_vm_get_broken_value(rb_vm_current_vm()); \
+	if (__v != Qundef) { \
+	    return ST_STOP; \
+	} \
+    } \
+    while (0)
+
 VALUE rb_vm_pop_broken_value(void);
 #define RETURN_IF_BROKEN() \
     do { \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110304/eaac071a/attachment.html>


More information about the macruby-changes mailing list