Source

ocaml-llvm-phantom / lib / value.ml

Full commit
open Llvm
open Spotlib.Spot
module P = Spotlib.Spot.Phantom
open P.Open

open Type

(** phantom *)
type 'a v = ('a, llvalue) P.t
type 'a vs = ('a, llvalue) P.ts

let unsafe_annotate v (_t : 'ty typ) : 'ty v = P.unsafe v

let dump v = dump_value !<v
let type_of (v : 'typ v) = P.unsafe & type_of !<v
let typs_of (ts : 'typs vs) : 'typs typs = 
  P.List.unsafe_of_list (List.map Llvm.type_of (P.List.to_list ts))
let set_name name v = set_value_name name !<v
let name v = value_name !<v

let function_params (f : ('args -> 'ret) pointer v) : 'args vs = 
  P.List.unsafe_list (Array.to_list (params !<f))