4d33672f7708f9ecb74385ac9bb05bacdce1c742
[libfirm] / ir / tr / entity.h
1 /*
2 **  Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
3 **  All rights reserved.
4 **
5 **  Authors: Martin Trapp, Christian Schaefer,
6 **           Goetz Lindenmaier
7 **
8 **  entity.h:  entities represent all program known objects.
9 **
10 **  An entity is the representation of program known objects in Firm.
11 **  The primary concept of entities is to represent members of complex
12 **  types, i.e., fields and methods of classes.  As not all programming
13 **  language model all variables and methods as members of some class,
14 **  the concept of entities is extended to cover also local and global
15 **  variables, and arbitrary procedures.
16 **
17 **  An entity always specifies the type of the object it represents and
18 **  the type of the object it is a part of, the owner of the entity.
19 **  Originally this is the type of the class of which the entity is a
20 **  member.
21 **  The owner of local variables is the procedure they are defined in.
22 **  The owner of global variables and procedures visible in the whole
23 **  program is a universally defined class type "GlobalType".  The owner
24 **  of procedures defined in the scope of an other procedure is the
25 **  enclosing procedure.
26 **
27 */
28
29 # ifndef _ENTITY_H_
30 # define _ENTITY_H_
31
32 # include "ident.h"
33 # include "type.h"
34
35 /*******************************************************************/
36 /** general                                                       **/
37 /*******************************************************************/
38
39 /* initalize entity module */
40 void init_entity (void);
41
42 /*******************************************************************/
43 /** ENTITY                                                        **/
44 /*******************************************************************/
45
46 #ifndef _IR_GRAPH_TYPEDEF_
47 #define _IR_GRAPH_TYPEDEF_
48 /* to resolve recursion between entity.h and irgraph.h */
49 typedef struct ir_graph ir_graph;
50 #endif
51
52 #ifndef _ENTITY_TYPEDEF_
53 #define _ENTITY_TYPEDEF_
54 /* to resolve recursion between entity.h and type.h */
55 typedef struct entity entity;
56 #endif
57
58 /* Creates a new entity.
59    Automatically inserts the entity as a member of owner. */
60 entity     *new_entity (type *owner, ident *name, type *type);
61
62 /* manipulate fields of entity */
63 const char *get_entity_name     (entity *ent);
64 ident      *get_entity_ident    (entity *ent);
65 /* returns the mangled name of the entity */
66 ident      *get_entity_ld_name  (entity *ent);
67
68 /*
69 char     *get_entity_ld_name  (entity *ent);
70 void      set_entity_ld_name  (entity *ent, char *ld_name);
71
72 ident    *get_entity_ld_ident (entity *ent);
73 void      set_entity_ld_ident (entity *ent, ident *ld_ident);
74 */
75
76 type     *get_entity_owner (entity *ent);
77 void      set_entity_owner (entity *ent, type *owner);
78 inline void  assert_legal_owner_of_ent(type *owner);
79
80 type     *get_entity_type (entity *ent);
81 void      set_entity_type (entity *ent, type *type);
82
83 /* The entity knows the corresponding irg if the entity is a method.
84    This allows to get from a Call to the called irg. */
85 ir_graph *get_entity_irg(entity *ent);
86 void      set_entity_irg(entity *ent, ir_graph *irg);
87
88
89 # endif /* _ENTITY_H_ */