Bugfix
[libfirm] / ir / tr / mangle.c
index 7706b0f..0f9a610 100644 (file)
@@ -1,18 +1,18 @@
 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-** All rights reserved.
-**
-** Authors: Martin Trapp, Christian Schaefer
-**
+* All rights reserved.
+*
+* Authors: Martin Trapp, Christian Schaefer
+*
 */
 
+/* $Id$ */
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 # include "mangle.h"
-# include <obstack.h>
 # include "obst.h"
-# include <stdlib.h>
 # include "misc.h"
 
 /* Make types visible to allow most efficient access */
@@ -31,25 +31,47 @@ mangle_entity (entity *ent)
   ident *res;
 
   type_id = mangle_type ((type *) ent->owner);
-  xoprintf (&mangle_obst, "%I_%I", type_id, ent->name);
+  obstack_grow(&mangle_obst, id_to_str(type_id), id_to_strlen(type_id));
+  obstack_1grow(&mangle_obst,'_');
+  obstack_grow(&mangle_obst,id_to_str(ent->name),id_to_strlen(ent->name));
   len = obstack_object_size (&mangle_obst);
   cp = obstack_finish (&mangle_obst);
-  res = id_from_str (cp, len);
+  res = id_from_str(cp, len);
   obstack_free (&mangle_obst, cp);
   return res;
 }
 
 ident *
-mangle_type (type *type)
+mangle_type (type *tp)
 {
+  assert (tp->kind == k_type);
+  return tp->name;
+}
+
+/* Returns a new ident that represents firstscnd. */
+ident *mangle (ident *first, ident* scnd) {
   char *cp;
   int len;
   ident *res;
 
-  assert (type->kind == k_type);
-  assert (type->type_op->code == tpo_class);
+  obstack_grow(&mangle_obst, id_to_str(first), id_to_strlen(first));
+  obstack_grow(&mangle_obst, id_to_str(scnd), id_to_strlen(scnd));
+  len = obstack_object_size (&mangle_obst);
+  cp = obstack_finish (&mangle_obst);
+  res = id_from_str (cp, len);
+  obstack_free (&mangle_obst, cp);
+  return res;
+}
+
+/* Returns a new ident that represents first_scnd. */
+ident *mangle_u (ident *first, ident* scnd) {
+  char *cp;
+  int len;
+  ident *res;
 
-  xoprintf (&mangle_obst, "%I", type->name);
+  obstack_grow(&mangle_obst, id_to_str(first), id_to_strlen(first));
+  obstack_1grow(&mangle_obst,'_');
+  obstack_grow(&mangle_obst,id_to_str(scnd),id_to_strlen(scnd));
   len = obstack_object_size (&mangle_obst);
   cp = obstack_finish (&mangle_obst);
   res = id_from_str (cp, len);
@@ -61,5 +83,5 @@ mangle_type (type *type)
 void
 init_mangle (void)
 {
-  obstack_init (&mangle_obst);
+  obstack_init(&mangle_obst);
 }