summaryrefslogtreecommitdiff
path: root/src/Translate.ml
diff options
context:
space:
mode:
authorSon Ho2022-02-08 23:00:17 +0100
committerSon Ho2022-02-08 23:00:17 +0100
commit5703ce3122bcfb69285a7f04abc8d80313a0747a (patch)
treea424f6dc1bb0598e3e47f1a3cc2ec4e15607dc91 /src/Translate.ml
parent229a9881fa26dce69b81524445045e7b1efcc6fc (diff)
Add type checking utilities for the pure ADT
Diffstat (limited to 'src/Translate.ml')
-rw-r--r--src/Translate.ml14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Translate.ml b/src/Translate.ml
index ba975c60..028114cf 100644
--- a/src/Translate.ml
+++ b/src/Translate.ml
@@ -61,7 +61,8 @@ let translate_function_to_symbolics (config : C.partial_config)
let translate_function_to_pure (config : C.partial_config)
(trans_ctx : trans_ctx)
(fun_sigs : SymbolicToPure.fun_sig_named_outputs RegularFunIdMap.t)
- (fdef : A.fun_def) : pure_fun_translation =
+ (pure_type_defs : Pure.type_def Pure.TypeDefId.Map.t) (fdef : A.fun_def) :
+ pure_fun_translation =
(* Debug *)
log#ldebug
(lazy ("translate_function_to_pure: " ^ Print.name_to_string fdef.A.name));
@@ -91,6 +92,7 @@ let translate_function_to_pure (config : C.partial_config)
{
SymbolicToPure.types_infos = type_context.type_infos;
cfim_type_defs = type_context.type_defs;
+ type_defs = pure_type_defs;
}
in
let fun_context =
@@ -216,6 +218,12 @@ let translate_module_to_pure (config : C.partial_config)
(* Translate all the type definitions *)
let type_defs = SymbolicToPure.translate_type_defs m.types in
+ (* Compute the type definition map *)
+ let type_defs_map =
+ Pure.TypeDefId.Map.of_list
+ (List.map (fun (def : Pure.type_def) -> (def.def_id, def)) type_defs)
+ in
+
(* Translate all the function *signatures* *)
let assumed_sigs =
List.map
@@ -240,7 +248,9 @@ let translate_module_to_pure (config : C.partial_config)
(* Translate all the functions *)
let pure_translations =
- List.map (translate_function_to_pure config trans_ctx fun_sigs) m.functions
+ List.map
+ (translate_function_to_pure config trans_ctx fun_sigs type_defs_map)
+ m.functions
in
(* Apply the micro-passes *)