Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fcs/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let isMono = false
// Utilities
// --------------------------------------------------------------------------------------

let dotnetExePath = DotNetCli.InstallDotNetSDK "2.1.4"
let dotnetExePath = DotNetCli.InstallDotNetSDK "2.1.100"

let runDotnet workingDir args =
let result =
Expand Down
37 changes: 24 additions & 13 deletions src/absil/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,7 @@ type MethodBody =
| PInvoke of PInvokeMethod (* platform invoke to native *)
| Abstract
| Native
| NotAvailable

type ILLazyMethodBody =
| ILLazyMethodBody of Lazy<MethodBody >
Expand Down Expand Up @@ -1859,7 +1860,8 @@ type ILResourceAccess =

[<RequireQualifiedAccess>]
type ILResourceLocation =
| Local of (unit -> byte[])
| LocalIn of string * int * int
| LocalOut of byte[]
| File of ILModuleRef * int32
| Assembly of ILAssemblyRef

Expand All @@ -1868,15 +1870,16 @@ type ILResource =
Location: ILResourceLocation;
Access: ILResourceAccess;
CustomAttrs: ILAttributes }
/// Read the bytes from a resource local to an assembly
member r.Bytes =
match r.Location with
| ILResourceLocation.Local b -> b()
| _ -> failwith "Bytes"
member r.GetBytes() =
match r.Location with
| ILResourceLocation.LocalIn (file, start, len) ->
FileSystem.ReadAllBytesShim(file).[start .. start + len - 1]
| ILResourceLocation.LocalOut bytes -> bytes
| _ -> failwith "GetBytes"

type ILResources =
| ILResources of Lazy<ILResource list>
member x.AsList = let (ILResources ltab) = x in (ltab.Force())
| ILResources of ILResource list
member x.AsList = let (ILResources ltab) = x in ltab

// --------------------------------------------------------------------
// One module in the "current" assembly
Expand Down Expand Up @@ -1912,6 +1915,11 @@ type ILAssemblyManifest =
EntrypointElsewhere: ILModuleRef option
}

[<RequireQualifiedAccess>]
type ILNativeResource =
| In of fileName: string * linkedResourceBase: int * linkedResourceStart: int * linkedResourceLength: int
| Out of unlinkedResource: byte[]

type ILModuleDef =
{ Manifest: ILAssemblyManifest option
CustomAttrs: ILAttributes
Expand All @@ -1923,7 +1931,7 @@ type ILModuleDef =
SubSystemFlags: int32
IsDLL: bool
IsILOnly: bool
Platform: ILPlatform option
Platform: ILPlatform option
StackReserveSize: int32 option
Is32Bit: bool
Is32BitPreferred: bool
Expand All @@ -1933,7 +1941,7 @@ type ILModuleDef =
ImageBase: int32
MetadataVersion: string
Resources: ILResources
NativeResources: list<Lazy<byte[]>> (* e.g. win32 resources *)
NativeResources: ILNativeResource list (* e.g. win32 resources *)
}
member x.ManifestOfAssembly =
match x.Manifest with
Expand Down Expand Up @@ -2515,6 +2523,9 @@ let mkMethodBody (zeroinit,locals,maxstack,code,tag) = MethodBody.IL (mkILMethod

let mkILVoidReturn = mkILReturn ILType.Void

let methBodyNotAvailable = mkMethBodyAux MethodBody.NotAvailable
let methBodyAbstract = mkMethBodyAux MethodBody.Abstract
let methBodyNative = mkMethBodyAux MethodBody.Native

let mkILCtor (access,args,impl) =
ILMethodDef(name=".ctor",
Expand Down Expand Up @@ -2764,8 +2775,7 @@ let mkILNestedExportedTypes l =
let mkILNestedExportedTypesLazy (l:Lazy<_>) =
ILNestedExportedTypes (lazy (List.foldBack addNestedExportedTypeToTable (l.Force()) Map.empty))

let mkILResources l = ILResources (notlazy l)
let mkILResourcesLazy l = ILResources l
let mkILResources l = ILResources l

let addMethodImplToTable y tab =
let key = (y.Overrides.MethodRef.Name,y.Overrides.MethodRef.ArgTypes.Length)
Expand Down Expand Up @@ -3751,7 +3761,8 @@ and refs_of_exported_types s (tab: ILExportedTypesAndForwarders) = List.iter (re

and refs_of_resource_where s x =
match x with
| ILResourceLocation.Local _ -> ()
| ILResourceLocation.LocalIn _ -> ()
| ILResourceLocation.LocalOut _ -> ()
| ILResourceLocation.File (mref,_) -> refs_of_modref s mref
| ILResourceLocation.Assembly aref -> refs_of_assref s aref

Expand Down
36 changes: 28 additions & 8 deletions src/absil/il.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ type MethodBody =
| PInvoke of PInvokeMethod (* platform invoke to native *)
| Abstract
| Native
| NotAvailable

// REVIEW: fold this into ILMethodDef.
[<RequireQualifiedAccess>]
Expand Down Expand Up @@ -1426,8 +1427,16 @@ type ILResourceAccess =

[<RequireQualifiedAccess>]
type ILResourceLocation =
| Local of (unit -> byte[]) (* resources may be re-read each time this function is called *)
/// Represents a manifest resource that can be read from within the PE file
| LocalIn of string * int * int

/// Represents a manifest resource that is due to be written to the output PE file
| LocalOut of byte[]

/// Represents a manifest resource in an associated file
| File of ILModuleRef * int32

/// Represents a manifest resource in a different assembly
| Assembly of ILAssemblyRef

/// "Manifest ILResources" are chunks of resource data, being one of:
Expand All @@ -1439,8 +1448,9 @@ type ILResource =
Location: ILResourceLocation
Access: ILResourceAccess
CustomAttrs: ILAttributes }
/// Read the bytes from a resource local to an assembly
member Bytes: byte[]

/// Read the bytes from a resource local to an assembly. Will fail for non-local resources.
member GetBytes : unit -> byte[]

/// Table of resources in a module.
[<NoEquality; NoComparison>]
Expand Down Expand Up @@ -1487,7 +1497,15 @@ type ILAssemblyManifest =
/// Records whether the entrypoint resides in another module.
EntrypointElsewhere: ILModuleRef option
}


[<RequireQualifiedAccess>]
type ILNativeResource =
/// Represents a native resource to be read from the PE file
| In of fileName: string * linkedResourceBase: int * linkedResourceStart: int * linkedResourceLength: int

/// Represents a native resource to be written in an output file
| Out of unlinkedResource: byte[]

/// One module in the "current" assembly, either a main-module or
/// an auxiliary module. The main module will have a manifest.
///
Expand All @@ -1512,9 +1530,9 @@ type ILModuleDef =
PhysicalAlignment: int32
ImageBase: int32
MetadataVersion: string
Resources: ILResources
/// e.g. win86 resources, as the exact contents of a .res or .obj file.
NativeResources: Lazy<byte[]> list }
Resources: ILResources
/// e.g. win86 resources, as the exact contents of a .res or .obj file. Must be unlinked manually.
NativeResources: ILNativeResource list }
member ManifestOfAssembly: ILAssemblyManifest
member HasManifest: bool

Expand Down Expand Up @@ -1749,6 +1767,9 @@ val mkILEmptyGenericParams: ILGenericParameterDefs
/// Make method definitions.
val mkILMethodBody: initlocals:bool * ILLocals * int * ILCode * ILSourceMarker option -> ILMethodBody
val mkMethodBody: bool * ILLocals * int * ILCode * ILSourceMarker option -> MethodBody
val methBodyNotAvailable: ILLazyMethodBody
val methBodyAbstract: ILLazyMethodBody
val methBodyNative: ILLazyMethodBody

val mkILCtor: ILMemberAccess * ILParameter list * MethodBody -> ILMethodDef
val mkILClassCtor: MethodBody -> ILMethodDef
Expand Down Expand Up @@ -1863,7 +1884,6 @@ val mkILExportedTypes: ILExportedTypeOrForwarder list -> ILExportedTypesAndForwa
val mkILExportedTypesLazy: Lazy<ILExportedTypeOrForwarder list> -> ILExportedTypesAndForwarders

val mkILResources: ILResource list -> ILResources
val mkILResourcesLazy: Lazy<ILResource list> -> ILResources

/// Making modules.
val mkILSimpleModule: assemblyName:string -> moduleName:string -> dll:bool -> subsystemVersion: (int * int) -> useHighEntropyVA: bool -> ILTypeDefs -> int32 option -> string option -> int -> ILExportedTypesAndForwarders -> string -> ILModuleDef
Expand Down
Loading