зеркало из https://github.com/github/ruby.git
* vm_insnhelper.h: define struct IFUNC.
* vm_eval.c (rb_iterate): use it. * vm_insnhelper.c (vm_yield_with_cfunc): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e512180a98
Коммит
b8fa8865ee
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Mar 11 04:56:04 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* vm_insnhelper.h: define struct IFUNC.
|
||||||
|
|
||||||
|
* vm_eval.c (rb_iterate): use it.
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_yield_with_cfunc): ditto.
|
||||||
|
|
||||||
Wed Mar 11 03:52:12 2015 Koichi Sasada <ko1@atdot.net>
|
Wed Mar 11 03:52:12 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* eval_intern.h (THROW_DATA_P): use RB_TYPE_P() instead of
|
* eval_intern.h (THROW_DATA_P): use RB_TYPE_P() instead of
|
||||||
|
|
|
@ -1104,22 +1104,23 @@ rb_iterate(VALUE (* it_proc) (VALUE), VALUE data1,
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
volatile VALUE retval = Qnil;
|
volatile VALUE retval = Qnil;
|
||||||
NODE *node = NEW_IFUNC(bl_proc, data2);
|
struct IFUNC *ifunc = (struct IFUNC *)NEW_IFUNC(bl_proc, data2);
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
rb_control_frame_t *volatile cfp = th->cfp;
|
rb_control_frame_t *volatile cfp = th->cfp;
|
||||||
|
|
||||||
node->nd_aid = rb_frame_this_func();
|
ifunc->id = rb_frame_this_func();
|
||||||
|
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
state = TH_EXEC_TAG();
|
state = TH_EXEC_TAG();
|
||||||
if (state == 0) {
|
if (state == 0) {
|
||||||
VAR_INITIALIZED(th);
|
VAR_INITIALIZED(th);
|
||||||
VAR_INITIALIZED(node);
|
VAR_INITIALIZED(ifunc);
|
||||||
iter_retry:
|
iter_retry:
|
||||||
{
|
{
|
||||||
rb_block_t *blockptr;
|
rb_block_t *blockptr;
|
||||||
if (bl_proc) {
|
if (bl_proc) {
|
||||||
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
|
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(th->cfp);
|
||||||
blockptr->iseq = (void *)node;
|
blockptr->iseq = (void *)ifunc;
|
||||||
blockptr->proc = 0;
|
blockptr->proc = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -2040,7 +2040,7 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
|
||||||
int argc, const VALUE *argv,
|
int argc, const VALUE *argv,
|
||||||
const rb_block_t *blockargptr)
|
const rb_block_t *blockargptr)
|
||||||
{
|
{
|
||||||
NODE *ifunc = (NODE *) block->iseq;
|
struct IFUNC *ifunc = (struct IFUNC *)block->iseq;
|
||||||
VALUE val, arg, blockarg;
|
VALUE val, arg, blockarg;
|
||||||
int lambda = block_proc_is_lambda(block->proc);
|
int lambda = block_proc_is_lambda(block->proc);
|
||||||
|
|
||||||
|
@ -2071,7 +2071,7 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
|
||||||
VM_ENVVAL_PREV_EP_PTR(block->ep), NULL /* cref */,
|
VM_ENVVAL_PREV_EP_PTR(block->ep), NULL /* cref */,
|
||||||
0, th->cfp->sp, 1, th->passed_bmethod_me, 0);
|
0, th->cfp->sp, 1, th->passed_bmethod_me, 0);
|
||||||
|
|
||||||
val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg);
|
val = (*ifunc->func) (arg, ifunc->data, argc, argv, blockarg);
|
||||||
|
|
||||||
th->cfp++;
|
th->cfp++;
|
||||||
return val;
|
return val;
|
||||||
|
|
|
@ -283,4 +283,12 @@ THROW_DATA_STATE(const struct THROW_DATA *obj)
|
||||||
return obj->throw_state;
|
return obj->throw_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct IFUNC {
|
||||||
|
VALUE flags;
|
||||||
|
VALUE reserved;
|
||||||
|
VALUE (*func)(ANYARGS);
|
||||||
|
void *data;
|
||||||
|
ID id;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* RUBY_INSNHELPER_H */
|
#endif /* RUBY_INSNHELPER_H */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче