Commits

camlspotter committed 3b36dbf

cleanup

Comments (0)

Files changed (4)

 
 open Llvm
 
-module Ltype = struct
+module Base = struct
   (** phantom *)
   include Phantom.Make(struct type t = lltype end)
   type 'a typ = 'a t 
   type void_pointer = i8 pointer
 end
 
-include Ltype
-
 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
+  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
   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 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 Make(A : sig val context : llcontext end) = struct
   include A
 
+  include Base
+  module Tagged = Tagged
+  module WithString = WithString
+
   (* shorter names *)
   let classify = classify_type
   
 
   (* void pointer is special in LLVM. It is illegal! *)
   let pointer_void = pointer i8
-
 end
 open Llvm
 
 (** phantom *)
-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
+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
 
 module type Tagged = sig
+  open Base
   type tag
   include Phantom_intf.S with type elt = tag * lltype
   val tags : 'a ts -> tag list
   val tag : tag -> 'a typ -> 'a t
 end
 
-module Tagged(Tag : sig type t end) : Tagged with type tag = Tag.t
+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
 
-module WithString : Tagged with type tag = string
+  val ( !:< ) : 'a typ -> Llvm.lltype
+  val ( !:> ) : Llvm.lltype -> unknown typ
+  val ( !:? ) : 'a typ -> unknown typ
 
-module Make(A : sig val context : llcontext end) : sig
+  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
+
   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
 let wrap v _t = v
 
 module Make(A : sig val context : llcontext end) = struct
-  module Ltype = struct
-    include Ltype
-    include Ltype.Make(A)
-  end
+  module Ltype = Ltype.Make(A)
 
   (* We cannot easily open Ltype, since it overwrites Phantom *)
   let (!:<) = Ltype.(!:<)
 open Llvm
 open Ltype
+open Ltype.Base
 
 (** phantom *)
 include Phantom_intf.S with type elt = llvalue