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.
19 /* Make types visible to allow most efficient access */
20 # include "entity_t.h"
24 static struct obstack mangle_obst;
27 mangle_type (type *tp)
29 assert (tp->kind == k_type);
34 mangle_entity (entity *ent)
41 type_id = mangle_type ((type *) ent->owner);
42 obstack_grow(&mangle_obst, get_id_str(type_id), get_id_strlen(type_id));
43 obstack_1grow(&mangle_obst,'_');
44 obstack_grow(&mangle_obst,get_id_str(ent->name),get_id_strlen(ent->name));
45 len = obstack_object_size (&mangle_obst);
46 cp = obstack_finish (&mangle_obst);
47 res = new_id_from_chars(cp, len);
48 obstack_free (&mangle_obst, cp);
53 /* Returns a new ident that represents firstscnd. */
54 ident *mangle (ident *first, ident* scnd) {
59 obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
60 obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
61 len = obstack_object_size (&mangle_obst);
62 cp = obstack_finish (&mangle_obst);
63 res = new_id_from_chars (cp, len);
64 obstack_free (&mangle_obst, cp);
68 /* Returns a new ident that represents first_scnd. */
69 ident *mangle_u (ident *first, ident* scnd) {
74 obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
75 obstack_1grow(&mangle_obst,'_');
76 obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd));
77 len = obstack_object_size (&mangle_obst);
78 cp = obstack_finish (&mangle_obst);
79 res = new_id_from_chars (cp, len);
80 obstack_free (&mangle_obst, cp);
86 firm_init_mangle (void)
88 obstack_init(&mangle_obst);