mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
[gamecode] Add etypes for long and ulong
And partial implementations in qfcc (most places will generate an internal error (not implemented) or segfault, but some low-hanging fruit has already been implemented).
This commit is contained in:
parent
0b92cd3a88
commit
c9b2a740a0
12 changed files with 121 additions and 2 deletions
|
@ -67,6 +67,8 @@ typedef enum {
|
|||
ev_uinteger,
|
||||
ev_short, // value is embedded in the opcode
|
||||
ev_double,
|
||||
ev_long,
|
||||
ev_ulong,
|
||||
|
||||
ev_invalid, // invalid type. used for instruction checking
|
||||
ev_type_count // not a type, gives number of types
|
||||
|
|
|
@ -1733,6 +1733,8 @@ typedef struct type_view_s {
|
|||
type_view_func uinteger_view;
|
||||
type_view_func short_view;
|
||||
type_view_func double_view;
|
||||
type_view_func long_view;
|
||||
type_view_func ulong_view;
|
||||
|
||||
type_view_func struct_view;
|
||||
type_view_func union_view;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "QF/fbsearch.h"
|
||||
#include "QF/cvar.h"
|
||||
|
@ -143,6 +144,10 @@ static void pr_debug_short_view (qfot_type_t *type, pr_type_t *value,
|
|||
void *_data);
|
||||
static void pr_debug_double_view (qfot_type_t *type, pr_type_t *value,
|
||||
void *_data);
|
||||
static void pr_debug_long_view (qfot_type_t *type, pr_type_t *value,
|
||||
void *_data);
|
||||
static void pr_debug_ulong_view (qfot_type_t *type, pr_type_t *value,
|
||||
void *_data);
|
||||
static void pr_debug_struct_view (qfot_type_t *type, pr_type_t *value,
|
||||
void *_data);
|
||||
static void pr_debug_union_view (qfot_type_t *type, pr_type_t *value,
|
||||
|
@ -168,6 +173,8 @@ static type_view_t raw_type_view = {
|
|||
pr_debug_uinteger_view,
|
||||
pr_debug_short_view,
|
||||
pr_debug_double_view,
|
||||
pr_debug_long_view,
|
||||
pr_debug_ulong_view,
|
||||
pr_debug_struct_view,
|
||||
pr_debug_union_view,
|
||||
pr_debug_enum_view,
|
||||
|
@ -1060,6 +1067,12 @@ value_string (pr_debug_data_t *data, qfot_type_t *type, pr_type_t *value)
|
|||
case ev_double:
|
||||
raw_type_view.double_view (type, value, data);
|
||||
break;
|
||||
case ev_long:
|
||||
raw_type_view.long_view (type, value, data);
|
||||
break;
|
||||
case ev_ulong:
|
||||
raw_type_view.ulong_view (type, value, data);
|
||||
break;
|
||||
case ev_invalid:
|
||||
case ev_type_count:
|
||||
dstring_appendstr (data->dstr, "<?""?>");
|
||||
|
@ -1363,6 +1376,24 @@ pr_debug_double_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
|||
dasprintf (dstr, "%.17g", *(double *)value);
|
||||
}
|
||||
|
||||
static void
|
||||
pr_debug_long_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
||||
{
|
||||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "%" PRIi64, *(int64_t *)value);
|
||||
}
|
||||
|
||||
static void
|
||||
pr_debug_ulong_view (qfot_type_t *type, pr_type_t *value, void *_data)
|
||||
{
|
||||
__auto_type data = (pr_debug_data_t *) _data;
|
||||
dstring_t *dstr = data->dstr;
|
||||
|
||||
dasprintf (dstr, "%" PRIu64, *(uint64_t *)value);
|
||||
}
|
||||
|
||||
static void
|
||||
pr_dump_struct (qfot_type_t *type, pr_type_t *value, void *_data,
|
||||
const char *struct_type)
|
||||
|
|
|
@ -357,7 +357,11 @@ set_address (sv_def_t *def, void *address)
|
|||
case ev_pointer:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
*(int **)def->field = (int *) address;
|
||||
*(pr_int_t **)def->field = (pr_int_t *) address;
|
||||
break;
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
*(pr_long_t **)def->field = (pr_long_t *) address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -390,7 +390,11 @@ set_address (sv_def_t *def, void *address)
|
|||
case ev_pointer:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
*(int **)def->field = (int *) address;
|
||||
*(pr_int_t **)def->field = (pr_int_t *) address;
|
||||
break;
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
*(pr_long_t **)def->field = (pr_long_t *) address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,6 +209,8 @@ typedef struct ex_value_s {
|
|||
union {
|
||||
const char *string_val; ///< string constant
|
||||
double double_val; ///< double constant
|
||||
int64_t long_val; ///< signed 64-bit constant
|
||||
uint64_t ulong_val; ///< unsigned 64-bit constant
|
||||
float float_val; ///< float constant
|
||||
float vector_val[3]; ///< vector constant
|
||||
int entity_val; ///< entity constant
|
||||
|
|
|
@ -1104,6 +1104,8 @@ static operation_t op_void[ev_type_count] = {
|
|||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1121,6 +1123,8 @@ static operation_t op_string[ev_type_count] = {
|
|||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1138,6 +1142,8 @@ static operation_t op_float[ev_type_count] = {
|
|||
do_op_float, // ev_uinteger
|
||||
do_op_float, // ev_short
|
||||
do_op_double, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1155,6 +1161,8 @@ static operation_t op_vector[ev_type_count] = {
|
|||
do_op_vector, // ev_uinteger
|
||||
do_op_vector, // ev_short
|
||||
do_op_vector, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1172,6 +1180,8 @@ static operation_t op_entity[ev_type_count] = {
|
|||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1189,6 +1199,8 @@ static operation_t op_field[ev_type_count] = {
|
|||
do_op_invalid, // ev_uinteger
|
||||
do_op_invalid, // ev_short
|
||||
do_op_invalid, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1206,6 +1218,8 @@ static operation_t op_func[ev_type_count] = {
|
|||
do_op_func, // ev_uinteger
|
||||
do_op_func, // ev_short
|
||||
do_op_func, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_func, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1223,6 +1237,8 @@ static operation_t op_pointer[ev_type_count] = {
|
|||
do_op_pointer, // ev_uinteger
|
||||
do_op_pointer, // ev_short
|
||||
do_op_pointer, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_pointer, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1240,6 +1256,8 @@ static operation_t op_quaternion[ev_type_count] = {
|
|||
do_op_quaternion, // ev_uinteger
|
||||
do_op_quaternion, // ev_short
|
||||
do_op_quaternion, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1257,6 +1275,8 @@ static operation_t op_integer[ev_type_count] = {
|
|||
do_op_uinteger, // ev_uinteger
|
||||
do_op_integer, // ev_short
|
||||
do_op_double, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1274,6 +1294,8 @@ static operation_t op_uinteger[ev_type_count] = {
|
|||
do_op_uinteger, // ev_uinteger
|
||||
do_op_uinteger, // ev_short
|
||||
do_op_double, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1291,6 +1313,8 @@ static operation_t op_short[ev_type_count] = {
|
|||
do_op_uinteger, // ev_uinteger
|
||||
do_op_short, // ev_short
|
||||
do_op_double, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1308,6 +1332,8 @@ static operation_t op_double[ev_type_count] = {
|
|||
do_op_uinteger, // ev_uinteger
|
||||
do_op_short, // ev_short
|
||||
do_op_double, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
do_op_invalid, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1325,6 +1351,8 @@ static operation_t op_compound[ev_type_count] = {
|
|||
do_op_compound, // ev_uinteger
|
||||
do_op_compound, // ev_short
|
||||
do_op_compound, // ev_double
|
||||
do_op_compound, // ev_long
|
||||
do_op_compound, // ev_ulong
|
||||
do_op_compound, // ev_invalid
|
||||
};
|
||||
|
||||
|
@ -1342,6 +1370,8 @@ static operation_t *do_op[ev_type_count] = {
|
|||
op_uinteger, // ev_uinteger
|
||||
op_short, // ev_short
|
||||
op_double, // ev_double
|
||||
0, // ev_long
|
||||
0, // ev_ulong
|
||||
op_compound, // ev_invalid
|
||||
};
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
# include <strings.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <QF/dstring.h>
|
||||
#include <QF/mathlib.h>
|
||||
|
@ -518,6 +519,12 @@ print_value (dstring_t *dstr, expr_t *e, int level, int id, expr_t *next)
|
|||
case ev_uinteger:
|
||||
label = va (0, "u %u", e->e.value->v.uinteger_val);
|
||||
break;
|
||||
case ev_long:
|
||||
label = va (0, "i %"PRIi64, e->e.value->v.long_val);
|
||||
break;
|
||||
case ev_ulong:
|
||||
label = va (0, "u %"PRIu64, e->e.value->v.ulong_val);
|
||||
break;
|
||||
case ev_short:
|
||||
label = va (0, "s %d", e->e.value->v.short_val);
|
||||
break;
|
||||
|
|
|
@ -1633,6 +1633,9 @@ unary_expr (int op, expr_t *e)
|
|||
case ev_quat:
|
||||
QuatNegate (expr_vector (e), q);
|
||||
return new_vector_expr (q);
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
internal_error (e, "long not implemented");
|
||||
case ev_integer:
|
||||
return new_integer_expr (-expr_integer (e));
|
||||
case ev_uinteger:
|
||||
|
@ -1725,6 +1728,9 @@ unary_expr (int op, expr_t *e)
|
|||
return new_integer_expr (!VectorIsZero (expr_vector (e)));
|
||||
case ev_quat:
|
||||
return new_integer_expr (!QuatIsZero (expr_quaternion (e)));
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
internal_error (e, "long not implemented");
|
||||
case ev_integer:
|
||||
return new_integer_expr (!expr_integer (e));
|
||||
case ev_uinteger:
|
||||
|
@ -1791,6 +1797,9 @@ unary_expr (int op, expr_t *e)
|
|||
case ev_quat:
|
||||
QuatConj (expr_vector (e), q);
|
||||
return new_vector_expr (q);
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
internal_error (e, "long not implemented");
|
||||
case ev_integer:
|
||||
return new_integer_expr (~expr_integer (e));
|
||||
case ev_uinteger:
|
||||
|
|
|
@ -94,6 +94,9 @@ test_expr (expr_t *e)
|
|||
return new_alias_expr (type_default, e);
|
||||
new = new_string_expr (0);
|
||||
break;
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
internal_error (e, "long not implemented");
|
||||
case ev_uinteger:
|
||||
case ev_integer:
|
||||
case ev_short:
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "qfalloca.h"
|
||||
|
||||
|
@ -161,6 +162,10 @@ operand_string (operand_t *op)
|
|||
return va (0, "int %d", op->value->v.integer_val);
|
||||
case ev_uinteger:
|
||||
return va (0, "uint %u", op->value->v.uinteger_val);
|
||||
case ev_long:
|
||||
return va (0, "long %"PRIi64, op->value->v.long_val);
|
||||
case ev_ulong:
|
||||
return va (0, "ulong %"PRIu64, op->value->v.ulong_val);
|
||||
case ev_short:
|
||||
return va (0, "short %d", op->value->v.short_val);
|
||||
case ev_void:
|
||||
|
@ -238,6 +243,12 @@ _print_operand (operand_t *op)
|
|||
case ev_uinteger:
|
||||
printf ("%u", op->value->v.uinteger_val);
|
||||
break;
|
||||
case ev_long:
|
||||
printf ("%"PRIu64, op->value->v.long_val);
|
||||
break;
|
||||
case ev_ulong:
|
||||
printf ("%"PRIu64, op->value->v.ulong_val);
|
||||
break;
|
||||
case ev_short:
|
||||
printf ("%d", op->value->v.short_val);
|
||||
break;
|
||||
|
|
|
@ -188,6 +188,8 @@ free_type (type_t *type)
|
|||
case ev_quat:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
case ev_short:
|
||||
case ev_double:
|
||||
break;
|
||||
|
@ -228,6 +230,8 @@ copy_chain (type_t *type, type_t *append)
|
|||
case ev_quat:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
case ev_short:
|
||||
case ev_double:
|
||||
internal_error (0, "copy basic type");
|
||||
|
@ -279,6 +283,8 @@ append_type (type_t *type, type_t *new)
|
|||
case ev_quat:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
case ev_short:
|
||||
case ev_double:
|
||||
internal_error (0, "append to basic type");
|
||||
|
@ -656,6 +662,8 @@ print_type_str (dstring_t *str, const type_t *type)
|
|||
case ev_quat:
|
||||
case ev_integer:
|
||||
case ev_uinteger:
|
||||
case ev_long:
|
||||
case ev_ulong:
|
||||
case ev_short:
|
||||
case ev_double:
|
||||
dasprintf (str, " %s", pr_type_name[type->type]);
|
||||
|
@ -820,6 +828,12 @@ encode_type (dstring_t *encoding, const type_t *type)
|
|||
case ev_uinteger:
|
||||
dasprintf (encoding, "I");
|
||||
return;
|
||||
case ev_long:
|
||||
dasprintf (encoding, "l");
|
||||
return;
|
||||
case ev_ulong:
|
||||
dasprintf (encoding, "L");
|
||||
return;
|
||||
case ev_short:
|
||||
dasprintf (encoding, "s");
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue