Finish initialising class of the main method before execution (#59)

This commit is contained in:
Patrick Stevens
2025-06-20 14:39:06 +01:00
committed by GitHub
parent 5a7cf11a5f
commit c620152fb1
3 changed files with 60 additions and 24 deletions

View File

@@ -527,7 +527,7 @@ module DumpedAssembly =
(baseTypeInfo : BaseTypeInfo option)
: ResolvedBaseType
=
let rec go (baseType : BaseTypeInfo option) =
let rec go (source : AssemblyName) (baseType : BaseTypeInfo option) =
match baseType with
| Some (BaseTypeInfo.TypeRef r) ->
let assy = loadedAssemblies.[source.FullName]
@@ -539,7 +539,7 @@ module DumpedAssembly =
| TypeResolutionResult.Resolved (assy, typeInfo) ->
match TypeInfo.isBaseType bct _.Name assy.Name typeInfo.TypeDefHandle with
| Some v -> v
| None -> go typeInfo.BaseType
| None -> go assy.Name typeInfo.BaseType
| Some (BaseTypeInfo.ForeignAssemblyType (assy, ty)) ->
let assy = loadedAssemblies.[assy.FullName]
@@ -547,7 +547,7 @@ module DumpedAssembly =
| Some v -> v
| None ->
let ty = assy.TypeDefs.[ty]
go ty.BaseType
go assy.Name ty.BaseType
| Some (BaseTypeInfo.TypeSpec _) -> failwith "TODO"
| Some (BaseTypeInfo.TypeDef h) ->
let assy = loadedAssemblies.[source.FullName]
@@ -556,7 +556,7 @@ module DumpedAssembly =
| Some v -> v
| None ->
let ty = assy.TypeDefs.[h]
go ty.BaseType
go assy.Name ty.BaseType
| None -> ResolvedBaseType.Object
go baseTypeInfo
go source baseTypeInfo

View File

@@ -142,6 +142,17 @@ type MethodInstructions =
ExceptionRegions : ImmutableArray<ExceptionRegion>
}
static member OnlyRet : MethodInstructions =
let op = IlOp.Nullary NullaryIlOp.Ret
{
Instructions = [ op, 0 ]
Locations = Map.empty |> Map.add 0 op
LocalsInit = false
LocalVars = None
ExceptionRegions = ImmutableArray.Empty
}
/// <summary>
/// Represents detailed information about a method in a .NET assembly.
/// This is a strongly-typed representation of MethodDefinition from System.Reflection.Metadata.