summaryrefslogtreecommitdiff
path: root/compiler/InterpreterUtils.ml
diff options
context:
space:
mode:
authorSon Ho2023-01-05 23:11:26 +0100
committerSon HO2023-02-03 11:21:46 +0100
commitefba91b5cc65d83c3f4d8a0d282eeda520abe82a (patch)
tree9af8c05626e89bf0f5abc94ff443b3f8194d6903 /compiler/InterpreterUtils.ml
parentace526e4d32d17ab73bcc2cdb3726cddcae8b1c4 (diff)
Add more loop examples and fix issues
Diffstat (limited to '')
-rw-r--r--compiler/InterpreterUtils.ml23
1 files changed, 20 insertions, 3 deletions
diff --git a/compiler/InterpreterUtils.ml b/compiler/InterpreterUtils.ml
index 670435a5..d60ddfe6 100644
--- a/compiler/InterpreterUtils.ml
+++ b/compiler/InterpreterUtils.ml
@@ -8,9 +8,22 @@ module L = Logging
open Utils
open TypesUtils
module PA = Print.EvalCtxLlbcAst
+open Cps
(** Some utilities *)
+(** Auxiliary function - call a function which requires a continuation,
+ and return the let context given to the continuation *)
+let get_cf_ctx_no_synth (f : cm_fun) (ctx : C.eval_ctx) : C.eval_ctx =
+ let nctx = ref None in
+ let cf ctx =
+ assert (!nctx = None);
+ nctx := Some ctx;
+ None
+ in
+ let _ = f cf ctx in
+ Option.get !nctx
+
let eval_ctx_to_string_no_filter = Print.Contexts.eval_ctx_to_string_no_filter
let eval_ctx_to_string = Print.Contexts.eval_ctx_to_string
let ety_to_string = PA.ety_to_string
@@ -368,12 +381,16 @@ let compute_absl_ids (xl : V.abs list) : ids_sets * ids_to_values =
let compute_abs_ids (x : V.abs) : ids_sets * ids_to_values =
compute_absl_ids [ x ]
-(** Compute the sets of ids found in an environment element. *)
-let compute_env_elem_ids (x : C.env_elem) : ids_sets * ids_to_values =
+(** Compute the sets of ids found in an environment. *)
+let compute_env_ids (x : C.env) : ids_sets * ids_to_values =
let compute, get_ids, get_ids_to_values = compute_ids () in
- compute#visit_env_elem () x;
+ compute#visit_env () x;
(get_ids (), get_ids_to_values ())
+(** Compute the sets of ids found in an environment element. *)
+let compute_env_elem_ids (x : C.env_elem) : ids_sets * ids_to_values =
+ compute_env_ids [ x ]
+
(** Compute the sets of ids found in a list of contexts. *)
let compute_contexts_ids (ctxl : C.eval_ctx list) : ids_sets * ids_to_values =
let compute, get_ids, get_ids_to_values = compute_ids () in