mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-14 00:40:55 +00:00
Store the function type in function values.
This fixes IMP msg = nil;
This commit is contained in:
parent
686937123c
commit
86968f662e
4 changed files with 19 additions and 8 deletions
|
@ -106,6 +106,11 @@ typedef struct ex_pointer_s {
|
||||||
struct def_s *def;
|
struct def_s *def;
|
||||||
} ex_pointer_t;
|
} ex_pointer_t;
|
||||||
|
|
||||||
|
typedef struct ex_func_s {
|
||||||
|
int val;
|
||||||
|
struct type_s *type;
|
||||||
|
} ex_func_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int size;
|
int size;
|
||||||
struct expr_s *e[1];
|
struct expr_s *e[1];
|
||||||
|
@ -166,7 +171,7 @@ typedef struct ex_value_s {
|
||||||
float float_val; ///< float constant
|
float float_val; ///< float constant
|
||||||
float vector_val[3]; ///< vector constant
|
float vector_val[3]; ///< vector constant
|
||||||
int entity_val; ///< entity constant
|
int entity_val; ///< entity constant
|
||||||
int func_val; ///< function constant
|
ex_func_t func_val; ///< function constant
|
||||||
ex_pointer_t pointer; ///< pointer constant
|
ex_pointer_t pointer; ///< pointer constant
|
||||||
float quaternion_val[4]; ///< quaternion constant
|
float quaternion_val[4]; ///< quaternion constant
|
||||||
int integer_val; ///< integer constant
|
int integer_val; ///< integer constant
|
||||||
|
@ -406,10 +411,11 @@ expr_t *new_field_expr (int field_val, struct type_s *type, struct def_s *def);
|
||||||
/** Create a new function constant expression node.
|
/** Create a new function constant expression node.
|
||||||
|
|
||||||
\param func_val The function constant being represented.
|
\param func_val The function constant being represented.
|
||||||
|
\param type The type of the function
|
||||||
\return The new function constant expression node
|
\return The new function constant expression node
|
||||||
(expr_t::e::func_val).
|
(expr_t::e::func_val).
|
||||||
*/
|
*/
|
||||||
expr_t *new_func_expr (int func_val);
|
expr_t *new_func_expr (int func_val, struct type_s *type);
|
||||||
|
|
||||||
/** Create a new pointer constant expression node.
|
/** Create a new pointer constant expression node.
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ struct ex_value_s *new_vector_val (const float *vector_val);
|
||||||
struct ex_value_s *new_entity_val (int entity_val);
|
struct ex_value_s *new_entity_val (int entity_val);
|
||||||
struct ex_value_s *new_field_val (int field_val, struct type_s *type,
|
struct ex_value_s *new_field_val (int field_val, struct type_s *type,
|
||||||
struct def_s *def);
|
struct def_s *def);
|
||||||
struct ex_value_s *new_func_val (int func_val);
|
struct ex_value_s *new_func_val (int func_val, struct type_s *type);
|
||||||
struct ex_value_s *new_pointer_val (int val, struct type_s *type,
|
struct ex_value_s *new_pointer_val (int val, struct type_s *type,
|
||||||
struct def_s *def);
|
struct def_s *def);
|
||||||
struct ex_value_s *new_quaternion_val (const float *quaternion_val);
|
struct ex_value_s *new_quaternion_val (const float *quaternion_val);
|
||||||
|
|
|
@ -165,6 +165,8 @@ get_type (expr_t *e)
|
||||||
case ex_temp:
|
case ex_temp:
|
||||||
return e->e.temp.type;
|
return e->e.temp.type;
|
||||||
case ex_value:
|
case ex_value:
|
||||||
|
if (e->e.value->type == ev_func)
|
||||||
|
return e->e.value->v.func_val.type;
|
||||||
if (e->e.value->type == ev_pointer)
|
if (e->e.value->type == ev_pointer)
|
||||||
return pointer_type (e->e.value->v.pointer.type);
|
return pointer_type (e->e.value->v.pointer.type);
|
||||||
if (e->e.value->type == ev_field)
|
if (e->e.value->type == ev_field)
|
||||||
|
@ -552,11 +554,11 @@ new_field_expr (int field_val, type_t *type, def_t *def)
|
||||||
}
|
}
|
||||||
|
|
||||||
expr_t *
|
expr_t *
|
||||||
new_func_expr (int func_val)
|
new_func_expr (int func_val, type_t *type)
|
||||||
{
|
{
|
||||||
expr_t *e = new_expr ();
|
expr_t *e = new_expr ();
|
||||||
e->type = ex_value;
|
e->type = ex_value;
|
||||||
e->e.value = new_func_val (func_val);
|
e->e.value = new_func_val (func_val, type);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,12 +167,13 @@ new_field_val (int field_val, type_t *type, def_t *def)
|
||||||
}
|
}
|
||||||
|
|
||||||
ex_value_t *
|
ex_value_t *
|
||||||
new_func_val (int func_val)
|
new_func_val (int func_val, type_t *type)
|
||||||
{
|
{
|
||||||
ex_value_t val;
|
ex_value_t val;
|
||||||
memset (&val, 0, sizeof (val));
|
memset (&val, 0, sizeof (val));
|
||||||
val.type = ev_func;
|
val.type = ev_func;
|
||||||
val.v.func_val = func_val;
|
val.v.func_val.val = func_val;
|
||||||
|
val.v.func_val.type = type;
|
||||||
return find_value (&val);
|
return find_value (&val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +237,8 @@ new_nil_val (type_t *type)
|
||||||
val.type = low_level_type (type);
|
val.type = low_level_type (type);
|
||||||
if (val.type == ev_pointer|| val.type == ev_field )
|
if (val.type == ev_pointer|| val.type == ev_field )
|
||||||
val.v.pointer.type = type->t.fldptr.type;
|
val.v.pointer.type = type->t.fldptr.type;
|
||||||
|
if (val.type == ev_func)
|
||||||
|
val.v.func_val.type = type;
|
||||||
return find_value (&val);
|
return find_value (&val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +504,7 @@ emit_value (ex_value_t *value, def_t *def)
|
||||||
reloc_def_string (cn);
|
reloc_def_string (cn);
|
||||||
break;
|
break;
|
||||||
case ev_func:
|
case ev_func:
|
||||||
if (val.v.func_val) {
|
if (val.v.func_val.val) {
|
||||||
reloc_t *reloc;
|
reloc_t *reloc;
|
||||||
reloc = new_reloc (cn->space, cn->offset, rel_def_func);
|
reloc = new_reloc (cn->space, cn->offset, rel_def_func);
|
||||||
reloc->next = pr.relocs;
|
reloc->next = pr.relocs;
|
||||||
|
|
Loading…
Reference in a new issue