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