Ejemplo n.º 1
0
int ScriptManager::LgetAxis(lua_State *L){
    int n= lua_gettop(L);
    if(n!=2){
        lua_pushstring(L,"Error in lua get axis");
        lua_error(L);
    }
    int no = lua_tointeger(L,1);
    if(!Base::getInstance()->getControllers().empty())
        lua_pushnumber(L,Base::getInstance()->getControllers()[no]->getAxis()[get_enum_value(L, 2)]);
    return 1;
}
Ejemplo n.º 2
0
int ScriptManager::LgetKey(lua_State *L){
    int n= lua_gettop(L);
    if(n!=2){
        lua_pushstring(L,"Error in lua is pressed");
        lua_error(L);
    }
    int no = lua_tointeger(L,1);
    if(!Base::getInstance()->getControllers().empty())
        lua_pushboolean(L,Base::getInstance()->getControllers()[0]->getKeys()[get_enum_value(L, 2)]);
    return 1;
}
Ejemplo n.º 3
0
bool enum_bitfield_big_enough(enum_t *enume, type_t *base_type,
                              unsigned bitfield_size)
{
	ir_mode    *mode        = get_ir_mode_storage(base_type);
	ir_tarval  *max         = get_mode_max(mode);
	ir_tarval  *min         = get_mode_min(mode);
	bool       is_signed    = is_type_signed(base_type);
	unsigned   mode_size    = get_mode_size_bits(mode);
	unsigned   shift_amount = mode_size - bitfield_size + is_signed;
	ir_tarval *adjusted_max;
	ir_tarval *adjusted_min;
	/* corner case: signed mode with just sign bit results in shift_amount
	 * being as big as mode_size triggering "modulo shift" which is not what
	 * we want here. */
	if (shift_amount >= mode_size) {
		assert(bitfield_size == 1 && mode_is_signed(mode));
		adjusted_max = get_mode_null(mode);
		adjusted_min = get_mode_all_one(mode);
	} else {
		adjusted_max = tarval_shr_unsigned(max, shift_amount);
		adjusted_min = tarval_shrs_unsigned(min, shift_amount);
	}

	for (entity_t *entry = enume->first_value;
	     entry != NULL && entry->kind == ENTITY_ENUM_VALUE;
	     entry = entry->base.next) {
		ir_tarval *tv = get_enum_value(&entry->enum_value);
		if (tv == NULL)
			continue;
		ir_tarval *tvc = tarval_convert_to(tv, mode);
		if (tarval_cmp(tvc, adjusted_min) == ir_relation_less
		 || tarval_cmp(tvc, adjusted_max) == ir_relation_greater) {
			return false;
		}
	}
	return true;
}
Ejemplo n.º 4
0
static ir_tarval *enum_constant_to_tarval(reference_expression_t const *const ref)
{
	entity_t *entity = ref->entity;
	assert(entity->kind == ENTITY_ENUM_VALUE);
	return get_enum_value(&entity->enum_value);
}