Commits

shawnh  committed cadb31b

Moved some typecheck code from llvm to typecheck module.

  • Participants
  • Parent commits 12501d4

Comments (0)

Files changed (3)

File blub_llvm.ml

       raise (Jit_failed msg)
 ;;
 
-let rec simplify_type = function
-    Typevar (r, _) as tv -> (
-      match !r with
-	  Some t -> simplify_type t
-	| None -> tv)
-  | x -> x
-;;
-
 let get_type typeinfo (ast:ast) =
-  simplify_type (PMap.find ast typeinfo)
+  simplify (PMap.find ast typeinfo)
 ;;
 
 

File blub_typecheck.ml

   ()
 ;;
 
-let rec simplify tv = 
+let rec simplify_tv tv = 
   let (r, id) = tv in
   match !r with
       Some t -> t
     | None -> Typevar tv
 ;;
 
+let rec simplify = function
+    Typevar (r, _) as tv -> (
+      match !r with
+	  Some t -> simplify t
+	| None -> tv)
+  | x -> x
+;;
+
+
 
 let rec unify (t1:type_) (t2:type_) =
   match t1, t2 with
 	  let (_, id1) = tv1 in
 	  let (_, id) = tv in
 	  printf "Comparing typevar %d against %d\n%!" id1 id;
-	  if ((simplify tv1) = (simplify tv)) then tv2 else inst_var tv tm'
+	  if ((simplify_tv tv1) = (simplify_tv tv)) then 
+	    tv2 
+	  else 
+	    inst_var tv tm'
   in
   let rec inst (t:type_) =
     match t with
 		let llvm_code = Blub_llvm.jit_compile globals env ast tmap in
 		let Fun (argtypes, _) = PMap.find ast tmap in
 
-		let argtypes = Array.map Blub_llvm.simplify_type argtypes in
+		let argtypes = Array.map Blub_typecheck.simplify argtypes in
 		printf "Adding JITcode for argtypes %a\n%!"
 		  (pp_array pp_type) argtypes;