return _get_class_n_members(clss);
}
-int get_class_member_index(ir_type *clss, entity *mem) {
- int i;
+int get_class_member_index(const ir_type *clss, entity *mem) {
+ int i, n;
assert(clss && (clss->type_op == type_class));
- for (i = 0; i < get_class_n_members(clss); i++)
+ for (i = 0, n = get_class_n_members(clss); i < n; ++i)
if (get_class_member(clss, i) == mem)
return i;
return -1;
return strct->attr.sa.members[pos];
}
-int get_struct_member_index(ir_type *strct, entity *mem) {
- int i;
+int get_struct_member_index(const ir_type *strct, entity *mem) {
+ int i, n;
assert(strct && (strct->type_op == type_struct));
- for (i = 0; i < get_struct_n_members(strct); i++)
+ for (i = 0, n = get_struct_n_members(strct); i < n; ++i)
if (get_struct_member(strct, i) == mem)
return i;
return -1;
assert(pos >= 0 && pos < get_union_n_members(uni));
return uni->attr.ua.members[pos];
}
+int get_union_member_index(const ir_type *uni, entity *mem) {
+ int i, n;
+ assert(uni && (uni->type_op == type_union));
+ for (i = 0, n = get_union_n_members(uni); i < n; ++i)
+ if (get_union_member(uni, i) == mem)
+ return i;
+ return -1;
+}
void set_union_member (ir_type *uni, int pos, entity *member) {
assert(uni && (uni->type_op == type_union));
assert(pos >= 0 && pos < get_union_n_members(uni));
return res;
}
+/* Returns index of member in tp, -1 if not contained. */
+int get_compound_member_index(const ir_type *tp, entity *member)
+{
+ const tp_op *op = get_type_tpop(tp);
+ int index = -1;
+
+ if (op->ops.get_member_index)
+ index = op->ops.get_member(tp, member);
+ else
+ assert(0 && "no members in this type");
+
+ return index;
+}
+
int is_compound_type(const ir_type *tp) {
assert(tp && tp->kind == k_type);
return tp->type_op->flags & TP_OP_FLAG_COMPOUND;
entity *get_class_member (const ir_type *clss, int pos);
/** Returns index of mem in clss, -1 if not contained. */
-int get_class_member_index(ir_type *clss, entity *mem);
+int get_class_member_index(const ir_type *clss, entity *mem);
/** Finds the member with name 'name'. If several members with the same
* name returns one of them. Returns NULL if no member found. */
entity *get_struct_member (const ir_type *strct, int pos);
/** Returns index of member in strct, -1 if not contained. */
-int get_struct_member_index(ir_type *strct, entity *member);
+int get_struct_member_index(const ir_type *strct, entity *member);
/** Overwrites the member at position pos, 0 <= pos < n_member with
the passed entity. */
/** Returns the entity at position pos of a union */
entity *get_union_member (const ir_type *uni, int pos);
+/** Returns index of member in uni, -1 if not contained. */
+int get_union_member_index(const ir_type *uni, entity *member);
+
/** Overwrites a entity at position pos in a union type. */
void set_union_member (ir_type *uni, int pos, entity *member);
*/
entity *get_compound_member(const ir_type *tp, int pos);
+/** Returns index of member in tp, -1 if not contained. */
+int get_compound_member_index(const ir_type *tp, entity *member);
+
/**
* Checks whether a type is compound.
*