[runtime][debug] type name inspection

This commit is contained in:
Vasily Levchenko
2020-01-08 16:08:49 +01:00
parent 3363c95c23
commit fced64fcc0
2 changed files with 15 additions and 0 deletions
+12
View File
@@ -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
+3
View File
@@ -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