Skip to content

Commit

Permalink
* include/ruby/intern.h, proc.c: revert rb_proc_call() and
Browse files Browse the repository at this point in the history
  create rb_proc_call_with_block() instaed.
* include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c:
  rb_blockptr should not be exposed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
ko1 committed Jun 10, 2008
1 parent 8b7a284 commit ed4139e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 22 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Wed Jun 11 01:28:12 2008 Koichi Sasada <[email protected]>

* include/ruby/intern.h, proc.c: revert rb_proc_call() and
create rb_proc_call_with_block() instaed.

* include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c:
rb_blockptr should not be exposed.

Tue Jun 10 21:07:19 2008 Kazuhiro NISHIYAMA <[email protected]>

* test/ruby/test_float.rb: add tests. [ruby-dev:35009]
Expand Down
2 changes: 1 addition & 1 deletion eval_jump.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
void
rb_call_end_proc(VALUE data)
{
rb_proc_call(data, rb_ary_new(), 0);
rb_proc_call(data, rb_ary_new());
}

/*
Expand Down
3 changes: 2 additions & 1 deletion include/ruby/intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ VALUE rb_class_new_instance(int, VALUE*, VALUE);
VALUE rb_block_proc(void);
VALUE rb_f_lambda(void);
VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
VALUE rb_proc_call(VALUE, VALUE, rb_blockptr);
VALUE rb_proc_call(VALUE, VALUE);
VALUE rb_proc_call_with_block(VALUE, int argc, VALUE *argv, VALUE);
int rb_proc_arity(VALUE);
VALUE rb_binding_new(void);
VALUE rb_obj_method(VALUE, VALUE);
Expand Down
2 changes: 0 additions & 2 deletions include/ruby/ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,6 @@ PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2);
PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);

typedef struct rb_block_struct *rb_blockptr;

typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*);

VALUE rb_each(VALUE);
Expand Down
30 changes: 23 additions & 7 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,26 @@ proc_call(int argc, VALUE *argv, VALUE procval)
}

VALUE
rb_proc_call(VALUE self, VALUE args, rb_blockptr blockptr)
rb_proc_call(VALUE self, VALUE args)
{
rb_proc_t *proc;
GetProcPtr(self, proc);
return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
RARRAY_LEN(args), RARRAY_PTR(args), blockptr);
RARRAY_LEN(args), RARRAY_PTR(args), 0);
}

VALUE
rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
{
rb_proc_t *proc, *pass_proc = 0;
GetProcPtr(self, proc);

if (!NIL_P(pass_procval)) {
GetProcPtr(pass_procval, pass_proc);
}

return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
argc, argv, &pass_proc->block);
}

/*
Expand Down Expand Up @@ -1584,7 +1598,7 @@ proc_binding(VALUE self)
return bindval;
}

static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr);
static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc);

static VALUE
make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
Expand All @@ -1600,7 +1614,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
}

static VALUE
curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)
curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
{
VALUE proc, passed, arity;
proc = RARRAY_PTR(args)[0];
Expand All @@ -1609,15 +1623,17 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)

passed = rb_ary_plus(passed, rb_ary_new4(argc, argv));
rb_ary_freeze(passed);

if(RARRAY_LEN(passed) < FIX2INT(arity)) {
if (blockptr) {
if (!NIL_P(passed_proc)) {
rb_warn("given block not used");
}
arity = make_curry_proc(proc, passed, arity);
return arity;
}
arity = rb_proc_call(proc, passed, blockptr);
return arity;
else {
return rb_proc_call_with_block(proc, RARRAY_LEN(passed), RARRAY_PTR(passed), passed_proc);
}
}

/*
Expand Down
15 changes: 10 additions & 5 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -3079,6 +3079,7 @@ call_trace_proc(VALUE args, int tracing)
struct call_trace_func_args *p = (struct call_trace_func_args *)args;
VALUE eventname = rb_str_new2(get_event_name(p->event));
VALUE filename = rb_str_new2(rb_sourcefile());
VALUE argv[6];
int line = rb_sourceline();
ID id = 0;
VALUE klass = 0;
Expand All @@ -3101,11 +3102,15 @@ call_trace_proc(VALUE args, int tracing)
klass = rb_iv_get(klass, "__attached__");
}
}
return rb_proc_call(p->proc, rb_ary_new3(6,
eventname, filename, INT2FIX(line),
id ? ID2SYM(id) : Qnil,
p->self ? rb_binding_new() : Qnil,
klass ? klass : Qnil), 0);

argv[0] = eventname;
argv[1] = filename;
argv[2] = INT2FIX(line);
argv[3] = id ? ID2SYM(id) : Qnil;
argv[4] = p->self ? rb_binding_new() : Qnil;
argv[5] = klass ? klass : Qnil;

return rb_proc_call_with_block(p->proc, 6, argv, Qnil);
}

static void
Expand Down
6 changes: 3 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2008-06-10"
#define RUBY_RELEASE_DATE "2008-06-11"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20080610
#define RUBY_RELEASE_CODE 20080611
#define RUBY_PATCHLEVEL 0

#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 6
#define RUBY_RELEASE_DAY 10
#define RUBY_RELEASE_DAY 11

#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];
Expand Down
12 changes: 9 additions & 3 deletions vm_insnhelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,7 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
const rb_block_t *blockptr)
{
NODE *ifunc = (NODE *) block->iseq;
VALUE val;
VALUE arg;
VALUE val, arg, blockarg;
int lambda = block_proc_is_lambda(block->proc);

if (lambda) {
Expand All @@ -669,11 +668,18 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
arg = argv[0];
}

if (blockptr) {
blockarg = vm_make_proc(th, th->cfp, blockptr);
}
else {
blockarg = Qnil;
}

vm_push_frame(th, 0, FRAME_MAGIC_IFUNC,
self, (VALUE)block->dfp,
0, th->cfp->sp, block->lfp, 1);

val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockptr);
val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg);

th->cfp++;
return val;
Expand Down

0 comments on commit ed4139e

Please sign in to comment.