Minor fixes.

This commit is contained in:
Nikolay Igotti
2016-10-13 15:10:54 +03:00
parent 6f666b6ca9
commit ed53aceaa5
2 changed files with 19 additions and 7 deletions
+14 -2
View File
@@ -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;
}
+5 -5
View File
@@ -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"