Ejemplo n.º 1
0
oop slotsMap::copy_add_argument_slot(slotsOop obj,
                                     stringOop name, 
                                     slotType type,
                                     oop contents,
                                     oop anno,
                                     bool mustAllocate) {
  assert_smi(contents, "arg data must be position");

  if (!name->is_unary())
    return ErrorCodes::vmString_prim_error(ARGUMENTCOUNTERROR);

  slotDesc* old = find_slot(name);
  slotsOop result;
  if (old == NULL)
    result= obj;
  else if (old->is_arg_slot()) {
    // No need to remove and reinsert because order is the same.
    // Only the annotation might be really different.
    // The index will be off by one (assumes that added slot is new)
    assert(smiOop(contents)->value() == smiOop(old->data)->value() + 1,
           "arg index wrong");
    return change_slot(obj, old, type, old->data, anno, mustAllocate);
  } else {
    result= (slotsOop)copy_remove_slot(obj, name, mustAllocate);
    if (oop(result) == failedAllocationOop || result->is_mark()) return result;
    assert(result->is_slots(), "just checking");
  }
  assert(smiOop(contents)->value() == arg_count(), "arg index wrong");
  return ((slotsMap*)result->map())->copy_add_new_slot(result, 
                                                       name, 
                                                       type, 
                                                       contents,
                                                       anno,
                                                       mustAllocate);
}
Ejemplo n.º 2
0
oop slotsMap::copy_add_data_slot(slotsOop obj,
                                 stringOop name, 
                                 slotType type,
                                 oop contents,
                                 oop anno,
                                 bool mustAllocate) {
  if (!name->is_unary()) {
    return ErrorCodes::vmString_prim_error(SLOTNAMEERROR);
  }

  slotDesc* old = find_slot(name);
  
  if (!old)
    return copy_add_new_slot(obj, name, type, contents, anno, mustAllocate);

  if (old->is_obj_slot())
    // change in place; if type is map_slot, just changes value
    return (slotsOop)change_slot(obj, old, OBJ_SLOT(type), contents, anno,
                                 mustAllocate);

  // remove then add obj slot
  slotsOop result= copy_remove_one_slot(obj, old, mustAllocate);
  if (oop(result) == failedAllocationOop) return result;
  slotsMap *new_map= (slotsMap*)result->map();
  
  return new_map->copy_add_new_slot(result, name, type, contents,
                                    anno, mustAllocate);
}
Ejemplo n.º 3
0
s32 mtapChangeSlot(u32 port, u32 slot)
{
	s32 data[4];
	u32 i;

	if(port > 4) return 0;

	if(state_open[port] == 0)
	{
		M_PRINTF("mtap manager doesn't work\n");
		return -1;
	}

	for(i=0; i < 4; i++)
		data[i] = -1;

	data[port] = slot;

	sio2_mtap_transfer_init();

	change_slot(data);

	sio2_transfer_reset();

	if(data[port] < 0)
	{
		M_PRINTF("Failed to change slot.\n");
		return data[port];
	}
	else
	{
		M_PRINTF("Change slot complete.\n");
		return 1;
	}
}
Ejemplo n.º 4
0
oop slotsMap::copy_add_method_slot( slotsOop obj,
                                    stringOop name, 
                                    slotType type, 
                                    oop contents,
                                    oop anno,
                                    bool mustAllocate) {

  if (type->is_vm_slot()) {
    // skip all the checks and do not try to remove it, since
    // vm slots do not change from obj to map, and rm will fetch anyway
    slotDesc* sd = obj->find_slot(name);
    return sd != NULL
     ? change_slot      (obj, sd,   type, contents, anno, mustAllocate)
     : copy_add_new_slot(obj, name, type, contents, anno, mustAllocate);
  }
  if ( contents->arg_count() != name->arg_count() )
    return ErrorCodes::vmString_prim_error(ARGUMENTCOUNTERROR);

  if (obj->is_method_like())
    return ErrorCodes::vmString_prim_error(BADTYPEERROR); // cannot add methods to methods

  slotDesc *old= find_slot(name);
  if (old && old->is_map_slot())
    // change in situ
    return change_slot(obj, old, type, contents, anno, mustAllocate);

  slotsOop result;
  if (old) {
    // remove the old slot, then add in a new one
    result= (slotsOop)copy_remove_one_slot(obj, old, mustAllocate);
    if (oop(result) == failedAllocationOop) return failedAllocationOop;

    if (old->is_assignment_slot_name(name)) {
      // replace the data slot as a map slot
      result= ((slotsMap*)result->map())->
        copy_add_new_slot(result, old->name, MAP_SLOT(old->type),
                          obj->get_slot(old), old->annotation, mustAllocate);
      if (oop(result) == failedAllocationOop) return failedAllocationOop;
    }
  } else
    result= obj;

  return ((slotsMap*)result->map())->
    copy_add_new_slot(result, name, MAP_SLOT(type), contents, anno,
                      mustAllocate);
}
Ejemplo n.º 5
0
void S9xHandlePortCommand (s9xcommand_t cmd, int16 data1, int16 data2)
{
    static bool quit_binding_down = false;

    if (data1 == true)
    {
        if (cmd.port[0] == PORT_QUIT)
            quit_binding_down = true;
        else if (cmd.port[0] == PORT_REWIND)
            Settings.Rewinding = true;
    }

    if (data1 == false) /* Release */
    {
        if (cmd.port[0] != PORT_QUIT)
        {
            quit_binding_down = false;
        }

        if (cmd.port[0] == PORT_COMMAND_FULLSCREEN)
        {
            top_level->toggle_fullscreen_mode ();
        }

        else if (cmd.port[0] == PORT_COMMAND_SAVE_SPC)
        {
            top_level->save_spc_dialog ();
        }

        else if (cmd.port[0] == PORT_OPEN_ROM)
        {
            top_level->open_rom_dialog ();
        }

        else if (cmd.port[0] == PORT_PAUSE)
        {
            if (!(top_level->user_pause))
                top_level->pause_from_user ();
            else
                top_level->unpause_from_user ();
        }

        else if (cmd.port[0] == PORT_REWIND)
        {
            Settings.Rewinding = false;
        }

        else if (cmd.port[0] == PORT_SEEK_TO_FRAME)
        {
            top_level->movie_seek_dialog ();
        }

        else if (cmd.port[0] == PORT_SWAP_CONTROLLERS)
        {
            swap_controllers_1_2 ();
        }

        else if (cmd.port[0] == PORT_QUIT)
        {
            if (quit_binding_down)
                S9xExit ();
        }

        else if (cmd.port[0] >= PORT_QUICKLOAD0 && cmd.port[0] <= PORT_QUICKLOAD9)
        {
            S9xQuickLoadSlot (cmd.port[0] - PORT_QUICKLOAD0);
        }

        else if (cmd.port[0] == PORT_SAVESLOT)
        {
            S9xQuickSaveSlot (gui_config->current_save_slot);
        }

        else if (cmd.port[0] == PORT_LOADSLOT)
        {
            S9xQuickLoadSlot (gui_config->current_save_slot);
        }

        else if (cmd.port[0] == PORT_INCREMENTSAVESLOT)
        {
            change_slot (1);
            S9xQuickSaveSlot (gui_config->current_save_slot);
        }

        else if (cmd.port[0] == PORT_DECREMENTLOADSLOT)
        {
            change_slot (-1);
            S9xQuickLoadSlot (gui_config->current_save_slot);
        }

        else if (cmd.port[0] == PORT_INCREMENTSLOT)
        {
            change_slot (1);
        }

        else if (cmd.port[0] == PORT_DECREMENTSLOT)
        {
            change_slot (-1);
        }

        else if (cmd.port[0] == PORT_GRABMOUSE)
        {
            top_level->toggle_grab_mouse ();
        }
    }
}