mproved mature method
[libfirm] / ir / tr / entity_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/tr/entity_t.h
4  * Purpose:     Representation of all program known entities -- private header.
5  * Author:      Martin Trapp, Christian Schaefer
6  * Modified by: Goetz Lindenmaier
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1998-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14 * @file entity_t.h
15 *
16 * entity.h:  entities represent all program known objects.
17 *
18 * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier
19 *
20 *  An entity is the representation of program known objects in Firm.
21 *  The primary concept of entities is to represent members of complex
22 *  types, i.e., fields and methods of classes.  As not all programming
23 *  language model all variables and methods as members of some class,
24 *  the concept of entities is extended to cover also local and global
25 *  variables, and arbitrary procedures.
26 *
27 *  An entity always specifies the type of the object it represents and
28 *  the type of the object it is a part of, the owner of the entity.
29 *  Originally this is the type of the class of which the entity is a
30 *  member.
31 *  The owner of local variables is the procedure they are defined in.
32 *  The owner of global variables and procedures visible in the whole
33 *  program is a universally defined class type "GlobalType".  The owner
34 *  of procedures defined in the scope of an other procedure is the
35 *  enclosing procedure.
36 */
37
38
39 # ifndef _ENTITY_T_H_
40 # define _ENTITY_T_H_
41
42 # include "entity.h"
43
44 /** A path in a compund graph. */
45 struct compound_graph_path {
46   firm_kind kind;       /**< dynamic type tag for compound graph path. */
47   type *tp;
48   int len;
49   entity *nodes[1];
50 };
51
52 /** the type of an entity */
53 struct entity {
54   firm_kind kind;       /**< dynamic type tag for entity. */
55   ident *name;          /**< name of this entity */
56   ident *ld_name;       /**< Unique name of this entity, i.e., the mangled
57                            name.  If the field is read before written a default
58                            magling is applies.  The name of the owner is prepended
59                            to the name of the entity, separated by a underscore.
60                            E.g.,  for a class `A' with field `a' this
61                            is the ident for `A_a'. */
62   type *type;           /**< The type of this entity, e.g., a method type, a
63                            basic type of the language or a class itself */
64   type *owner;          /**< The compound type (e.g. class type) this entity belongs to. */
65   ent_allocation allocation;  /**< Distinguishes static and dynamically allocated
66                                  entities and some further cases. */
67   ent_visibility visibility;  /**< Specifies visibility to external program
68                                  fragments */
69   ent_variability variability;  /**< Specifies variability of entities content */
70   ent_volatility volatility;    /**< Specifies volatility of entities content */
71   int  offset;          /**< Offset in byte for this entity.  Fixed when layout
72                            of owner is determined.  */
73   void *link;           /**< To store some intermediate information */
74   unsigned long visit;  /**< visited counter for walks of the type information */
75   struct dbg_info* dbi;    /**< A pointer to information for debug support. */
76
77   /* ------------- fields for atomic entities  ---------------*/
78   ir_node *value;            /**< value if entity is not of variability uninitialized.
79                                Only for atomic entities. */
80
81   /* ------------- fields for compound entities ---------------*/
82   ir_node **values;     /**< constant values of compound entities. Only available if
83                           variablility not uninitialized.  Must be set for variability constant
84                            */
85   compound_graph_path **val_paths;    /**< paths corresponding to constant values. Only available if
86                           variablility not uninitialized.  Must be set for variability constant */
87
88   /* ------------- fields for entities owned by a class type ---------------*/
89   entity **overwrites;  /**< A list of entities this entity overwrites. */
90   entity **overwrittenby;  /**< A list of entities that overwrite this entity.  */
91
92   /* ------------- fields for methods ---------------*/
93   enum peculiarity peculiarity;
94   ir_graph *irg;        /**< If (type == method_type) this is the corresponding irg.
95                            The ir_graph constructor automatically sets this field.
96                            Yes, it must be here. */
97 #ifdef DEBUG_libfirm
98   int nr;             /**< a unique node number for each node to make output
99                               readable. */
100 #endif
101 };
102
103 INLINE long get_entity_nr(entity *ent);
104
105 # endif /* _ENTITY_T_H_ */