summaryrefslogtreecommitdiff
path: root/compiler/BorrowCheck.ml
diff options
context:
space:
mode:
authorSon Ho2024-06-05 14:50:21 +0200
committerSon Ho2024-06-05 14:50:21 +0200
commit49c8e42ec3bcfc323e61c5ba0345abeb41372ac4 (patch)
treedc6ce67a0aaa0d8656ca607880a9d2f764668b84 /compiler/BorrowCheck.ml
parent35c6b1c3c3dbd1b782cb00206c773021f5c74765 (diff)
Implement a BorrowCheck.borrow_check_crate
Diffstat (limited to '')
-rw-r--r--compiler/BorrowCheck.ml28
1 files changed, 28 insertions, 0 deletions
diff --git a/compiler/BorrowCheck.ml b/compiler/BorrowCheck.ml
new file mode 100644
index 00000000..52f42c37
--- /dev/null
+++ b/compiler/BorrowCheck.ml
@@ -0,0 +1,28 @@
+open Interpreter
+open LlbcAst
+
+(** The local logger *)
+let log = Logging.borrow_check_log
+
+(** Borrow-check a crate.
+
+ Note that we don't return anything: if we find borrow-checking errors,
+ we register them and print them later.
+ *)
+let borrow_check_crate (crate : crate) : unit =
+ (* Debug *)
+ log#ldebug (lazy "translate_crate_to_pure");
+
+ (* Compute the translation context *)
+ let trans_ctx = compute_contexts crate in
+
+ (* Borrow-check *)
+ let borrow_check_fun (fdef : fun_decl) : unit =
+ match fdef.body with
+ | None -> ()
+ | Some _ ->
+ let synthesize = false in
+ let _ = evaluate_function_symbolic synthesize trans_ctx fdef in
+ ()
+ in
+ List.iter borrow_check_fun (FunDeclId.Map.values crate.fun_decls)