summaryrefslogtreecommitdiff
path: root/src/Interpreter.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/Interpreter.ml')
-rw-r--r--src/Interpreter.ml52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/Interpreter.ml b/src/Interpreter.ml
index 51144ba2..3a2939ef 100644
--- a/src/Interpreter.ml
+++ b/src/Interpreter.ml
@@ -13,7 +13,7 @@ module SA = SymbolicAst
(** The local logger *)
let log = L.interpreter_log
-let compute_type_fun_contexts (m : M.llbc_module) :
+let compute_type_fun_global_contexts (m : M.llbc_module) :
C.type_context * C.fun_context * C.global_context =
let type_decls_list, _, _ = M.split_declarations m.declarations in
let type_decls, fun_decls, global_decls = M.compute_defs_maps m in
@@ -28,10 +28,8 @@ let compute_type_fun_contexts (m : M.llbc_module) :
let global_context = { C.global_decls } in
(type_context, fun_context, global_context)
-let initialize_eval_context
- (type_context : C.type_context)
- (fun_context : C.fun_context)
- (global_context : C.global_context)
+let initialize_eval_context (type_context : C.type_context)
+ (fun_context : C.fun_context) (global_context : C.global_context)
(type_vars : T.type_var list) : C.eval_ctx =
C.reset_global_counters ();
{
@@ -56,12 +54,9 @@ let initialize_eval_context
- the list of symbolic values introduced for the input values
- the instantiated function signature
*)
-let initialize_symbolic_context_for_fun
- (type_context : C.type_context)
- (fun_context : C.fun_context)
- (global_context : C.global_context)
- (fdef : A.fun_decl) :
- C.eval_ctx * V.symbolic_value list * A.inst_fun_sig =
+let initialize_symbolic_context_for_fun (type_context : C.type_context)
+ (fun_context : C.fun_context) (global_context : C.global_context)
+ (fdef : A.fun_decl) : C.eval_ctx * V.symbolic_value list * A.inst_fun_sig =
(* The abstractions are not initialized the same way as for function
* calls: they contain *loan* projectors, because they "provide" us
* with the input values (which behave as if they had been returned
@@ -75,7 +70,10 @@ let initialize_symbolic_context_for_fun
* *)
let sg = fdef.signature in
(* Create the context *)
- let ctx = initialize_eval_context type_context fun_context global_context sg.type_params in
+ let ctx =
+ initialize_eval_context type_context fun_context global_context
+ sg.type_params
+ in
(* Instantiate the signature *)
let type_params = List.map (fun tv -> T.TypeVar tv.T.index) sg.type_params in
let inst_sg = instantiate_fun_sig type_params sg in
@@ -212,8 +210,9 @@ let evaluate_function_symbolic_synthesize_backward_from_return
- the symbolic AST generated by the symbolic execution
*)
let evaluate_function_symbolic (config : C.partial_config) (synthesize : bool)
- (type_context : C.type_context) (fun_context : C.fun_context) (global_context : C.global_context)
- (fdef : A.fun_decl) (back_id : T.RegionGroupId.id option) :
+ (type_context : C.type_context) (fun_context : C.fun_context)
+ (global_context : C.global_context) (fdef : A.fun_decl)
+ (back_id : T.RegionGroupId.id option) :
V.symbolic_value list * SA.expression option =
(* Debug *)
let name_to_string () =
@@ -226,7 +225,8 @@ let evaluate_function_symbolic (config : C.partial_config) (synthesize : bool)
(* Create the evaluation context *)
let ctx, input_svs, inst_sg =
- initialize_symbolic_context_for_fun type_context fun_context global_context fdef
+ initialize_symbolic_context_for_fun type_context fun_context global_context
+ fdef
in
(* Create the continuation to finish the evaluation *)
@@ -293,8 +293,12 @@ module Test = struct
assert (body.A.arg_count = 0);
(* Create the evaluation context *)
- let type_context, fun_context, global_context = compute_type_fun_contexts m in
- let ctx = initialize_eval_context type_context fun_context global_context [] in
+ let type_context, fun_context, global_context =
+ compute_type_fun_global_contexts m
+ in
+ let ctx =
+ initialize_eval_context type_context fun_context global_context []
+ in
(* Insert the (uninitialized) local variables *)
let ctx = C.ctx_push_uninitialized_vars ctx body.A.locals in
@@ -338,15 +342,16 @@ module Test = struct
(** Execute the symbolic interpreter on a function. *)
let test_function_symbolic (config : C.partial_config) (synthesize : bool)
- (type_context : C.type_context) (fun_context : C.fun_context) (global_context : C.global_context)
- (fdef : A.fun_decl) : unit =
+ (type_context : C.type_context) (fun_context : C.fun_context)
+ (global_context : C.global_context) (fdef : A.fun_decl) : unit =
(* Debug *)
log#ldebug
(lazy ("test_function_symbolic: " ^ Print.fun_name_to_string fdef.A.name));
(* Evaluate *)
let evaluate =
- evaluate_function_symbolic config synthesize type_context fun_context global_context fdef
+ evaluate_function_symbolic config synthesize type_context fun_context
+ global_context fdef
in
(* Execute the forward function *)
let _ = evaluate None in
@@ -376,12 +381,15 @@ module Test = struct
in
(* Filter the opaque functions *)
let no_loop_funs = List.filter fun_decl_is_transparent no_loop_funs in
- let type_context, fun_context, global_context = compute_type_fun_contexts m in
+ let type_context, fun_context, global_context =
+ compute_type_fun_global_contexts m
+ in
let test_fun (def : A.fun_decl) : unit =
(* Execute the function - note that as the symbolic interpreter explores
* all the path, some executions are expected to "panic": we thus don't
* check the return value *)
- test_function_symbolic config synthesize type_context fun_context global_context def
+ test_function_symbolic config synthesize type_context fun_context
+ global_context def
in
List.iter test_fun no_loop_funs
end