Fixed comments and convert them to doxygen.
[libfirm] / ir / tr / trvrfy.c
1
2 #include "trvrfy.h"
3
4 static int check_class(type *tp) {
5   int i, j, k;
6   int found;
7
8   //printf("\n"); DDMT(tp);
9
10   for (i = 0; i < get_class_n_members(tp); i++) {
11
12     entity *mem = get_class_member(tp, i);
13     assert(mem && "NULL members not allowed");
14     //printf(" %d, %d", get_entity_n_overwrites(mem), get_class_n_supertypes(tp)); DDME(mem);
15     if (!mem) return error_null_mem;
16     assert(get_entity_n_overwrites(mem) <= get_class_n_supertypes(tp));
17     for (j = 0; j < get_entity_n_overwrites(mem); j++) {
18       entity *ovw = get_entity_overwrites(mem, j);
19       //printf(" overwrites: "); DDME(ovw);
20       /* Check whether ovw is member of one of tp's supertypes. If so,
21          the representation is correct. */
22       found = false;
23       for (k = 0; k < get_class_n_supertypes(tp); k++) {
24         if (get_class_member_index(get_class_supertype(tp, k), ovw) >= 0) {
25           found = true;
26           break;
27         }
28       }
29       if (!found) {
30         DDMT(tp); DDME(mem);
31         assert(found && "overwrites an entity not contained in direct supertype");
32         return error_ent_not_cont;
33       }
34     }
35
36   }
37   return 0;
38 }
39
40 static int check_type(type *tp) {
41   switch (get_type_tpop_code(tp)) {
42   case tpo_class:
43     return check_class(tp);
44   default: break;
45   }
46   return 0;
47 }
48
49
50 static int check_entity(entity *ent) {
51   return 0;
52 }
53
54 static void check_tore(type_or_ent *tore, void *env) {
55   int *res = env;
56   if (is_type(tore)) {
57     *res = check_type((type *)tore);
58   } else {
59     assert(is_entity(tore));
60     *res = check_entity((entity *)tore);
61   }
62 }
63
64
65 int tr_vrfy() {
66   int res;
67
68   type_walk(check_tore, NULL, &res);
69   return res;
70 }