Il2CppSignature.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "il2cpp-config.h"
  2. #include "il2cpp-class-internals.h"
  3. #include "Il2CppSignature.h"
  4. #include "Il2CppTypeCompare.h"
  5. #include "Il2CppTypeHash.h"
  6. #include "utils/HashUtils.h"
  7. using il2cpp::utils::HashUtils;
  8. namespace il2cpp
  9. {
  10. namespace metadata
  11. {
  12. size_t Il2CppSignatureHash::operator()(const Il2CppSignature& signature) const
  13. {
  14. return Hash(signature);
  15. }
  16. size_t Il2CppSignatureHash::Hash(const Il2CppSignature& signature)
  17. {
  18. size_t retVal = signature.Count;
  19. for (size_t i = 0; i < signature.Count; ++i)
  20. retVal = HashUtils::Combine(retVal, Il2CppTypeHash::Hash(signature.Types[i]));
  21. return retVal;
  22. }
  23. bool Il2CppSignatureCompare::operator()(const Il2CppSignature& s1, const Il2CppSignature& s2) const
  24. {
  25. return Equals(s1, s2);
  26. }
  27. bool Il2CppSignatureCompare::Equals(const Il2CppSignature& s1, const Il2CppSignature& s2)
  28. {
  29. if (s1.Count != s2.Count)
  30. return false;
  31. for (size_t i = 0; i < s1.Count; ++i)
  32. {
  33. if (!Il2CppTypeEqualityComparer::AreEqual(s1.Types[i], s2.Types[i]))
  34. return false;
  35. }
  36. return true;
  37. }
  38. } /* namespace metadata */
  39. } /* namespace il2cpp */