3 * File name: ir/tr/mangle.c
4 * Purpose: Methods to manipulate names.
5 * Author: Martin Trapp, Christian Schaefer
6 * Modified by: Goetz Lindenmaier
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
23 /* Make types visible to allow most efficient access */
24 # include "entity_t.h"
28 static struct obstack mangle_obst;
31 mangle_type (type *tp)
33 assert (tp->kind == k_type);
38 mangle_entity (entity *ent)
45 type_id = mangle_type ((type *) ent->owner);
46 obstack_grow(&mangle_obst, get_id_str(type_id), get_id_strlen(type_id));
47 obstack_1grow(&mangle_obst,'_');
48 obstack_grow(&mangle_obst,get_id_str(ent->name),get_id_strlen(ent->name));
49 len = obstack_object_size (&mangle_obst);
50 cp = obstack_finish (&mangle_obst);
51 res = id_from_str(cp, len);
52 obstack_free (&mangle_obst, cp);
57 /* Returns a new ident that represents firstscnd. */
58 ident *mangle (ident *first, ident* scnd) {
63 obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
64 obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
65 len = obstack_object_size (&mangle_obst);
66 cp = obstack_finish (&mangle_obst);
67 res = id_from_str (cp, len);
68 obstack_free (&mangle_obst, cp);
72 /* Returns a new ident that represents first_scnd. */
73 ident *mangle_u (ident *first, ident* scnd) {
78 obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
79 obstack_1grow(&mangle_obst,'_');
80 obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd));
81 len = obstack_object_size (&mangle_obst);
82 cp = obstack_finish (&mangle_obst);
83 res = id_from_str (cp, len);
84 obstack_free (&mangle_obst, cp);
92 obstack_init(&mangle_obst);