Source

TyLLVM / src / LLVM_types.ml

Full commit
type _ f =
  | Ret : 'a t -> 'a t f
  | App : 'a t * 'b f -> ('a * 'b) f

and _ t =
  | Int : int -> int t
  | Array : int * 'a t -> 'a t array t
  | Pointer : 'a t -> 'a t t
  | FunctionPointer : 'a f -> 'a f t

type 'a value = 'a t * 'a

let rec to_string : type a. a t -> string = fun data ->
  let rec aux : type a. string -> a f -> string = fun acc -> function
    | Ret t -> to_string t ^ " @(" ^ acc ^ ") *"
    | App (t, f) -> aux (acc ^ ", " ^ to_string t) f (* FALSE ! Also before *)
  in
  match data with
    | Int i -> "i" ^ string_of_int i
    | Array (i, t) ->
        "[" ^ string_of_int i ^ " x " ^ to_string t ^ "]"
    | Pointer t -> to_string t ^ "*"
    | FunctionPointer f -> aux "" f