X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fident%2Fmangle.c;h=12a877c99ddc1143b37985740eedd3fbb7ddbd73;hb=2a2686741df6ab65c2ea76eeecc9fa72aed394e7;hp=c27798edb80fbd7dd618c914ec6de467db9e8b1d;hpb=de956ac9fb4d36a87928d4bfd0b3ce98990ec767;p=libfirm diff --git a/ir/ident/mangle.c b/ir/ident/mangle.c index c27798edb..12a877c99 100644 --- a/ir/ident/mangle.c +++ b/ir/ident/mangle.c @@ -21,7 +21,6 @@ * @file * @brief Methods to manipulate names. * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck - * @version $Id$ */ #include "config.h" @@ -29,6 +28,7 @@ #include "ident_t.h" #include "obst.h" +#include "irprintf.h" /* Make types visible to allow most efficient access */ #include "entity_t.h" @@ -45,25 +45,6 @@ static inline ident *mangle_type(const ir_type *tp) return tp->name; } -ident *id_mangle_entity(const ir_entity *ent) -{ - ident *type_id; - char *cp; - int len; - ident *res; - - type_id = mangle_type(ent->owner); - 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 = new_id_from_chars(cp, len); - obstack_free(&mangle_obst, cp); - return res; -} - - /* Returns a new ident that represents 'firstscnd'. */ ident *id_mangle(ident *first, ident *scnd) { @@ -74,7 +55,7 @@ ident *id_mangle(ident *first, ident *scnd) 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); + cp = (char*)obstack_finish(&mangle_obst); res = new_id_from_chars(cp, len); obstack_free(&mangle_obst, cp); return res; @@ -91,7 +72,7 @@ ident *id_mangle3(const char *prefix, ident *scnd, const char *suffix) obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd)); obstack_grow(&mangle_obst, suffix, strlen(suffix)); len = obstack_object_size(&mangle_obst); - cp = obstack_finish(&mangle_obst); + cp = (char*)obstack_finish(&mangle_obst); res = new_id_from_chars(cp, len); obstack_free(&mangle_obst, cp); return res; @@ -108,7 +89,7 @@ static ident *id_mangle_3(ident *first, char c, ident *scnd) obstack_1grow(&mangle_obst, c); obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd)); len = obstack_object_size(&mangle_obst); - cp = obstack_finish(&mangle_obst); + cp = (char*)obstack_finish(&mangle_obst); res = new_id_from_chars(cp, len); obstack_free(&mangle_obst, cp); return res; @@ -126,33 +107,12 @@ ident *id_mangle_dot(ident *first, ident *scnd) return id_mangle_3(first, '.', scnd); } -/* returns a mangled name for a Win32 function using it's calling convention */ -ident *id_decorate_win32_c_fkt(const ir_entity *ent, ident *id) +void firm_init_mangle(void) { - ir_type *tp = get_entity_type(ent); - unsigned cc_mask = get_method_calling_convention(tp); - char buf[16]; - int size, i; - - if (IS_CDECL(cc_mask)) - return id_mangle3("_", id, ""); - else if (IS_STDCALL(cc_mask)) { - size = 0; - for (i = get_method_n_params(tp) - 1; i >= 0; --i) { - size += get_type_size_bytes(get_method_param_type(tp, i)); - } - - snprintf(buf, sizeof(buf), "@%d", size); - - if (cc_mask & cc_reg_param) - return id_mangle3("@", id, buf); - else - return id_mangle3("_", id, buf); - } - return id; + obstack_init(&mangle_obst); } -void firm_init_mangle(void) +void firm_finish_mangle(void) { - obstack_init(&mangle_obst); + obstack_free(&mangle_obst, NULL); }