Commit 24db5475 authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

improved add routinesC

[r241]
parent 3d7c0f81
......@@ -234,8 +234,13 @@ void remove_class_member(type *clss, entity *member) {
}
void add_class_subtype (type *clss, type *subtype) {
int i;
assert(clss && (clss->type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.subtypes, subtype);
for (i = 0; i < get_class_n_subtype(subtype); i++)
if (get_class_subtype(subtype, i) == clss)
/* Class already registered */
return;
ARR_APP1 (type *, subtype->attr.ca.supertypes, clss);
}
int get_class_n_subtype (type *clss) {
......@@ -263,9 +268,14 @@ void remove_class_subtype(type *clss, type *subtype) {
}
void add_class_supertype (type *clss, type *supertype) {
int i;
assert(clss && (clss->type_op == type_class));
assert(supertype && (supertype -> type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.supertypes, supertype);
for (i = 0; i < get_class_n_supertype(supertype); i++)
if (get_class_supertype(supertype, i) == clss)
/* Class already registered */
return;
ARR_APP1 (type *, supertype->attr.ca.subtypes, clss);
}
int get_class_n_supertype (type *clss) {
......
......@@ -206,8 +206,9 @@ void set_class_member (type *clss, entity *member, int pos);
void remove_class_member(type *clss, entity *member);
/* Adds subtype as subtype to clss and also
clss as supertype to subtype */
/* Adds subtype as subtype to clss.
Checks whether clss is a supertype of subtype. If not
adds also clss as supertype to subtype. */
void add_class_subtype (type *clss, type *subtype);
/* Returns the number of subtypes */
int get_class_n_subtype (type *clss);
......@@ -221,8 +222,9 @@ void set_class_subtype (type *clss, type *subtype, int pos);
void remove_class_subtype(type *clss, type *subtype);
/* Adds supertype as supertype to class and also
class as subtype to supertype. */
/* Adds supertype as supertype to class.
Checks whether clss is a subtype of supertype. If not
adds also clss as subtype to supertype. */
void add_class_supertype (type *clss, type *supertype);
/* Returns the number of supertypes */
int get_class_n_supertype (type *clss);
......
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