Source

ocaml-llvm-phantom / lib / genvalue.ml

Full commit
(* CR jfuruse: This should be Value.Generic *)

(* open Llvm *)
open Llvm_executionengine

open Spotlib.Spot
module P = Spotlib.Spot.Phantom
open P.Open

open Type


module GV = GenericValue

(** phantom *)
type 'a v = ('a, GV.t) Phantom.t
type 'a vs = ('a, GV.t) Phantom.ts

let of_float : ([>`floating] as 'a) typ -> float -> 'a v = 
  fun ty v -> P.unsafe & GV.of_float !<ty v

let unsafe_of_pointer : 'a (* unsafe *) -> 'b pointer v = 
  fun v -> P.unsafe & GV.of_pointer v

let of_int32 : ([>`int] as 'a) typ -> int32 -> 'a v =
  fun ty v -> P.unsafe & GV.of_int32 !<ty v

let of_int : ([>`int] as 'a) typ -> int -> 'a v =
  fun ty v -> P.unsafe & GV.of_int !<ty v

let of_nativeint : ([>`int] as 'a) typ -> nativeint -> 'a v =
  fun ty v -> P.unsafe & GV.of_nativeint !<ty v

let of_int64 : ([>`int] as 'a) typ -> int64 -> 'a v =
  fun ty v -> P.unsafe & GV.of_int64 !<ty v

let as_float : ([>`floating] as 'a) typ -> 'a v -> float = 
  fun ty v -> GV.as_float !<ty !<v
let as_unsafe_pointer : 'a pointer v -> 'b (* unsafe *) = fun v -> GV.as_pointer !<v
let as_int32 : ([>`int] as 'a) v -> int32  = fun v -> GV.as_int32 !<v
let as_int : ([>`int] as 'a) v -> int = fun v -> GV.as_int !<v
let as_nativeint : ([>`int] as 'a) v -> nativeint = fun v -> GV.as_nativeint !<v
let as_int64 : ([>`int] as 'a) v -> int64 = fun v -> GV.as_int64 !<v