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 /** a obstack used for temporary space */
25 static struct obstack mangle_obst;
27 /** returned a mangled type name, currently no mangling */
29 mangle_type (type *tp)
31 assert (tp->kind == k_type);
36 mangle_entity (entity *ent)
43 type_id = mangle_type(ent->owner);
44 obstack_grow(&mangle_obst, get_id_str(type_id), get_id_strlen(type_id));
45 obstack_1grow(&mangle_obst,'_');
46 obstack_grow(&mangle_obst,get_id_str(ent->name),get_id_strlen(ent->name));
47 len = obstack_object_size (&mangle_obst);
48 cp = obstack_finish (&mangle_obst);
49 res = new_id_from_chars(cp, len);
50 obstack_free (&mangle_obst, cp);
55 /* Returns a new ident that represents 'firstscnd'. */
56 ident *mangle (ident *first, ident* scnd) {
61 obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
62 obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
63 len = obstack_object_size (&mangle_obst);
64 cp = obstack_finish (&mangle_obst);
65 res = new_id_from_chars (cp, len);
66 obstack_free (&mangle_obst, cp);
70 /* Returns a new ident that represents first_scnd. */
71 ident *mangle_u (ident *first, ident* scnd) {
76 obstack_grow(&mangle_obst, get_id_str(first), get_id_strlen(first));
77 obstack_1grow(&mangle_obst,'_');
78 obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd));
79 len = obstack_object_size (&mangle_obst);
80 cp = obstack_finish (&mangle_obst);
81 res = new_id_from_chars (cp, len);
82 obstack_free (&mangle_obst, cp);
88 firm_init_mangle (void)
90 obstack_init(&mangle_obst);