* @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
* @version $Id$
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
#include <string.h>
#include <stdlib.h>
#include "tv_t.h"
#include "irdump.h"
#include "irgraph_t.h"
-
#include "callgraph.h"
-
-/**
- * An interval initializer.
- */
-typedef struct interval_initializer interval_initializer;
-
-/**
- * A value initializer.
- */
-typedef struct value_initializer value_initializer;
-
-struct interval_initializer {
- int first_index; /**< The first index of the initialized interval. */
- int last_index; /**< The last index of the initialized interval. */
- interval_initializer *next; /**< Points to the next interval initializer. */
-};
-
-struct value_initializer {
- ir_entity *ent; /**< The initialized entity. */
- value_initializer *next; /**< Points to the next value initializer. */
-};
-
-typedef union initializer {
- ir_node *value; /**< The value of the initializer. */
- ir_node **values; /**< The values of an interval. */
- value_initializer *val_init; /**< Points the the head of the next value initializers. */
- interval_initializer *int_init; /**< Points to the head of the next value initializers. */
-} initializer;
+#include "error.h"
/*-----------------------------------------------------------------*/
/** general **/
/**
* Add an entity to it's already set owner type.
*/
-static INLINE void insert_entity_in_owner(ir_entity *ent) {
+static inline void insert_entity_in_owner(ir_entity *ent) {
ir_type *owner = ent->owner;
switch (get_type_tpop_code(owner)) {
case tpo_class:
case tpo_array:
set_array_element_entity(owner, ent);
break;
- default: assert(0);
+ default:
+ panic("Unsupported type kind");
}
} /* insert_entity_in_owner */
*
* @return the new created entity
*/
-static INLINE ir_entity *
+static inline ir_entity *
new_rd_entity(dbg_info *db, ir_type *owner, ident *name, ir_type *type)
{
ir_entity *res;
assert(!id_contains_char(name, ' ') && "entity name should not contain spaces");
- res = xmalloc(sizeof(*res));
- memset(res, 0, sizeof(*res));
+ res = XMALLOCZ(ir_entity);
res->kind = k_entity;
res->name = name;
assert(ent->overwrittenby == NULL);
}
if (is_compound_entity(ent)) {
- if (ent->attr.cmpd_attr.val_paths) {
- for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i)
- if (ent->attr.cmpd_attr.val_paths[i]) {
- /* free_compound_graph_path(ent->attr.cmpd_attr.val_paths[i]) ; * @@@ warum nich? */
- /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
- /* DEL_ARR_F(ent->attr.cmpd_attr.val_paths); */
- }
- ent->attr.cmpd_attr.val_paths = NULL;
+ if (ent->has_initializer) {
+ /* TODO: free initializers */
+ } else {
+ if (ent->attr.cmpd_attr.val_paths) {
+ for (i = get_compound_ent_n_values(ent) - 1; i >= 0; --i)
+ if (ent->attr.cmpd_attr.val_paths[i]) {
+ /* free_compound_graph_path(ent->attr.cmpd_attr.val_paths[i]) ; * @@@ warum nich? */
+ /* Geht nich: wird mehrfach verwendet!!! ==> mehrfach frei gegeben. */
+ DEL_ARR_F(ent->attr.cmpd_attr.val_paths);
+ }
+ ent->attr.cmpd_attr.val_paths = NULL;
+ }
+ if (ent->attr.cmpd_attr.values)
+ DEL_ARR_F(ent->attr.cmpd_attr.values);
+ ent->attr.cmpd_attr.values = NULL;
}
- /* if (ent->attr.cmpd_attr.values) DEL_ARR_F(ent->attr.cmpd_attr.values); *//* @@@ warum nich? */
- ent->attr.cmpd_attr.values = NULL;
} else if (is_method_entity(ent)) {
if (ent->attr.mtd_attr.param_access) {
DEL_ARR_F(ent->attr.mtd_attr.param_access);
assert(get_type_state(new_owner) != layout_fixed);
if (old->owner == new_owner) return old;
- newe = xmalloc(sizeof(*newe));
+ newe = XMALLOC(ir_entity);
memcpy(newe, old, sizeof(*newe));
newe->owner = new_owner;
if (is_Class_type(new_owner)) {
assert(old && old->kind == k_entity);
if (old->name == new_name) return old;
- newe = xmalloc(sizeof(*newe));
+ newe = XMALLOC(ir_entity);
memcpy(newe, old, sizeof(*newe));
newe->name = new_name;
newe->ld_name = NULL;