From bf46cfa9a9b8d32223094b2c627d0058dd375618 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Tue, 25 Jun 2024 19:22:35 -0700 Subject: [PATCH 1/2] WrappedTypeAnalysisContext.IsValueType --- Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs | 2 ++ Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs | 2 ++ Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs | 2 ++ Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs | 2 ++ Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs | 2 -- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs index 83eebd2f..e7b6e9a4 100644 --- a/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/ArrayTypeAnalysisContext.cs @@ -19,5 +19,7 @@ public ArrayTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext refe public override string DefaultName => $"{ElementType.Name}[{Rank}]"; + public sealed override bool IsValueType => false; + public int Rank { get; } } diff --git a/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs index 45b44328..928cf9fe 100644 --- a/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/ByRefTypeAnalysisContext.cs @@ -17,5 +17,7 @@ public ByRefTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext refe public override string DefaultName => $"{ElementType.Name}&"; + public sealed override bool IsValueType => false; + public override TypeAnalysisContext ElementType => base.ElementType ?? throw new("TODO Support TYPE_BYREF"); } diff --git a/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs index 7dc64df7..395a3911 100644 --- a/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs @@ -17,4 +17,6 @@ public PointerTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext re public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_PTR; public override string DefaultName => $"{ElementType.Name}*"; + + public sealed override bool IsValueType => true; } diff --git a/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs index e6e9a52e..e10ebb83 100644 --- a/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/SzArrayTypeAnalysisContext.cs @@ -17,4 +17,6 @@ public SzArrayTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext re public override Il2CppTypeEnum Type => Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY; public override string DefaultName => $"{ElementType.Name}[]"; + + public sealed override bool IsValueType => false; } diff --git a/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs index 4c19f563..ed27a87d 100644 --- a/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/WrappedTypeAnalysisContext.cs @@ -12,8 +12,6 @@ public abstract class WrappedTypeAnalysisContext : ReferencedTypeAnalysisContext public override string DefaultNs => ElementType.Namespace; - public override bool IsValueType => ElementType.IsValueType; //We don't set a definition so the default implementation cannot determine if we're a value type or not. - protected WrappedTypeAnalysisContext(TypeAnalysisContext elementType, AssemblyAnalysisContext referencedFrom) : base(referencedFrom) { ElementType = elementType; From 51f2474269b7bee5637753ddb22ede221cbe5a18 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Wed, 26 Jun 2024 07:20:00 -0700 Subject: [PATCH 2/2] Fix pointer type --- Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs b/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs index 395a3911..70309d88 100644 --- a/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs +++ b/Cpp2IL.Core/Model/Contexts/PointerTypeAnalysisContext.cs @@ -18,5 +18,5 @@ public PointerTypeAnalysisContext(Il2CppType rawType, AssemblyAnalysisContext re public override string DefaultName => $"{ElementType.Name}*"; - public sealed override bool IsValueType => true; + public sealed override bool IsValueType => false; }