summaryrefslogtreecommitdiff
path: root/compiler/InterpreterExpansion.ml
diff options
context:
space:
mode:
authorSon Ho2024-05-30 22:34:05 +0200
committerSon Ho2024-05-30 22:34:05 +0200
commit4b87c34cb91485bae744cd5aa42d63493686fdd3 (patch)
tree3ba25311666127dc9d30b9790cd3bc1c67fca798 /compiler/InterpreterExpansion.ml
parent170ce1c399d3ae6b2ff9485037eae4d89e7879f2 (diff)
Remove the options from the functions synthesizing the symbolic AST
Diffstat (limited to '')
-rw-r--r--compiler/InterpreterExpansion.ml25
-rw-r--r--compiler/InterpreterExpansion.mli7
2 files changed, 12 insertions, 20 deletions
diff --git a/compiler/InterpreterExpansion.ml b/compiler/InterpreterExpansion.ml
index 388d7382..3c264c6e 100644
--- a/compiler/InterpreterExpansion.ml
+++ b/compiler/InterpreterExpansion.ml
@@ -447,8 +447,7 @@ let expand_symbolic_bool (config : config) (span : Meta.span)
(sv : symbolic_value) (sv_place : SA.mplace option) :
eval_ctx ->
(eval_ctx * eval_ctx)
- * ((SymbolicAst.expression * SymbolicAst.expression) option -> eval_result)
- =
+ * (SymbolicAst.expression * SymbolicAst.expression -> eval_result) =
fun ctx ->
(* Compute the expanded value *)
let original_sv = sv in
@@ -465,9 +464,8 @@ let expand_symbolic_bool (config : config) (span : Meta.span)
let ctx_true = apply_expansion see_true in
let ctx_false = apply_expansion see_false in
(* Compute the continuation to build the expression *)
- let cf e =
- let el = match e with Some (a, b) -> Some [ a; b ] | None -> None in
- S.synthesize_symbolic_expansion span sv sv_place seel el
+ let cf (e0, e1) =
+ S.synthesize_symbolic_expansion span sv sv_place seel [ e0; e1 ]
in
(* Return *)
((ctx_true, ctx_false), cf)
@@ -535,8 +533,7 @@ let expand_symbolic_value_no_branching (config : config) (span : Meta.span)
let expand_symbolic_adt (config : config) (span : Meta.span)
(sv : symbolic_value) (sv_place : SA.mplace option) :
- eval_ctx ->
- eval_ctx list * (SymbolicAst.expression list option -> eval_result) =
+ eval_ctx -> eval_ctx list * (SymbolicAst.expression list -> eval_result) =
fun ctx ->
(* Debug *)
log#ldebug (lazy ("expand_symbolic_adt:" ^ symbolic_value_to_string ctx sv));
@@ -571,8 +568,7 @@ let expand_symbolic_int (config : config) (span : Meta.span)
(int_type : integer_type) (tgts : scalar_value list) :
eval_ctx ->
(eval_ctx list * eval_ctx)
- * ((SymbolicAst.expression list * SymbolicAst.expression) option ->
- eval_result) =
+ * (SymbolicAst.expression list * SymbolicAst.expression -> eval_result) =
fun ctx ->
(* Sanity check *)
sanity_check __FILE__ __LINE__ (sv.sv_ty = TLiteral (TInteger int_type)) span;
@@ -589,13 +585,10 @@ let expand_symbolic_int (config : config) (span : Meta.span)
in
let ctx_otherwise = ctx in
(* Update the symbolic ast *)
- let cf e =
- match e with
- | None -> None
- | Some (el, e) ->
- let seel = List.map (fun x -> Some x) seel in
- S.synthesize_symbolic_expansion span sv sv_place (seel @ [ None ])
- (Some (el @ [ e ]))
+ let cf (el, e) =
+ let seel = List.map (fun x -> Some x) seel in
+ S.synthesize_symbolic_expansion span sv sv_place (seel @ [ None ])
+ (el @ [ e ])
in
((ctx_branches, ctx_otherwise), cf)
diff --git a/compiler/InterpreterExpansion.mli b/compiler/InterpreterExpansion.mli
index 7f8c3a0a..9b5ebed3 100644
--- a/compiler/InterpreterExpansion.mli
+++ b/compiler/InterpreterExpansion.mli
@@ -38,7 +38,7 @@ val expand_symbolic_adt :
symbolic_value ->
SA.mplace option ->
eval_ctx ->
- eval_ctx list * (SymbolicAst.expression list option -> eval_result)
+ eval_ctx list * (SymbolicAst.expression list -> eval_result)
(** Expand a symbolic boolean.
@@ -51,7 +51,7 @@ val expand_symbolic_bool :
SA.mplace option ->
eval_ctx ->
(eval_ctx * eval_ctx)
- * ((SymbolicAst.expression * SymbolicAst.expression) option -> eval_result)
+ * (SymbolicAst.expression * SymbolicAst.expression -> eval_result)
(** Symbolic integers are expanded upon evaluating a [SwitchInt].
@@ -76,8 +76,7 @@ val expand_symbolic_int :
scalar_value list ->
eval_ctx ->
(eval_ctx list * eval_ctx)
- * ((SymbolicAst.expression list * SymbolicAst.expression) option ->
- eval_result)
+ * (SymbolicAst.expression list * SymbolicAst.expression -> eval_result)
(** If this mode is activated through the [config], greedily expand the symbolic
values which need to be expanded. See {!type:Contexts.config} for more information.