/***********************************************************************
 * Bdbj 1.1 (by Jon Cook August 2001)
 *
 * invokesim.def 
 * 
 * Deals with stepping back into the end of a method in the simulation.
 * 
 ***********************************************************************/

/* START JJC */

#define SIM_REV (over_mode == R_OVERFIRST ? R_OVER : over_mode ) 

define_insn(INVOKEVIRTUAL)
{
        int is_virtual;
	slots obj;
	
	CHECK_VALID_CBUFF;
	obj = *( GET_LAST_SLOT( debug->cbuffer_p, debug->cbuffer_s, debug->cbuffer_e ) );
	
	idx = (uint16)((getpc(0) << 8) | getpc(1));
	get_method_info(idx);
	is_virtual = method_method()->idx >= 0;
	if( is_virtual ) {
	  load_offset_ref(mtable, &obj, method_dtable_offset);
	  load_offset_ref(tmp, mtable,
			  DTABLE_METHODOFFSET + method_idx() * DTABLE_METHODSIZE);
	} 
	if( is_virtual )
	  suc = reverseVirtualMachine_simulation( (methods*)(tmp)[0].v.taddr, debug, callback, SIM_REV, false, false );
	else
	  suc = reverseVirtualMachine_simulation( method_method(), debug, callback, SIM_REV, false, false );
}

define_insn(INVOKESPECIAL)
{
	idx = (uint16)((getpc(0) << 8) | getpc(1));
	get_special_method_info(idx);
	suc = reverseVirtualMachine_simulation( method_method(), debug, callback, SIM_REV, false, false );
}

define_insn(INVOKESTATIC)
{	idx = (uint16)((getpc(0) << 8) | getpc(1));
	get_method_info(idx);
	suc = reverseVirtualMachine_simulation( method_method(), debug, callback, SIM_REV, false, false );
}

define_insn(INVOKEINTERFACE)
{
	slots obj;

	CHECK_VALID_CBUFF;
	obj = *( GET_LAST_SLOT( debug->cbuffer_p, debug->cbuffer_s, debug->cbuffer_e ) );

	idx = (uint16)((getpc(0) << 8) | getpc(1));
	get_interface_method_info(idx);

	idx = (uint8)getpc(2) - 1;
	softcall_lookupinterfacemethod(tmp, method_method(), &obj);

	suc = reverseVirtualMachine_simulation( (methods*)(tmp)[0].v.taddr, debug, callback, SIM_REV, false, false );
}

/* END JJC */
