Commits

camlspotter committed c30bfcb

builder2 fix

Comments (0)

Files changed (4)

     lv_f
 
 
-  let if_then_else (f_lv_cond : bool v) (f_lv_then : 'a v) (f_lv_else : 'a v) : 'a v = 
+  let if_then_else (f_lv_cond : bool v) (f_lv_then : unit -> 'a v) (f_lv_else : unit -> 'a v) : 'a v = 
     (* get the current bb *)
     let start_bb = Block.insertion in
     (* get the function being defined *)
     let then_bb = Block.append ~name:"then" the_function in
     (* Emit 'then' value. *)
     Block.position_at_end then_bb;
-    let lv_then = f_lv_then in
+    let lv_then = f_lv_then () in
     (* Codegen of 'then' can change the current block, update then_bb for the
      * phi. We create a new name because one is used for the phi node, and the
      * other is used for the conditional branch. *)
     let else_bb = Block.append ~name:"else" the_function in
     (* Emit 'else' value. *)
     Block.position_at_end else_bb;
-    let lv_else = f_lv_else in
+    let lv_else = f_lv_else () in
     (* Codegen of 'else' can change the current block, update else_bb for the
      * phi. We create a new name because one is used for the phi node, and the
      * other is used for the conditional branch. *)
   end
 
   val func : string -> 'a typ -> 'b Ltype.WithString.ts -> ('b vs -> 'a v) -> ('b -> 'a) pointer v
-  val if_then_else : bool v -> 'a v -> 'a v -> 'a v
+  val if_then_else : bool v -> (unit -> 'a v) -> (unit -> 'a v) -> 'a v
 end
       let context = context
     end)
     include M
-    module Builder = Lbuilder.Make(M)
+    module CreateBuilder(A : sig end) = Lbuilder2.Make(M)
   end
 end
       val run_function_if_opt : ('a -> 'b) pointer v -> unit
     end
 
-    module Builder : sig
-      
-      module Monad : sig
-        include Monad.T with type 'a t = Llvm.llbuilder -> 'a
-        val run : 'a t -> 'a
-      end 
-      
-      type 'a m = 'a Monad.t
-
-      val magicM : 'a v m -> 'b v m
-
-      val call : ?name:string -> ('a -> 'b) pointer v -> 'a vs -> 'b v m
-
-      val call_va_args : ?name:string -> ('a -> dots -> 'b) pointer v -> 'a vs -> unknown v list -> 'b v m
-
-      val global_stringptr : ?name:string -> string -> i8 pointer v m
-      val bitcast : ?name:string -> 'a v -> 'b typ -> 'b v m
-      val unsafe_gep : ?name:string -> 'a pointer v -> i32 v list -> 'b pointer v m
-      val load : ?name:string -> 'a pointer v -> 'a v m
-      val store : 'a v -> dst:'a pointer v -> unit m
-      val ret : 'a v -> unit m
-      val phi : ?name:string -> ('a v * Llvm.llbasicblock) list -> 'a v m
-      val cond_br : bool v -> Llvm.llbasicblock -> Llvm.llbasicblock -> unit m
-      val br : Llvm.llbasicblock -> unit m
-      val is_null : ?name:string -> 'a pointer v -> bool v m
-      val add : ?name:string -> 'a v -> 'a v -> 'a v m
-      val sub : ?name:string -> 'a v -> 'a v -> 'a v m
-      val mul : ?name:string -> 'a v -> 'a v -> 'a v m
-      val sdiv : ?name:string -> 'a v -> 'a v -> 'a v m
-      val fadd : ?name:string -> 'a v -> 'a v -> 'a v m
-      val fsub : ?name:string -> 'a v -> 'a v -> 'a v m
-      val fmul : ?name:string -> 'a v -> 'a v -> 'a v m
-      val fdiv : ?name:string -> 'a v -> 'a v -> 'a v m
-      val icmp : Llvm.Icmp.t -> ?name:string -> 'a v -> 'a v -> bool v m
-      val fcmp : Llvm.Fcmp.t -> ?name:string -> 'a v -> 'a v -> bool v m
-      val printf : string -> unknown v list -> unit m
-      val cast : ?name:string -> 'a v -> 'b typ -> 'b v m
-      val pointercast : ?name:string -> 'a pointer v -> 'b typ -> 'b v m
-      val malloc : ?name:string -> cont:'a typ -> i32 v -> 'a pointer v m
-      val malloc_lty : ?name:string -> cont:'a typ -> 'a pointer v m
-      val memcpy : dst:void_pointer v -> src:void_pointer v -> size:i32 v -> void_pointer v m
-      val bzero : void_pointer v -> size:i32 v -> unit m
-      val free : void_pointer v -> unit m
-      val unsafe_const_load : ?name:string -> 'a pointer v -> int list -> 'b v m
-      val unsafe_const_store : 'a pointer v -> int list -> 'b v -> unit m
-
+    module CreateBuilder(A : sig end) : sig
+      val builder : Llvm.llbuilder
+    
+      val call : ?name:string -> ('a -> 'b) pointer v -> 'a vs -> 'b v
+      val call_va_args : ?name: string -> ('a -> dots -> 'b) pointer v -> 'a vs -> unknown v list -> 'b v
+    
+      val global_stringptr : ?name:string -> string -> i8 pointer v
+    
+      val bitcast : ?name:string -> 'a v -> 'b typ -> 'b v
+    
+      val unsafe_gep : ?name:string -> 'a pointer v -> i32 v list -> 'unsafe pointer v
+        
+      val load : ?name:string -> 'a pointer v -> 'a v
+      val store : 'a v -> dst:'a pointer v -> unit
+        
+      val ret : 'a v -> unit
+        
+      val phi : ?name:string -> ('a v * Llvm.llbasicblock) list -> 'a v
+    
+      val cond_br : bool v -> Llvm.llbasicblock -> Llvm.llbasicblock -> unit
+    
+      val br : Llvm.llbasicblock -> unit
+    
+      val is_null : ?name:string -> 'a pointer v -> bool v
+    
+      val add : ?name:string -> 'a v -> 'a v -> 'a v
+      val sub : ?name:string -> 'a v -> 'a v -> 'a v
+      val mul : ?name:string -> 'a v -> 'a v -> 'a v
+      val sdiv : ?name:string -> 'a v -> 'a v -> 'a v
+      val fadd : ?name:string -> 'a v -> 'a v -> 'a v
+      val fsub : ?name:string -> 'a v -> 'a v -> 'a v
+      val fmul : ?name:string -> 'a v -> 'a v -> 'a v
+      val fdiv : ?name:string -> 'a v -> 'a v -> 'a v
+      val icmp : Llvm.Icmp.t -> ?name:string -> 'a v -> 'a v -> bool v
+      val fcmp : Llvm.Fcmp.t -> ?name:string -> 'a v -> 'a v -> bool v
+    
+      val printf : string -> unknown v list -> unit
+    
+      val cast : ?name:string -> 'a v -> 'b typ -> 'b v
+      val pointercast : ?name:string -> 'a pointer v -> 'b typ -> 'b v
+    
+      val malloc : ?name:string -> cont:'a typ -> i32 v -> 'a pointer v
+      val malloc_lty : ?name:string -> cont:'a typ -> 'a pointer v
+      val memcpy : dst:void_pointer v -> src:void_pointer v -> size:i32 v -> void_pointer v
+      val bzero : void_pointer v -> size:i32 v -> unit
+      val free : void_pointer v -> unit
+      val unsafe_const_load : ?name:string -> 'a pointer v -> int list -> 'unsafe v
+      val unsafe_const_store : 'a pointer v -> int list -> 'unsafe v -> unit
+    
       module Block : sig
-        val position_at_end : Llvm.llbasicblock -> unit m
-        val insertion : Llvm.llbasicblock m
+        val position_at_end : Llvm.llbasicblock -> unit
+        val insertion : Llvm.llbasicblock
         val append : ?name:string -> ('a -> 'b) pointer v -> Llvm.llbasicblock
         val parent : Llvm.llbasicblock -> ('a -> 'b) pointer v
       end
-
-      val func : string -> 'a typ -> 'b Ltype.WithString.ts -> ('b vs -> 'a v m) -> ('b -> 'a) pointer v m
-      val if_then_else : bool v m -> 'a v m -> 'a v m -> 'a v m
+    
+      val func : string -> 'a typ -> 'b Ltype.WithString.ts -> ('b vs -> 'a v) -> ('b -> 'a) pointer v
+      val if_then_else : bool v -> (unit -> 'a v) -> (unit -> 'a v) -> 'a v
     end
   end
 end