Commits

camlspotter committed 1bfb47e

numbered func and run_funciton

  • Participants
  • Parent commits 6453891

Comments (0)

Files changed (4)

       (* \ Format.eprintf "Created function %s@." name; *)
       return lv_f
 
+  let func0 name ?dump ret () f = func name ?dump ret P.c0 (fun self -> P.uncurry0 (f self))
+  let func1 name ?dump ret (arg0,t0) f = func name ?dump ret (P.c1 (P.combine arg0 t0)) (fun self -> P.uncurry1 (f self))
+  let func2 name ?dump ret (arg0,t0) (arg1,t1) f = func name ?dump ret (P.c2 (P.combine arg0 t0) (P.combine arg1 t1)) (fun self -> P.uncurry2 (f self))
+  let func3 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) f = func name ?dump ret (P.c3 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2)) (fun self -> P.uncurry3 (f self))
+  let func4 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) (arg3,t3) f = func name ?dump ret (P.c4 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2) (P.combine arg3 t3)) (fun self -> P.uncurry4 (f self))
+  let func5 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) (arg3,t3) (arg4,t4) f = func name ?dump ret (P.c5 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2) (P.combine arg3 t3) (P.combine arg4 t4)) (fun self -> P.uncurry5 (f self))
+  let func6 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) (arg3,t3) (arg4,t4) (arg5,t5) f = func name ?dump ret (P.c6 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2) (P.combine arg3 t3) (P.combine arg4 t4) (P.combine arg5 t5)) (fun self -> P.uncurry6 (f self))
+  let func7 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) (arg3,t3) (arg4,t4) (arg5,t5) (arg6,t6) f = func name ?dump ret (P.c7 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2) (P.combine arg3 t3) (P.combine arg4 t4) (P.combine arg5 t5) (P.combine arg6 t6)) (fun self -> P.uncurry7 (f self))
+  let func8 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) (arg3,t3) (arg4,t4) (arg5,t5) (arg6,t6) (arg7,t7) f = func name ?dump ret (P.c8 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2) (P.combine arg3 t3) (P.combine arg4 t4) (P.combine arg5 t5) (P.combine arg6 t6) (P.combine arg7 t7)) (fun self -> P.uncurry8 (f self))
+  let func9 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) (arg3,t3) (arg4,t4) (arg5,t5) (arg6,t6) (arg7,t7) (arg8,t8) f = func name ?dump ret (P.c9 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2) (P.combine arg3 t3) (P.combine arg4 t4) (P.combine arg5 t5) (P.combine arg6 t6) (P.combine arg7 t7) (P.combine arg8 t8)) (fun self -> P.uncurry9 (f self))
+  let func10 name ?dump ret (arg0,t0) (arg1,t1) (arg2,t2) (arg3,t3) (arg4,t4) (arg5,t5) (arg6,t6) (arg7,t7) (arg8,t8) (arg9,t9) f = func name ?dump ret (P.c10 (P.combine arg0 t0) (P.combine arg1 t1) (P.combine arg2 t2) (P.combine arg3 t3) (P.combine arg4 t4) (P.combine arg5 t5) (P.combine arg6 t6) (P.combine arg7 t7) (P.combine arg8 t8) (P.combine arg9 t9)) (fun self -> P.uncurry10 (f self))
+
   (* stupid lambda abstraction is required for polymorphism *)    
   let current_function : unit -> ('a -> 'b) pointer v m = fun () -> perform
     current_bb <-- Block.insertion;
 open Spotlib.Spot
-open Spotlib.Spot.Phantom.Open
+open Spotlib.Spot.Phantom
 open Type
 open Value
 
       Self is for recursion.
   *)
 
-
+  val func0 : string -> ?dump:bool -> 'res typ
+    -> unit
+    -> ((tpl0 -> 'res) pointer v -> unit -> 'res v m)
+    -> (tpl0 -> 'res) pointer v m
+  val func1 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ)
+    -> ((('a0) tpl1 -> 'res) pointer v -> 'a0 v -> 'res v m)
+    -> (('a0) tpl1 -> 'res) pointer v m
+  val func2 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ)
+    -> ((('a0,'a1) tpl2 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'res v m)
+    -> (('a0,'a1) tpl2 -> 'res) pointer v m
+  val func3 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ)
+    -> ((('a0,'a1,'a2) tpl3 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'res v m)
+    -> (('a0,'a1,'a2) tpl3 -> 'res) pointer v m
+  val func4 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ) -> (string * 'a3 typ)
+    -> ((('a0,'a1,'a2,'a3) tpl4 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'a3 v -> 'res v m)
+    -> (('a0,'a1,'a2,'a3) tpl4 -> 'res) pointer v m
+  val func5 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ) -> (string * 'a3 typ) -> (string * 'a4 typ)
+    -> ((('a0,'a1,'a2,'a3,'a4) tpl5 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'a3 v -> 'a4 v -> 'res v m)
+    -> (('a0,'a1,'a2,'a3,'a4) tpl5 -> 'res) pointer v m
+  val func6 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ) -> (string * 'a3 typ) -> (string * 'a4 typ) -> (string * 'a5 typ)
+    -> ((('a0,'a1,'a2,'a3,'a4,'a5) tpl6 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'a3 v -> 'a4 v -> 'a5 v -> 'res v m)
+    -> (('a0,'a1,'a2,'a3,'a4,'a5) tpl6 -> 'res) pointer v m
+  val func7 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ) -> (string * 'a3 typ) -> (string * 'a4 typ) -> (string * 'a5 typ) -> (string * 'a6 typ)
+    -> ((('a0,'a1,'a2,'a3,'a4,'a5,'a6) tpl7 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'a3 v -> 'a4 v -> 'a5 v -> 'a6 v -> 'res v m)
+    -> (('a0,'a1,'a2,'a3,'a4,'a5,'a6) tpl7 -> 'res) pointer v m
+  val func8 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ) -> (string * 'a3 typ) -> (string * 'a4 typ) -> (string * 'a5 typ) -> (string * 'a6 typ) -> (string * 'a7 typ)
+    -> ((('a0,'a1,'a2,'a3,'a4,'a5,'a6,'a7) tpl8 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'a3 v -> 'a4 v -> 'a5 v -> 'a6 v -> 'a7 v -> 'res v m)
+    -> (('a0,'a1,'a2,'a3,'a4,'a5,'a6,'a7) tpl8 -> 'res) pointer v m
+  val func9 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ) -> (string * 'a3 typ) -> (string * 'a4 typ) -> (string * 'a5 typ) -> (string * 'a6 typ) -> (string * 'a7 typ) -> (string * 'a8 typ)
+    -> ((('a0,'a1,'a2,'a3,'a4,'a5,'a6,'a7,'a8) tpl9 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'a3 v -> 'a4 v -> 'a5 v -> 'a6 v -> 'a7 v -> 'a8 v -> 'res v m)
+    -> (('a0,'a1,'a2,'a3,'a4,'a5,'a6,'a7,'a8) tpl9 -> 'res) pointer v m
+  val func10 : string -> ?dump:bool -> 'res typ
+    -> (string * 'a0 typ) -> (string * 'a1 typ) -> (string * 'a2 typ) -> (string * 'a3 typ) -> (string * 'a4 typ) -> (string * 'a5 typ) -> (string * 'a6 typ) -> (string * 'a7 typ) -> (string * 'a8 typ) -> (string * 'a9 typ)
+    -> ((('a0,'a1,'a2,'a3,'a4,'a5,'a6,'a7,'a8,'a9) tpl10 -> 'res) pointer v -> 'a0 v -> 'a1 v -> 'a2 v -> 'a3 v -> 'a4 v -> 'a5 v -> 'a6 v -> 'a7 v -> 'a8 v -> 'a9 v -> 'res v m)
+    -> (('a0,'a1,'a2,'a3,'a4,'a5,'a6,'a7,'a8,'a9) tpl10 -> 'res) pointer v m
 
   (** Connecting basic blocks *)
 

examples/double_phantom.ml

 end)
 open Monad.Open
 
-let double = build (func "double" ~dump:true 
-                      i32 (P.c1 (P.combine "param" i32)) 
-                      (fun _self -> P.uncurry1 (mul (Const.i32_of_int 2))))
+let double = build (func1 "double" ~dump:true 
+                      i32 ("param", i32)
+                      (fun _self -> mul (Const.i32_of_int 2)))
 
 let run_double = ExecutionEngine.run_function1 double
 
 open Spotlib.Spot
 open Format
 
+(*
 let f ppf n = 
   let rec g ppf = function
     | 0 -> fprintf ppf "('a%d * _)" n
     n
 
 let _ = for i = 0 to 9 do f stdout i done
+*)
+
+let def_func ppf = function
+  | 0 -> 
+      fprintf ppf "let func0 name ?dump ret () f = func name ?dump ret P.c0 (fun self -> P.uncurry0 (f self))@."
+  | n -> 
+      fprintf ppf "let func%d name ?dump ret %a f = func name ?dump ret (P.c%d %a) (fun self -> P.uncurry%d (f self))@."
+        n 
+        (list (fun ppf -> fprintf ppf " ")
+           (fun ppf i -> fprintf ppf "(arg%d,t%d)" i i)) (List.from_to 0 (n-1))
+        n
+        (list (fun ppf -> fprintf ppf " ")
+           (fun ppf i -> fprintf ppf "(P.combine arg%d t%d)" i i)) (List.from_to 0 (n-1))
+        n
+;;
+
+let type_func ppf = function
+  | 0 -> fprintf ppf "(tpl0 -> 'res) pointer v"
+  | n -> 
+      fprintf ppf "((%a) tpl%d -> 'res) pointer v"
+        (list (fun ppf -> fprintf ppf ",")
+           (fun ppf i -> fprintf ppf "'a%d" i)) (List.from_to 0 (n-1))
+        n
+
+let sig_func ppf = function
+  | 0 -> 
+      fprintf ppf "val func0 : string -> ?dump:bool -> 'res typ@.";
+      fprintf ppf "  -> unit@.";
+      fprintf ppf "  -> (%a -> unit -> 'res v m)@." type_func 0;
+      fprintf ppf "  -> %a m@." type_func 0
+        
+  | n -> 
+      fprintf ppf "val func%d : string -> ?dump:bool -> 'res typ@." n;
+      fprintf ppf "  -> %a@."
+        (list (fun ppf -> fprintf ppf " -> ")
+           (fun ppf i -> fprintf ppf "(string * 'a%d typ)" i)) (List.from_to 0 (n-1));
+      fprintf ppf "  -> (%a -> %a -> 'res v m)@."
+        type_func n
+        (list (fun ppf -> fprintf ppf " -> ")
+           (fun ppf i -> fprintf ppf "'a%d v" i)) (List.from_to 0 (n-1));
+      fprintf ppf "  -> %a m@."
+        type_func n
+
+let _ = 
+  for i = 0 to 10 do
+    def_func stdout i;
+  done;
+  for i = 0 to 10 do
+    sig_func stdout i;
+  done
+