From ed53aceaa53faa605575560948c813244e8611f6 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Thu, 13 Oct 2016 15:10:54 +0300 Subject: [PATCH] Minor fixes. --- runtime/src/main/cpp/TypeInfo.cpp | 16 ++++++++++++++-- runtime/src/main/cpp/TypeInfo.h | 10 +++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/runtime/src/main/cpp/TypeInfo.cpp b/runtime/src/main/cpp/TypeInfo.cpp index c4878c26852..8c1bc2aa962 100644 --- a/runtime/src/main/cpp/TypeInfo.cpp +++ b/runtime/src/main/cpp/TypeInfo.cpp @@ -4,11 +4,23 @@ extern "C" { int LookupFieldOffset(const TypeInfo* info, FieldNameHash nameSignature) { - assert(false); // not implemented yet + // TODO: make it binary search? + for (int i = 0; i < info->fieldsCount_; ++i) { + if (info->fields_[i].nameSignature_ == nameSignature) { + return info->fields_[i].fieldOffset_; + } + } + assert(false); return -1; } -void* LookupMethod(const TypeInfo* info, MethodNameHash nameSignature) { +void* LookupOpenMethod(const TypeInfo* info, MethodNameHash nameSignature) { + // TODO: make it binary search? + for (int i = 0; i < info->openMethodsCount_; ++i) { + if (info->openMethods_[i].nameSignature_ == nameSignature) { + return info->openMethods_[i].methodEntryPoint_; + } + } assert(false); // not implemented yet return nullptr; } diff --git a/runtime/src/main/cpp/TypeInfo.h b/runtime/src/main/cpp/TypeInfo.h index f3fa4d70ca8..8c433221d95 100644 --- a/runtime/src/main/cpp/TypeInfo.h +++ b/runtime/src/main/cpp/TypeInfo.h @@ -28,8 +28,8 @@ struct TypeInfo { TypeInfo* const* implementedInterfaces_; int implementedInterfacesCount_; void* const* vtable_; // TODO: place vtable at the end of TypeInfo to eliminate the indirection - const MethodTableRecord* methods_; - int methodsCount_; + const MethodTableRecord* openMethods_; + int openMethodsCount_; const FieldTableRecord* fields_; int fieldsCount_; }; @@ -38,10 +38,10 @@ struct TypeInfo { extern "C" { #endif // Find offset of given hash in table. -int LookupFieldOffset(const TypeInfo* type_info, LocalHash hash); +int LookupFieldOffset(const TypeInfo* type_info, FieldNameHash hash); -// Find method by its hash. -void* LookupMethod(const TypeInfo* info, MethodNameHash nameSignature); +// Find open method by its hash. Other methods are resolved in compile-time. +void* LookupOpenMethod(const TypeInfo* info, MethodNameHash nameSignature); #ifdef __cplusplus } // extern "C"