diff options
Diffstat (limited to 'vm/Misc.cpp')
-rw-r--r-- | vm/Misc.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/vm/Misc.cpp b/vm/Misc.cpp index 3b1179e44..3cbd5633c 100644 --- a/vm/Misc.cpp +++ b/vm/Misc.cpp @@ -266,6 +266,23 @@ std::string dvmHumanReadableDescriptor(const char* descriptor) { return result; } +std::string dvmHumanReadableType(const Object* obj) +{ + if (obj == NULL) { + return "(null)"; + } + if (obj->clazz == NULL) { + /* should only be possible right after a plain dvmMalloc() */ + return "(raw)"; + } + std::string result(dvmHumanReadableDescriptor(obj->clazz->descriptor)); + if (dvmIsClassObject(obj)) { + const ClassObject* clazz = reinterpret_cast<const ClassObject*>(obj); + result += "<" + dvmHumanReadableDescriptor(clazz->descriptor) + ">"; + } + return result; +} + /* * Return a newly-allocated string for the "dot version" of the class * name for the given type descriptor. That is, The initial "L" and |