[K/N] Support of collectReferenceFieldValues function

This commit is contained in:
Pavel Kunyavskiy
2022-06-30 12:05:32 +02:00
committed by Space
parent 3f1e06b32e
commit c7131a68ce
4 changed files with 164 additions and 0 deletions
@@ -16,6 +16,9 @@
#include "KAssert.h"
#include "TypeInfo.h"
#include "Memory.h"
#include "Types.h"
#include "KString.h"
extern "C" {
@@ -39,4 +42,14 @@ InterfaceTableRecord const* LookupInterfaceTableRecord(InterfaceTableRecord cons
return interfaceTable + l;
}
RUNTIME_NOTHROW int Kotlin_internal_reflect_getObjectReferenceFieldsCount(ObjHeader* object) {
auto *info = object->type_info();
if (info->IsArray()) return 0;
return info->objOffsetsCount_;
}
RUNTIME_NOTHROW OBJ_GETTER(Kotlin_internal_reflect_getObjectReferenceFieldByIndex, ObjHeader* object, int index) {
RETURN_OBJ(*reinterpret_cast<ObjHeader**>(reinterpret_cast<uintptr_t>(object) + object->type_info()->objOffsets_[index]));
}
}