Fix argument ordering bug (#58)

This commit is contained in:
Patrick Stevens
2025-06-20 12:40:45 +01:00
committed by GitHub
parent 71b12b5684
commit 5a7cf11a5f
11 changed files with 221 additions and 47 deletions

View File

@@ -244,6 +244,7 @@ type DumpedAssembly =
interface IDisposable with
member this.Dispose () = this.PeReader.Dispose ()
type TypeResolutionResult =
| FirstLoadAssy of WoofWare.PawPrint.AssemblyReference
| Resolved of DumpedAssembly * TypeInfo<TypeDefn>
@@ -516,3 +517,46 @@ module Assembly =
match assemblies.TryGetValue assy.Name.FullName with
| false, _ -> TypeResolutionResult.FirstLoadAssy assy
| true, toAssy -> resolveTypeFromName toAssy assemblies ty.Namespace ty.Name genericArgs
[<RequireQualifiedAccess>]
module DumpedAssembly =
let resolveBaseType
(bct : BaseClassTypes<DumpedAssembly>)
(loadedAssemblies : ImmutableDictionary<string, DumpedAssembly>)
(source : AssemblyName)
(baseTypeInfo : BaseTypeInfo option)
: ResolvedBaseType
=
let rec go (baseType : BaseTypeInfo option) =
match baseType with
| Some (BaseTypeInfo.TypeRef r) ->
let assy = loadedAssemblies.[source.FullName]
// TODO: generics
match Assembly.resolveTypeRef loadedAssemblies assy assy.TypeRefs.[r] None with
| TypeResolutionResult.FirstLoadAssy _ ->
failwith
"seems pretty unlikely that we could have constructed this object without loading its base type"
| TypeResolutionResult.Resolved (assy, typeInfo) ->
match TypeInfo.isBaseType bct _.Name assy.Name typeInfo.TypeDefHandle with
| Some v -> v
| None -> go typeInfo.BaseType
| Some (BaseTypeInfo.ForeignAssemblyType (assy, ty)) ->
let assy = loadedAssemblies.[assy.FullName]
match TypeInfo.isBaseType bct _.Name assy.Name ty with
| Some v -> v
| None ->
let ty = assy.TypeDefs.[ty]
go ty.BaseType
| Some (BaseTypeInfo.TypeSpec _) -> failwith "TODO"
| Some (BaseTypeInfo.TypeDef h) ->
let assy = loadedAssemblies.[source.FullName]
match TypeInfo.isBaseType bct _.Name assy.Name h with
| Some v -> v
| None ->
let ty = assy.TypeDefs.[h]
go ty.BaseType
| None -> ResolvedBaseType.Object
go baseTypeInfo