git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-07-16 00:38:07 +00:00
Родитель 934b700100
Коммит 34f8c6becd
1 изменённых файлов: 58 добавлений и 58 удалений

116
vm_eval.c
Просмотреть файл

@ -45,85 +45,85 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
again: again:
switch (me->type) { switch (me->type) {
case VM_METHOD_TYPE_ISEQ: { case VM_METHOD_TYPE_ISEQ: {
rb_control_frame_t *reg_cfp; rb_control_frame_t *reg_cfp;
int i; int i;
rb_vm_set_finish_env(th); rb_vm_set_finish_env(th);
reg_cfp = th->cfp; reg_cfp = th->cfp;
CHECK_STACK_OVERFLOW(reg_cfp, argc + 1); CHECK_STACK_OVERFLOW(reg_cfp, argc + 1);
*reg_cfp->sp++ = recv; *reg_cfp->sp++ = recv;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
*reg_cfp->sp++ = argv[i]; *reg_cfp->sp++ = argv[i];
} }
vm_setup_method(th, reg_cfp, recv, argc, blockptr, 0 /* flag */, me); vm_setup_method(th, reg_cfp, recv, argc, blockptr, 0 /* flag */, me);
val = vm_exec(th); val = vm_exec(th);
break; break;
} }
case VM_METHOD_TYPE_CFUNC: { case VM_METHOD_TYPE_CFUNC: {
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass); EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass);
{ {
rb_control_frame_t *reg_cfp = th->cfp; rb_control_frame_t *reg_cfp = th->cfp;
rb_control_frame_t *cfp = rb_control_frame_t *cfp =
vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC, vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC,
recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1); recv, (VALUE)blockptr, 0, reg_cfp->sp, 0, 1);
cfp->me = me; cfp->me = me;
val = call_cfunc(me->body.cfunc.func, recv, me->body.cfunc.argc, argc, argv); val = call_cfunc(me->body.cfunc.func, recv, me->body.cfunc.argc, argc, argv);
if (reg_cfp != th->cfp + 1) { if (reg_cfp != th->cfp + 1) {
rb_bug("cfp consistency error - call0"); rb_bug("cfp consistency error - call0");
} }
vm_pop_frame(th); vm_pop_frame(th);
} }
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass); EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass);
break; break;
} }
case VM_METHOD_TYPE_ATTRSET: { case VM_METHOD_TYPE_ATTRSET: {
if (argc != 1) { if (argc != 1) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
} }
val = rb_ivar_set(recv, me->body.attr_id, argv[0]); val = rb_ivar_set(recv, me->body.attr_id, argv[0]);
break; break;
} }
case VM_METHOD_TYPE_IVAR: { case VM_METHOD_TYPE_IVAR: {
if (argc != 0) { if (argc != 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc); rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
} }
val = rb_attr_get(recv, me->body.attr_id); val = rb_attr_get(recv, me->body.attr_id);
break; break;
} }
case VM_METHOD_TYPE_BMETHOD: { case VM_METHOD_TYPE_BMETHOD: {
val = vm_call_bmethod(th, recv, argc, argv, blockptr, me); val = vm_call_bmethod(th, recv, argc, argv, blockptr, me);
break; break;
} }
case VM_METHOD_TYPE_ZSUPER: { case VM_METHOD_TYPE_ZSUPER: {
klass = RCLASS_SUPER(klass); klass = RCLASS_SUPER(klass);
if (!klass || !(me = rb_method_entry(klass, id))) { if (!klass || !(me = rb_method_entry(klass, id))) {
return method_missing(recv, id, argc, argv, 0); return method_missing(recv, id, argc, argv, 0);
} }
RUBY_VM_CHECK_INTS(); RUBY_VM_CHECK_INTS();
goto again; goto again;
} }
case VM_METHOD_TYPE_OPTIMIZED: { case VM_METHOD_TYPE_OPTIMIZED: {
switch (me->body.optimize_type) { switch (me->body.optimize_type) {
case OPTIMIZED_METHOD_TYPE_SEND: case OPTIMIZED_METHOD_TYPE_SEND:
val = send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE); val = send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE);
break; break;
case OPTIMIZED_METHOD_TYPE_CALL: { case OPTIMIZED_METHOD_TYPE_CALL: {
rb_proc_t *proc; rb_proc_t *proc;
GetProcPtr(recv, proc); GetProcPtr(recv, proc);
val = rb_vm_invoke_proc(th, proc, proc->block.self, argc, argv, blockptr); val = rb_vm_invoke_proc(th, proc, proc->block.self, argc, argv, blockptr);
break; break;
}
default:
rb_bug("vm_call0: unsupported optimized method type (%d)", me->body.optimize_type);
val = Qundef;
break;
} }
break; default:
rb_bug("vm_call0: unsupported optimized method type (%d)", me->body.optimize_type);
val = Qundef;
break;
}
break;
} }
default: default:
rb_bug("vm_call0: unsupported method type (%d)", me->type); rb_bug("vm_call0: unsupported method type (%d)", me->type);