Changed implementation of tr module.
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 14 Mar 2001 15:35:15 +0000 (15:35 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Wed, 14 Mar 2001 15:35:15 +0000 (15:35 +0000)
[r141]

42 files changed:
ir/common/common.c
ir/common/common.h
ir/common/firm.c
ir/ident/ident.h
ir/ir/ircons.c
ir/ir/ircons.h
ir/ir/irdump.c
ir/ir/irgraph.h
ir/ir/irnode.c
ir/ir/irnode.h
ir/ir/irnode_t.h
ir/ir/irop.c
ir/ir/iropt.c
ir/ir/irprog.c
ir/ir/irprog.h
ir/ir/irprog_t.h
ir/tr/Makefile
ir/tr/Makefile.in
ir/tr/entity.c
ir/tr/mangle.c
ir/tr/mangle.h
ir/tr/type.c
ir/tr/type.h
ir/tr/typewalk.c
testprograms/array-heap_example.c
testprograms/array-stack_example.c
testprograms/call_str_example.c
testprograms/cond_example.c
testprograms/const_eval_example.c
testprograms/dead_block_example.c
testprograms/empty.c
testprograms/global_var_example.c
testprograms/if_else_example.c
testprograms/if_example.c
testprograms/if_while_example.c
testprograms/inheritance_example.c
testprograms/irr_cf_example.c
testprograms/irr_loop_example.c
testprograms/memory_example.c
testprograms/oo_program_example.c
testprograms/three_cfpred_example.c
testprograms/while_example.c

index 92c7137..c120d20 100644 (file)
@@ -26,6 +26,8 @@ const char* print_firm_kind(void *firm_thing) {
   assert (firm_thing);
   switch (*(firm_kind *)firm_thing) {
     case k_entity: { return "k_enitity"; } break;
+    case k_type: { return "k_type"; } break;
+#if 0
     case k_type_class: { return "k_type_class"; } break;
     case k_type_strct: { return "k_type_strct:"; } break;
     case k_type_method: { return "k_type_method:"; } break;
@@ -34,6 +36,7 @@ const char* print_firm_kind(void *firm_thing) {
     case k_type_enumeration: { return "k_type_enumeration"; } break;
     case k_type_pointer: { return "k_type_pointer"; } break;
     case k_type_primitive: { return "k_type_primitive"; } break;
+#endif
     case k_ir_node: { return "k_ir_node"; } break;
   }
   return "";
index 9681572..ca4b4b6 100644 (file)
 /* a list of firm kinds */
 typedef enum {
   k_entity,
+  k_type,
+  k_ir_node
+} firm_kind;
+
+#if 0
   k_type_class,
   k_type_strct,
   k_type_method,
@@ -48,8 +53,7 @@ typedef enum {
   k_type_enumeration,
   k_type_pointer,
   k_type_primitive,
-  k_ir_node
-} firm_kind;
+#endif
 
 /* returns the kind of the thing */
 firm_kind get_kind(void *firm_thing);
index 94fda9f..b981cad 100644 (file)
@@ -16,6 +16,7 @@
 # include "xp_help.h"
 # include "irnode_t.h"
 # include "tv_t.h"
+# include "tpop_t.h"
 
 void
 init_firm (void)
@@ -28,7 +29,9 @@ init_firm (void)
   xprintf_register ('R', ir_node_print);
   /* initialize all ident stuff */
   id_init ();
-  /* create an obstack and put alle tarvals in a pdeq */
+  /* create the type kinds. */
+  init_tpop ();
+  /* create an obstack and put all tarvals in a pdeq */
   tarval_init_1 ();
   /* initialize all modes an ir node can consist of */
   init_mode ();
index c211854..96fcf12 100644 (file)
@@ -58,7 +58,8 @@ inline ident      *id_from_str (char *str, int len);
  * SYNOPSIS
  *  char *cp = id_to_str (ident *id);
  * FUNCTION
- *  Returns the string cp represented by id. This string cp is not Null terminated!
+ *  Returns the string cp represented by id. This string cp is not
+ *  Null terminated!
  * INPUTS
  *  id - the ident
  * RESULT
index 5015199..072186b 100644 (file)
@@ -404,7 +404,7 @@ new_r_Cond (ir_graph *irg, ir_node *block, ir_node *c)
 
 ir_node *
 new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
-           ir_node *callee, int arity, ir_node **in, type_method *type)
+           ir_node *callee, int arity, ir_node **in, type *type)
 {
   ir_node **r_in;
   ir_node *res;
@@ -418,6 +418,7 @@ new_r_Call (ir_graph *irg, ir_node *block, ir_node *store,
 
   res = new_ir_node (irg, block, op_Call, mode_T, r_arity, r_in);
 
+  assert(is_method_type(type));
   set_Call_type(res, type);
   res = optimize (res);
   irn_vrfy (res);
@@ -1433,7 +1434,7 @@ new_Cond (ir_node *c)
 
 ir_node *
 new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
-         type_method *type)
+         type *type)
 {
   return new_r_Call (current_ir_graph, current_ir_graph->current_block,
                     store, callee, arity, in, type);
index 42d8430..8472af6 100644 (file)
@@ -1118,7 +1118,7 @@ ir_node *new_r_Sel    (ir_graph *irg, ir_node *block, ir_node *store,
                       entity *ent);
 ir_node *new_r_Call   (ir_graph *irg, ir_node *block, ir_node *store,
                       ir_node *callee, int arity, ir_node **in,
-                      type_method *type);
+                      type *type);
 ir_node *new_r_Add    (ir_graph *irg, ir_node *block,
                       ir_node *op1, ir_node *op2, ir_mode *mode);
 ir_node *new_r_Sub    (ir_graph *irg, ir_node *block,
@@ -1201,7 +1201,7 @@ ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
 ir_node *new_Sel    (ir_node *store, ir_node *objptr, int arity, ir_node **in,
                      entity *ent);
 ir_node *new_Call   (ir_node *store, ir_node *callee, int arity, ir_node **in,
-                    type_method *type);
+                    type *type);
 ir_node *new_Add    (ir_node *op1, ir_node *op2, ir_mode *mode);
 ir_node *new_Sub    (ir_node *op1, ir_node *op2, ir_mode *mode);
 ir_node *new_Minus  (ir_node *op,  ir_mode *mode);
index b1200da..b9384b6 100644 (file)
@@ -46,6 +46,7 @@
 #define METH_PAR_EDGE_ATTR   "label: \"param %d\" color: green"
 #define METH_RES_EDGE_ATTR   "label: \"res %d\" color: green"
 #define TYPE_SUPER_EDGE_ATTR "label: \"supertype\" color: blue"
+#define UNION_EDGE_ATTR      "label: \"component\" color: blue"
 #define PTR_PTS_TO_EDGE_ATTR "label: \"points to\" color:green"
 #define ARR_ELT_TYPE_EDGE_ATTR "label: \"arr elt\" color:green"
 
@@ -73,9 +74,9 @@ dump_node_opcode (ir_node *n)
     if (get_SymConst_kind(n) == linkage_ptr_info) {
       xfprintf (F, "%I", get_SymConst_ptrinfo(n));
     } else {
-      assert(get_kind(get_SymConst_type(n)) == k_type_class);
-      assert(get_class_ident((type_class *)get_SymConst_type(n)));
-      xfprintf (F, "%s ", id_to_str(get_class_ident((type_class *)get_SymConst_type(n))));
+      assert(get_kind(get_SymConst_type(n)) == k_type);
+      assert(get_type_nameid(get_SymConst_type(n)));
+      xfprintf (F, "%s ", id_to_str(get_type_nameid(get_SymConst_type(n))));
       if (get_SymConst_kind == type_tag)
        xfprintf (F, "tag");
       else
@@ -317,10 +318,9 @@ dump_ir_node (ir_node *n)
     xfprintf (F, DEFAULT_NODE_ATTR);
     break;
   case iro_SymConst:
-    assert(get_kind(get_SymConst_type(n)) == k_type_class);
-    assert(get_class_ident((type_class *)get_SymConst_type(n)));
-    xfprintf (F, "\"%s ",
-             id_to_str(get_class_ident((type_class *)get_SymConst_type(n))));
+    assert(get_kind(get_SymConst_type(n)) == k_type);
+    assert(get_type_nameid(get_SymConst_type(n)));
+    xfprintf (F, "\"%s ", get_type_name(get_SymConst_type(n)));
     switch (n->attr.i.num){
     case type_tag:
       xfprintf (F, "tag\" ");
@@ -497,73 +497,75 @@ dump_type_info (type_or_ent *tore, void *env) {
       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
                 ENT_TYPE_EDGE_ATTR "}\n", tore, get_entity_type(ent));
     } break;
-  case k_type_class:
+  case k_type:
     {
-      type_class *type = (type_class *)tore;
-      xfprintf (F, "\"class %I\" " TYPE_CLASS_NODE_ATTR "}\n", get_class_ident(type));
-      for (i=0; i < get_class_n_supertype(type); i++)
-       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
-                 TYPE_SUPER_EDGE_ATTR "}\n",
-                 type, get_class_supertype(type, i));
-    } break;
-  case k_type_strct:
-    {
-      type_strct *type = (type_strct *)tore;
-      xfprintf (F, "\"strct %I\"}\n", get_strct_ident(type));
-      /* edges !!!??? */
-    } break;
-  case k_type_method:
-    {
-      type_method *type = (type_method *)tore;
-      xfprintf (F, "\"meth %I\" " TYPE_METH_NODE_ATTR "}\n", get_method_ident(type));
-      for (i = 0; i < get_method_arity(type); i++)
-       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
-                 METH_PAR_EDGE_ATTR "}\n",
-                 tore, get_method_param_type(type, i), i);
-      for (i = 0; i < get_method_n_res(type); i++)
-       xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
-                 METH_RES_EDGE_ATTR "}\n",
-                 tore, get_method_res_type(type, i), i);
-    } break;
-  case k_type_union:
-    {
-      type_union *type = (type_union *)tore;
-      xfprintf (F, "\"union %I\"}\n", get_union_ident(type));
-      /* edges !!!??? */
-    } break;
-  case k_type_array:
-    {
-      type_array *type = (type_array *)tore;
-      xfprintf (F, "\"array %I\"}\n", get_array_ident(type));
-      xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
-               ARR_ELT_TYPE_EDGE_ATTR "}\n", tore, get_array_element_type(type), i);
-      /* edges !!!??? */
-    } break;
-  case k_type_enumeration:
-    {
-      type_enumeration *type = (type_enumeration *)tore;
-      xfprintf (F, "\"enum %I\"}\n", get_enumeration_ident(type));
-    } break;
-  case k_type_pointer:
-    {
-      type_pointer *type = (type_pointer *)tore;
-      xfprintf (F, "\"ptr %I\"}\n", get_pointer_ident(type));
-      xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
-               PTR_PTS_TO_EDGE_ATTR "}\n", tore,
-               get_pointer_points_to_type(type), i);
-    } break;
-  case k_type_primitive:
-    {
-      type_primitive *type = (type_primitive *)tore;
-      xfprintf (F, "\"prim %I, mode %I\"}\n", get_primitive_ident(type),
-               get_mode_ident(get_primitive_mode(type)));
-    } break;
+      type *type = tore;
+      xfprintf (F, "\"%I %I", get_type_tpop_nameid(type), get_type_nameid(type));
+
+      switch (get_type_tpop_code(type)) {
+      case tpo_class:
+       {
+         xfprintf (F, "\" " TYPE_CLASS_NODE_ATTR "}\n");
+         for (i=0; i < get_class_n_supertype(type); i++)
+           xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+                     TYPE_SUPER_EDGE_ATTR "}\n",
+                     type, get_class_supertype(type, i));
+       } break;
+      case tpo_struct:
+       {
+         xfprintf (F, "\"}\n");
+       } break;
+      case tpo_method:
+       {
+         xfprintf (F, "\" " TYPE_METH_NODE_ATTR "}\n");
+         for (i = 0; i < get_method_n_params(type); i++)
+           xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+                     METH_PAR_EDGE_ATTR "}\n",
+                     type, get_method_param_type(type, i), i);
+         for (i = 0; i < get_method_n_res(type); i++)
+           xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+                     METH_RES_EDGE_ATTR "}\n",
+                     type, get_method_res_type(type, i), i);
+       } break;
+      case tpo_union:
+       {
+         xfprintf (F, "\"}\n");
+         for (i = 0; i < get_union_n_types(type); i++)
+           xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+                     "label: \"%I\"f" UNION_EDGE_ATTR "}\n",
+                     type, get_union_unioned_type(type, i), get_union_delim_nameid(type, i));
+       } break;
+      case tpo_array:
+       {
+         xfprintf (F, "\"}\n");
+         xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+                   ARR_ELT_TYPE_EDGE_ATTR "}\n", type, get_array_element_type(type), i);
+       } break;
+      case tpo_enumeration:
+       {
+         xfprintf (F, "\"}\n");
+       } break;
+      case tpo_pointer:
+       {
+         xfprintf (F, "\"}\n");
+         xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
+                   PTR_PTS_TO_EDGE_ATTR "}\n", type,
+                   get_pointer_points_to_type(type), i);
+       } break;
+      case tpo_primitive:
+       {
+         xfprintf (F, "mode %I\"}\n", get_mode_ident(get_type_mode(type)));
+       } break;
+      default: break;
+      } /* switch type */
+
+    } break; /* case k_type */
   default:
     {
       xfprintf (F, "\" faulty type \"}\n");
       printf(" *** irdump,  %s(l.%i), faulty type.\n", __FUNCTION__, __LINE__);
     } break;
-  }
+  } /* switch kind_or_entity */
 }
 
 /************************************************************************/
index af47542..11329db 100644 (file)
@@ -29,7 +29,7 @@ extern ir_graph *current_ir_graph;
 
 /* Create a new ir graph to built ir for a procedure.
    ent is the entity representing this procedure, i.e., the type of the
-   entity must be type_method.  The constructor automatically sets the
+   entity must be of a method type.  The constructor automatically sets the
    field irg of the entity to the new ir graph.
    n_loc is the number of local variables in this procedure including
    the procedure parameters. */
index 701de9e..b3361c8 100644 (file)
@@ -146,7 +146,7 @@ ir_node_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN)
     XPF1 ("%I", get_irn_mode(np)->name);
     XPC  (" ");
     XP   (symconst_name_arr[get_irn_symconst_attr(np).num]);
-    XPF1 (" %#N", get_class_ident((type_class *)get_SymConst_type(np)));
+    XPF1 (" %#N", get_type_nameid(get_SymConst_type(np)));
     break;
   case iro_Start:              /* don't dump mode of these */
   case iro_Cond:
@@ -335,7 +335,7 @@ get_irn_symconst_attr (ir_node *node)
   return node->attr.i;
 }
 
-inline type_method *
+inline type *
 get_irn_call_attr (ir_node *node)
 {
   assert (node->op == op_Call);
@@ -741,15 +741,16 @@ set_Call_param (ir_node *node, int pos, ir_node *param) {
   set_irn_n(node, pos + CALL_PARAM_OFFSET, param);
 }
 
-inline type_method *
+inline type *
 get_Call_type (ir_node *node) {
   assert (node->op == op_Call);
   return node->attr.call;
 }
 
 inline void
-set_Call_type (ir_node *node, type_method *type) {
+set_Call_type (ir_node *node, type *type) {
   assert (node->op == op_Call);
+  assert (is_method_type(type));
   node->attr.call = type;
 }
 
index 353de84..5df68e6 100644 (file)
@@ -180,8 +180,8 @@ inline int      get_Call_arity (ir_node *node);
 /* inline void     set_Call_arity (ir_node *node, ir_node *arity); */
 inline ir_node *get_Call_param (ir_node *node, int pos);
 inline void     set_Call_param (ir_node *node, int pos, ir_node *param);
-inline type_method *get_Call_type (ir_node *node);
-inline void     set_Call_type (ir_node *node, type_method *type);
+inline type    *get_Call_type (ir_node *node);
+inline void     set_Call_type (ir_node *node, type *type);
 
 /* For unary and binary arithmetic operations the access to the
    operands can be factored out.  Left is the first, right the
index 2882e7f..d00b906 100644 (file)
@@ -53,7 +53,7 @@ typedef union {
   struct tarval *con;   /* For Const: contains the value of the constant */
   symconst_attr  i;     /* For SymConst. */
   sel_attr       s;     /* For Sel. */
-  type_method   *call;  /* For Call: pointer to the type of the method to call */
+  type          *call;  /* For Call: pointer to the type of the method to call */
   long           proj;  /* For Proj: contains the result position to project */
   alloc_attr     a;     /* For Alloc. */
   type          *f;     /* For Free. */
@@ -104,7 +104,7 @@ inline long          get_irn_proj_attr     (ir_node *node);
 inline alloc_attr    get_irn_alloc_attr    (ir_node *node);
 inline type         *get_irn_free_attr     (ir_node *node);
 inline symconst_attr get_irn_symconst_attr (ir_node *node);
-type_method  *get_irn_call_attr     (ir_node *node);
+type         *get_irn_call_attr     (ir_node *node);
 sel_attr      get_irn_sel_attr      (ir_node *node);
 int           get_irn_phi_attr      (ir_node *node);
 block_attr    get_irn_return_attr   (ir_node *node);
index 40b10f8..1f68929 100644 (file)
@@ -96,7 +96,7 @@ init_op(void)
 
   op_Sel = new_ir_op (iro_Sel, id_from_str ("Sel", 3), sizeof (sel_attr), 1);
 
-  op_Call = new_ir_op (iro_Call, id_from_str ("Call", 4), sizeof (type_method *), 1);
+  op_Call = new_ir_op (iro_Call, id_from_str ("Call", 4), sizeof (type *), 1);
   op_Add = new_ir_op (iro_Add, id_from_str ("Add", 3), 0, 0);
   op_Minus = new_ir_op (iro_Minus, id_from_str ("Minus", 5), 0, 0);
   op_Sub = new_ir_op (iro_Sub, id_from_str ("Sub", 3), 0, 1);
index 6a42358..25036d8 100644 (file)
@@ -768,8 +768,7 @@ vt_cmp (const void *elt, const void *key)
     return (get_irn_symconst_attr(a).num != get_irn_symconst_attr(b).num)
       || (get_irn_symconst_attr(a).tori.typ != get_irn_symconst_attr(b).tori.typ);
   case iro_Call:
-    return (get_irn_call_attr(a)->kind != get_irn_call_attr(b)->kind)
-      || (get_irn_call_attr(a)->arity != get_irn_call_attr(b)->arity);
+    return (get_irn_call_attr(a) != get_irn_call_attr(b));
   case iro_Sel:
     return (get_irn_sel_attr(a).ent->kind != get_irn_sel_attr(b).ent->kind)
       || (get_irn_sel_attr(a).ent->name != get_irn_sel_attr(b).ent->name)
index 2e00771..128298d 100644 (file)
@@ -60,7 +60,7 @@ void set_irp_main_irg(ir_graph *main_irg) {
   irp->main_irg = main_irg;
 }
 
-type_class *get_glob_type(void) {
+type *get_glob_type(void) {
   assert(irp);
   return irp->glob_type;
 }
index ea3fc01..bd487df 100644 (file)
@@ -51,7 +51,7 @@ type *get_irp_type(int pos);
 void  set_irp_type(int pos, type *typ);
 
 /** Functions to access the fields of ir_prog **/
-type_class *get_glob_type(void);
+type *get_glob_type(void);
 
 #ifdef DEBUG_libfirm
 /* Returns a new, unique number to number nodes or the like. */
index d34b2b5..82bff49 100644 (file)
@@ -6,15 +6,14 @@
 
 struct ir_prog {
   firm_kind kind;
-  ir_graph *main_irg;              /* entry point to the compiled program */
+  ir_graph  *main_irg;            /* entry point to the compiled program */
                   /* or a list, in case we compile a library or the like? */
-  ir_graph **graphs;               /* all graphs in the ir */
-  type_class *glob_type;           /* global type.  Class as it can have
-                                     fields and procedures.  Does this work?
-                                     Better name??? @@@ */
-  type **types;                    /* all types in the ir */
-  /*struct obstack *obst;          * @@@ Should we place all types and
-                                      entities on an obstack, too? */
+  ir_graph **graphs;              /* all graphs in the ir */
+  type      *glob_type;           /* global type.  Must be a class as it can
+                                    have fields and procedures.  */
+  type     **types;               /* all types in the ir */
+  /*struct obstack *obst;         * @@@ Should we place all types and
+                                     entities on an obstack, too? */
 #ifdef DEBUG_libfirm
   long max_node_nr;                /* to generate unique numbers for nodes. */
 #endif
index 4618bd8..c17a176 100644 (file)
@@ -22,7 +22,7 @@ X_INCLUDES  =
 SHELL       = /bin/sh
 MAKE        = /usr/bin/make
 
-DISTRIBMEMBERS  = entity.m type.m typewalk.m
+DISTRIBMEMBERS  = entity.m type.m typewalk.m tpop.m
 MEMBERS         =  $(DISTRIBMEMBERS) mangle.m
 
 CFILES = $(MEMBERS:.m=.c)
@@ -31,7 +31,8 @@ HFILES = $(MEMBERS:.m=.h)
 HFILES +=  type_or_entity.h
 HFILES +=  common.h debug.h gmp.h host.h ident.h irgraph.h  \
            irgwalk.h irmode.h irnode.h irop.h label.h misc.h \
-           obst.h pset.h set.h tv.h xprintf.h xp_help.h entity_t.h
+           obst.h pset.h set.h tv.h xprintf.h xp_help.h entity_t.h \
+          type_t.h tpop_t.h
 
 DISTRIB = $(DISTRIBMEMBERS:.m=.h)
 DISTRIB += type_or_entity.h
index d3a86ea..dc29119 100644 (file)
@@ -10,12 +10,12 @@ srcdir = @srcdir@
 topdir = ../..
 subdir := ir/tr
 
-INSTALL_HEADERS = mangle.h type.h entity.h type_or_entity.h typewalk.h
+INSTALL_HEADERS = entity.h mangle.h tpop.h type.h typewalk.h type_or_entity.h
 
 SOURCES = $(INSTALL_HEADERS)
 
 SOURCES += Makefile.in \
-               entity.c entity_t.h typewalk.c mangle.c type.c
+               entity.c entity_t.h mangle.c tpop.c tpop_t.h type.c type_t.h typewalk.c
 
 
 include $(topdir)/MakeRules
index eb4d407..7b8255b 100644 (file)
@@ -43,17 +43,17 @@ new_entity (type *owner, ident *name, type *type)
 
   res->visit = 0;
 
-  switch (get_kind(owner)) {
-  case k_type_class: {
-    add_class_member ((type_class *) owner, res);
+  switch (get_type_tpop_code(owner)) {
+  case tpo_class: {
+    add_class_member (owner, res);
   } break;
-  case k_type_strct: {
-    add_strct_member ((type_strct *) owner, res);
+  case tpo_struct: {
+    add_struct_member (owner, res);
   } break;
-  case k_type_union: {
+  case tpo_union: {
     /* not implemented */
   } break;
-  case k_type_method: {
+  case tpo_method: {
     /* not implemented */
   } break;
   default: ;
@@ -92,10 +92,10 @@ set_entity_owner (entity *ent, type *owner) {
 
 inline void   /* should this go into type.c? */
 assert_legal_owner_of_ent(type *owner) {
-  assert (owner->clss.kind   == k_type_class ||
-          owner->uni.kind    == k_type_union ||
-          owner->array.kind  == k_type_array ||
-          owner->method.kind == k_type_method );
+  assert (get_type_tpop_code(owner) == tpo_class ||
+          get_type_tpop_code(owner) == tpo_union ||
+          get_type_tpop_code(owner) == tpo_array ||
+          get_type_tpop_code(owner) == tpo_method );
 }
 
 inline ident *
@@ -134,7 +134,7 @@ set_entity_offset (entity *ent, int offset) {
 inline ir_graph *
 get_entity_irg(entity *ent) {
   assert (ent);
-  assert (get_kind(ent->type) == k_type_method);
+  assert (is_method_type(ent->type));
   return ent->irg;
 }
 
@@ -142,6 +142,6 @@ inline void
 set_entity_irg(entity *ent, ir_graph *irg) {
   assert (ent && ent->type);
   assert (irg);
-  assert (get_kind(ent->type) == k_type_method);
+  assert (is_method_type(ent->type));
   ent->irg = irg;
 }
index b13f303..7706b0f 100644 (file)
 # include "mangle.h"
 # include <obstack.h>
 # include "obst.h"
-# include "entity.h"
 # include <stdlib.h>
-# include "ident_t.h"
+# include "misc.h"
 
 /* Make types visible to allow most efficient access */
 # include "entity_t.h"
+# include "type_t.h"
+# include "tpop_t.h"
 
 static struct obstack mangle_obst;
 
@@ -45,9 +46,10 @@ mangle_type (type *type)
   int len;
   ident *res;
 
-  assert (type->kind == k_type_class);
+  assert (type->kind == k_type);
+  assert (type->type_op->code == tpo_class);
 
-  xoprintf (&mangle_obst, "%I", type->clss.name);
+  xoprintf (&mangle_obst, "%I", type->name);
   len = obstack_object_size (&mangle_obst);
   cp = obstack_finish (&mangle_obst);
   res = id_from_str (cp, len);
index 38a507e..ee10063 100644 (file)
@@ -17,5 +17,5 @@ void init_mangle (void);
    a separating "_". f*/
 ident *mangle_entity (entity *ent);
 
-/* Sorry, I'm not sure what this does... */
+/* Sorry, I'm not sure what this does... seems to copy the string. */
 ident *mangle_type   (type *type);
index 1020e9c..e5d79c9 100644 (file)
-
-/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Martin Trapp, Christian Schaefer &
-**          Goetz Lindenmaier
-**
-** type.c: datastructures to hold type information.
-*/
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-# include "type.h"
-# include "irprog.h"  /* So that constructors can add the type to global
-                        data structure. */
+/****h* libfirm/type.c
+ *
+ * NAME
+ *   file type.c - implementation of the datastructure to hold
+ *   type information.
+ * COPYRIGHT
+ *  (C) 2001 by Universitaet Karlsruhe
+ * AUTHORS
+ *  Martin Trapp, Christian Schaefer, Goetz Lindenmaier
+ *
+ * NOTES
+ *  This module supplies a datastructure to represent all types
+ *  known in the compiled program.  This includes types specified
+ *  in the program as well as types defined by the language.  In the
+ *  view of the intermediate representation there is no difference
+ *  between these types.
+ *
+ *  There exist several kinds of types, arranged by the structure of
+ *  the type.  A type is described by a set of attributes.  Some of
+ *  these attributes are common to all types, others depend on the
+ *  kind of the type.
+ *
+ *  Types are different from the modes defined in irmode:  Types are
+ *  on the level of the programming language, modes at the level of
+ *  the target processor.
+ *
+ * SEE ALSO
+ *   type_t.h type tpop
+ *****
+ */
+# include <stdlib.h>
+# include <stddef.h>
+# include "type_t.h"
+# include "tpop_t.h"
 # include "array.h"
-# include "ident_t.h"
-
-unsigned long type_visited = 0;
-
-void
-init (void)
-{
-}
 
 /*******************************************************************/
-/** TYPE_CLASS                                                    **/
+/** TYPE                                                          **/
 /*******************************************************************/
 
-type_class *
-new_type_class (ident *name) /*, int members) */
-{
-  type_class *res;
+unsigned long type_visited;
 
-  res = (type_class *) xmalloc (sizeof (type_class));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_class;
-  res->name = name;
+inline type *
+new_type(tp_op *type_op, ir_mode *mode, ident* name) {
+  type *res;
 
-  res->members = NEW_ARR_F (entity *, 1);
-  res->subtypes = NEW_ARR_F (type_class *, 1);
-  res->supertypes = NEW_ARR_F (type_class *, 1);
+  int node_size = offsetof (type, attr) +  type_op->attr_size;
+  res = (type *) xmalloc (node_size);
+  add_irp_type(res);   /* Remember the new type global. */
 
+  res->kind = k_type;
+  res->type_op = type_op;
+  res->mode = mode;
+  res->name = name;
+  res->size = -1;
   res->visit = 0;
 
   return res;
 }
 
-/* manipulate fields of type_class */
-const char *
-get_class_name  (type_class *clss) {
-  assert(clss);
-  return id_to_str(clss->name);
+tp_op*      get_type_tpop(type *tp) {
+  assert(tp);
+  return tp->type_op;
 }
 
-/* field: ident */
-ident *
-get_class_ident (type_class *clss) {
-  assert(clss);
-  return clss->name;
+ident*      get_type_tpop_nameid(type *tp) {
+  assert(tp);
+  return tp->type_op->name;
 }
-
-/*
-void   set_class_name  (type_class *clss, char *name);
-void   set_class_ident (type_class *clss, ident* ident);
-*/
-
-/* field: member */
-void
-add_class_member (type_class *clss, entity *member)
-{
-  ARR_APP1 (entity *, clss->members, member);
+const char* get_type_tpop_name(type *tp) {
+  assert(tp);
+  return id_to_str(tp->type_op->name);
 }
-
-entity *
-get_class_member (type_class *clss, int pos)
-{
-  assert (clss);
-  return clss->members[pos+1];
+tp_opcode    get_type_tpop_code(type *tp) {
+  assert(tp);
+  return tp->type_op->code;
 }
-
-void
-set_class_member (type_class *clss, entity *member, int pos)
-{
-  clss->members[pos+1] = member;
+ir_mode*    get_type_mode(type *tp) {
+  assert(tp);
+  return tp->mode;
 }
-
-int
-get_class_n_member (type_class *clss)
-{
-  int res;
-
-  assert(clss);
-  res = (ARR_LEN (clss->members))-1;
-  return res;
+void        set_type_mode(type *tp, ir_mode* m) {
+  assert(tp);
+  tp->mode = m;
 }
-
-/* field: subtype */
-void
-add_class_subtype (type_class *clss,  type_class *subtype)
-{
-  ARR_APP1 (type_class *, clss->subtypes, subtype);
+ident*      get_type_nameid(type *tp) {
+  assert(tp);
+  return tp->name;
 }
-
-type_class *
-get_class_subtype (type_class *clss, int pos)
-{
-  assert (clss);
-  return clss->subtypes[pos+1];
+void        set_type_nameid(type *tp, ident* id) {
+  assert(tp);
+  tp->name = id;
 }
-
-void
-set_class_subtype (type_class *clss, type_class *subtype, int pos)
-{
-  clss->subtypes[pos+1] = subtype;
+const char* get_type_name(type *tp) {
+  assert(tp);
+  return id_to_str(tp->name);
 }
-
-int
-get_class_n_subtype (type_class *clss)
-{
-  assert(clss);
-  return (ARR_LEN (clss->subtypes))-1;
+int         get_type_size(type *tp) {
+  assert(tp);
+  return tp->size;
 }
-
-/* field: supertype */
-void
-add_class_supertype (type_class *clss, type_class *supertype)
-{
-  ARR_APP1 (type_class *, clss->supertypes, supertype);
+void        set_type_size(type *tp, int size) {
+  assert(tp);
+  tp->size = size;
 }
-
-type_class *
-get_class_supertype (type_class *clss, int pos)
-{
-  assert (clss);
-  return clss->supertypes[pos+1];
-}
-
-void
-set_class_supertype (type_class *clss, type_class *supertype, int pos)
-{
-  clss->supertypes[pos+1] = supertype;
+unsigned long get_type_visited(type *tp) {
+  assert(tp);
+  return tp->visit;
 }
-
-int
-get_class_n_supertype (type_class *clss)
-{
-  assert(clss);
-  return (ARR_LEN (clss->supertypes))-1;
+void        set_type_visited(type *tp, unsigned long num) {
+  assert(tp);
+  tp->visit = num;
 }
-
-int
-get_class_size (type_class *clss) {
-  assert(clss);
-  return clss->size;
+/* Sets visited field in type to type_visited. */
+void        mark_type_visited(type *tp) {
+  assert(tp);
+  assert(tp->visit < type_visited);
+  tp->visit = type_visited;
 }
 
-void
-set_class_size (type_class *clss, int size) {
-  assert(clss);
-  clss->size = size;
+int is_type            (void *thing) {
+  assert(thing);
+  if (get_kind(thing) == k_type)
+    return 1;
+  else
+    return 0;
 }
 
-
 /*******************************************************************/
-/** TYPE_STRCT                                                   **/
+/** TYPE_CLASS                                                    **/
 /*******************************************************************/
 
-type_strct *
-new_type_strct (ident *name) /*, int members) */
-{
-  type_strct *res;
+/* create a new class type */
+type   *new_type_class (ident *name) {
+  type *res;
 
-  res = (type_strct *) xmalloc (sizeof (type_strct));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_strct;
-  res->name = name;
+  res = new_type(type_class, NULL, name);
 
-  res->members = NEW_ARR_F (entity *, 1);
-  res->visit = 0;
+  res->attr.ca.members    = NEW_ARR_F (entity *, 1);
+  res->attr.ca.subtypes   = NEW_ARR_F (type *, 1);
+  res->attr.ca.supertypes = NEW_ARR_F (type *, 1);
 
   return res;
 }
-
-/* manipulate fields of type_strct */
-
-const char *
-get_strct_name  (type_strct *strct) {
-  assert(strct);
-  return ID_TO_STR(strct->name);
+/* manipulate private fields of class type  */
+void    add_class_member   (type *clss, entity *member) {
+  assert(clss && (clss->type_op == type_class));
+  ARR_APP1 (entity *, clss->attr.ca.members, member);
 }
-
-
-ident *
-get_strct_ident (type_strct *strct) {
-  assert(strct);
-  return strct->name;
+int     get_class_n_member (type *clss) {
+  assert(clss && (clss->type_op == type_class));
+  return (ARR_LEN (clss->attr.ca.members))-1;
 }
-
-int
-get_strct_n_member (type_strct *strct)
-{
-  int res;
-
-  assert(strct);
-  res = (ARR_LEN (strct->members))-1;
-  return res;
+entity *get_class_member   (type *clss, int pos) {
+  assert(clss && (clss->type_op == type_class));
+  return clss->attr.ca.members[pos+1];
 }
-
-void
-add_strct_member (type_strct *strct, entity *member)
-{
-  ARR_APP1 (type_strct *, strct->members, member);
+void    set_class_member   (type *clss, entity *member, int pos) {
+  assert(clss && (clss->type_op == type_class));
+  clss->attr.ca.members[pos+1] = member;
 }
 
-entity *
-get_strct_member (type_strct *strct, int pos)
-{
-  assert (strct);
-  return strct->members[pos+1];
+void    add_class_subtype   (type *clss, type *subtype) {
+  assert(clss && (clss->type_op == type_class));
+  ARR_APP1 (type *, clss->attr.ca.subtypes, subtype);
 }
-
-void
-set_strct_member (type_strct *strct, int pos, entity *member)
-{
-  strct->members[pos+1] = member;
+int     get_class_n_subtype (type *clss) {
+  assert(clss && (clss->type_op == type_class));
+  return (ARR_LEN (clss->attr.ca.subtypes))-1;
+}
+type   *get_class_subtype   (type *clss, int pos) {
+  assert(clss && (clss->type_op == type_class));
+  return clss->attr.ca.subtypes[pos+1];
+}
+void    set_class_subtype   (type *clss, type *subtype, int pos) {
+  assert(clss && (clss->type_op == type_class));
+  clss->attr.ca.subtypes[pos+1] = subtype;
 }
 
-/*
-void   set_strct_name  (type_strct *strct, char *name);
-void   set_strct_ident (type_strct *strct, ident* ident);
-*/
-
+void    add_class_supertype   (type *clss, type *supertype) {
+  assert(clss && (clss->type_op == type_class));
+  ARR_APP1 (type *, clss->attr.ca.supertypes, supertype);
+}
+int     get_class_n_supertype (type *clss) {
+  assert(clss && (clss->type_op == type_class));
+  return (ARR_LEN (clss->attr.ca.supertypes))-1;
+}
+type   *get_class_supertype   (type *clss, int pos) {
+  assert(clss && (clss->type_op == type_class));
+  return clss->attr.ca.supertypes[pos+1];
+}
+void    set_class_supertype   (type *clss, type *supertype, int pos) {
+  assert(clss && (clss->type_op == type_class));
+  clss->attr.ca.supertypes[pos+1] = supertype;
+}
+/* typecheck */
+bool    is_class_type(type *clss) {
+  assert(clss);
+  if (clss->type_op == type_class) return 1; else return 0;
+}
 
 /*******************************************************************/
-/** TYPE_METHOD                                                   **/
+/** TYPE_STRUCT                                                   **/
 /*******************************************************************/
 
-/* create a new type_method */
-type_method *
-new_type_method (ident *name, int arity, int n_res)
-{
-  type_method *res;
-
-  res = (type_method *) xmalloc (sizeof (type_method));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_method;
-
-  res->name = name;   /* do I need the name, or is the name in entity sufficient? */
-  res->arity = arity;
-  res->param_type = (type **) xmalloc (sizeof (type *) * arity);
-  res->n_res  = n_res;
-  res->res_type = (type **) xmalloc (sizeof (type *) * n_res);
-
-  res->visit = 0;
-
+/* create a new type struct */
+type   *new_type_struct (ident *name) {
+  type *res;
+  res = new_type(type_struct, NULL, name);
+  res->attr.sa.members = NEW_ARR_F (entity *, 1);
   return res;
 }
-
-/* manipulate fields of type_method */
-const char *
-get_method_name  (type_method *method) {
-  assert(method);
-  return ID_TO_STR(method->name);
+/* manipulate private fields of struct */
+void    add_struct_member   (type *strct, entity *member) {
+  assert(strct && (strct->type_op == type_struct));
+  ARR_APP1 (entity *, strct->attr.sa.members, member);
 }
-
-ident *
-get_method_ident (type_method *method) {
-  assert(method);
-  return method->name;
+int     get_struct_n_member (type *strct) {
+  assert(strct && (strct->type_op == type_struct));
+  return (ARR_LEN (strct->attr.sa.members))-1;
 }
-
-/*
-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) {
-  return method->arity;
+entity *get_struct_member   (type *strct, int pos) {
+  assert(strct && (strct->type_op == type_struct));
+  return strct->attr.sa.members[pos+1];
 }
-
-inline int
-get_method_arity (type_method *method) {
-  return method->arity;
+void    set_struct_member   (type *strct, int pos, entity *member) {
+  assert(strct && (strct->type_op == type_struct));
+  strct->attr.sa.members[pos+1] = member;
 }
-
-/*
-inline void
-set_method_arity (type_method *method, int arity) {
-  method->arity = arity;
-  / change array size, somehow copy.  *
+/* typecheck */
+bool    is_struct_type(type *strct) {
+  assert(strct);
+  if (strct->type_op == type_struct) return 1; else return 0;
 }
-*/
 
-inline type *
-get_method_param_type(type_method *method, int pos) {
-  return method->param_type[pos];
-}
+/*******************************************************************/
+/** TYPE_METHOD                                                   **/
+/*******************************************************************/
 
-inline void
-set_method_param_type(type_method *method, int pos, type* type) {
-  method->param_type[pos] = type;
+/* Create a new method type.
+   N_param is the number of parameters, n_res the number of results.  */
+type *new_type_method (ident *name, int n_param, int n_res) {
+  type *res;
+  res = new_type(type_method, NULL, name);
+  res->attr.ma.n_params   = n_param;
+  res->attr.ma.param_type = (type **) xmalloc (sizeof (type *) * n_param);
+  res->attr.ma.n_res      = n_res;
+  res->attr.ma.res_type   = (type **) xmalloc (sizeof (type *) * n_res);
+  return res;
 }
 
-
-inline int
-get_method_n_res (type_method *method) {
-  return method->n_res;
+/* manipulate private fields of method. */
+int   get_method_n_params  (type *method) {
+  assert(method && (method->type_op == type_method));
+  return method->attr.ma.n_params;
 }
-
-/*
-inline void
-set_method_n_res (type_method *method, int n_res) {
-  method->n_res = n_res;
+type *get_method_param_type(type *method, int pos) {
+  assert(method && (method->type_op == type_method));
+  return method->attr.ma.param_type[pos];
 }
-*/
-
-inline type *
-get_method_res_type(type_method *method, int pos) {
-  return method->res_type[pos];
+void  set_method_param_type(type *method, int pos, type* type) {
+  assert(method && (method->type_op == type_method));
+  method->attr.ma.param_type[pos] = type;
 }
 
-inline void
-set_method_res_type(type_method *method, int pos, type* type) {
-  method->res_type[pos] = type;
+int   get_method_n_res   (type *method) {
+  assert(method && (method->type_op == type_method));
+  return method->attr.ma.n_res;
 }
-
+type *get_method_res_type(type *method, int pos) {
+  assert(method && (method->type_op == type_method));
+  return method->attr.ma.res_type[pos];
+}
+void  set_method_res_type(type *method, int pos, type* type) {
+  assert(method && (method->type_op == type_method));
+  method->attr.ma.res_type[pos] = type;
+}
+/* typecheck */
+bool  is_method_type     (type *method) {
+  assert(method);
+  if (method->type_op == type_method) return 1; else return 0;
+}
+/*****/
 
 /*******************************************************************/
 /** TYPE_UNION                                                    **/
 /*******************************************************************/
 
-/* create a new type_union -- set unioned types by hand. */
-type_union *
-new_type_union (ident *name, int n_types)
-{
-  type_union *res;
-
-  res = (type_union *) xmalloc (sizeof (type_union));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_union;
-  res->name = name;   /* do I need a name? */
-  res->n_types = n_types;
-  /*
-  res->unioned_type = (int *) xmalloc (sizeof (int) * n_types);
-  */
-
-  res->visit = 0;
-
+/* create a new type uni */
+type  *new_type_uni (ident *name, int n_types) {
+  type *res;
+  res = new_type(type_union, NULL, name);
+  res->attr.ua.n_types = n_types;
+  res->attr.ua.unioned_type = (type **)  xmalloc (sizeof (type *)  * n_types);
+  res->attr.ua.delim_names  = (ident **) xmalloc (sizeof (ident *) * n_types);
   return res;
 }
-
-/* manipulate fields of type_union */
-/*
-char *
-get_union_name  (type_union *uni) {
-  assert(uni);
-  return ID_TO_STR(uni->name);
+/* manipulate private fields of struct */
+int    get_union_n_types      (type *uni) {
+  assert(uni && (uni->type_op == type_union));
+  return uni->attr.ua.n_types;
+}
+type  *get_union_unioned_type (type *uni, int pos) {
+  assert(uni && (uni->type_op == type_union));
+  return uni->attr.ua.unioned_type[pos];
+}
+void   set_union_unioned_type (type *uni, int pos, type *type) {
+  assert(uni && (uni->type_op == type_union));
+  uni->attr.ua.unioned_type[pos] = type;
+}
+ident *get_union_delim_nameid (type *uni, int pos) {
+  assert(uni && (uni->type_op == type_union));
+  return uni->attr.ua.delim_names[pos];
+}
+const char *get_union_delim_name (type *uni, int pos) {
+  assert(uni && (uni->type_op == type_union));
+  return id_to_str(uni->attr.ua.delim_names[pos]);
+}
+void   set_union_delim_nameid (type *uni, int pos, ident *id) {
+  assert(uni && (uni->type_op == type_union));
+  uni->attr.ua.delim_names[pos] = id;
 }
-*/
 
-ident *
-get_union_ident (type_union *uni) {
+/* typecheck */
+bool   is_union_type         (type *uni) {
   assert(uni);
-  return uni->name;
+  if (uni->type_op == type_union) return 1; else return 0;
 }
 
-/*
-void   set_union_name  (type_union *union, char *name);
-void   set_union_ident (type_union *union, ident* ident);
-*/
-/*
-int    get_union_n_types (type_union *union);
-void   set_union_n_types (type_union *union, int n);
-type  *get_union_unioned_type (type_union *union, int pos);
-void   set_union_unioned_type (type_union *union, int pos, type *type);
-*/
-
 /*******************************************************************/
 /** TYPE_ARRAY                                                    **/
 /*******************************************************************/
 
-/* create a new type_array */
-inline type_array *
-new_type_array (ident *name, int n_dimensions)
-{
-  type_array *res;
-
-  res = (type_array *) xmalloc (sizeof (type_array));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_array;
-  res->name = name;
-  res->n_dimensions = n_dimensions;
-  res->lower_bound = (int *) xmalloc (sizeof (int) * n_dimensions);
-  res->upper_bound = (int *) xmalloc (sizeof (int) * n_dimensions);
-
-  res->visit = 0;
 
+/* create a new type array -- set dimension sizes independently */
+type *new_type_array         (ident *name, int n_dimensions) {
+  type *res;
+  res = new_type(type_array, NULL, name);
+  res->attr.aa.n_dimensions = n_dimensions;
+  res->attr.aa.lower_bound  = (int *) xmalloc (sizeof (int) * n_dimensions);
+  res->attr.aa.upper_bound  = (int *) xmalloc (sizeof (int) * n_dimensions);
   return res;
 }
-
-/* manipulate fields of type_array */
-/*
-char *
-get_array_name  (type_array *array) {
-  assert(array);
-  return ID_TO_STR(array->name);
+/* manipulate private fields of array type */
+int   get_array_n_dimensions (type *array) {
+  assert(array && (array->type_op == type_array));
+  return array->attr.aa.n_dimensions;
 }
-*/
-
-ident *
-get_array_ident (type_array *array) {
-  assert(array);
-  return array->name;
+void  set_array_bounds       (type *array, int dimension, int lower_bound,
+                                                          int upper_bound) {
+  assert(array && (array->type_op == type_array));
+  array->attr.aa.lower_bound[dimension] = lower_bound;
+  array->attr.aa.upper_bound[dimension] = upper_bound;
 }
-
-/*
-void   set_array_name  (type_array *array, char *name);
-void   set_array_ident (type_array *array, ident* ident);
-*/
-
-inline void
-set_array_dimensions (type_array* array, int n) {
-  array->n_dimensions = n;
-}
-
-inline int
-get_array_dimensions (type_array* array) {
-  return array->n_dimensions;
-}
-
-inline void
-set_array_bounds (type_array* array, int dimension, int lower_bound,
-                 int upper_bound) {
-  array->lower_bound[dimension-1] = lower_bound;
-  array->upper_bound[dimension-1] = upper_bound;
+void  set_array_lower_bound  (type *array, int dimension, int lower_bound) {
+  assert(array && (array->type_op == type_array));
+  array->attr.aa.lower_bound[dimension] = lower_bound;
 }
-
-inline void
-set_array_lower_bound (type_array* array, int dimension, int lower_bound) {
-  array->lower_bound[dimension-1] = lower_bound;
+void  set_array_upper_bound  (type *array, int dimension, int upper_bound) {
+  assert(array && (array->type_op == type_array));
+  array->attr.aa.upper_bound[dimension] = upper_bound;
 }
-
-inline void
-set_array_upper_bound (type_array* array, int dimension, int upper_bound) {
-  array->upper_bound[dimension-1] = upper_bound;
+int   get_array_lower_bound  (type *array, int dimension) {
+  assert(array && (array->type_op == type_array));
+  return array->attr.aa.lower_bound[dimension];
 }
-
-inline int
-get_array_lower_bound (type_array* array, int dimension) {
-  return array->lower_bound[dimension-1];
+int   get_array_upper_bound  (type *array, int dimension) {
+  assert(array && (array->type_op == type_array));
+  return array->attr.aa.upper_bound[dimension];
 }
-
-inline int
-get_array_upper_bound (type_array* array, int dimension) {
-  return array->upper_bound[dimension-1];
+void  set_array_element_type (type *array, type *type) {
+  assert(array && (array->type_op == type_array));
+  array->attr.aa.element_type = type;
 }
-
-inline void set_array_element_type (type_array *array, type *type) {
-  array->element_type = type;
+type *get_array_element_type (type *array) {
+  assert(array && (array->type_op == type_array));
+  return array->attr.aa.element_type;
 }
-
-inline type *
-get_array_element_type (type_array *array) {
-  return array->element_type;
+/* typecheck */
+bool   is_array_type         (type *array) {
+  assert(array);
+  if (array->type_op == type_array) return 1; else return 0;
 }
 
-
 /*******************************************************************/
 /** TYPE_ENUMERATION                                              **/
 /*******************************************************************/
 
 /* create a new type enumeration -- set the enumerators independently */
-type_enumeration *
-new_type_enumeration (ident *name /* , int n_enums */)
-{
-  type_enumeration *res;
-
-  res = (type_enumeration *) xmalloc (sizeof (type_enumeration));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_enumeration;
-  res->name = name;
-  /*
-  res->n_enums = n_enums;
-  res->enum = (int *) xmalloc (sizeof (int) * n_enums);
-  */
-
-  res->visit = 0;
-
+type   *new_type_enumeration    (ident *name, int n_enums) {
+  type *res;
+  res = new_type(type_enumeration, NULL, name);
+  res->attr.ea.n_enums     = n_enums;
+  res->attr.ea.enumer      = (tarval **) xmalloc (sizeof (tarval *) * n_enums);
+  res->attr.ea.enum_nameid = (ident  **) xmalloc (sizeof (ident  *) * n_enums);
   return res;
 }
 
-/* manipulate fields of type_enumeration */
-/*
-char *
-get_enumeration_name  (type_enumeration *enumeration) {
-  assert(enumeration);
-  return ID_TO_STR(enumeration->name);
+/* manipulate fields of enumeration type. */
+int     get_enumeration_n_enums (type *enumeration) {
+  assert(enumeration && (enumeration->type_op == type_enumeration));
+  return enumeration->attr.ea.n_enums;
+}
+void    set_enumeration_enum    (type *enumeration, int pos, tarval *con) {
+  assert(enumeration && (enumeration->type_op == type_enumeration));
+  enumeration->attr.ea.enumer[pos] = con;
+}
+tarval *get_enumeration_enum    (type *enumeration, int pos) {
+  assert(enumeration && (enumeration->type_op == type_enumeration));
+  return enumeration->attr.ea.enumer[pos];
+}
+void    set_enumeration_nameid  (type *enumeration, int pos, ident *id) {
+  assert(enumeration && (enumeration->type_op == type_enumeration));
+  enumeration->attr.ea.enum_nameid[pos] = id;
+}
+ident  *get_enumeration_nameid  (type *enumeration, int pos) {
+  assert(enumeration && (enumeration->type_op == type_enumeration));
+  return enumeration->attr.ea.enum_nameid[pos];
+}
+const char *get_enumeration_name(type *enumeration, int pos) {
+  assert(enumeration && (enumeration->type_op == type_enumeration));
+  return id_to_str(enumeration->attr.ea.enum_nameid[pos]);
 }
-*/
 
-ident *
-get_enumeration_ident (type_enumeration *enumeration) {
+/* typecheck */
+bool    is_enumeration_type     (type *enumeration) {
   assert(enumeration);
-  return enumeration->name;
+  if (enumeration->type_op == type_enumeration) return 1; else return 0;
 }
 
-/*
-void   set_enumeration_name  (type_enumeration *enumeration, char *name);
-void   set_enumeration_ident (type_enumeration *enumeration, ident* ident);
-*/
-/*
-void     set_enumeration_n_enums (type_enumeration *enumeration, int n);
-int     *get_enumeration_n_enums (type_enumeration *enumeration);
-void     set_enumeration_enum    (type_enumeration *enumeration, int pos,
-                                 ir_node const);
-ir_node *get_enumeration_enum    (type_enumeration *enumeration, int pos);
-*/
-
-
 /*******************************************************************/
 /** TYPE_POINTER                                                  **/
 /*******************************************************************/
 
-/* create a new type pointer */
-type_pointer *
-new_type_pointer (ident *name, type *points_to)
-{
-  type_pointer *res;
-
-  res = (type_pointer *) xmalloc (sizeof (type_pointer));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_pointer;
-  res->name = name;
-  res->points_to = points_to;
-
-  res->visit = 0;
-
+/* Create a new type pointer */
+type *new_type_pointer           (ident *name, type *points_to) {
+  type *res;
+  res = new_type(type_pointer, mode_p, name);
+  res->attr.pa.points_to = points_to;
   return res;
 }
-
 /* manipulate fields of type_pointer */
-/*
-char *
-get_pointer_name  (type_pointer *pointer) {
-  assert(pointer);
-  return ID_TO_STR(pointer->name);
-}
-*/
-
-ident *
-get_pointer_ident (type_pointer *pointer) {
-  assert(pointer);
-  return pointer->name;
+void  set_pointer_points_to_type (type *pointer, type *type) {
+  assert(pointer && (pointer->type_op == type_pointer));
+  pointer->attr.pa.points_to = type;
 }
-
-/*
-void   set_pointer_name  (type_pointer *pointer, char *name);
-void   set_pointer_ident (type_pointer *pointer, ident* ident);
-*/
-
-inline void
-set_pointer_points_to_type (type_pointer *pointer, type* type) {
-  pointer->points_to = type;
+type *get_pointer_points_to_type (type *pointer) {
+  assert(pointer && (pointer->type_op == type_pointer));
+  return pointer->attr.pa.points_to;
 }
 
-inline type *
-get_pointer_points_to_type (type_pointer *pointer) {
-  return pointer->points_to;
+/* typecheck */
+bool  is_pointer_type            (type *pointer) {
+  assert(pointer);
+  if (pointer->type_op == type_pointer) return 1; else return 0;
 }
 
 
@@ -578,122 +460,15 @@ get_pointer_points_to_type (type_pointer *pointer) {
 /** TYPE_PRIMITIVE                                                **/
 /*******************************************************************/
 
-/* create a new type_primitive */
-inline type_primitive *
-new_type_primitive (ident *name, ir_mode *mode)
-{
-  type_primitive *res;
-
-  res = (type_primitive *) xmalloc (sizeof (type_primitive));
-  add_irp_type((type *) res);   /* Remember the new type global. */
-  res->kind = k_type_primitive;
-  res->name = name;
-  res->mode = mode;
-
-  res->visit = 0;
-
+/* create a new type primitive */
+type *new_type_primitive (ident *name, ir_mode *mode) {
+  type *res;
+  res = new_type(type_primitive, mode_p, name);
   return res;
 }
 
-/* manipulate fields of type_primitive */
-
-const char  *
-get_primitive_name  (type_primitive *primitive) {
+/* typecheck */
+bool  is_primitive_type  (type *primitive) {
   assert(primitive);
-  return ID_TO_STR(primitive->name);
-}
-
-
-ident *
-get_primitive_ident (type_primitive *primitive) {
-  assert(primitive);
-  return primitive->name;
-}
-/*
-void   set_primitive_name  (type_primitive *primitive, char *name);
-void   set_primitive_ident (type_primitive *primitive, ident* ident);
-*/
-
-inline ir_mode *
-get_primitive_mode (type_primitive *primitive) {
-  return primitive->mode;
-}
-
-inline void
-set_primitive_mode (type_primitive *primitive, ir_mode *mode) {
-  primitive->mode = mode;
-}
-
-
-
-
-/*******************************************************************/
-/**  To manage all different types the same                       **/
-/*******************************************************************/
-
-
-int
-is_type(void *thing) {
-  firm_kind kind;
-
-  kind = get_kind(thing);
-  if (   (kind == k_type_class)
-      || (kind == k_type_strct)
-      || (kind == k_type_method)
-      || (kind == k_type_union)
-      || (kind == k_type_array)
-      || (kind == k_type_enumeration)
-      || (kind == k_type_pointer)
-      || (kind == k_type_primitive))
-    return 1;
-  else
-    return 0;
-}
-
-int
-is_type_class(void *thing) {
-  if (get_kind(thing) == k_type_class) return 1;
-  else return 0;
-}
-
-int
-is_type_strct(void *thing) {
-  if (get_kind(thing) == k_type_strct) return 1;
-  else return 0;
-}
-
-int
-is_type_method(void *thing) {
-  if (get_kind(thing) == k_type_method) return 1;
-  else return 0;
-}
-
-int
-is_type_union(void *thing) {
-  if (get_kind(thing) == k_type_union) return 1;
-  else return 0;
-}
-
-int
-is_type_array(void *thing) {
-  if (get_kind(thing) == k_type_array) return 1;
-  else return 0;
-}
-
-int
-is_type_pointer(void *thing) {
-  if (get_kind(thing) == k_type_pointer) return 1;
-  else return 0;
-}
-
-int
-is_type_enumeration(void *thing) {
-  if (get_kind(thing) == k_type_enumeration) return 1;
-  else return 0;
-}
-
-int
-is_type_primitive(void *thing) {
-  if (get_kind(thing) == k_type_primitive) return 1;
-  else return 0;
+  if (primitive->type_op == type_primitive) return 1; else return 0;
 }
index 9c749ac..e76734b 100644 (file)
-/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Martin Trapp, Christian Schaefer &
-**          Goetz Lindenmaier
-**
-
-@@@@@@@  Improve documentation: distinguish fields that are
-set by the frontend and contain knowledge specified by the source
-program from fields containing information derived by analysis/optimization
-or lowering phases.
-
-
-**  type.h: datastructures to hold type information.
-**
-**  This module supplies datastructures to represent all types
-**  known in the compiled program.  This includes types specified
-**  in the program as well as types defined by the language.  In the
-**  view of the intermediate representation there is no difference
-**  between these types.
-**  Types are different from the modes defined in irmode:  Types are
-**  on the level of the programming language, modes at the level of
-**  the target processor.
-**
-**
-**  General datastructure
-**  =====================
-**
-**  Firm distinguishes several different type constructs.  These are
-**  implemented as structs.  A union of the individual structs constructs
-**  the firm node "type".
-**
-**  All type constructs have the following fields:
-**
-**  kind         A firm_kind tag containing k_type_class.  This is useful
-**               for dynamically checking the sort of a type.  Automatically
-**               generated.
-**
-**  name         An identifier specifying the type name.  Set by the frontend.
-**
-**  visit        A counter for walks of the type information.
-**
-**
-**  General functionality
-**  =====================
-**
-**  is_type(t)   Returns true if t is a type node, else false.
-**
-**
-**  type_class
-**  ==========
-**
-**  Type_class represents class types.  A list of fields and
-**  methods is associated with a class.  Further a class can
-**  inherit from and bequest to other classes.
-**
-**  fields:
-**  -------
-**
-**  **member     All entities belonging to this class.  This are methodes
-**               which have type_method or fields that can have any of the
-**               following types: k_type_class, k_type_strct, k_type_union,
-**               k_type_array, k_type_enumeration, k_type_pointer, k_type_primitive.
-**
-**  **subtypes   A list of direct subclasses.
-**
-**  **supertypes A list of direct superclasses.
-**
-**
-**  type_strct
-**  ==========
-**
-**  Type_strct represents aggregate types that consist of a list
-**  of fields.
-**
-**  fields:
-**  -------
-**
-**  **member     All entities belonging to this class.  This are the fields
-**               that can have any of the following types:  k_type_class,
-**               k_type_strct, k_type_union, k_type_array, k_type_enumeration,
-**              k_type_pointer, k_type_primitive.
-**
-**  type_method
-**  ===========
-**
-**  Type_method represents method, function and procedure types.
-**
-**  fields:
-**  -------
-**
-**  arity        Number of parameters to the procedure. @@@ better n_params
-**               A procedure in FIRM has only call by value parameters.
-**
-**  **param_type A list with the types of parameters.  This list is ordered.
-**               The nth type in this list corresponds to the nth element
-**               in the parameter tuple that is a result of the start node.
-**              (See ircons.h for more information.)
-**
-**  n_res        The number of results of the method.  In general, procedures
-**               have zero results, functions one.
-**
-**  **res_type   A list with the types of parameters.  This list is ordered.
-**              The nth type in this list corresponds to the nth input to
-**              Return nodes.  (See ircons.h for more information.)
-**
-**
-**  type_union
-**  ==========
-**
-**  Type_union represents union types.
-**
-**  fields:
-**  -------
-**
-**  **unioned_type   A list of unioned types.
-**
-**
-**  type_array
-**  ==========
-**
-**  Type_array represents rectangular multi dimensional arrays.
-**
-**  fields:
-**  -------
-**
-**  n_dimensions     Number of array dimensions.
-**
-**  *lower_bound     Lower bounds of dimensions.  Mostly all 0.
-**
-**  *upper_bound     Upper bounds or dimensions.
-**
-**  *element_type    The type of the array elements.
-**
-**
-**  type_enumeration
-**  ================
-**
-**  Enumeration types.  These need not necessarily be represented explicitly
-**  by Firm types, as the frontend can lower them to integer constants as
-**  well.  For debugging purposes or similar tasks this information is useful.
-**
-**  fields:
-**  -------
-**
-**  **enum           The target values representing the constants used to
-**                   represent individual enumerations.
-**
-**  **enum_name      Idents containing the source program name of the enumeration
-**                  constants
-**
-**  type_pointer
-**  ============
-**
-**  Pointer types.
-**
-**  fields:
-**  -------
-**
-**  *mode            The mode used to implement a pointer.  @@@ So far this field
-**                   is constant and set to mode_P.  Maybe we will move this
-**                  to a global constant (irprog), or are there processors
-**                  that require a set of different pointer modes?
-**
-**  *points_to       The type of the entity this pointer points to.
-**
-**  type_primitive
-**  ==============
-**
-**  Primitive types are types that represent indivisible data values that
-**  map directly to modes.
-**
-**  fields:
-**  -------
-**
-**  mode             The mode to be used for this type.
-**
-*/
-
+/****h* libfirm/type
+ *
+ * NAME
+ *   file type.h - datastructure to hold type information.
+ * COPYRIGHT
+ *  (C) 2001 by Universitaet Karlsruhe
+ * AUTHORS
+ *  Goetz Lindenmaier
+ *
+ * NOTES
+ *  This module supplies a datastructure to represent all types
+ *  known in the compiled program.  This includes types specified
+ *  in the program as well as types defined by the language.  In the
+ *  view of the intermediate representation there is no difference
+ *  between these types.
+ *
+ *  There exist several kinds of types, arranged by the structure of
+ *  the type.  A type is described by a set of attributes.  Some of
+ *  these attributes are common to all types, others depend on the
+ *  kind of the type.
+ *
+ *  Types are different from the modes defined in irmode:  Types are
+ *  on the level of the programming language, modes at the level of
+ *  the target processor.
+ *
+ * SEE ALSO
+ *   tpop.h
+ *****
+ */
 # ifndef _TYPE_H_
 # define _TYPE_H_
 
+# include "tpop.h"
 # include "common.h"
 # include "ident.h"
 # include "irmode.h"
+# include "bool.h"
 
 #ifndef _ENTITY_TYPEDEF_
 #define _ENTITY_TYPEDEF_
@@ -190,334 +42,351 @@ or lowering phases.
 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 */
+/****s* type/type
+ *
+ * NAME
+ *   type - An abstract data type to represent types.
+ * NOTE
+ *  This is the abstract data type with which any type known in the
+ *  compiled program can be represented.  This includes types specified
+ *  in the program as well as types defined by the language.  In the
+ *  view of the intermediate representation there is no difference
+ *  between these types.
+ *
+ *  There exist several kinds of types, arranged by the structure of
+ *  the type.  These are distinguished by a type opcode.
+ *  A type is described by a set of attributes.  Some of these attributes
+ *  are common to all types, others depend on the kind of the type.
+ *
+ *  The following describes the common attributes.  They can only be
+ *  accessed by the functions given below.
+ *
+ * ATTRIBUTES
+ *  The common fields are:
+ *
+ *  firm_kind    A firm_kind tag containing k_type.  This is useful
+ *               for dynamically checking whether a node is a type node.
+ *  type_op      A tp_op specifying the kind of the type.
+ *  mode         The mode to be used to represent the type on a machine.
+ *               @@@ maybe not global field??
+ *  name         An identifier specifying the name of the type.  To be
+ *               set by the frontend.
+ *  size         The size of the type, i.e. an entity of this type will
+ *               occupy size bytes in memory.  In several cases this is
+ *               determined when fixing the layout of this type (class,
+ *               struct, union, array, enumeration).
+ *  visit        A counter for walks of the type information.
+ *
+ *  These fields can only be accessed via access functions.
+ *
+ *  Depending on the value of type_op, i.e., depending on the kind of the
+ *  type the adt contains further attributes.  These are documented below.
+ * SEE ALSO
+ *   class, struct, method, union, array, enumeration, pointer, primitive
+ * SOURCE
+ */
+typedef struct type type;
+
+tp_op*      get_type_tpop(type *tp);
+ident*      get_type_tpop_nameid(type *tp);
+const char* get_type_tpop_name(type *tp);
+tp_opcode   get_type_tpop_code(type *tp);
+
+ir_mode*    get_type_mode(type *tp);
+void        set_type_mode(type *tp, ir_mode* m);
+
+ident*      get_type_nameid(type *tp);
+void        set_type_nameid(type *tp, ident* id);
+const char* get_type_name(type *tp);
+
+int         get_type_size(type *tp);
+void        set_type_size(type *tp, int size);
+
+unsigned long get_type_visited(type *tp);
+void        set_type_visited(type *tp, unsigned long num);
+/* Sets visited field in type to type_visited. */
+void        mark_type_visited(type *tp);
+/*****/
+
+/****v* type/visited
+ *
+ * NAME
+ *   type_visited -  visited flag to traverse the type information
+ * PURPOSE
+ *   Increase this flag by one before traversing the type information.
+ *   Mark type nodes as visited by set_type_visited(type, type_visited).
+ *   Check whether node was already visited by comparing get_type_visited(type)
+ *   and type_visited.
+ *   Or use the function to walk all types.
+ * SEE ALSO
+ *   typewalk
+ * SOURCE
+ */
 extern unsigned long type_visited;
+/*****/
+
+/****f* type/is_type
+ *
+ * NAME
+ *   is_type - Checks whether a pointer points to a type.
+ * SYNOPSIS
+ *   bool is_type            (void *thing);
+ * INPUTS
+ *   thing - a pointer
+ * RESULT
+ *   true if the thing is a type, else false
+ ***
+ */
+int is_type            (void *thing);
 
-/*******************************************************************/
-/** TYPE_CLASS                                                    **/
-/*******************************************************************/
-
-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. */
-  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 */
-
-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);
-*/
-
-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                                                   **/
-/*******************************************************************/
-
-typedef struct {
-  firm_kind kind;
-  ident *name;
-  entity **members;
-  unsigned long visit;     /* visited counter for walks of the type information */
-} type_strct;
-
-
-/* create a new type_strct */
-type_strct *new_type_strct (ident *name);
-
-/* manipulate fields of type_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);
-*/
-
-
-/*******************************************************************/
-/** TYPE_METHOD                                                   **/
-/*******************************************************************/
-
-typedef struct {
-  firm_kind kind;
-  ident *name;         /* Name of the method type.  Usually method
-                         types are not explicitly named (but the entity). */
-  int arity;           /* number of parameters, better n_params */
-  type **param_type;   /* code generation needs this information.
-                          Should it be generated by the frontend,
-                          or does this impose unnecessary work for
-                          optimizations that change the parameters of
-                          methods? */
-  int n_res;           /* number of results */
-  type **res_type;     /* array with result types */
-  unsigned long visit; /* visited counter for walks of the type information */
-} 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 */
-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 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 type *get_method_res_type(type_method *method, int pos);
-inline void  set_method_res_type(type_method *method, int pos, type* type);
-
-
-/*******************************************************************/
-/** TYPE_UNION                                                    **/
-/*******************************************************************/
-
-typedef struct {
-  firm_kind kind;
-  ident *name;             /* do I need a name? */
-  int n_types;
-  /* type **unioned_type;    ... or something like that? */
-  unsigned long visit;     /* visited counter for walks of the type information */
-} type_union;
-
-/* create a new type_union -- set unioned types by hand. */
-type_union *new_type_union (ident *name, int n_types);
-
-/* manipulate fields of type_union */
-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);
-*/
-/*
-int    get_union_n_types (type_union *union);
-void   set_union_n_types (type_union *union, int n);
-type  *get_union_unioned_type (type_union *union, int pos);
-void   set_union_unioned_type (type_union *union, int pos, type *type);
-*/
-
-/*******************************************************************/
-/** TYPE_ARRAY                                                    **/
-/*******************************************************************/
-
-/* multidimensional, polyhedric arrays */
-typedef struct {
-  firm_kind kind;
-  ident *name;
-  int n_dimensions;
-  int *lower_bound;
-  int *upper_bound;
-  type *element_type;
-  unsigned long visit;     /* visited counter for walks of the type information */
-} type_array;
-
+/****** type/class
+ * NAME
+ *  Representation of a class type.
+ * NOTE
+ *  If the type opcode is set to type_class the type represents class
+ *  types.  A list of fields and methods is associated with a class.
+ *  Further a class can inherit from and bequest to other classes.
+ *  @@@ value class???
+ * ATTRIBUTES
+ *  The following attributes are private to this type kind.
+ *  member     All entities belonging to this class.  This are methode entities
+ *             which have type_method or fields that can have any of the
+ *             following type kinds: type_class, type_struct, type_union,
+ *             type_array, type_enumeration, type_pointer, type_primitive.
+ *
+ *  subtypes   A list of direct subclasses.
+ *
+ *  supertypes A list of direct superclasses.
+ *
+ *  These are dynamic lists that can be grown with an "add_" function,
+ *  but not shrinked.
+ * SOURCE
+ */
+/* create a new class type */
+type   *new_type_class (ident *name);
+
+/* manipulate private fields of class type  */
+void    add_class_member   (type *clss, entity *member);
+int     get_class_n_member (type *clss);
+entity *get_class_member   (type *clss, int pos);
+void    set_class_member   (type *clss, entity *member, int pos);
+
+void    add_class_subtype   (type *clss, type *subtype);
+int     get_class_n_subtype (type *clss);
+type   *get_class_subtype   (type *clss, int pos);
+void    set_class_subtype   (type *clss, type *subtype, int pos);
+
+void    add_class_supertype   (type *clss, type *supertype);
+int     get_class_n_supertype (type *clss);
+type   *get_class_supertype   (type *clss, int pos);
+void    set_class_supertype   (type *clss, type *supertype, int pos);
+
+/* typecheck */
+bool    is_class_type(type *clss);
+/*****/
+
+/****** type/struct
+ * NAME
+ *  Representation of a struct type.
+ * NOTE
+ *  Type_strct represents aggregate types that consist of a list
+ *  of fields.
+ * ATTRIBUTES
+ *  member   All entities belonging to this class.  This are the fields
+ *           that can have any of the following types:  type_class,
+ *           type_struct, type_union, type_array, type_enumeration,
+ *          type_pointer, type_primitive.
+ *           This is a dynamic list that can be grown with an "add_" function,
+ *           but not shrinked.
+ * SOURCE
+ */
+/* create a new type struct */
+type   *new_type_struct (ident *name);
+
+/* manipulate private fields of struct */
+void    add_struct_member   (type *strct, entity *member);
+int     get_struct_n_member (type *strct);
+entity *get_struct_member   (type *strct, int pos);
+void    set_struct_member   (type *strct, int pos, entity *member);
+
+/* typecheck */
+bool    is_struct_type(type *strct);
+/*****/
+
+/****** type/method
+ * NAME
+ *  Representation of a method type.
+ * NOTE
+ *  A method type represents a method, function or procedure type.
+ *  It contains a list of the parameter and result types, as these
+ *  are part of the type description.  These lists should not
+ *  be changed by a optimization, as a change creates a new method
+ *  type.  Therefore optimizations should allocated new method types.
+ *  The set_ routines are only for construction by a frontend.
+ * ATTRIBUTES
+ *  n_params    Number of parameters to the procedure.
+ *              A procedure in FIRM has only call by value parameters.
+ *
+ *  param_type  A list with the types of parameters.  This list is ordered.
+ *              The nth type in this list corresponds to the nth element
+ *              in the parameter tuple that is a result of the start node.
+ *             (See ircons.h for more information.)
+ *
+ *  n_res       The number of results of the method.  In general, procedures
+ *              have zero results, functions one.
+ *
+ *  res_type    A list with the types of parameters.  This list is ordered.
+ *              The nth type in this list corresponds to the nth input to
+ *             Return nodes.  (See ircons.h for more information.)
+ * SOURCE
+ */
+
+/* Create a new method type.
+   N_param is the number of parameters, n_res the number of results.
+   The arrays for the parameter and result types are not initialized by
+   the constructor. */
+type *new_type_method (ident *name, int n_param, int n_res);
+
+/* manipulate private fields of method. */
+int   get_method_n_params  (type *method);
+type *get_method_param_type(type *method, int pos);
+void  set_method_param_type(type *method, int pos, type* type);
+
+int   get_method_n_res   (type *method);
+type *get_method_res_type(type *method, int pos);
+void  set_method_res_type(type *method, int pos, type* type);
+
+/* typecheck */
+bool  is_method_type     (type *method);
+/*****/
+
+/****** type/union
+ * NAME
+ *   Representation of a union type.
+ * NOTE
+ *   The union type represents union types.
+ * ATTRIBUTES
+ *   n_types        Number of unioned types.
+ *   unioned_type   A list of unioned types.
+ *   delim_names    Idents for the names of the union delimiters.
+ * SOURCE
+ */
+/* create a new type union
+   The arrays for the types and idents are not initialized by the
+   constructor. */
+type  *new_type_union (ident *name, int n_types);
+
+/* manipulate private fields of struct */
+int    get_union_n_types      (type *uni);
+
+type  *get_union_unioned_type (type *uni, int pos);
+void   set_union_unioned_type (type *uni, int pos, type *type);
+
+ident *get_union_delim_nameid (type *uni, int pos);
+const char *get_union_delim_name (type *uni, int pos);
+void   set_union_delim_nameid (type *uni, int pos, ident *id);
+
+/* typecheck */
+bool   is_union_type          (type *uni);
+/*****/
+
+/****** type/array
+ * NAME
+ *   Representation of an array type.
+ * NOTE
+ *   The array type represents rectangular multi dimensional arrays.
+ * ATTRIBUTES
+ *   n_dimensions     Number of array dimensions.
+ *   *lower_bound     Lower bounds of dimensions.  Usually all 0.
+ *   *upper_bound     Upper bounds or dimensions.
+ *   *element_type    The type of the array elements.
+ * SOURCE
+ */
 /* create a new type array -- set dimension sizes independently */
-type_array *new_type_array (ident *name, int n_dimensions);
-
-/* manipulate fields of type_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);
+type *new_type_array         (ident *name, int n_dimensions);
+
+/* manipulate private fields of array type */
+int   get_array_n_dimensions (type *array);
+void  set_array_bounds       (type *array, int dimension, int lower_bound,
+                                                          int upper_bound);
+void  set_array_lower_bound  (type *array, int dimension, int lower_bound);
+void  set_array_upper_bound  (type *array, int dimension, int upper_bound);
+int   get_array_lower_bound  (type *array, int dimension);
+int   get_array_upper_bound  (type *array, int dimension);
+
+void  set_array_element_type (type *array, type *type);
+type *get_array_element_type (type *array);
+
+/* typecheck */
+bool   is_array_type         (type *array);
+/*****/
+
+/****** type/enumeration
+ * NAME
+ *  Representation of an enumeration type.
+ * NOTE
+ *  Enumeration types need not necessarily be represented explicitly
+ *  by Firm types, as the frontend can lower them to integer constants as
+ *  well.  For debugging purposes or similar tasks this information is useful.
+ * ATTRIBUTES
+ *   *enum           The target values representing the constants used to
+ *                   represent individual enumerations.
+ *   *enum_nameid    Idents containing the source program name of the enumeration
+ *                  constants
+ *
+*****
 */
-void  set_array_n_dimensions  (type_array *array, int n);
-int   get_array_n_dimensions  (type_array *array);
-
-void  set_array_bounds      (type_array *array, int dimension, int lower_bound,
-                                                              int upper_bound);
-void  set_array_lower_bound (type_array *array, int dimension, int lower_bound);
-void  set_array_upper_bound (type_array *array, int dimension, int upper_bound);
-int   get_array_lower_bound (type_array *array, int dimension);
-int   get_array_upper_bound (type_array *array, int dimension);
-
-void  set_array_element_type (type_array *array, type *type);
-type *get_array_element_type (type_array *array);
-
-/*******************************************************************/
-/** TYPE_ENUMERATION                                              **/
-/*******************************************************************/
-/** Enums are needed to keep debugging information.  They can as well
-    be lowered to integers. **/
-
-typedef struct {
-  firm_kind kind;
-  ident *name;
-  /*
-  tarval **enum     * Contains all constant nodes that represent a member
-                      of the enum -- enumerators. */
-  /*
-  ident **enum_name * Contains the names of the enum fields as specified by
-                      the source program */
-  /* is ir_node the propper array member? */
-  unsigned long visit;     /* visited counter for walks of the type information */
-} type_enumeration;
-
 /* create a new type enumeration -- set the enumerators independently */
-type_enumeration *new_type_enumeration (ident *name /* , int n_enums */);
-
-/* manipulate fields of type_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);
-*/
-/*
-void     set_enumeration_n_enums (type_enumeration *enumeration, int n);
-int     *get_enumeration_n_enums (type_enumeration *enumeration);
-void     set_enumeration_enum    (type_enumeration *enumeration, int pos,
-                                 ir_node const);
-ir_node *get_enumeration_enum    (type_enumeration *enumeration, int pos);
-*/
-
-/*******************************************************************/
-/** TYPE_POINTER                                                  **/
-/*******************************************************************/
-
-typedef struct {
-  firm_kind kind;
-  ident *name;
-  /* ir_mode *mode;      * The mode to be used for this type.
-                            Not here as there might be several pointer types?
-                            A method get_pointer_mode should read a unique,
-                            global variable. */
-  type *points_to;
-  unsigned long visit;     /* visited counter for walks of the type information */
-} type_pointer;
-
-/* create a new type pointer */
-type_pointer *new_type_pointer (ident *name, type *points_to);
+type   *new_type_enumeration    (ident *name, int n_enums);
+
+/* manipulate fields of enumeration type. */
+int     get_enumeration_n_enums (type *enumeration);
+
+void    set_enumeration_enum    (type *enumeration, int pos, tarval *con);
+tarval *get_enumeration_enum    (type *enumeration, int pos);
+
+void    set_enumeration_nameid  (type *enumeration, int pos, ident *id);
+ident  *get_enumeration_nameid  (type *enumeration, int pos);
+const char *get_enumeration_name(type *enumeration, int pos);
+
+/* typecheck */
+bool    is_enumeration_type     (type *enumeration);
+/*****/
+
+/****** type/pointer
+ * NAME
+ *   Representation of a pointer type.
+ * NOTE
+ *   Pointer types.
+ * ATTRIBUTES
+ *   points_to       The type of the entity this pointer points to.
+ * SOURCE
+ */
+/* Create a new type pointer */
+type *new_type_pointer           (ident *name, type *points_to);
 
 /* manipulate fields of type_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);
-void   set_pointer_ident (type_pointer *pointer, ident* ident);
+void  set_pointer_points_to_type (type *pointer, type *type);
+type *get_pointer_points_to_type (type *pointer);
+
+/* typecheck */
+bool  is_pointer_type            (type *pointer);
+/*****/
+
+/****** type/primitive
+ * NAME
+ *   Representation of a primitive type.
+ * NOTE
+ *   Primitive types are types that represent indivisible data values that
+ *   map directly to modes.  They don't have a private attribute.  The
+ *   important information they carry is held in the common mode field.
+ * SOURCE
 */
-void  set_pointer_points_to_type (type_pointer *pointer, type *type);
-type *get_pointer_points_to_type (type_pointer *pointer);
-
-/*******************************************************************/
-/** TYPE_PRIMITIVE                                                **/
-/*******************************************************************/
-
-/* primitive, language-defined types */
-/* What is the type of an entity if it is atomic?  Are alle basic data
-   types classses in Sather? Else this is needed. */
-typedef struct {
-  firm_kind kind;
-  ident *name;
-  ir_mode *mode;           /* The mode to be used for this type */
-  unsigned long visit;     /* visited counter for walks of the type information */
-} type_primitive;
-
 /* create a new type primitive */
-type_primitive *new_type_primitive (ident *name, ir_mode *mode);
-
-/* manipulate fields of type_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);
-void   set_primitive_ident (type_primitive *primitive, ident* ident);
-*/
-ir_mode *get_primitive_mode (type_primitive *primitive);
-void     set_primitive_mode (type_primitive *primitive, ir_mode *mode);
-
-
-
-
-/*******************************************************************/
-/**  To manage all different types the same                       **/
-/*******************************************************************/
-
-union type {
-  firm_kind kind;
-  type_class clss;
-  type_strct strct;
-  type_method method;
-  type_array array;
-  type_union uni;  /* union is keyword */
-  type_enumeration enumeration;
-  type_pointer pointer;
-  type_primitive primitive;
-};
-
-
-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);
-
-
+type *new_type_primitive (ident *name, ir_mode *mode);
 
+/* typecheck */
+bool  is_primitive_type  (type *primitive);
+/*****/
 
 # endif /* _TYPE_H_ */
index 5f136b6..5fe1eaa 100644 (file)
@@ -23,6 +23,7 @@
 
 /* Make types visible to allow most efficient access */
 # include "entity_t.h"
+#include "type_t.h"
 
 typedef struct type_walk_env {
   void *pre;
@@ -36,157 +37,128 @@ void type_walk_2(type_or_ent *tore,
               void (post)(type_or_ent*, void*),
               void *env)
 {
-  int i, visited = 0;
+  int i;
 
   /* marked? */
   switch (get_kind(tore)) {
   case k_entity:
-    if (((entity *)tore)->visit >= type_visited) visited = 1; break;
-  case k_type_class:
-    if (((type_class *)tore)->visit >= type_visited) visited = 1; break;
-  case k_type_strct:
-    if (((type_strct *)tore)->visit >= type_visited) visited = 1; break;
-  case k_type_method:
-    if (((type_method *)tore)->visit >= type_visited) visited = 1; break;
-  case k_type_union:
-    if (((type_union *)tore)->visit >= type_visited) visited = 1; break;
-  case k_type_array:
-    if (((type_array *)tore)->visit >= type_visited) visited = 1; break;
-  case k_type_enumeration:
-    if (((type_enumeration *)tore)->visit >= type_visited) visited = 1; break;
-  case k_type_pointer:
-    if (((type_pointer *)tore)->visit >= type_visited) visited = 1;  break;
-  case k_type_primitive:
-    if (((type_primitive *)tore)->visit >= type_visited) visited = 1;  break;
+    if (((entity *)tore)->visit >= type_visited) return; break;
+  case k_type:
+    if (((type *)tore)->visit >= type_visited) return; break;
   default:
     break;
   }
 
-  if (!visited) { /* not marked. */
-
-    /* execute pre method */
-    if(pre)
-      pre(tore, env);
-
-    /* iterate */
-    switch (get_kind(tore)) {
-    case k_entity:
-      {
-       entity *ent = (entity *)tore;
-       ent->visit = type_visited;
-       type_walk_2((type_or_ent *)get_entity_owner(ent), pre, post, env);
-       type_walk_2((type_or_ent *)get_entity_type(ent), pre, post, env);
-      }
-      break;
-    case k_type_class:
-      {
-       int i;
-       ((type_class *)tore)->visit = type_visited;
-       /* CS */
-       for (i=0; i<get_class_n_member((type_class *)tore); i++)
-         {
-           type_walk_2((type_or_ent *)get_class_member((type_class *)tore, i),
-                       pre, post, env);
-         }
-       for (i=0; i<get_class_n_subtype((type_class *)tore); i++)
-         {
-           type_walk_2((type_or_ent *)get_class_subtype((type_class *)tore, i),
-                       pre, post, env);
-         }
-       for (i=0; i<get_class_n_supertype((type_class *)tore); i++)
+  /* execute pre method */
+  if(pre)
+    pre(tore, env);
+
+  /* iterate */
+  switch (get_kind(tore)) {
+  case k_entity:
+    {
+
+      entity *ent = (entity *)tore;
+      ent->visit = type_visited;
+      type_walk_2((type_or_ent *)get_entity_owner(ent), pre, post, env);
+      type_walk_2((type_or_ent *)get_entity_type(ent), pre, post, env);
+    }
+    break;
+  case k_type:
+    {
+      type *tp = (type *)tore;
+      mark_type_visited(tp);
+      switch (get_type_tpop_code(tp))
+       case tpo_class:
          {
-           type_walk_2((type_or_ent *)get_class_supertype((type_class *)tore, i),
+           for (i=0; i<get_class_n_member(tp); i++)
+             type_walk_2((type_or_ent *)get_class_member(tp, i), pre, post, env);
+           for (i=0; i<get_class_n_subtype(tp); i++)
+             type_walk_2((type_or_ent *)get_class_subtype(tp, i), pre, post, env);
+           for (i=0; i<get_class_n_supertype(tp); i++)   {
+             type_walk_2((type_or_ent *)get_class_supertype(tp, i), pre, post, env);
+           }
+           break;
+         case tpo_struct:
+           {
+             for (i=0; i<get_struct_n_member(tp); i++)
+               type_walk_2((type_or_ent *)get_struct_member(tp, i), pre, post, env);
+           }
+           break;
+         case tpo_method:
+           {
+             for (i = 0; i < get_method_n_params(tp); i++)
+               type_walk_2((type_or_ent *)get_method_param_type(tp, i), pre, post, env);
+             for (i = 0; i < get_method_n_res(tp); i++)
+               type_walk_2((type_or_ent *)get_method_res_type(tp, i), pre, post, env);
+           }
+           break;
+         case tpo_union:
+           {
+             for (i = 0; i < get_union_n_types(tp); i++)
+               type_walk_2((type_or_ent *)get_union_unioned_type(tp, i), pre, post, env);
+           }
+           break;
+         case tpo_array:
+           type_walk_2((type_or_ent *)get_array_element_type(tp),
                        pre, post, env);
-         }
-      }
-      break;
-    case k_type_strct:
-      {
-       int i;
-
-       ((type_strct *)tore)->visit = type_visited;
-       /* CS */
-       for (i=0; i<get_strct_n_member((type_strct *)tore); i++)
-         {
-           type_walk_2((type_or_ent *)get_strct_member((type_strct *)tore, i),
+           break;
+         case tpo_enumeration:
+           /* a leave */
+           break;
+         case tpo_pointer:
+           type_walk_2((type_or_ent *)get_pointer_points_to_type(tp),
                        pre, post, env);
+           break;
+         case tpo_primitive:
+           /* a leave. */
+           break;
+         default:
+           printf(" *** Faulty type! \n");
+           break;
          }
-      }
-      break;
-    case k_type_method:
-      {
-       type_method *meth  = (type_method *)tore;
-       meth->visit = type_visited;
-       for (i = 0; i < get_method_arity(meth); i++)
-         type_walk_2((type_or_ent *)get_method_param_type(meth, i), pre, post, env);
-       for (i = 0; i < get_method_n_res(meth); i++)
-         type_walk_2((type_or_ent *)get_method_res_type(meth, i), pre, post, env);
-      }
-      break;
-    case k_type_union:
-      ((type_union *)tore)->visit = type_visited;
-      /* !!!!! */
-      break;
-    case k_type_array:
-      ((type_array *)tore)->visit = type_visited;
-      type_walk_2((type_or_ent *)get_array_element_type((type_array *)tore),
-                 pre, post, env);
-      break;
-    case k_type_enumeration:
-      ((type_enumeration *)tore)->visit = type_visited;
-      /* a leave */
-      break;
-    case k_type_pointer:
-      ((type_pointer *)tore)->visit = type_visited;
-      type_walk_2((type_or_ent *)get_pointer_points_to_type((type_pointer *)tore),
-                 pre, post, env);
-      break;
-    case k_type_primitive:
-      ((type_primitive *)tore)->visit = type_visited;
-      /* a leave. */
-      break;
-    default:
-      break;
-    }
-
-    /* execute post method */
-    if(post)
-      post(tore, env);
+    } break; /* end case k_type */
+  default:
+    printf(" *** Faulty type or entity! \n");
+    break;
   }
 
+  /* execute post method */
+  if(post)
+    post(tore, env);
+
   return;
 }
 
 void start_type_walk(ir_node *node, void *env) {
   void *pre  = ((type_walk_env *)env)->pre;
   void *post = ((type_walk_env *)env)->post;
-  void *envi  = ((type_walk_env *)env)->env;
+  void *envi = ((type_walk_env *)env)->env;
 
   assert(node);
 
-    switch (get_irn_opcode(node)) {  /* node label */
-    case iro_SymConst:
-      if (   (get_SymConst_kind(node) == type_tag)
-         || (get_SymConst_kind(node) == size))
-       type_walk_2((type_or_ent *)get_SymConst_type(node), pre, post, envi);
-      break;
-    case iro_Sel:
-      type_walk_2((type_or_ent *)get_Sel_entity(node), pre, post, envi);
-      break;
-    case iro_Call:
-      type_walk_2((type_or_ent *)get_Call_type(node), pre, post, envi);
-      break;
-    case iro_Alloc:
-      type_walk_2((type_or_ent *)get_Alloc_type(node), pre, post, envi);
-      break;
-    case iro_Free:
-      printf("here in typewalk\n");
-      type_walk_2((type_or_ent *)get_Free_type(node), pre, post, envi);
-      break;
-  assert(node);
-    default:
-      break;
-    }
+  switch (get_irn_opcode(node)) {  /* node label */
+  case iro_SymConst:
+    if (   (get_SymConst_kind(node) == type_tag)
+          || (get_SymConst_kind(node) == size))
+      type_walk_2((type_or_ent *)get_SymConst_type(node), pre, post, envi);
+    break;
+  case iro_Sel:
+    type_walk_2((type_or_ent *)get_Sel_entity(node), pre, post, envi);
+    break;
+  case iro_Call:
+    type_walk_2((type_or_ent *)get_Call_type(node), pre, post, envi);
+    break;
+  case iro_Alloc:
+    type_walk_2((type_or_ent *)get_Alloc_type(node), pre, post, envi);
+    break;
+  case iro_Free:
+    printf("here in typewalk\n");
+    type_walk_2((type_or_ent *)get_Free_type(node), pre, post, envi);
+    break;
+  default:
+    break;
+  }
 }
 
 void type_walk(void (pre)(type_or_ent*, void*),
@@ -218,6 +190,6 @@ void type_walk_irg (ir_graph *irg,
 
   type_walk_2((type_or_ent *)get_irg_ent(irg), pre, post, env);
 
-  /* @@@ free type_walk_env!! */
+  free(type_env);
   return;
 }
index 4698219..fcda4f5 100644 (file)
@@ -44,26 +44,26 @@ int
 main(void)
 {
   /* describes the method main */
-  type_class     *owner;
-  type_method    *proc_main;
-  entity         *proc_main_e;
+  type     *owner;
+  type     *proc_main;
+  entity   *proc_main_e;
 
   /* describes types defined by the language */
-  type_primitive *prim_t_int;
+  type     *prim_t_int;
 
   /* describes the array and its fields. */
-  type_array     *array_type;   /* the type information for the array */
-  entity         *array_ent;    /* the entity representing a field of the array */
+  type     *array_type;   /* the type information for the array */
+  entity   *array_ent;    /* the entity representing a field of the array */
 
   /* Needed while finding the element size.  */
-  type_primitive *elt_type;
-  ir_mode        *elt_type_mode;
-  int            size;
-  ir_node        *arr_size;
+  type     *elt_type;
+  ir_mode  *elt_type_mode;
+  int       size;
+  ir_node  *arr_size;
 
   /* holds the graph and nodes. */
-  ir_graph       *main_irg;
-  ir_node        *array, *array_ptr, *c3, *elt, *val, *x;
+  ir_graph *main_irg;
+  ir_node  *array, *array_ptr, *c3, *elt, *val, *x;
 
   init_firm ();
 
@@ -89,7 +89,7 @@ main(void)
 # define U_BOUND 9
   array_type = new_type_array(id_from_str("a", 1), N_DIMS);
   set_array_bounds(array_type, 1, L_BOUND, U_BOUND);
-  set_array_element_type(array_type, (union type*)prim_t_int);
+  set_array_element_type(array_type, prim_t_int);
   /* As the array is accessed by Sel nodes, we need information about
      the entity the node selects.  Entities of an array are it's elements
      which are, in this case, integers. */
@@ -100,9 +100,8 @@ main(void)
      are not modeled by dataflow edges need an explicit allocate node.
      If the variable shall be placed on the stack, set stack_alloc.  */
   /*   first compute size in bytes. */
-  elt_type = (type_primitive *)get_array_element_type(array_type);
-  if (! (elt_type->kind == k_type_primitive)) printf(" do something else\n");
-  elt_type_mode = get_primitive_mode(elt_type);
+  elt_type = get_array_element_type(array_type);
+  elt_type_mode = get_type_mode(elt_type);
   /*   better: read bounds out of array type information */
   size = (U_BOUND - L_BOUND + 1) * get_mode_size(elt_type_mode);
   /*   make constant representing the size */
index 4280e6f..2c18f6c 100644 (file)
@@ -36,22 +36,22 @@ int
 main(void)
 {
   /* describes the general structure of a C-file */
-  type_class     *owner;        /* the class standing for everything in this file */
-  type_method    *proc_main;    /* Typeinformation for method main. */
+  type           *owner;        /* the class standing for everything in this file */
+  type           *proc_main;    /* Typeinformation for method main. */
   entity         *proc_main_e;  /* The entity describing that method main is an
                                    entity of the fake class representing the file. */
 
   /* describes types defined by the language */
-  type_primitive *prim_t_int;
+  type           *prim_t_int;
 
   /* describes the array and its fields. */
   entity         *array_ent;    /* the entity representing the array as member
                                    of the stack/method */
-  type_array     *array_type;   /* the type information for the array */
+  type           *array_type;   /* the type information for the array */
   entity         *field_ent;    /* the entity representing a field of the array */
 
   /* Needed while finding the element size.  */
-  type_primitive *elt_type;
+  type           *elt_type;
   ir_mode        *elt_type_mode;
   int            size;
   ir_node        *arr_size;
@@ -75,8 +75,8 @@ main(void)
   /* build typeinformation of procedure main */
   owner = new_type_class (id_from_str ("ARRAY-STACK_EXAMPLE", 19));
   proc_main = new_type_method(id_from_str("main", 4), 0, 1);
-  set_method_res_type(proc_main, 0, (type *)prim_t_int);
-  proc_main_e = new_entity ((type*)owner, id_from_str ("main", 4), (type *)proc_main);
+  set_method_res_type(proc_main, 0, prim_t_int);
+  proc_main_e = new_entity (owner, id_from_str ("main", 4), proc_main);
 
   main_irg = new_ir_graph (proc_main_e, 4);
 
@@ -86,15 +86,15 @@ main(void)
 # define U_BOUND 9
   array_type = new_type_array(id_from_str("a", 1), N_DIMS);
   set_array_bounds(array_type, 1, L_BOUND, U_BOUND);
-  set_array_element_type(array_type, (type*)prim_t_int);
+  set_array_element_type(array_type, prim_t_int);
   /* The array is an entity of the method, placed on the mehtod's own memory,
      the stack frame. */
-  array_ent = new_entity((type *)proc_main, id_from_str("a", 1), (type *)array_type);
+  array_ent = new_entity(proc_main, id_from_str("a", 1), array_type);
   /* As the array is accessed by Sel nodes, we need information about
      the entity the node select.  Entities of an array are it's elements
      which are, in this case, integers. */
   /* change entity owner types.   */
-  field_ent = new_entity((type*)array_type, id_from_str("array_field", 11), (type*)prim_t_int);
+  field_ent = new_entity(array_type, id_from_str("array_field", 11), prim_t_int);
 
   /* Now the "real" program: */
   /* Select the array from the stack frame.  */
index cfac7a3..7c8f5e2 100644 (file)
 
 int main(int argc, char **argv)
 {
-  ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *proc_main; /* type information for the method main */
-  type_method *proc_called; /* type information for called method f */
-  entity *ent;            /* represents this method as entity of owner */
-  ir_node *x, *const_str, *proc_ptr, *call;
+  ir_graph *irg;         /* this variable contains the irgraph */
+  type     *owner;       /* the class in which this method is defined */
+  type     *proc_main;   /* type information for the method main */
+  type     *proc_called; /* type information for called method f */
+  entity   *ent;         /* represents this method as entity of owner */
+  ir_node  *x, *const_str, *proc_ptr, *call;
 
   printf("\nCreating an IR graph: CALL_STR_EXAMPLE...\n");
 
@@ -59,8 +59,8 @@ int main(int argc, char **argv)
 
   /* Make the entity for main needed for a correct  ir_graph.  */
 #define ENTITYNAME "main"
-  ent = new_entity ((type *)owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)),
-                    (type *)proc_main);
+  ent = new_entity (owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)),
+                    proc_main);
 
   /* Generates the basic graph for the method represented by entity ent, that
    * is, generates start and end blocks and nodes and a first, initial block.
index bd6ca02..5f4694c 100644 (file)
 
 int main(int argc, char **argv)
 {
-  ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *method;    /* the type of this method */
-  entity *ent;            /* represents this method as entity of owner */
-  ir_node *x, *x_then, *arg1, *c2, *c10, *cmpGt, *cmpLt, *and, *f, *t, *b;
+  ir_graph *irg;       /* this variable contains the irgraph */
+  type     *owner;     /* the class in which this method is defined */
+  type     *method;    /* the type of this method */
+  entity   *ent;       /* represents this method as entity of owner */
+  ir_node  *x, *x_then, *arg1, *c2, *c10, *cmpGt, *cmpLt, *and, *f, *t, *b;
 
   printf("\nCreating an IR graph: COND_EXAMPLE...\n");
 
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
 
   owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
   method = new_type_method (id_from_str("main", 4), 0, 2);
-  ent = new_entity ((type *)owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)), (type *)method);
+  ent = new_entity (owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)), method);
 
 
   /* Generates the basic graph for the method represented by entity ent, that
index a8e1635..3e7b6e9 100644 (file)
@@ -26,8 +26,8 @@ int
 main(void)
 {
   ir_graph *irg;
-  type_class *owner;
-  type_method *method;    /* the type of this method */
+  type *owner;
+  type *method;    /* the type of this method */
   entity *ent;
   ir_node *a, *b, *c, *d, *x;
 
@@ -42,7 +42,7 @@ main(void)
 
   owner = new_type_class (id_from_str ("CONST_EVAL_EXAMPLE", 18));
   method = new_type_method (id_from_str("main", 4), 0, 2);
-  ent = new_entity ((type *)owner, id_from_str ("main", 4), (type *)method);
+  ent = new_entity (owner, id_from_str ("main", 4), method);
 
   irg = new_ir_graph (ent, 4);
 
index 1809a44..cc3522b 100644 (file)
@@ -45,8 +45,8 @@
 int main(int argc, char **argv)
 {
   ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *proc_main; /* type information for the method main */
+  type *owner;      /* the class in which this method is defined */
+  type *proc_main; /* type information for the method main */
   entity *ent;            /* represents this method as entity of owner */
   ir_node *c1, *c2, *cond, *f, *t, *endBlock, *Block1, *jmp, *Block2,
           *deadBlock, *x;
@@ -71,9 +71,9 @@ int main(int argc, char **argv)
   owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
   proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
                               NRARGS, NRES);
-  ent = new_entity ((type *)owner,
+  ent = new_entity (owner,
                     id_from_str (METHODNAME, strlen(METHODNAME)),
-                    (type *)proc_main);
+                    proc_main);
 
 #define NUM_OF_LOCAL_VARS 1
 
index 238da87..b5b0d1f 100644 (file)
 
 int main(int argc, char **argv)
 {
-  ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *proc_main; /* type information for the method main */
-  entity *ent;            /* represents this method as entity of owner */
-  ir_node *x;
+  ir_graph *irg;        /* this variable contains the irgraph */
+  type     *owner;      /* the class in which this method is defined */
+  type     *proc_main;  /* type information for the method main */
+  entity   *ent;        /* represents this method as entity of owner */
+  ir_node  *x;
 
   printf("\nCreating an IR graph: EMPTY...\n");
 
index 33da68c..c5e038e 100644 (file)
 
 int main(int argc, char **argv)
 {
-  ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *proc_main; /* type information for the method main */
-  type_primitive *prim_t_int;  /* describes int type defined by the language */
-  entity *main_ent;       /* represents this method as entity of owner */
-  entity *i_ent;          /* the entity representing the global variable i */
-  ir_node *x, *i_ptr, *store;
+  ir_graph *irg;        /* this variable contains the irgraph */
+  type     *owner;      /* the class in which this method is defined */
+  type     *proc_main;  /* type information for the method main */
+  type     *prim_t_int; /* describes int type defined by the language */
+  entity   *main_ent;   /* represents this method as entity of owner */
+  entity   *i_ent;      /* the entity representing the global variable i */
+  ir_node  *x, *i_ptr, *store;
 
   printf("\nCreating an IR graph: GLOBAL_VAR ...\n");
 
@@ -63,9 +63,9 @@ int main(int argc, char **argv)
   owner = get_glob_type();
   proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
                               NRARGS, NRES);
-  main_ent = new_entity ((type *)owner,
+  main_ent = new_entity (owner,
                         id_from_str (METHODNAME, strlen(METHODNAME)),
-                        (type *)proc_main);
+                        proc_main);
 
   /* Generates the basic graph for the method represented by entity main_ent, that
    * is, generates start and end blocks and nodes and a first, initial block.
@@ -74,9 +74,9 @@ int main(int argc, char **argv)
 #define NUM_OF_LOCAL_VARS 0
 
   /* Generate the entities for the global variables. */
-  i_ent = new_entity ((type *)get_glob_type(),
+  i_ent = new_entity (get_glob_type(),
                      id_from_str ("i", strlen("i")),
-                     (type *)prim_t_int);
+                     prim_t_int);
 
   irg = new_ir_graph (main_ent, NUM_OF_LOCAL_VARS);
 
index ab19907..77a9bb5 100644 (file)
 
 int main(int argc, char **argv)
 {
-  ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *method;    /* the type of this method */
-  entity *ent;            /* represents this method as entity of owner */
-  ir_node *x, *x_then, *x_else, *c0, *c1, *c2, *cmpGt, *f, *t, *b;
+  ir_graph *irg;       /* this variable contains the irgraph */
+  type     *owner;     /* the class in which this method is defined */
+  type     *method;    /* the type of this method */
+  entity   *ent;       /* represents this method as entity of owner */
+  ir_node  *x, *x_then, *x_else, *c0, *c1, *c2, *cmpGt, *f, *t, *b;
 
   printf("\ncreating an IR graph: IF_ELSE_EXAMPLE...\n");
 
@@ -53,8 +53,8 @@ int main(int argc, char **argv)
 
   owner = get_glob_type();
   method = new_type_method (id_from_str("main", 4), 0, 2);
-  ent = new_entity ((type *)owner, id_from_str (ENTITYNAME,
-                   strlen(ENTITYNAME)), (type *)method);
+  ent = new_entity (owner, id_from_str (ENTITYNAME,
+                   strlen(ENTITYNAME)), method);
 
   /* Generates the basic graph for the method represented by entity ent, that
    * is, generates start and end blocks and nodes and a first, initial block.
index c93abed..9373260 100644 (file)
@@ -27,10 +27,10 @@ int
 main(void)
 {
   ir_graph *irg;
-  type_class *owner;
+  type *owner;
   entity *ent;
-  type_method *proc_main; /* type information for the method main */
-  type_primitive *typ;
+  type *proc_main; /* type information for the method main */
+  type *typ;
   ir_node *x, *r, *t, *f, *a, *cmp;
   int a_pos, b_pos;
 
@@ -46,14 +46,14 @@ main(void)
   owner = get_glob_type();
   proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
                              NRARGS, NRES);
-  ent = new_entity ((type *)owner,
+  ent = new_entity (owner,
                     id_from_str (METHODNAME, strlen(METHODNAME)),
-                    (type *)proc_main);
+                    proc_main);
 
 #define RES_NAME "int"
   typ = new_type_primitive(id_from_str(RES_NAME, strlen(RES_NAME)), mode_i);
-  set_method_param_type(proc_main, 0, (type*)typ);
-  set_method_res_type(proc_main, 0, (type*)typ);
+  set_method_param_type(proc_main, 0, typ);
+  set_method_res_type(proc_main, 0, typ);
 
   /* Generates start and end blocks and nodes and a first, initial block */
   irg = new_ir_graph (ent, 2);
index a58acba..20ffc26 100644 (file)
@@ -34,8 +34,8 @@ int
 main(void)
 {
   ir_graph *irg;
-  type_class *owner;
-  type_method *proc_main;
+  type *owner;
+  type *proc_main;
   entity *ent;
   ir_node *b, *x, *r, *t, *f;
 
@@ -57,7 +57,7 @@ main(void)
   proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
                               NRARGS, NRES);
   owner = new_type_class (id_from_str ("IF_WHILE_EXAMPLE", 16));
-  ent = new_entity ((type *)owner, id_from_str ("main", 4), (type *)proc_main);
+  ent = new_entity (owner, id_from_str ("main", 4), proc_main);
 
   /* Generates start and end blocks and nodes and a first, initial block */
   irg = new_ir_graph (ent, 4);
index 4cc155d..229b157 100644 (file)
@@ -37,9 +37,9 @@
 int main(int argc, char **argv)
 {
   ident *ii, *ci, *di, *ei, *m1i, *m2i, *inti, *ai; /* suffix i names identifiers */
-  type_class  *it, *ct, *dt, *et;                   /*        t names types       */
-  type_method *m1t, *m2t;
-  type_primitive *intt;
+  type  *it, *ct, *dt, *et;                   /*        t names types       */
+  type  *m1t, *m2t;
+  type  *intt;
   entity *c_m1e, *c_m2e, *e_m2e, *d_ae, *e_ae;        /*        e names entities    */
 
   ir_node *x;
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
 
   /** add structure to type graph **/
   /* parameters of methods */
-  set_method_param_type(m2t, 0, (type *)intt);
+  set_method_param_type(m2t, 0, intt);
   /* inheritance */
   add_class_subtype(it, ct);
   add_class_subtype(ct, et);
@@ -82,11 +82,11 @@ int main(int argc, char **argv)
   add_class_supertype(et, dt);
 
   /** make entities **/
-  c_m1e = new_entity((type *)ct, m1i, (type *)m1t);
-  c_m2e = new_entity((type *)ct, m2i, (type *)m2t);
-  e_m2e = new_entity((type *)et, m2i, (type *)m2t);
-  d_ae = new_entity((type *)dt, ai, (type *)intt);
-  e_ae = new_entity((type *)et, ai, (type *)intt);
+  c_m1e = new_entity(ct, m1i, m1t);
+  c_m2e = new_entity(ct, m2i, m2t);
+  e_m2e = new_entity(et, m2i, m2t);
+  d_ae  = new_entity(dt, ai, intt);
+  e_ae  = new_entity(et, ai, intt);
 
   printf("Done building the graph.  Dumping it.\n");
   dump_all_types();
index 5feee43..8f231a6 100644 (file)
 
 int main(int argc, char **argv)
 {
-  ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *proc_main; /* typeinformation for the method main */
-  entity *ent;            /* represents this method as entity of owner */
-  ir_node *expr, *c1, *c2, *cond, *f, *t, *jmp, *x;
+  ir_graph *irg;        /* this variable contains the irgraph */
+  type     *owner;      /* the class in which this method is defined */
+  type     *proc_main;  /* typeinformation for the method main */
+  entity   *ent;        /* represents this method as entity of owner */
+  ir_node  *expr, *c1, *c2, *cond, *f, *t, *jmp, *x;
 
   printf("\nCreating an IR graph: IRR_CF...\n");
 
index dff1dfa..43c1d00 100644 (file)
 
 int main(int argc, char **argv)
 {
-  ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *proc_main; /* typeinformation for the method main */
-  entity *ent;            /* represents this method as entity of owner */
-  ir_node *expr, *c1, *c2, *c3, *cond, *f, *t, *loopBlock1, *f_l1, *t_l1,
-          *loopBlock2, *f_l2, *t_l2, *x;
+  ir_graph *irg;        /* this variable contains the irgraph */
+  type     *owner;      /* the class in which this method is defined */
+  type     *proc_main;  /* typeinformation for the method main */
+  entity   *ent;        /* represents this method as entity of owner */
+  ir_node  *expr, *c1, *c2, *c3, *cond, *f, *t, *loopBlock1, *f_l1, *t_l1,
+           *loopBlock2, *f_l2, *t_l2, *x;
 
 
   /* init library */
@@ -65,9 +65,9 @@ int main(int argc, char **argv)
   owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
   proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
                               NRARGS, NRES);
-  ent = new_entity ((type *)owner,
+  ent = new_entity (owner,
                     id_from_str (METHODNAME, strlen(METHODNAME)),
-                    (type *)proc_main);
+                    proc_main);
 
 #define NUM_OF_LOCAL_VARS 0
 
index 9a70fac..5366b4a 100644 (file)
@@ -53,10 +53,10 @@ int
 main(void)
 {
   ir_graph *irg;
-  type_class *owner;
-  type_method *method;    /* the type of this method */
-  entity *ent;
-  ir_node *a, *b, *x, *y, *r;
+  type     *owner;
+  type     *method;    /* the type of this method */
+  entity   *ent;
+  ir_node  *a, *b, *x, *y, *r;
 
   printf("\nCreating an IR graph: MEMORY_EXAMPLE...\n");
 
@@ -67,7 +67,7 @@ main(void)
   /* a class to get started with, containing the main procedure */
   owner = new_type_class (id_from_str ("MEMORY_EXAMPLE", 14));
   method = new_type_method (id_from_str("main", 4), 0, 2);
-  ent = new_entity ((type *)owner, id_from_str ("main", 4), (type *)method);
+  ent = new_entity (owner, id_from_str ("main", 4), method);
 
   /* Generates start and end blocks and nodes and a first, initial block */
   irg = new_ir_graph (ent, 4);
index 852dd66..32370fb 100644 (file)
 int
 main(void)
 {
-  type_primitive *prim_t_int;
-  type_class   *owner, *class_prima, *class_langint;
-  type_method  *proc_main, *proc_set, *proc_c;
-  type_pointer *class_p_ptr;
-  entity       *proc_main_e, *proc_set_e, *proc_c_e, *a_e;
+  type     *prim_t_int;
+  type     *owner, *class_prima, *class_langint;
+  type     *proc_main, *proc_set, *proc_c;
+  type     *class_p_ptr;
+  entity   *proc_main_e, *proc_set_e, *proc_c_e, *a_e;
 
   ir_graph     *main_irg, *set_a_irg, *c_irg;
   ir_node      *c2, *c5, *obj_o, *obj_size, *proc_ptr, *call, *x;
@@ -62,10 +62,9 @@ main(void)
   printf("\nCreating an IR graph: OO_PROGRAM_EXAMPLE...\n");
   owner = get_glob_type();
   proc_main = new_type_method(id_from_str("main", 4), 0, 1);
-  set_method_res_type(proc_main, 0, (type *)prim_t_int);
+  set_method_res_type(proc_main, 0, prim_t_int);
 
-  proc_main_e = new_entity ((type *)owner, id_from_str ("main", 4),
-                            (type *)proc_main);
+  proc_main_e = new_entity (owner, id_from_str ("main", 4), proc_main);
   main_irg = new_ir_graph (proc_main_e, 4);
   /* Remark that this irg is the main routine of the program. */
   set_irp_main_irg(main_irg);
@@ -77,19 +76,18 @@ main(void)
   /* allocate the defined object and generate the type information */
   class_prima = new_type_class(id_from_str ("PRIMA", 5));
   obj_size = new_SymConst((type_or_id_p)class_prima, size);
-  obj_o    = new_Alloc(get_store(), obj_size, (type *)class_prima, heap_alloc);
+  obj_o    = new_Alloc(get_store(), obj_size, class_prima, heap_alloc);
   set_store(new_Proj(obj_o, mode_M, 0));  /* make the changed memory visible */
   obj_o    = new_Proj(obj_o, mode_p, 1);  /* remember the pointer to the object */
   /* we need type information for pointers to the class: */
   class_p_ptr = new_type_pointer (id_from_str ("class_prima_ptr", 15),
-                                 (type *)class_prima);
+                                 class_prima);
 
   /* get the pointer to the procedure from the class type */
   proc_set = new_type_method(id_from_str("set_a", 5), 2, 0);
-  set_method_param_type(proc_set, 0, (type *)class_p_ptr);
-  set_method_param_type(proc_set, 1, (type *)prim_t_int);
-  proc_set_e = new_entity((type *)class_prima, id_from_str ("set_a", 5),
-                         (type*)proc_set);
+  set_method_param_type(proc_set, 0, class_p_ptr);
+  set_method_param_type(proc_set, 1, prim_t_int);
+  proc_set_e = new_entity(class_prima, id_from_str ("set_a", 5), proc_set);
   proc_ptr = new_simpleSel(get_store(),  /* The memory the object is allocated in */
                      obj_o,             /* The pointer to the object */
                      proc_set_e );      /* The feature to select */
@@ -106,11 +104,10 @@ main(void)
 
   /* get the pointer to the procedure from the class type */
   proc_c   = new_type_method(id_from_str("c", 1 ), 2, 1);
-  set_method_param_type(proc_c, 0, (type *)class_p_ptr);
-  set_method_param_type(proc_c, 1, (type *)prim_t_int);
-  set_method_res_type(proc_c, 0, (type *)prim_t_int);
-  proc_c_e = new_entity((type *)class_prima, id_from_str ("c", 1),
-                       (type*)proc_c);
+  set_method_param_type(proc_c, 0, class_p_ptr);
+  set_method_param_type(proc_c, 1, prim_t_int);
+  set_method_res_type(proc_c, 0, prim_t_int);
+  proc_c_e = new_entity(class_prima, id_from_str ("c", 1), proc_c);
   proc_ptr = new_simpleSel(get_store(), obj_o, proc_c_e);
 
   /* call procedure c, first built array with parameters */
@@ -151,8 +148,8 @@ main(void)
   par1 = new_Proj(get_irg_args(set_a_irg), mode_I, 1);
   /* Create and select the entity to set */
   class_langint = new_type_class(id_from_str ("Int", 3));
-  a_e = new_entity((type *)class_prima, id_from_str ("a", 1),
-                  (type*)class_langint);
+  a_e = new_entity(class_prima, id_from_str ("a", 1),
+                  class_langint);
   a_ptr = new_simpleSel(get_store(), self, a_e);
   /* perform the assignment */
   set_store(new_Proj(new_Store(get_store(), a_ptr, par1), mode_M, 0));
index 201ad7a..c0f6cce 100644 (file)
@@ -49,8 +49,8 @@
 int main(int argc, char **argv)
 {
   ir_graph *irg;          /* this variable contains the irgraph */
-  type_class *owner;      /* the class in which this method is defined */
-  type_method *proc_main; /* type information for the method main */
+  type *owner;      /* the class in which this method is defined */
+  type *proc_main; /* type information for the method main */
   entity *ent;            /* represents this method as entity of owner */
   ir_node *c1, *c2, *cond, *f, *t, *endBlock, *Block1, *jmp,
           *scndCondBlock, *Block2, *Block3, *x;
@@ -74,9 +74,9 @@ int main(int argc, char **argv)
   proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
                              NRARGS, NRES);
   /** @@@ setting of arg/res types misses **/
-  ent = new_entity ((type *)owner,
+  ent = new_entity (owner,
                     id_from_str (METHODNAME, strlen(METHODNAME)),
-                    (type *)proc_main);
+                    proc_main);
 
 #define NUM_OF_LOCAL_VARS 2
 
index 3c19927..6e296bc 100644 (file)
 int
 main(void)
 {
-  type_primitive *prim_t_int;
+  type *prim_t_int;
   ir_graph *irg;
-  type_class *owner;
-  type_method *proc_main;
+  type *owner;
+  type *proc_main;
   entity *ent;
   ir_node *b, *x, *r, *t, *f;
 
@@ -54,10 +54,10 @@ main(void)
 
   proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
                               NRARGS, NRES);
-  set_method_param_type(proc_main, 0, (type *)prim_t_int);
+  set_method_param_type(proc_main, 0, prim_t_int);
 
   owner = new_type_class (id_from_str ("WHILE_EXAMPLE", 16));
-  ent = new_entity ((type *)owner, id_from_str ("main", 4), (type *)proc_main);
+  ent = new_entity (owner, id_from_str ("main", 4), proc_main);
 
   /* Generates start and end blocks and nodes and a first, initial block */
   irg = new_ir_graph (ent, 4);