refactoring in op_send
@@ -739,51 +739,9 @@ static inline int op_send( mrbc_vm *vm, mrbc_value *regs )
{
FETCH_BBB();
- mrbc_value recv = regs[a];
-
- // Block param
- int bidx = a + c + 1;
-
- mrbc_release( &regs[bidx] );
- regs[bidx].tt = MRBC_TT_NIL;
-
const char *sym_name = mrbc_get_irep_symbol(vm->pc_irep->ptr_to_sym, b);
- mrbc_sym sym_id = str_to_symid(sym_name);
- mrbc_proc *m = find_method(vm, &recv, sym_id);
- if( m == 0 ) {
- mrb_class *cls = find_class_by_object( vm, &recv );
- console_printf("No method. Class:%s Method:%s\n",
- symid_to_str(cls->sym_id), sym_name );
- return 0;
- }
-
- // m is C func
- if( m->c_func ) {
- m->func(vm, regs + a, c);
- if( m->func == c_proc_call ) return 0;
-
- int release_reg = a+1;
- while( release_reg <= bidx ) {
- mrbc_release(&regs[release_reg]);
- release_reg++;
- }
- return 0;
- }
-
- // m is Ruby method.
- // callinfo
- mrbc_push_callinfo(vm, sym_id, c);
-
- // target irep
- vm->pc = 0;
- vm->pc_irep = m->irep;
- vm->inst = m->irep->code;
-
- // new regs
- vm->current_regs += a;
-
- return 0;
+ return op_send_by_name( vm, sym_name, regs, a, b, c);
}
