Advertisement
AngraMainyu

Untitled

Oct 4th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.95 KB | None | 0 0
  1. open Microsoft.FSharp.NativeInterop
  2.  
  3. [<Struct>]
  4. type Point =
  5.     struct
  6.         val X: double
  7.         val Y: double
  8.     end
  9.  
  10.  
  11. [<EntryPoint>]
  12. let main argv =
  13.     let myPtr = NativePtr.stackalloc<Point>(1)
  14.     let obj = NativePtr.read myPtr in
  15.         let x = obj.X
  16.         let y = obj.Y
  17.     0
  18.  
  19. //    .entrypoint
  20. //    .locals init (
  21. //        [0] native int myPtr,
  22. //        [1] valuetype Program/Point obj,
  23. //        [2] float64 x,
  24. //        [3] float64 y
  25. //    )
  26. //    IL_0000: nop
  27. //    IL_0001: ldc.i4.1
  28. //    IL_0002: sizeof Program/Point
  29. //    IL_0008: mul
  30. //    IL_0009: localloc
  31. //    IL_000b: stloc.0
  32. //    IL_000c: ldloc.0
  33. //    IL_000d: ldobj Program/Point
  34. //    IL_0012: stloc.1
  35. //    IL_0013: ldloca.s obj
  36. //    IL_0015: ldfld float64 Program/Point::X@
  37. //    IL_001a: stloc.2
  38. //    IL_001b: ldloca.s obj
  39. //    IL_001d: ldfld float64 Program/Point::Y@
  40. //    IL_0022: stloc.3
  41. //    IL_0023: ldc.i4.0
  42. //    IL_0024: ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement