forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIl2CppTypeHash.cpp
More file actions
53 lines (48 loc) · 1.47 KB
/
Il2CppTypeHash.cpp
File metadata and controls
53 lines (48 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "il2cpp-config.h"
#include "il2cpp-class-internals.h"
#include "Il2CppTypeHash.h"
#include "utils/StringUtils.h"
#include "utils/HashUtils.h"
using il2cpp::utils::HashUtils;
using il2cpp::utils::StringUtils;
namespace il2cpp
{
namespace metadata
{
size_t Il2CppTypeHash::operator()(const Il2CppType* t1) const
{
return Hash(t1);
}
size_t Il2CppTypeHash::Hash(const Il2CppType* t1)
{
size_t hash = t1->type;
hash = HashUtils::Combine(hash, t1->byref);
switch (t1->type)
{
case IL2CPP_TYPE_VALUETYPE:
case IL2CPP_TYPE_CLASS:
{
return HashUtils::Combine(hash, reinterpret_cast<size_t>(t1->data.typeHandle));
}
case IL2CPP_TYPE_SZARRAY:
case IL2CPP_TYPE_PTR:
{
return HashUtils::Combine(hash, Hash(t1->data.type));
}
case IL2CPP_TYPE_GENERICINST:
{
const Il2CppGenericInst *inst = t1->data.generic_class->context.class_inst;
hash = HashUtils::Combine(hash, Hash(t1->data.generic_class->type));
for (uint32_t i = 0; i < inst->type_argc; ++i)
{
hash = HashUtils::Combine(hash, Hash(inst->type_argv[i]));
}
return hash;
}
default:
return hash;
}
return hash;
}
} /* namespace vm */
} /* namespace il2cpp */