just to creste ir ir/ directory
[libfirm] / ir / tr / type.h
index bee2ee1..9c749ac 100644 (file)
@@ -184,8 +184,19 @@ or lowering phases.
 # include "ident.h"
 # include "irmode.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_ */
+/* to resolve recursion between entity.h and irgraph.h */
 typedef union type type;
+/*#endif */
+
 
 /* visited flag to traverse the type information */
 extern unsigned long type_visited;
@@ -194,39 +205,56 @@ extern unsigned long type_visited;
 /** TYPE_CLASS                                                    **/
 /*******************************************************************/
 
-typedef struct {
+typedef struct type_class type_class;
+
+struct type_class {
   firm_kind kind;
-  ident *name;
-  /** needs list with it's entities -- does it really??
-      Entities can be added during their creation.
-  entities **member; **/
-  /** to represent inheritance
-  type_class **subtypes;    * direct subtypes *
-  type_class **supertypes;  * direct supertypes *
-  **/
-  unsigned long visit;     /* visited counter for walks of the type information */
-} type_class;
+  ident *name;             /* needs list with it's entities
+                             does it really??
+                             Entities can be added during their creation. */
+  struct entity **members;        /* to represent inheritance */
+  type_class **subtypes;   /* direct subtypes */
+  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. */
+
+};
 
 
 /* create a new type_class */
 type_class *new_type_class (ident *name);
 
 /* manipulate fields of type_class */
-char  *get_class_name  (type_class *clss);
-ident *get_class_ident (type_class *clss);
-/*
+
+const char  *get_class_name  (type_class *clss);
+ident       *get_class_ident (type_class *clss);
+
+/* Not necessary now!
 void   set_class_name  (type_class *clss, char *name);
 void   set_class_ident (type_class *clss, ident* ident);
 */
 
-/*  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
-*/
+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 *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 *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);
+
 
 /*******************************************************************/
 /** TYPE_STRCT                                                   **/
@@ -235,10 +263,7 @@ void   set_class_ident (type_class *clss, ident* ident);
 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;
 
@@ -247,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);
@@ -274,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);
 
@@ -311,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);
@@ -343,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);
@@ -385,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);
@@ -418,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);
@@ -445,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);
@@ -473,7 +506,16 @@ union type {
   type_primitive primitive;
 };
 
-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);