ParamInfo.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace HybridCLR.Editor.ABI
  8. {
  9. public class ParamInfo
  10. {
  11. public TypeInfo Type { get; set; }
  12. public int Index { get; set; }
  13. //public bool IsNative2ManagedByAddress => Type.PorType >= ParamOrReturnType.STRUCT_NOT_PASS_AS_VALUE;
  14. public bool IsPassToManagedByAddress => Type.GetParamSlotNum() > 1;
  15. public bool IsPassToNativeByAddress => Type.PorType == ParamOrReturnType.STRUCTURE_AS_REF_PARAM;
  16. public string Native2ManagedParamValue(PlatformABI canv)
  17. {
  18. return IsPassToManagedByAddress ? $"(uint64_t)&__arg{Index}" : $"*(uint64_t*)&__arg{Index}";
  19. }
  20. public string Managed2NativeParamValue(PlatformABI canv)
  21. {
  22. return IsPassToNativeByAddress ? $"(uint64_t)(localVarBase+argVarIndexs[{Index}])" : $"*({Type.GetTypeName()}*)(localVarBase+argVarIndexs[{Index}])";
  23. }
  24. }
  25. public class ReturnInfo
  26. {
  27. public TypeInfo Type { get; set; }
  28. public bool IsVoid => Type.PorType == ParamOrReturnType.VOID;
  29. public int GetParamSlotNum(PlatformABI canv)
  30. {
  31. return Type.GetParamSlotNum();
  32. }
  33. public override string ToString()
  34. {
  35. return Type.GetTypeName();
  36. }
  37. }
  38. }