2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Opcode of types.
9 * @author Goetz Lindenmaier, Michael Beck
18 const tp_op *type_class; const tp_op *get_tpop_class (void) { return type_class; }
19 const tp_op *type_struct; const tp_op *get_tpop_struct (void) { return type_struct; }
20 const tp_op *type_method; const tp_op *get_tpop_method (void) { return type_method; }
21 const tp_op *type_union; const tp_op *get_tpop_union (void) { return type_union; }
22 const tp_op *type_array; const tp_op *get_tpop_array (void) { return type_array; }
23 const tp_op *type_enumeration; const tp_op *get_tpop_enumeration(void) { return type_enumeration; }
24 const tp_op *type_pointer; const tp_op *get_tpop_pointer (void) { return type_pointer; }
25 const tp_op *type_primitive; const tp_op *get_tpop_primitive (void) { return type_primitive; }
26 const tp_op *tpop_code; const tp_op *get_tpop_code_type (void) { return tpop_code; }
27 const tp_op *tpop_none; const tp_op *get_tpop_none (void) { return tpop_none; }
28 const tp_op *tpop_unknown; const tp_op *get_tpop_unknown (void) { return tpop_unknown; }
31 new_tpop(tp_opcode code, ident *name, unsigned flags, size_t attr_size, const tp_op_ops *ops)
33 tp_op *res = XMALLOC(tp_op);
37 res->attr_size = attr_size;
42 memset(&res->ops, 0, sizeof(res->ops));
47 void free_tpop(const tp_op *tpop)
52 static const tp_op_ops
53 /** tpop operations for class types */
62 get_class_member_index
64 /** tpop operations for struct types */
73 get_struct_member_index
75 /** tpop operations for method types */
86 /** tpop operations for union types */
95 get_union_member_index
97 /** tpop operations for array types */
101 free_array_automatic_entities,
108 /** tpop operations for enumeration types */
110 free_enumeration_attrs,
111 free_enumeration_entities,
113 set_enumeration_mode,
119 /** tpop operations for pointer types */
122 free_pointer_entities,
130 /** tpop operations for pseudo types */
141 /** tpop operations for primitive types */
155 #define ID(s) new_id_from_chars(s, sizeof(s) - 1)
156 type_class = new_tpop(tpo_class , ID("class"), TP_OP_FLAG_COMPOUND, sizeof(cls_attr), &class_ops);
157 type_struct = new_tpop(tpo_struct , ID("struct"), TP_OP_FLAG_COMPOUND, sizeof(stc_attr), &struct_ops);
158 type_method = new_tpop(tpo_method , ID("method"), 0, sizeof(mtd_attr), &method_ops);
159 type_union = new_tpop(tpo_union , ID("union"), TP_OP_FLAG_COMPOUND, sizeof(uni_attr), &union_ops);
160 type_array = new_tpop(tpo_array , ID("array"), 0, sizeof(arr_attr), &array_ops);
161 type_enumeration = new_tpop(tpo_enumeration, ID("enumeration"), 0, sizeof(enm_attr), &enum_ops);
162 type_pointer = new_tpop(tpo_pointer , ID("pointer"), 0, sizeof(ptr_attr), &pointer_ops);
163 type_primitive = new_tpop(tpo_primitive , ID("primitive"), 0, sizeof(pri_attr), &null_ops);
164 tpop_code = new_tpop(tpo_code , ID("code"), 0, 0, &null_ops);
165 tpop_none = new_tpop(tpo_none , ID("None"), 0, 0, &pseudo_ops);
166 tpop_unknown = new_tpop(tpo_unknown , ID("Unknown"), 0, 0, &pseudo_ops);
170 void finish_tpop(void)
172 free_tpop(type_class ); type_class = NULL;
173 free_tpop(type_struct ); type_struct = NULL;
174 free_tpop(type_method ); type_method = NULL;
175 free_tpop(type_union ); type_union = NULL;
176 free_tpop(type_array ); type_array = NULL;
177 free_tpop(type_enumeration); type_enumeration = NULL;
178 free_tpop(type_pointer ); type_pointer = NULL;
179 free_tpop(type_primitive ); type_primitive = NULL;
180 free_tpop(tpop_code ); tpop_code = NULL;
181 free_tpop(tpop_none ); tpop_none = NULL;
182 free_tpop(tpop_unknown ); tpop_unknown = NULL;
185 const char *get_tpop_name(const tp_op *op)
187 return get_id_str(op->name);
190 tp_opcode (get_tpop_code)(const tp_op *op)
192 return _get_tpop_code(op);