summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-29 08:06:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-29 08:06:19 +0000
commit92b4a05e07de480fabc70dae35c4b6dd2b1f42c9 (patch)
tree599d822117e67be4b0bcc5be81595147591e2cf3
parent58553ca18487083d8a7f72068545e75788e1c8bc (diff)
vm_eval.c: rb_yield_block
* vm_eval.c (rb_yield_block): yield block with rb_block_call_func arguments. * range.c (range_each): use rb_yield_block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--include/ruby/ruby.h1
-rw-r--r--range.c2
-rw-r--r--vm.c8
-rw-r--r--vm_eval.c11
5 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d08447f..1e2b9a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
-Fri Nov 29 17:02:48 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Nov 29 17:06:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_eval.c (rb_yield_block): yield block with rb_block_call_func
+ arguments.
+
+ * range.c (range_each): use rb_yield_block.
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): constify argv.
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index baa6f47..bf874c8 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1509,6 +1509,7 @@ VALUE rb_yield(VALUE);
VALUE rb_yield_values(int n, ...);
VALUE rb_yield_values2(int n, const VALUE *argv);
VALUE rb_yield_splat(VALUE);
+VALUE rb_yield_block(VALUE, VALUE, int, const VALUE *, VALUE); /* rb_block_call_func */
int rb_block_given_p(void);
void rb_need_block(void);
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE);
diff --git a/range.c b/range.c
index ab89b82..db8e9ee 100644
--- a/range.c
+++ b/range.c
@@ -796,7 +796,7 @@ range_each(VALUE range)
args[0] = end;
args[1] = EXCL(range) ? Qtrue : Qfalse;
- rb_block_call(tmp, rb_intern("upto"), 2, args, rb_yield, 0);
+ rb_block_call(tmp, rb_intern("upto"), 2, args, rb_yield_block, 0);
}
else {
if (!discrete_object_p(beg)) {
diff --git a/vm.c b/vm.c
index 5acdf2b..7b3447f 100644
--- a/vm.c
+++ b/vm.c
@@ -699,6 +699,14 @@ vm_yield(rb_thread_t *th, int argc, const VALUE *argv)
blockptr->klass);
}
+static inline VALUE
+vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr)
+{
+ const rb_block_t *blockptr = check_block(th);
+ return invoke_block_from_c(th, blockptr, blockptr->self, argc, argv, blockargptr, 0,
+ blockptr->klass);
+}
+
static VALUE
vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, VALUE defined_class,
int argc, const VALUE *argv, const rb_block_t *blockptr)
diff --git a/vm_eval.c b/vm_eval.c
index 2dcbd45..6ac0f49 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -14,6 +14,7 @@
static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status);
static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref);
static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
+static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr);
static NODE *vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr);
static VALUE vm_exec(rb_thread_t *th);
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref, rb_block_t *base_block);
@@ -988,6 +989,16 @@ rb_yield_splat(VALUE values)
return v;
}
+VALUE
+rb_yield_block(VALUE val, VALUE arg, int argc, const VALUE *argv, VALUE blockarg)
+{
+ const rb_block_t *blockptr = 0;
+ if (!NIL_P(blockarg)) {
+ rb_notimplement();
+ }
+ return vm_yield_with_block(GET_THREAD(), argc, argv, blockptr);
+}
+
static VALUE
loop_i(void)
{