aboutsummaryrefslogtreecommitdiff
path: root/gold/stringpool.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2006-08-18 22:29:20 +0000
committerIan Lance Taylor <iant@google.com>2006-08-18 22:29:20 +0000
commit14bfc3f55540e60253cc4aae73261325309f750a (patch)
treecb74fe438b44c7aa6e02f05e14f13ba1ae0b508a /gold/stringpool.h
parent476308bf9bd077b87791da50a13a74b2698c01c7 (diff)
downloadgdb-14bfc3f55540e60253cc4aae73261325309f750a.zip
gdb-14bfc3f55540e60253cc4aae73261325309f750a.tar.gz
gdb-14bfc3f55540e60253cc4aae73261325309f750a.tar.bz2
Another snapshot of the current state of the sources. Gets to the
point of symbol resolution and can now issue a multiple definition error. Also added target selection infrastructure.
Diffstat (limited to 'gold/stringpool.h')
-rw-r--r--gold/stringpool.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/gold/stringpool.h b/gold/stringpool.h
new file mode 100644
index 0000000..873c26a
--- /dev/null
+++ b/gold/stringpool.h
@@ -0,0 +1,70 @@
+// stringpool.h -- a string pool for gold -*- C++ -*-
+
+#include <string>
+#include <list>
+
+// Stringpool
+// Manage a pool of unique strings.
+
+#ifndef GOLD_STRINGPOOL_H
+#define GOLD_STRINGPOOL_H
+
+namespace gold
+{
+
+class Stringpool
+{
+ public:
+ Stringpool();
+
+ ~Stringpool();
+
+ // Add a string to the pool. This returns a canonical permanent
+ // pointer to the string.
+ const char* add(const char*);
+
+ const char* add(const std::string& s)
+ { return this->add(s.c_str()); }
+
+ // Add the prefix of a string to the pool.
+ const char* add(const char *, size_t);
+
+ private:
+ Stringpool(const Stringpool&);
+ Stringpool& operator=(const Stringpool&);
+
+ struct stringdata
+ {
+ // Length of data in buffer.
+ size_t len;
+ // Allocated size of buffer.
+ size_t alc;
+ // Buffer.
+ char data[1];
+ };
+
+ const char* add_string(const char*);
+
+ struct Stringpool_hash
+ {
+ size_t
+ operator()(const char*) const;
+ };
+
+ struct Stringpool_eq
+ {
+ bool
+ operator()(const char* p1, const char* p2) const
+ { return strcmp(p1, p2) == 0; }
+ };
+
+ typedef Unordered_set<const char*, Stringpool_hash, Stringpool_eq,
+ std::allocator<const char*>,
+ true> String_set_type;
+ String_set_type string_set_;
+ std::list<stringdata*> strings_;
+};
+
+} // End namespace gold.
+
+#endif // !defined(GOLD_STRINGPOOL_H)