set_type_size_bits(tp, 8*align);
}
+/* Returns a human readable string for the enum entry. */
+const char *get_type_state_name(type_state s) {
+#define X(a) case a: return #a;
+ switch (s) {
+ X(layout_undefined);
+ X(layout_fixed);
+ }
+ return "<unknown>";
+#undef X
+}
+
+
type_state (get_type_state)(const type *tp) {
return _get_type_state(tp);
}
return _is_class_type(clss);
}
-/* Returns true if low is subclass of high. */
-int is_subclass_of(type *low, type *high) {
- int i;
- assert(is_Class_type(low) && is_Class_type(high));
- if (low == high) return 1;
- /* depth first search from high downwards. */
- for (i = 0; i < get_class_n_subtypes(high); i++) {
- if (low == get_class_subtype(high, i))
- return 1;
- if (is_subclass_of(low, get_class_subtype(high, i)))
- return 1;
- }
- return 0;
-}
-
/*----------------------------------------------------------------**/
/* TYPE_STRUCT */
/*----------------------------------------------------------------**/
/* create a new type array -- set dimension sizes independently */
-type *new_type_array (ident *name, int n_dimensions,
- type *element_type) {
+type *new_type_array(ident *name, int n_dimensions, type *element_type) {
type *res;
int i;
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
for (i = 0; i < n_dimensions; i++) {
- res->attr.aa.lower_bound[i] = new_Unknown(mode_Iu);
- res->attr.aa.upper_bound[i] = new_Unknown(mode_Iu);
- res->attr.aa.order[i] = i;
+ res->attr.aa.lower_bound[i] = new_Unknown(mode_Iu);
+ res->attr.aa.upper_bound[i] = new_Unknown(mode_Iu);
+ res->attr.aa.order[i] = i;
}
current_ir_graph = rem;
assert(array && (array->type_op == type_array));
array->attr.aa.order[dimension] = order;
}
+
int get_array_order (const type *array, int dimension) {
assert(array && (array->type_op == type_array));
return array->attr.aa.order[dimension];
}
+int find_array_dimension(const type *array, int order) {
+ int dim;
+
+ assert(array && (array->type_op == type_array));
+
+ for (dim = 0; dim < array->attr.aa.n_dimensions; ++dim) {
+ if (array->attr.aa.order[dim] == order)
+ return dim;
+ }
+ return -1;
+}
+
void set_array_element_type (type *array, type *tp) {
assert(array && (array->type_op == type_array));
assert(!is_Method_type(tp));