Commit 603ff7b1 authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

Rimproved interface to type array.

emoved bug in xgprintf.c
tav.c.
aFaulty use of va_arg, became visible with new, stricter gcc 2.96.

[r159]
parent 57c32a36
......@@ -53,6 +53,9 @@ new_entity (type *owner, ident *name, type *type)
case tpo_union: {
add_union_member (owner, res);
} break;
case tpo_array: {
set_array_element_entity(owner, res);
} break;
default: assert(0);
}
......@@ -91,7 +94,9 @@ inline void /* should this go into type.c? */
assert_legal_owner_of_ent(type *owner) {
assert (get_type_tpop_code(owner) == tpo_class ||
get_type_tpop_code(owner) == tpo_union ||
get_type_tpop_code(owner) == tpo_struct);
get_type_tpop_code(owner) == tpo_struct ||
get_type_tpop_code(owner) == tpo_array); /* Yes, array has an entity
-- to select fields! */
}
inline ident *
......
......@@ -357,12 +357,15 @@ bool is_union_type (type *uni) {
/* create a new type array -- set dimension sizes independently */
type *new_type_array (ident *name, int n_dimensions) {
type *new_type_array (ident *name, int n_dimensions,
type *element_type) {
type *res;
res = new_type(type_array, NULL, name);
res->attr.aa.n_dimensions = n_dimensions;
res->attr.aa.lower_bound = (int *) xmalloc (sizeof (int) * n_dimensions);
res->attr.aa.upper_bound = (int *) xmalloc (sizeof (int) * n_dimensions);
res->attr.aa.element_type = element_type;
new_entity(res, name, element_type);
return res;
}
......@@ -401,6 +404,15 @@ type *get_array_element_type (type *array) {
assert(array && (array->type_op == type_array));
return array->attr.aa.element_type;
}
void set_array_element_entity (type *array, entity *ent) {
assert(array && (array->type_op == type_array));
array->attr.aa.element_ent = ent;
}
entity *get_array_element_entity (type *array) {
assert(array && (array->type_op == type_array));
return array->attr.aa.element_ent;
}
/* typecheck */
bool is_array_type (type *array) {
assert(array);
......
......@@ -308,10 +308,15 @@ void set_union_delim_nameid (type *uni, int pos, ident *id);
* *lower_bound Lower bounds of dimensions. Usually all 0.
* *upper_bound Upper bounds or dimensions.
* *element_type The type of the array elements.
* *element_ent An entity for the array elements to be used for
* element selection with Sel.
* SOURCE
*/
/* create a new type array -- set dimension sizes independently */
type *new_type_array (ident *name, int n_dimensions);
/* create a new type array --
Set dimension sizes after call to constructor with set_* routines.
Entity for array elements is built automatically. */
type *new_type_array (ident *name, int n_dimensions,
type *element_type);
/* manipulate private fields of array type */
int get_array_n_dimensions (type *array);
......@@ -325,6 +330,9 @@ int get_array_upper_bound (type *array, int dimension);
void set_array_element_type (type *array, type *type);
type *get_array_element_type (type *array);
void set_array_element_entity (type *array, entity *ent);
entity *get_array_element_entity (type *array);
/* typecheck */
bool is_array_type (type *array);
/*****/
......
......@@ -55,6 +55,8 @@ typedef struct {
int *lower_bound; /* Lower bounds of dimensions. Usually all 0. */
int *upper_bound; /* Upper bounds or dimensions. */
type *element_type; /* The type of the array elements. */
entity *element_ent; /* Entity for the array elements, to be used for
element selection with Sel. */
} arr_attr;
typedef struct {
......
......@@ -1500,7 +1500,6 @@ tarval_ord (tarval *tv, int *fail)
}
}
int
tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN)
......@@ -1598,6 +1597,7 @@ tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN)
return printed;
}
ir_mode *
get_tv_mode (tarval *tv)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment