some fixes for xml dumper / still buggy.
[libfirm] / ir / tr / type_t.h
1 /*
2  * (C) 2001 by Universitaet Karlsruhe
3  */
4
5 /* $Id$ */
6
7 # ifndef _TYPE_T_H_
8 # define _TYPE_T_H_
9 # ifdef HAVE_CONFIG_H
10 # include "config.h"
11 # endif
12 # include "type.h"
13 /**
14  * @file type_t.h
15  * This file contains the datatypes hidden in type.h.
16  *
17  * @author Goetz Lindenmaier
18  * @see  type.h tpop_t.h tpop.h
19  */
20
21 /** class attributes */
22 typedef struct {
23   entity **members;    /**< fields and methods of this class */
24   type   **subtypes;   /**< direct subtypes */
25   type   **supertypes; /**< direct supertypes */
26   peculiarity peculiarity;
27   int dfn;             /**< number used for 'instanceof' operator */
28 } cls_attr;
29
30 /** struct attributs */
31 typedef struct {
32   entity **members;    /**< fields of this struct. No method entities
33                           allowed. */
34 } stc_attr;
35
36 /** method attributes */
37 typedef struct {
38   int n_params;        /**< number of parameters */
39   type **param_type;   /**< code generation needs this information. */
40   type *value_params;  /**< A type whose entities represent copied value arguments. */
41   int n_res;           /**< number of results */
42   type **res_type;     /**< array with result types */
43   type *value_ress;    /**< A type whose entities represent copied value results. */
44   variadicity variadicity; /**< variadicity of the method */
45 } mtd_attr;
46
47 /** union attributs */
48 typedef struct {
49   int     n_types;
50   /* type  **unioned_type; * a list of unioned types. */
51   /* ident **delim_names;  * names of the union delimiters. */
52   entity **members;    /**< fields of this union. No method entities
53                           allowed.  */
54
55 } uni_attr;
56
57 /** array attributs */
58 typedef struct {
59   int   n_dimensions;  /**< Number of array dimensions.  */
60   ir_node **lower_bound;   /**< Lower bounds of dimensions.  Usually all 0. */
61   ir_node **upper_bound;   /**< Upper bounds or dimensions. */
62   int *order;              /**< Ordering of dimensions. */
63   type *element_type;  /**< The type of the array elements. */
64   entity *element_ent; /**< Entity for the array elements, to be used for
65                           element selection with Sel. */
66 } arr_attr;
67
68 /** enum attributs */
69 typedef struct {
70   int      n_enums;    /**< Number of enumerators. */
71   tarval **enumer;     /**< Contains all constants that represent a member
72                           of the enum -- enumerators. */
73   ident  **enum_nameid;/**< Contains the names of the enum fields as specified by
74                           the source program */
75 } enm_attr;
76
77 /** pointer attributs */
78 typedef struct {
79   type *points_to;     /**< The type of the enitity the pointer points to. */
80 } ptr_attr;
81
82 /*
83 typedef struct {   * No private attr yet! *
84 } pri_attr; */
85
86
87 /*
88 typedef struct {        * No private attr, must be smaller than others! *
89 } id_attr;
90 */
91
92 /** general type attributs */
93 typedef union {
94   cls_attr ca;
95   stc_attr sa;
96   mtd_attr ma;
97   uni_attr ua;
98   arr_attr aa;
99   enm_attr ea;
100   ptr_attr pa;
101 } tp_attr;
102
103 /** the structure of a type */
104 struct type {
105   firm_kind kind;
106   tp_op *type_op;
107   ident *name;
108   type_state state;        /**< Represents the types state: layout undefined or
109                               fixed. */
110   int size;                /**< Size of an entity of this type.  This is determined
111                               when fixing the layout of this class.  Size must be
112                               given in bytes. */
113   ir_mode *mode;           /**< The mode for atomic types */
114   unsigned long visit;     /**< visited counter for walks of the type information */
115   void *link;              /**< holds temporary data - like in irnode_t.h */
116   struct dbg_info* dbi;    /**< A pointer to information for debug support. */
117
118 #ifdef DEBUG_libfirm
119   int nr;             /**< a unique node number for each node to make output
120                               readable. */
121 #endif
122   tp_attr attr;            /* type kind specific fields. This must be the last
123                               entry in this struct!  Varying size! */
124 };
125
126 /**
127  *   Creates a new type representation:
128  *
129  *   @param type_op - the kind of this type.  May not be type_id.
130  *   @param mode    - the mode to be used for this type, may be NULL
131  *   @param name    - an ident for the name of this type.
132  *   @return a new type of the given type.  The remaining private attributes are not
133  *   @return initalized.  The type is in state layout_undefined.
134  *
135  */
136 INLINE type *
137 new_type(tp_op *type_op,
138          ir_mode *mode,
139          ident* name);
140 void free_type_attrs       (type *tp);
141
142 INLINE void free_class_attrs      (type *clss);
143 INLINE void free_struct_attrs     (type *strct);
144 INLINE void free_method_attrs     (type *method);
145 INLINE void free_union_attrs      (type *uni);
146 INLINE void free_array_attrs      (type *array);
147 INLINE void free_enumeration_attrs(type *enumeration);
148 INLINE void free_pointer_attrs    (type *pointer);
149 INLINE void free_primitive_attrs  (type *primitive);
150
151
152 /** initialize the type module */
153 void init_type (void);
154
155 # endif /* _TYPE_T_H_ */