just to creste ir ir/ directory
[libfirm] / ir / tr / type.h
index f6851a3..9c749ac 100644 (file)
@@ -183,14 +183,20 @@ or lowering phases.
 # include "common.h"
 # include "ident.h"
 # include "irmode.h"
-# include "entity.h"
+
+#ifndef _ENTITY_TYPEDEF_
+#define _ENTITY_TYPEDEF_
+/* to resolve recursion between entity.h and type.h */
+typedef struct entity entity;
+#endif
 
 /* for recursive type definiton */
-#ifndef _TYPE_TYPEDEF_
-#define _TYPE_TYPEDEF_
+/*#ifndef _TYPE_TYPEDEF_ */
+/*#define _TYPE_TYPEDEF_ */
 /* to resolve recursion between entity.h and irgraph.h */
 typedef union type type;
-#endif
+/*#endif */
+
 
 /* visited flag to traverse the type information */
 extern unsigned long type_visited;
@@ -211,6 +217,10 @@ struct type_class {
   type_class **supertypes; /* direct supertypes */
   unsigned long visit;     /* visited counter for walks of
                              the type information */
+  int size;                /* Size of an entity of this type.  This is determined
+                             when fixing the layout of this class.  Size must be
+                             given in bytes. */
+
 };
 
 
@@ -219,35 +229,32 @@ type_class *new_type_class (ident *name);
 
 /* manipulate fields of type_class */
 
-char  *get_class_name  (type_class *class);
-ident *get_class_ident (type_class *class);
+const char  *get_class_name  (type_class *clss);
+ident       *get_class_ident (type_class *clss);
 
 /* Not necessary now!
-void   set_class_name  (type_class *class, char *name);
-void   set_class_ident (type_class *class, ident* ident);
+void   set_class_name  (type_class *clss, char *name);
+void   set_class_ident (type_class *clss, ident* ident);
 */
 
-void add_class_member (type_class *class, entity *member);
-entity *get_class_member (type_class *class, int pos);
-void set_class_member (type_class *class, entity *member, int pos);
+void    add_class_member (type_class *clss, entity *member);
+int     get_class_n_member (type_class *clss);
+entity *get_class_member (type_class *clss, int pos);
+void    set_class_member (type_class *clss, entity *member, int pos);
 
-void add_class_subtype (type_class *class,  type_class *subtype);
-type_class *get_class_subtype (type_class *class, int pos);
-void set_class_subtype (type_class *class, type_class *subtype, int pos);
+void        add_class_subtype (type_class *clss,type_class *subtype);
+int         get_class_n_subtype (type_class *clss);
+type_class *get_class_subtype (type_class *clss, int pos);
+void        set_class_subtype (type_class *clss, type_class *subtype, int pos);
 
-void add_class_supertype (type_class *class, type_class *supertype);
-type_class *get_class_supertype (type_class *class, int pos);
-void set_class_supertype (type_class *class, type_class *supertype, int pos);
+void        add_class_supertype (type_class *clss, type_class *supertype);
+int         get_class_n_supertype (type_class *clss);
+type_class *get_class_supertype (type_class *clss, int pos);
+void        set_class_supertype (type_class *clss, type_class *supertype, int pos);
 
+int         get_class_size (type_class *clss);
+void        set_class_size (type_class *clss, int size);
 
-/*  get_class_entity_arr
-    get_class_n_entities
-    get_class_entity(class, pos)
-    set_class_entity(class, pos, entity)
-    get_class_sub_arr
-    ...
-    get_class_super_arr
-*/
 
 /*******************************************************************/
 /** TYPE_STRCT                                                   **/
@@ -256,10 +263,7 @@ void set_class_supertype (type_class *class, type_class *supertype, int pos);
 typedef struct {
   firm_kind kind;
   ident *name;
-  /** needs list with it's entities -- does it really??
-      Entities can be added during their creation.
-  int n_members;
-  entity **member; **/
+  entity **members;
   unsigned long visit;     /* visited counter for walks of the type information */
 } type_strct;
 
@@ -268,8 +272,14 @@ typedef struct {
 type_strct *new_type_strct (ident *name);
 
 /* manipulate fields of type_strct */
-char  *get_strct_name  (type_strct *strct);
-ident *get_strct_ident (type_strct *strct);
+const char  *get_strct_name  (type_strct *strct);
+ident       *get_strct_ident (type_strct *strct);
+
+void         add_strct_member (type_strct *strct, entity *member);
+int          get_strct_n_member (type_strct *strct);
+entity      *get_strct_member (type_strct *strct, int pos);
+void         set_strct_member (type_strct *strct, int pos, entity *member);
+
 /*
 void   set_strct_name  (type_strct *strct, char *name);
 void   set_strct_ident (type_strct *strct, ident* ident);
@@ -295,23 +305,25 @@ typedef struct {
   unsigned long visit; /* visited counter for walks of the type information */
 } type_method;
 
-/* create a new type_method */
+/* Create a new type_method.
+   Arity is the number of parameters. */
 type_method *new_type_method (ident *name, int arity, int n_res);
 
 /* manipulate fields of type_method */
-char  *get_method_name  (type_method *method);
-ident *get_method_ident (type_method *method);
+const char  *get_method_name  (type_method *method);
+ident       *get_method_ident (type_method *method);
 /*
 void   set_method_name  (type_method *method, char *name);
 void   set_method_ident (type_method *method, ident* ident); */
 
+inline int   get_method_n_params (type_method *method);
 inline int   get_method_arity (type_method *method);
-inline void  set_method_arity (type_method *method, int arity);
+/*inline void  set_method_arity (type_method *method, int arity);*/
 inline type *get_method_param_type(type_method *method, int pos);
 inline void  set_method_param_type(type_method *method, int pos, type* type);
 
 inline int   get_method_n_res (type_method *method);
-inline void  set_method_n_res (type_method *method, int n_res);
+/*inline void  set_method_n_res (type_method *method, int n_res);*/
 inline type *get_method_res_type(type_method *method, int pos);
 inline void  set_method_res_type(type_method *method, int pos, type* type);
 
@@ -332,8 +344,8 @@ typedef struct {
 type_union *new_type_union (ident *name, int n_types);
 
 /* manipulate fields of type_union */
-char  *get_union_name  (type_union *uni);
-ident *get_union_ident (type_union *uni);
+const char  *get_union_name  (type_union *uni);
+ident       *get_union_ident (type_union *uni);
 /*
 void   set_union_name  (type_union *union, char *name);
 void   set_union_ident (type_union *union, ident* ident);
@@ -364,8 +376,8 @@ typedef struct {
 type_array *new_type_array (ident *name, int n_dimensions);
 
 /* manipulate fields of type_array */
-char  *get_array_name  (type_array *array);
-ident *get_array_ident (type_array *array);
+const char  *get_array_name  (type_array *array);
+ident       *get_array_ident (type_array *array);
 /*
 void   set_array_name  (type_array *array, char *name);
 void   set_array_ident (type_array *array, ident* ident);
@@ -406,8 +418,8 @@ typedef struct {
 type_enumeration *new_type_enumeration (ident *name /* , int n_enums */);
 
 /* manipulate fields of type_enumeration */
-char  *get_enumeration_name  (type_enumeration *enumeration);
-ident *get_enumeration_ident (type_enumeration *enumeration);
+const char  *get_enumeration_name  (type_enumeration *enumeration);
+ident       *get_enumeration_ident (type_enumeration *enumeration);
 /*
 void   set_enumeration_name  (type_enumeration *enumeration, char *name);
 void   set_enumeration_ident (type_enumeration *enumeration, ident* ident);
@@ -439,7 +451,7 @@ typedef struct {
 type_pointer *new_type_pointer (ident *name, type *points_to);
 
 /* manipulate fields of type_pointer */
-char  *get_pointer_name  (type_pointer *pointer);
+const char  *get_pointer_name  (type_pointer *pointer);
 ident *get_pointer_ident (type_pointer *pointer);
 /*
 void   set_pointer_name  (type_pointer *pointer, char *name);
@@ -466,7 +478,7 @@ typedef struct {
 type_primitive *new_type_primitive (ident *name, ir_mode *mode);
 
 /* manipulate fields of type_primitive */
-char  *get_primitive_name  (type_primitive *primitive);
+const char  *get_primitive_name  (type_primitive *primitive);
 ident *get_primitive_ident (type_primitive *primitive);
 /*
 void   set_primitive_name  (type_primitive *primitive, char *name);
@@ -495,7 +507,15 @@ union type {
 };
 
 
-int is_type(void *thing);
+int is_type            (void *thing);
+int is_type_class      (void *thing);
+int is_type_strct      (void *thing);
+int is_type_method     (void *thing);
+int is_type_union      (void *thing);
+int is_type_array      (void *thing);
+int is_type_pointer    (void *thing);
+int is_type_enumeration(void *thing);
+int is_type_primitive  (void *thing);