1. camlspotter
  2. ocaml-llvm-phantom

Commits

camlspotter  committed 69c08d4

fallback!

  • Participants
  • Parent commits 3b36dbf
  • Branches default

Comments (0)

Files changed (4)

File ltype.ml

View file
 
 open Llvm
 
-module Base = struct
+module Ltype = struct
   (** phantom *)
   include Phantom.Make(struct type t = lltype end)
   type 'a typ = 'a t 
   
   (* void pointer is special in LLVM. It is illegal! *)
   type void_pointer = i8 pointer
-end
 
-module type Tagged = sig
-  type tag
-  include Phantom_intf.S with type elt = tag * lltype
-  val tags : 'a ts -> tag list
-  val types : 'a ts -> 'a Base.typs
-  val combine : tag list -> 'a Base.typs -> 'a ts
-  val tag : tag -> 'a Base.typ -> 'a t
-end
-
-module Tagged(Tag : sig type t end) = struct
-  type tag = Tag.t
-  include Phantom.Make(struct 
-    type t = tag * lltype
-  end)
-
-  let tags ts = List.map fst (to_list ts)
-  let types (ts : 'a ts) : 'a Base.ts = 
-    Base.of_list (List.map (fun (_,ty) -> Base.unsafe ty) (to_list ts))
-  let combine tags (ts : 'a Base.ts) : 'a ts =
-    of_list (List.map unsafe (List.combine tags (Base.to_list ts)))
-  let tag t v = (t, v)
-end
-
-module WithString = Tagged(struct type t = string end)
-
-module Make(A : sig val context : llcontext end) = struct
-  include A
-
-  include Base
-  module Tagged = Tagged
-  module WithString = WithString
-
-  (* shorter names *)
   let classify = classify_type
   
   let void = void_type
     | _ -> assert false
   
   let string_of = string_of_lltype
+end
 
-  (* now applied context *)
+include Ltype
+
+module Make(A : sig val context : llcontext end) = struct
+  include A
+
+  include Ltype
+
   let void = void context
   let i1 = i1 context
   let i8 = i8 context
 
   (* void pointer is special in LLVM. It is illegal! *)
   let pointer_void = pointer i8
+
 end
+
+module type Tagged = sig
+  type tag
+  include Phantom_intf.S with type elt = tag * lltype
+  val tags : 'a ts -> tag list
+  val types : 'a ts -> 'a typs
+  val combine : tag list -> 'a typs -> 'a ts
+  val tag : tag -> 'a typ -> 'a t
+end
+
+module Tagged(Tag : sig type t end) = struct
+  type tag = Tag.t
+  include Phantom.Make(struct 
+    type t = tag * lltype
+  end)
+
+  let tags ts = List.map fst (to_list ts)
+  let types (ts : 'a ts) : 'a Ltype.ts = 
+    Ltype.of_list (List.map (fun (_,ty) -> Ltype.unsafe ty) (to_list ts))
+  let combine tags (ts : 'a Ltype.ts) : 'a ts =
+    of_list (List.map unsafe (List.combine tags (Ltype.to_list ts)))
+  let tag t v = (t, v)
+end
+
+module WithString = Tagged(struct type t = string end)

File ltype.mli

View file
 open Llvm
 
 (** phantom *)
-module Base : sig
-  include Phantom_intf.S with type elt = lltype
-  type 'a typ = 'a t
-  type 'a typs = 'a ts
-  
-  val ( !:< ) : 'a typ -> lltype
-  val ( !:> ) : lltype -> unknown typ
-  val ( !:? ) : 'a typ -> unknown typ
-  
-  (** descriptors *)
-  
-  type void
-  type i1 = [`int | `i1]
-  type i8 = [`int | `i8]
-  type i16 = [`int | `i16]
-  type i32 = [`int | `i32]
-  type i64 = [`int | `i64]
-  type 'a integer
-  (* type float *) (* use OCaml's float *)
-  type double = [`floating | `double]
-  type dots
-  type 'a struct_
-  (* type ('a, 'b) array_ *) (* use OCaml's array *)
-  type 'a pointer
-  type 'a vector
-  (* void pointer is special in LLVM. It is illegal! *)
-  type void_pointer = i8 pointer
-end
+include Phantom_intf.S with type elt = lltype
+type 'a typ = 'a t
+type 'a typs = 'a ts
 
-module type Tagged = sig
-  open Base
-  type tag
-  include Phantom_intf.S with type elt = tag * lltype
-  val tags : 'a ts -> tag list
-  val types : 'a ts -> 'a typs
-  val combine : tag list -> 'a typs -> 'a ts
-  val tag : tag -> 'a typ -> 'a t
-end
+val ( !:< ) : 'a typ -> lltype
+val ( !:> ) : lltype -> unknown typ
+val ( !:? ) : 'a typ -> unknown typ
 
-module Make(A : sig val context : Llvm.llcontext end) : sig
-  include Phantom_intf.S with type elt = lltype 
-                         and type 'a t = 'a Base.t 
-                         and type 'a ts = 'a Base.ts
-  type 'a typ = 'a Base.typ
-  type 'a typs = 'a Base.typs
-      
-  type void = Base.void
-  type i1 = Base.i1
-  type i8 = Base.i8
-  type i16 = Base.i16
-  type i32 = Base.i32
-  type i64 = Base.i64
-  type 'a integer = 'a Base.integer
-  type double = Base.double
-  type dots = Base.dots
-  type 'a struct_ = 'a Base.struct_
-  (* type ('a, 'b) array_ *) (* use OCaml's array *)
-  type 'a pointer = 'a Base.pointer
-  type 'a vector = 'a Base.vector
-  (* void pointer is special in LLVM. It is illegal! *)
-  type void_pointer = Base.void_pointer
+(** descriptors *)
 
-  val ( !:< ) : 'a typ -> Llvm.lltype
-  val ( !:> ) : Llvm.lltype -> unknown typ
-  val ( !:? ) : 'a typ -> unknown typ
+type void
+type i1 = [`int | `i1]
+type i8 = [`int | `i8]
+type i16 = [`int | `i16]
+type i32 = [`int | `i32]
+type i64 = [`int | `i64]
+type 'a integer
+(* type float *) (* use OCaml's float *)
+type double = [`floating | `double]
+type dots
+type 'a struct_
+(* type ('a, 'b) array_ *) (* use OCaml's array *)
+type 'a pointer
+type 'a vector
+(* void pointer is special in LLVM. It is illegal! *)
+type void_pointer = i8 pointer
 
-  module Tagged(Tag : sig type t end) : sig
-    type tag
-    include Phantom_intf.S with type elt = tag * lltype
-    val tags : 'a ts -> tag list
-    val types : 'a ts -> 'a typs
-    val combine : tag list -> 'a typs -> 'a ts
-    val tag : tag -> 'a typ -> 'a t
-  end
-
-  module WithString : Tagged with type tag = string
-
+module Make(A : sig val context : llcontext end) : sig
   val void : void typ
   val i1 : i1 typ
   val i8 : i8 typ
 
   val string_of : 'a typ -> string
   val classify : 'a typ -> TypeKind.t
+
 end
+
+module type Tagged = sig
+  type tag
+  include Phantom_intf.S with type elt = tag * lltype
+  val tags : 'a ts -> tag list
+  val types : 'a ts -> 'a typs
+  val combine : tag list -> 'a typs -> 'a ts
+  val tag : tag -> 'a typ -> 'a t
+end
+
+module Tagged(Tag : sig type t end) : Tagged with type tag = Tag.t
+
+module WithString : Tagged with type tag = string

File lvalue.ml

View file
 let wrap v _t = v
 
 module Make(A : sig val context : llcontext end) = struct
-  module Ltype = Ltype.Make(A)
+  module Ltype = struct
+    include Ltype
+    include Ltype.Make(A)
+  end
 
   (* We cannot easily open Ltype, since it overwrites Phantom *)
   let (!:<) = Ltype.(!:<)

File lvalue.mli

View file
 open Llvm
 open Ltype
-open Ltype.Base
 
 (** phantom *)
 include Phantom_intf.S with type elt = llvalue