summaryrefslogtreecommitdiffhomepage
path: root/ir/ident
diff options
context:
space:
mode:
authorChristoph Mallon <mallon@cs.uni-saarland.de>2015-01-27 23:07:28 +0100
committerChristoph Mallon <mallon@cs.uni-saarland.de>2015-01-28 12:37:31 +0100
commitaf027d188a378eef5737c9b370d7ff901136e02e (patch)
treeb295bfe7ddba9636ae8ed3a9f41ff104f65bf86b /ir/ident
parent1c9b1e1432e69a6c5825e75fbc9c1180f9d8c283 (diff)
ident: Replace id_mangle*() by new_id_fmt().
Diffstat (limited to 'ir/ident')
-rw-r--r--ir/ident/ident.c24
-rw-r--r--ir/ident/ident_t.h5
-rw-r--r--ir/ident/mangle.c63
3 files changed, 24 insertions, 68 deletions
diff --git a/ir/ident/ident.c b/ir/ident/ident.c
index d422a83..60acc79 100644
--- a/ir/ident/ident.c
+++ b/ir/ident/ident.c
@@ -13,14 +13,19 @@
#include "hashptr.h"
#include "ident_t.h"
+#include "obst.h"
#include "set.h"
static set *id_set;
+/** An obstack used for temporary space */
+static struct obstack id_obst;
+
void init_ident(void)
{
/* it's ok to use memcmp here, we check only strings */
id_set = new_set(memcmp, 128);
+ obstack_init(&id_obst);
}
ident *new_id_from_chars(const char *str, size_t len)
@@ -35,6 +40,24 @@ ident *new_id_from_str(const char *str)
return new_id_from_chars(str, strlen(str));
}
+static ident *new_ident_from_obst(struct obstack *const obst)
+{
+ size_t const len = obstack_object_size(obst);
+ char *const string = (char*)obstack_finish(obst);
+ ident *const res = new_id_from_chars(string, len);
+ obstack_free(obst, string);
+ return res;
+}
+
+ident *new_id_fmt(char const *const fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ obstack_vprintf(&id_obst, fmt, ap);
+ va_end(ap);
+ return new_ident_from_obst(&id_obst);
+}
+
const char *(get_id_str)(ident *id)
{
return get_id_str_(id);
@@ -42,6 +65,7 @@ const char *(get_id_str)(ident *id)
void finish_ident(void)
{
+ obstack_free(&id_obst, NULL);
del_set(id_set);
id_set = NULL;
}
diff --git a/ir/ident/ident_t.h b/ir/ident/ident_t.h
index 246465f..9e64532 100644
--- a/ir/ident/ident_t.h
+++ b/ir/ident/ident_t.h
@@ -30,11 +30,6 @@ void init_ident(void);
*/
void finish_ident(void);
-/** initializes the name mangling code */
-void firm_init_mangle(void);
-
-void firm_finish_mangle(void);
-
#define NEW_IDENT(x) new_id_from_chars((x), sizeof(x) - 1)
#endif
diff --git a/ir/ident/mangle.c b/ir/ident/mangle.c
deleted file mode 100644
index 3dbb9cf..0000000
--- a/ir/ident/mangle.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * This file is part of libFirm.
- * Copyright (C) 2012 University of Karlsruhe.
- */
-
-/**
- * @file
- * @brief Methods to manipulate names.
- * @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
- */
-#include "ident_t.h"
-#include "obst.h"
-
-/** An obstack used for temporary space */
-static struct obstack mangle_obst;
-
-static ident *new_ident_from_obst(struct obstack *obst)
-{
- size_t len = obstack_object_size(obst);
- char *string = (char*)obstack_finish(obst);
- ident *res = new_id_from_chars(string, len);
- obstack_free(obst, string);
- return res;
-}
-
-static void grow_string(char const *const s)
-{
- obstack_grow(&mangle_obst, s, strlen(s));
-}
-
-/** Returns a new ident that represents 'prefixscndsuffix'. */
-ident *id_mangle3(char const *const prefix, ident *const middle, char const *const suffix)
-{
- grow_string(prefix);
- grow_string(get_id_str(middle));
- grow_string(suffix);
- return new_ident_from_obst(&mangle_obst);
-}
-
-/** Returns a new ident that represents first<c>scnd. */
-static ident *id_mangle_3(ident *first, char c, ident *scnd)
-{
- grow_string(first);
- obstack_1grow(&mangle_obst, c);
- grow_string(scnd);
- return new_ident_from_obst(&mangle_obst);
-}
-
-/* Returns a new ident that represents first.scnd. */
-ident *id_mangle_dot(ident *first, ident *scnd)
-{
- return id_mangle_3(first, '.', scnd);
-}
-
-void firm_init_mangle(void)
-{
- obstack_init(&mangle_obst);
-}
-
-void firm_finish_mangle(void)
-{
- obstack_free(&mangle_obst, NULL);
-}