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