Jacques-Pascal Deplaix avatar Jacques-Pascal Deplaix committed 5f29131

Improving the type signatures and add main.ml to the Makefile (doesn't compile)

Comments (0)

Files changed (4)

 type 'a t = {data : 'a}
 
 type llvm_int = [`Int of (int * Big_int.big_int option)]
-type 'a llvm_array = [`Array of (int * 'a)]
-type 'a llvm_pointer = [`Pointer of ('a * int option)]
-type ('a, 'b) llvm_function_pointer = [`Function_pointer of ('a array * 'b * int option)]
+type 'a llvm_array = [`Array of (int * 'a t)]
+type 'a llvm_pointer = [`Pointer of ('a t * int option)]
+type ('a, 'b) llvm_function_pointer = [`Function_pointer of ('a t array * 'b t * int option)]
 
 let int i x = {data = `Int (i, x)}
 let array i x = {data = `Array (i, x)}
 let rec to_string data =
   let rec aux acc arr = function
     | 0 -> acc
-    | n -> aux (acc ^ ", " ^ to_string arr.(n)) arr (pred n)
+    | n -> aux (acc ^ ", " ^ to_string arr.(n).data) arr (pred n)
   in
   match data with
     | `Int (i, _) -> "i" ^ string_of_int i
-    | `Pointer (t, _) -> to_string t ^ "*"
+    | `Pointer (t, _) -> to_string t.data ^ "*"
     | `Array (i, t) ->
-        "[" ^ string_of_int i ^ " x " ^ to_string t ^ "]"
+        "[" ^ string_of_int i ^ " x " ^ to_string t.data ^ "]"
     | `Function_pointer (a, t, _) ->
-        to_string t ^ " @("
+        to_string t.data ^ " @("
         ^ aux
-          (if Array.length a > 0 then to_string a.(0) else "")
+          (if Array.length a > 0 then to_string a.(0).data else "")
           a
           (Array.length a - 1)
         ^ ") *"
 type 'a t
 
 type llvm_int = [`Int of (int * Big_int.big_int option)]
-type 'a llvm_array = [`Array of (int * 'a)]
-type 'a llvm_pointer = [`Pointer of ('a * int option)]
-type ('a, 'b) llvm_function_pointer = [`Function_pointer of ('a array * 'b * int option)]
+type 'a llvm_array = [`Array of (int * 'a t)]
+type 'a llvm_pointer = [`Pointer of ('a t * int option)]
+type ('a, 'b) llvm_function_pointer = [`Function_pointer of ('a t array * 'b t * int option)]
 
 val int : int -> Big_int.big_int option -> llvm_int t
-val array : int -> 'a -> 'a llvm_array t
-val pointer : 'a -> int option -> 'a llvm_pointer t
-val function_pointer : 'a array -> 'b -> int option -> ('a, 'b) llvm_function_pointer t
+val array : int -> 'a t -> 'a llvm_array t
+val pointer : 'a t -> int option -> 'a llvm_pointer t
+val function_pointer : 'a t array -> 'b t -> int option -> ('a, 'b) llvm_function_pointer t
 
 val to_string :
   ([< llvm_int
 # Just for testing
 all:
-	ocamlc LLVM_types.mli LLVM_types.ml LLVM.mli LLVM.ml
+	ocamlc LLVM_types.mli LLVM_types.ml LLVM.mli LLVM.ml main.ml
 let () =
   LLVM.print_context_module
     (LLVM.new_global
-      ~link_type:(Some `Internal)
-      ~constant:true
-      "msg" (LLVM.Array (13, LLVM.Int 8)));
+       ~link_type:(Some `Internal)
+       ~constant:true
+       "msg"
+       (LLVM_types.array 13 (LLVM_types.int 8 None))
+    );
   LLVM.print_context_module
     (LLVM.new_declaration
-      (LLVM.Int 32) "puts" [| LLVM.Pointer (LLVM.Int 8); LLVM.Int 32 |]
-      ~link_type: (Some `External))
+       (LLVM_types.int 32 None)
+       "puts"
+       [| LLVM_types.pointer (LLVM_types.int 8 None); LLVM_types.int 32 None |]
+      ~link_type:(Some `External)
+    )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.