No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Parameter.cpp 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "il2cpp-config.h"
  2. #include "il2cpp-runtime-metadata.h"
  3. #include "il2cpp-class-internals.h"
  4. #include "il2cpp-object-internals.h"
  5. #include "Parameter.h"
  6. #include "vm-utils/BlobReader.h"
  7. #include "vm/Class.h"
  8. #include "vm/Object.h"
  9. #include "vm/Method.h"
  10. namespace il2cpp
  11. {
  12. namespace vm
  13. {
  14. Il2CppObject* Parameter::GetDefaultParameterValueObject(const MethodInfo* method, int32_t parameterPosition, bool* isExplicitySetNullDefaultValue)
  15. {
  16. const Il2CppType* typeOfDefaultValue;
  17. const char* data = Method::GetParameterDefaultValue(method, parameterPosition, &typeOfDefaultValue, isExplicitySetNullDefaultValue);
  18. if (data == NULL)
  19. return NULL;
  20. Il2CppClass* parameterType = Class::FromIl2CppType(method->parameters[parameterPosition]);
  21. if (il2cpp::vm::Class::IsValuetype(parameterType))
  22. {
  23. if (il2cpp::vm::Class::IsNullable(parameterType))
  24. {
  25. parameterType = il2cpp::vm::Class::GetNullableArgument(parameterType);
  26. typeOfDefaultValue = &parameterType->byval_arg;
  27. }
  28. Class::SetupFields(parameterType);
  29. IL2CPP_ASSERT(parameterType->size_inited);
  30. void* value = alloca(parameterType->instance_size - sizeof(Il2CppObject));
  31. utils::BlobReader::GetConstantValueFromBlob(method->klass->image, typeOfDefaultValue->type, data, value);
  32. return Object::Box(parameterType, value);
  33. }
  34. Il2CppObject* value = NULL;
  35. utils::BlobReader::GetConstantValueFromBlob(method->klass->image, typeOfDefaultValue->type, data, &value);
  36. return value;
  37. }
  38. }
  39. }