adding assertion to prevent recursive compound types
[libfirm] / ir / tr / tpop_t.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/tr/tpop_t.h
4  * Purpose:     Opcode of types -- private header.
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 # ifndef _TPOP_T_H_
13 # define _TPOP_T_H_
14
15 # include <stddef.h>
16 # include "tpop.h"
17 /**
18  * @file tpop_t.h
19  *
20  * This file contains the datatypes hidden in tpop.h.
21  *
22  * @author Goetz Lindenmaier
23  * @see  tpop.h
24  */
25
26 /** possible flags for a type opcode */
27 enum tp_op_flags_t {
28   TP_OP_FLAG_COMPOUND = 1   /**< is a compound type */
29 };
30
31 /** The type opcode */
32 struct tp_op {
33   tp_opcode code;       /**< the tpop code */
34   ident *name;          /**< the name of the type opcode */
35   size_t attr_size;     /**< the attribute size for a type of this opcode */
36   unsigned flags;       /**< flags for this opcode */
37 };
38
39 /**
40  *   Returns a new type opcode.
41  *
42  *   Allocates a new tp_op struct and initializes it's fields with
43  *   the passed values.  This function is only to be used during
44  *   initialization of the library.
45  *
46  *   @param code        the enum for this type opcode.
47  *   @param name        an ident for the name of the type opcode.
48  *   @param flags       additional flags
49  *   @param attr_size   the size of the attributes necessary for a type with
50  *                      this opcode
51  *   @return A new type opcode.
52  */
53 tp_op *new_tpop (tp_opcode code, ident *name, unsigned flags, size_t attr_size);
54
55 /**
56  * Free a tpop datastructure.
57  */
58 void free_tpop(tp_op* tpop);
59
60 /**
61  *   Initialize the tpop module.
62  *
63  *   Must be called during the initialization of the library. Allocates
64  *   opcodes and sets the globals that are external visible as specified
65  *   in tpop.h.
66  *   Allocates opcodes for classes, struct, method, union, array,
67  *   enumeration, pointer and primitive and sets the according values.
68  */
69 void init_tpop (void);
70
71 /**
72  *  Finalize the tpop module.
73  *
74  *  Frees all type opcodes.
75  */
76 void finish_tpop(void);
77
78 /**
79  *   Returns the size of the attribute to this kind
80  *   of type.
81  *
82  *   Internal feature.
83  *
84  *   @param op  The type opcode to get the size for.
85  *   @return The size of the attribute of types with this opcode.
86  *
87  */
88 int get_tpop_attr_size (const tp_op *op);
89
90
91 /* ---------------- *
92  * inline functions *
93  * -----------------*/
94
95 static INLINE tp_opcode
96 __get_tpop_code(const tp_op *op) {
97   return op->code;
98 }
99
100 static INLINE ident *
101 __get_tpop_ident(const tp_op *op){
102   return op->name;
103 }
104
105 static INLINE int
106 __get_tpop_attr_size(const tp_op *op) {
107   return op->attr_size;
108 }
109
110 #define get_tpop_code(op)      __get_tpop_code(op)
111 #define get_tpop_ident(op)     __get_tpop_ident(op)
112 #define get_tpop_attr_size(op) __get_tpop_attr_size(op)
113
114 #endif /* _TPOP_T_H_ */