added copyright information
[libfirm] / ir / tr / tpop.c
1 /*
2  * Project:     libFIRM
3  * File name:   ir/tr/tpop.c
4  * Purpose:     Opcode of types.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2001-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13
14 #ifdef HAVE_CONFIG_H
15 # include <config.h>
16 #endif
17
18 # include "misc.h"
19 # include "tpop_t.h"
20 # include "type_t.h"
21
22 tp_op *type_class;         tp_op *get_type_class      () { return type_class;       }
23 tp_op *type_struct;        tp_op *get_type_struct     () { return type_struct;      }
24 tp_op *type_method;        tp_op *get_type_method     () { return type_method;      }
25 tp_op *type_union;         tp_op *get_type_union      () { return type_union;       }
26 tp_op *type_array;         tp_op *get_type_array      () { return type_array;       }
27 tp_op *type_enumeration;   tp_op *get_type_enumeration() { return type_enumeration; }
28 tp_op *type_pointer;       tp_op *get_type_pointer    () { return type_pointer;     }
29 tp_op *type_primitive;     tp_op *get_type_primitive  () { return type_primitive;   }
30 tp_op *type_id;            tp_op *get_type_id         () { return type_id;          }
31
32 tp_op *
33 new_tpop (tp_opcode code, ident *name, size_t attr_size)
34 {
35   tp_op *res;
36
37   res = (tp_op *) xmalloc (sizeof (tp_op));
38   res->code = code;
39   res->name = name;
40   res->attr_size = attr_size;
41   return res;
42 }
43
44 void
45 init_tpop(void)
46 {
47   type_class       = new_tpop (tpo_class      , id_from_str("class"      , 5), sizeof (cls_attr));
48   type_struct      = new_tpop (tpo_struct     , id_from_str("struct"     , 6), sizeof (stc_attr));
49   type_method      = new_tpop (tpo_method     , id_from_str("method"     , 6), sizeof (mtd_attr));
50   type_union       = new_tpop (tpo_union      , id_from_str("union"      , 5), sizeof (uni_attr));
51   type_array       = new_tpop (tpo_array      , id_from_str("array"      , 5), sizeof (arr_attr));
52   type_enumeration = new_tpop (tpo_enumeration, id_from_str("enumeration",11), sizeof (enm_attr));
53   type_pointer     = new_tpop (tpo_pointer    , id_from_str("pointer"    , 7), sizeof (ptr_attr));
54   type_primitive   = new_tpop (tpo_primitive  , id_from_str("primitive"  , 9), /* sizeof (pri_attr) */ 0);
55   type_id          = new_tpop (tpo_id         , id_from_str("type_id"    , 7), /* sizeof (id_attr)  */ 0);
56 }
57
58 /* Returns the string for the tp_opcode. */
59 const char  *get_tpop_name      (tp_op *op) {
60   return get_id_str(op->name);
61 }
62
63 tp_opcode get_tpop_code (tp_op *op){
64   return op->code;
65 }
66
67 ident *get_tpop_ident(tp_op *op){
68   return op->name;
69 }
70
71 /* returns the attribute size of the operator. */
72 int get_tpop_attr_size (tp_op *op) {
73   return op->attr_size;
74 }