Add a reference table implementation.
This is suitable for pinned array references and the like.
I've also brought in some of the human-readable type printing stuff
for the benefit of the reference table dumping code.
This patch includes tests, but doesn't yet wire anything up.
Change-Id: Iaf6066201bbd254e033dee4fd0b8dfd0bc17afa9
diff --git a/src/utils.h b/src/utils.h
index 842db63..ea51d1e 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -5,10 +5,13 @@
#include "globals.h"
#include "logging.h"
+#include "stringpiece.h"
#include "stringprintf.h"
namespace art {
+class Object;
+
template<typename T>
static inline bool IsPowerOfTwo(T x) {
return (x & (x - 1)) == 0;
@@ -132,6 +135,17 @@
return result;
}
+// Return a newly-allocated string containing a human-readable equivalent
+// of 'descriptor'. So "I" would be "int", "[[I" would be "int[][]",
+// "[Ljava/lang/String;" would be "java.lang.String[]", and so forth.
+std::string PrettyDescriptor(const StringPiece& descriptor);
+
+// Returns a human-readable string form of the name of the class of
+// the given object. So given a java.lang.String, the output would
+// be "java.lang.String". Given an array of int, the output would be "int[]".
+// Given String.class, the output would be "java.lang.Class<java.lang.String>".
+std::string PrettyType(const Object* obj);
+
} // namespace art
#endif // ART_SRC_UTILS_H_