fixed the type of the entity number
[libfirm] / ir / tr / trvrfy.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/tr/trvrfy.h
4  * Purpose:     Check types and entities for correctness.
5  * Author:      Michael Beck, Goetz Lindenmaier
6  * Modified by:
7  * Created:     29.1.2003
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12 #ifndef TRVRFY_H
13 #define TRVRFY_H
14
15 #include "firm_types.h"
16
17 /**
18  * @file trvrfy.h
19  *
20  * Methods to verify the type representations.
21  *
22  * @author Michael Beck, Goetz Lindenmaier
23  *
24  * Methods to verify the type representations.
25  * Copyright 2003 University of Karlsruhe.
26  * Created 29.1.2003.
27  *
28  */
29
30 /**
31  * possible trvrfy() error codes
32  */
33 enum trvrfy_error_codes {
34   no_error = 0,                      /**< no error */
35   error_ent_not_cont,                /**< overwritten entity not in superclass */
36   error_null_mem,                    /**< compound contains NULL member */
37   error_const_on_wrong_irg,          /**< constant placed on wrong IRG */
38   error_existent_entity_without_irg, /**< Method entities with pecularity_exist must have an irg */
39   error_wrong_ent_overwrites,        /**< number of entity overwrites exceeds number of class overwrites */
40   error_inherited_ent_without_const, /**< inherited method entity not pointing to existent entity */
41   error_glob_ent_allocation,         /**< wrong allocation of a global entity */
42   error_ent_const_mode,              /**< Mode of constant in entity did not match entities type. */
43   error_ent_wrong_owner              /**< Mode of constant in entity did not match entities type. */
44 };
45
46 /**
47  * Checks a type.
48  *
49  * @return
50  *  0   if no error encountered
51  */
52 int check_type(ir_type *tp);
53
54 /**
55  * Check an entity. Currently, we check only if initialized constants
56  * are build on the const irg graph.
57  *
58  * @return
59  *  0   if no error encountered
60  *  != 0    a trvrfy_error_codes code
61  */
62 int check_entity(entity *ent);
63
64 /**
65  * Walks the type information and performs a set of sanity checks.
66  *
67  * Currently, the following checks are executed:
68  * - values of initialized entities must be allocated on the constant IRG
69  * - class types: doesn't have NULL members
70  * - class types: all overwrites are existent in the super type
71  *
72  * @return
73  *    0 if graph is correct
74  *    else error code.
75  */
76 int tr_vrfy(void);
77
78 /**
79  * If NDEBUG is defined performs nothing, else calls the tr_vrfy() function.
80  */
81 #ifdef NDEBUG
82 #define TR_VRFY()       0
83 #else
84 #define TR_VRFY()       tr_vrfy()
85 #endif
86
87 #endif /* TRVRFY_H */