/* -*- c -*- */
/*
- Project: libFIRM
- File name: ir/ana/pto_name.c
- Purpose: Names for abstract objects
- Author: Florian
- Modified by:
- Created: Sat Nov 13 19:35:27 CET 2004
- CVS-ID: $Id$
- Copyright: (c) 1999-2004 Universität Karlsruhe
- Licence: This file is protected by the GPL - GNU GENERAL PUBLIC LICENSE.
-*/
-
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief Names for abstract objects
+ * @author Florian
+ * @date Sat Nov 13 19:35:27 CET 2004
+ * @version $Id$
+ */
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
# include "pto_name.h"
# include "pto_util.h"
+#include <assert.h>
+
+#ifdef HAVE_STRING_H
# include <string.h> /* for memcpy */
-# include <obstack.h>
+#endif
# include <errno.h>
+# include "obst.h"
# include "irnode.h"
# include "irprog.h"
# include "xmalloc.h"
# endif /* defined PTO_COLOR */
/* See whether the given entity is a field. */
-static int is_field (entity *ent)
+static int is_field (ir_entity *ent)
{
- type *tp = get_entity_type (ent);
+ ir_type *tp = get_entity_type (ent);
if (is_Primitive_type (tp) || is_Pointer_type (tp)) {
/* actually, we don't get by by restricting ourselves to pointer types */
}
}
-/* Helper to collect_fields(type*): collect all fields of the given
+/* Helper to collect_fields(ir_type*): collect all fields of the given
clazz and its super classes into the given obstack. */
-static void _collect_fields (type *clazz, struct obstack *obst)
+static void _collect_fields (ir_type *clazz, struct obstack *obst)
{
int n_members = get_class_n_members (clazz);
int n_supers = get_class_n_supertypes (clazz);
int i;
for (i = 0; i < n_members; i ++) {
- entity *ent = get_class_member (clazz, i);
+ ir_entity *ent = get_class_member (clazz, i);
if (is_field (ent)) {
if (allocation_static != get_entity_allocation (ent)) {
}
for (i = 0; i < n_supers; i ++) {
- type *s_clazz = get_class_supertype (clazz, i);
+ ir_type *s_clazz = get_class_supertype (clazz, i);
_collect_fields (s_clazz, obst);
}
/* Collect the fields of the given class and its super classes into an array.
The last entry of the array is written NULL. */
-static entity **collect_fields (type *clazz)
+static ir_entity **collect_fields (ir_type *clazz)
{
struct obstack obst;
int n_fields;
- entity ** fields;
+ ir_entity ** fields;
void *tmp;
if (NULL != get_type_link (clazz)) {
__FUNCTION__,
get_type_name (clazz)));
- return ((entity **) get_type_link (clazz));
+ return ((ir_entity **) get_type_link (clazz));
} else {
DBGPRINT (2, (stdout, "%s: new field list for \"%s\"\n",
__FUNCTION__,
n_fields = obstack_object_size (&obst) / sizeof (void*);
- fields = NALLOC (n_fields * sizeof (entity*));
+ fields = NALLOC (n_fields * sizeof (ir_entity*));
tmp = obstack_finish(&obst);
- memcpy (fields, tmp, n_fields * sizeof (entity*));
+ memcpy (fields, tmp, n_fields * sizeof (ir_entity*));
obstack_free (&obst, NULL);
/* Write a node for the given descriptor into the given stream */
static void pto_name_dump_desc (desc_t *desc, FILE *stream)
{
- type *tp = desc->tp;
+ ir_type *tp = desc->tp;
const char *tp_name = get_type_name (tp);
ir_node *nd;
if (NULL != nd) {
ir_graph *graph = get_irn_irg (nd);
- entity *method = get_irg_entity (graph);
+ ir_entity *method = get_irg_entity (graph);
const char *ent_name = get_entity_name (method);
const char *own_name = get_type_name (get_entity_owner (method));
int i;
for (i = 0; i < obj_desc->n_fields; i ++) {
- entity *field = obj_desc->fields [i];
+ ir_entity *field = obj_desc->fields [i];
if (is_Pointer_type (get_entity_type (field))) {
const char *ent_name = get_entity_name (field);
Exported Implementation:
=================================================== */
/* Find the given descriptor's entry for the given entity */
-qset_t *get_entry (desc_t *desc, entity *ent)
+qset_t *get_entry (desc_t *desc, ir_entity *ent)
{
if (desc->kind == object) {
return (arr_desc->value);
} else {
assert (0 && "invalid descriptor");
- return NULL;
}
+ return NULL;
}
/* get a new descriptor for the given type at the given node */
-desc_t *new_name (type *tp, ir_node *node, int ctx)
+desc_t *new_name (ir_type *tp, ir_node *node, int ctx)
{
desc_t *desc = NULL;
static int n_glob_fields = N_GLOB_INITIAL_FIELDS;
/* get a new descriptor for the given (presumably static) entity */
-desc_t *new_ent_name (entity *ent)
+desc_t *new_ent_name (ir_entity *ent)
{
int i;
int missing = TRUE;
- type *tp = get_entity_type (ent);
+ ir_type *tp = get_entity_type (ent);
assert (is_Pointer_type (tp));
tp = get_pointer_points_to_type (tp);
obj_glob->node = NULL;
obj_glob->n_fields = 0;
- obj_glob->fields = (entity**) NALLOC (N_GLOB_INITIAL_FIELDS * sizeof (entity*));
+ obj_glob->fields = (ir_entity**) NALLOC (N_GLOB_INITIAL_FIELDS * sizeof (ir_entity*));
obj_glob->values = (qset_t**) NALLOC (N_GLOB_INITIAL_FIELDS * sizeof (qset_t*));
obj_glob->prev = all_descs;
if (missing) {
if (obj_glob->n_fields == n_glob_fields) {
- entity **fields = obj_glob->fields;
+ ir_entity **fields = obj_glob->fields;
qset_t **values = obj_glob->values;
n_glob_fields *= 2;
- obj_glob->fields = (entity**) NALLOC (n_glob_fields * sizeof (entity*));
+ obj_glob->fields = (ir_entity**) NALLOC (n_glob_fields * sizeof (ir_entity*));
obj_glob->values = (qset_t**) NALLOC (n_glob_fields * sizeof (qset_t*));
- memcpy (obj_glob->fields, fields, obj_glob->n_fields * sizeof (entity*));
+ memcpy (obj_glob->fields, fields, obj_glob->n_fields * sizeof (ir_entity*));
memcpy (obj_glob->values, values, obj_glob->n_fields * sizeof (qset_t*));
/* free (fields); */
\f
/*
$Log$
+ Revision 1.19 2006/12/13 19:46:47 beck
+ rename type entity into ir_entity
+
+ Revision 1.18 2006/01/13 22:56:21 beck
+ renamed all types 'type' to 'ir_type'
+
+ Revision 1.17 2005/12/16 16:59:54 grund
+ *** empty log message ***
+
+ Revision 1.16 2005/12/05 12:19:54 beck
+ added missing include <assert.h> (not anymore included in libFirm)
+
+ Revision 1.15 2005/03/02 10:14:38 beck
+ placed a return on all execution pathes
+
Revision 1.14 2005/02/17 08:45:38 liekweg
Don't return a value for an invalid descriptor