Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Microsoft.FSharp.NativeInterop
- [<Struct>]
- type Point =
- struct
- val X: double
- val Y: double
- end
- [<EntryPoint>]
- let main argv =
- let myPtr = NativePtr.stackalloc<Point>(1)
- let obj = NativePtr.read myPtr in
- let x = obj.X
- let y = obj.Y
- 0
- // .entrypoint
- // .locals init (
- // [0] native int myPtr,
- // [1] valuetype Program/Point obj,
- // [2] float64 x,
- // [3] float64 y
- // )
- // IL_0000: nop
- // IL_0001: ldc.i4.1
- // IL_0002: sizeof Program/Point
- // IL_0008: mul
- // IL_0009: localloc
- // IL_000b: stloc.0
- // IL_000c: ldloc.0
- // IL_000d: ldobj Program/Point
- // IL_0012: stloc.1
- // IL_0013: ldloca.s obj
- // IL_0015: ldfld float64 Program/Point::X@
- // IL_001a: stloc.2
- // IL_001b: ldloca.s obj
- // IL_001d: ldfld float64 Program/Point::Y@
- // IL_0022: stloc.3
- // IL_0023: ldc.i4.0
- // IL_0024: ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement