Fixed typos, improved docu
[libfirm] / ir / tr / type_t.h
index 71358b6..27e7e1c 100644 (file)
@@ -10,8 +10,8 @@
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  */
 
-#ifndef _TYPE_T_H_
-#define _TYPE_T_H_
+#ifndef _FIRM_TR_TYPE_T_H_
+#define _FIRM_TR_TYPE_T_H_
 
 #include "firm_config.h"
 #include "type.h"
@@ -35,33 +35,34 @@ typedef struct {
   ir_type **supertypes;/**< direct supertypes */
   peculiarity peculiarity;  /**< peculiarity of this class */
   entity  *type_info;  /**< a entity representing this class, used for type info */
+  unsigned vtable_size;/**< size of the vtable */
   unsigned final;      /**< non-zero if this is a final class */
   int dfn;             /**< number used for 'instanceof' operator */
 } cls_attr;
 
 /** struct attributes */
 typedef struct {
-  entity **members;    /**< fields of this struct. No method entities allowed. */
+  entity **members;    /**< Fields of this struct. No method entities allowed. */
 } stc_attr;
 
 /** A (type, entity) pair */
 typedef struct {
-  ir_type *tp;         /**< a type */
-  entity  *ent;        /**< an entity */
+  ir_type *tp;         /**< A type. */
+  entity  *ent;        /**< An entity. */
 } tp_ent_pair;
 
 /** method attributes */
 typedef struct {
-  int n_params;                   /**< number of parameters */
-  tp_ent_pair *param_type;        /**< array of parameter type/value entities pairs */
+  int n_params;                   /**< Number of parameters. */
+  tp_ent_pair *param_type;        /**< Array of parameter type/value entities pairs. */
   ir_type *value_params;          /**< A type whose entities represent copied value arguments. */
-  int n_res;                      /**< number of results */
-  tp_ent_pair *res_type;          /**< array of result type/value entity pairs */
+  int n_res;                      /**< Number of results. */
+  tp_ent_pair *res_type;          /**< Array of result type/value entity pairs. */
   ir_type *value_ress;            /**< A type whose entities represent copied value results. */
   variadicity variadicity;        /**< variadicity of the method. */
-  int first_variadic_param;       /**< index of the first variadic param or -1 if non-variadic .*/
+  int first_variadic_param;       /**< index of the first variadic parameter or -1 if non-variadic .*/
   unsigned additional_properties; /**< Set of additional method properties. */
-  unsigned irg_calling_conv;      /**< this is a set of calling convention flags. */
+  unsigned irg_calling_conv;      /**< A set of calling convention flags. */
 } mtd_attr;
 
 /** union attributes */
@@ -115,15 +116,20 @@ typedef union {
   ptr_attr pa;      /**< attributes of a pointer type */
 } tp_attr;
 
+enum type_flags {
+  tf_none         = 0,  /**< No flags. */
+  tf_frame_type   = 1,  /**< Set if this is a frame type. */
+  tf_lowered_type = 2,  /**< Set if this is a lowered type. */
+  tf_layout_fixed = 4   /**< set if the layout of a type is fixed */
+};
+
 /** the structure of a type */
 struct ir_type {
   firm_kind kind;          /**< the firm kind, must be k_type */
   const tp_op *type_op;    /**< the type operation of the type */
   ident *name;             /**< The name of the type */
   visibility visibility;   /**< Visibility of entities of this type. */
-  char frame_type;         /**< True if this is a frame type, false else */
-  type_state state;        /**< Represents the types state: layout undefined or
-                                fixed. */
+  unsigned flags;          /**< Type flags, a bitmask of enum type_flags. */
   int size;                /**< Size of an entity of this type. This is determined
                                 when fixing the layout of this class.  Size must be
                                 given in bits. */
@@ -135,11 +141,12 @@ struct ir_type {
   unsigned long visit;     /**< visited counter for walks of the type information */
   void *link;              /**< holds temporary data - like in irnode_t.h */
   struct dbg_info *dbi;    /**< A pointer to information for debug support. */
+  ir_type *assoc_type;     /**< The associated lowered/unlowered type */
 
   /* ------------- fields for analyses ---------------*/
 
 #ifdef DEBUG_libfirm
-  int nr;             /**< a unique node number for each node to make output
+  long nr;              /**< a unique node number for each node to make output
                            readable. */
 #endif
   tp_attr attr;            /* type kind specific fields. This must be the last
@@ -279,7 +286,7 @@ _get_type_size_bytes(const ir_type *tp) {
 static INLINE type_state
 _get_type_state(const ir_type *tp) {
   assert(tp && tp->kind == k_type);
-  return tp->state;
+  return tp->flags & tf_layout_fixed ? layout_fixed : layout_undefined;
 }
 
 static INLINE unsigned long
@@ -337,6 +344,18 @@ _get_class_member   (const ir_type *clss, int pos) {
   return clss->attr.ca.members[pos];
 }
 
+static INLINE unsigned
+_get_class_vtable_size(const ir_type *clss) {
+  assert(clss && (clss->type_op == type_class));
+  return clss->attr.ca.vtable_size;
+}
+
+static INLINE void
+_set_class_vtable_size(ir_type *clss, unsigned vtable_size) {
+  assert(clss && (clss->type_op == type_class));
+  clss->attr.ca.vtable_size = vtable_size;
+}
+
 static INLINE int
 _is_class_final   (const ir_type *clss) {
   assert(clss && (clss->type_op == type_class));
@@ -470,6 +489,8 @@ _set_method_calling_convention(ir_type *method, unsigned cc_mask) {
 #define is_Class_type(clss)               _is_class_type(clss)
 #define get_class_n_members(clss)         _get_class_n_members(clss)
 #define get_class_member(clss, pos)       _get_class_member(clss, pos)
+#define get_class_vtable_size(clss)       _get_class_vtable_size(clss)
+#define set_class_vtable_size(clss, size) _set_class_vtable_size(clss, size)
 #define is_class_final(clss)              _is_class_final(clss)
 #define set_class_final(clss, final)      _set_class_final(clss, final)
 #define is_Struct_type(strct)             _is_struct_type(strct)
@@ -488,4 +509,4 @@ _set_method_calling_convention(ir_type *method, unsigned cc_mask) {
 #define get_method_calling_convention(method)           _get_method_calling_convention(method)
 #define set_method_calling_convention(method, cc_mask)  _set_method_calling_convention(method, cc_mask)
 
-#endif /* _TYPE_T_H_ */
+#endif /* _FIRM_TR_TYPE_T_H_ */