+/* Number of Cast nodes that create an instance of this type */
+int get_type_n_casts(ir_type *tp) {
+ ir_node **casts;
+
+ assert(tp && is_type(tp));
+
+ casts = get_type_cast_array(tp);
+ return ARR_LEN(casts);
+}
+
+
+int get_class_n_upcasts(ir_type *clss) {
+ int i, n_casts = get_type_n_casts(clss);
+ int n_instances = 0;
+ for (i = 0; i < n_casts; ++i) {
+ ir_node *cast = get_type_cast(clss, i);
+ if (is_Cast_upcast(cast)) n_instances ++;
+ }
+ return n_instances;
+}
+
+int get_class_n_downcasts(ir_type *clss) {
+ int i, n_casts = get_type_n_casts(clss);
+ int n_instances = 0;
+ for (i = 0; i < n_casts; ++i) {
+ ir_node *cast = get_type_cast(clss, i);
+ if (is_Cast_downcast(cast)) n_instances ++;
+ }
+ return n_instances;
+}
+
+
+/* Cast node that creates an instance of this type */
+ir_node *get_type_cast(ir_type *tp, int pos) {
+ ir_node **casts;
+ assert(0 <= pos && pos < get_type_n_casts(tp));
+
+ casts = get_type_cast_array(tp);
+ return casts[pos];
+}
+
+void add_type_cast(ir_type *tp, ir_node *n) {
+ ir_node **casts;
+
+ assert(tp && is_type(tp));
+ assert(n && is_ir_node(n));
+
+ casts = get_type_cast_array(tp);
+ ARR_APP1(ir_node *, casts, n);
+ set_type_cast_array(tp, casts);
+}
+
+void set_type_cast(ir_type *tp, int pos, ir_node *n) {
+ ir_node **casts;
+
+ assert(0 <= pos && pos < get_type_n_casts(tp));
+ assert(n && is_ir_node(n));
+
+ casts = get_type_cast_array(tp);
+ casts[pos] = n;
+}
+
+/**------------------------------------------------------------------*/
+
+int get_type_n_pointertypes_to(ir_type *tp) {
+ ir_type ** pts;
+
+ assert(tp && is_type(tp));
+
+ pts = get_type_pointertype_array(tp);
+ return ARR_LEN(pts);
+}
+
+ir_type *get_type_pointertype_to(ir_type *tp, int pos) {
+ ir_type ** pts;
+
+ assert(0 <= pos && pos < get_type_n_pointertypes_to(tp));
+
+ pts = get_type_pointertype_array(tp);
+ return pts[pos];
+}
+
+void add_type_pointertype_to(ir_type *tp, ir_type *ptp) {
+ ir_type ** pts;
+
+ assert(tp && is_type(tp));
+ assert(ptp && is_Pointer_type(ptp));
+
+ pts = get_type_pointertype_array(tp);
+ ARR_APP1(ir_node *, pts, ptp);
+ set_type_pointertype_array(tp, pts);
+}
+
+void set_type_pointertype_to(ir_type *tp, int pos, ir_type *ptp) {
+ ir_type ** pts;
+
+ assert(0 <= pos && pos < get_type_n_pointertypes_to(tp));
+ assert(ptp && is_Pointer_type(ptp));
+
+ pts = get_type_pointertype_array(tp);
+ pts[pos] = ptp;
+}
+
+
+/**------------------------------------------------------------------*/
+
+int get_type_n_arraytypes_of(ir_type *tp) {
+ ir_type ** pts;
+
+ assert(tp && is_type(tp));
+
+ pts = get_type_arraytype_array(tp);
+ return ARR_LEN(pts);
+}
+
+ir_type *get_type_arraytype_of(ir_type *tp, int pos) {
+ ir_type ** pts;
+
+ assert(0 <= pos && pos < get_type_n_arraytypes_of(tp));
+
+ pts = get_type_arraytype_array(tp);
+ return pts[pos];
+}
+
+void add_type_arraytype_of(ir_type *tp, ir_type *atp) {
+ ir_type ** pts;
+
+ assert(tp && is_type(tp));
+ assert(atp && is_Array_type(atp));
+
+ pts = get_type_arraytype_array(tp);
+ ARR_APP1(ir_node *, pts, atp);
+ set_type_arraytype_array(tp, pts);
+}
+
+void set_type_arraytype_of(ir_type *tp, int pos, ir_type *atp) {
+ ir_type ** pts;
+
+ assert(0 <= pos && pos < get_type_n_arraytypes_of(tp));
+ assert(atp && is_Array_type(atp));
+
+ pts = get_type_arraytype_array(tp);
+ pts[pos] = atp;
+}
+