X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Ftr%2Fmangle.c;h=5adb6661acc3f9830da687dd77ddf28d9f8ae3f6;hb=b8f363d7be29eb5702e130be3796ff7162410e6a;hp=7706b0f23d7af749ef121abd168201ce421a0d07;hpb=a3a4f27fa76972a5aa4773b34ad83796eaf1fcfc;p=libfirm diff --git a/ir/tr/mangle.c b/ir/tr/mangle.c index 7706b0f23..5adb6661a 100644 --- a/ir/tr/mangle.c +++ b/ir/tr/mangle.c @@ -1,19 +1,23 @@ -/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe -** All rights reserved. -** -** Authors: Martin Trapp, Christian Schaefer -** -*/ +/* + * Project: libFIRM + * File name: ir/tr/mangle.c + * Purpose: Methods to manipulate names. + * Author: Martin Trapp, Christian Schaefer + * Modified by: Goetz Lindenmaier + * Created: + * CVS-ID: $Id$ + * Copyright: (c) 1998-2003 Universität Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ + + #ifdef HAVE_CONFIG_H # include #endif # include "mangle.h" -# include # include "obst.h" -# include -# include "misc.h" /* Make types visible to allow most efficient access */ # include "entity_t.h" @@ -22,6 +26,13 @@ static struct obstack mangle_obst; +static INLINE ident * +mangle_type (type *tp) +{ + assert (tp->kind == k_type); + return tp->name; +} + ident * mangle_entity (entity *ent) { @@ -31,25 +42,41 @@ 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, get_id_str(type_id), get_id_strlen(type_id)); + obstack_1grow(&mangle_obst,'_'); + obstack_grow(&mangle_obst,get_id_str(ent->name),get_id_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) -{ + +/* 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, get_id_str(first), get_id_strlen(first)); + obstack_grow(&mangle_obst, get_id_str(scnd), get_id_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, get_id_str(first), get_id_strlen(first)); + obstack_1grow(&mangle_obst,'_'); + obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd)); len = obstack_object_size (&mangle_obst); cp = obstack_finish (&mangle_obst); res = id_from_str (cp, len); @@ -61,5 +88,5 @@ mangle_type (type *type) void init_mangle (void) { - obstack_init (&mangle_obst); + obstack_init(&mangle_obst); }