case tpo_union: {
add_union_member (owner, res);
} break;
+ case tpo_array: {
+ set_array_element_entity(owner, res);
+ } break;
default: assert(0);
}
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 *
/* 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;
}
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);
* *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);
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);
/*****/
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 {
}
}
-
\f
int
tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN)
return printed;
}
+
ir_mode *
get_tv_mode (tarval *tv)
{