[runtime][debug] type name inspection
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "KAssert.h"
|
||||
#include "KString.h"
|
||||
#include "Memory.h"
|
||||
#include "Natives.h"
|
||||
#include "Porting.h"
|
||||
@@ -176,6 +177,17 @@ RUNTIME_USED const char* Konan_DebugGetFieldName(KRef obj, int index) {
|
||||
return extendedTypeInfo->fieldNames_[index];
|
||||
}
|
||||
|
||||
RUNTIME_USED const char* Konan_DebugGetTypeName(KRef obj) {
|
||||
if (obj == nullptr)
|
||||
return nullptr;
|
||||
|
||||
auto type_info = obj->type_info();
|
||||
if (type_info == nullptr)
|
||||
return "<unknown>";
|
||||
|
||||
return CreateCStringFromString(type_info->relativeName_);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // !KONAN_NO_DEBUG_API
|
||||
|
||||
@@ -60,6 +60,9 @@ RUNTIME_USED void* Konan_DebugGetFieldAddress(KRef obj, int index);
|
||||
// Compute address of field or an array element at the index, or null, if incorrect.
|
||||
RUNTIME_USED const char* Konan_DebugGetFieldName(KRef obj, int index);
|
||||
|
||||
// Returns name of type.
|
||||
RUNTIME_USED const char* Konan_DebugGetTypeName(KRef obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user