summaryrefslogtreecommitdiff
path: root/src/constant_fold.ml
diff options
context:
space:
mode:
authorJon French2019-01-02 12:39:34 +0000
committerJon French2019-01-02 12:39:34 +0000
commitdd5ac9c9b814e0e0c502b4959f8c5c0746ffefd8 (patch)
tree992c7db0b4b4772310ba9b4829e84ca1911dfb1f /src/constant_fold.ml
parent3506f72e7c360a1a7502fb6196a1efd65b819c27 (diff)
restore V_attempted_read behaviour after merge
Diffstat (limited to 'src/constant_fold.ml')
-rw-r--r--src/constant_fold.ml12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/constant_fold.ml b/src/constant_fold.ml
index acae4581..a46f2765 100644
--- a/src/constant_fold.ml
+++ b/src/constant_fold.ml
@@ -78,7 +78,9 @@ and exp_of_value =
| V_tuple vs ->
mk_exp (E_tuple (List.map exp_of_value vs))
| V_unit -> mk_lit_exp L_unit
- | V_attempted_read str -> mk_exp (E_id (mk_id str))
+ | V_attempted_read str ->
+ prerr_endline ("constant_fold folding away V_attempted_read " ^ str);
+ mk_exp (E_id (mk_id str))
| _ -> failwith "No expression for value"
(* We want to avoid evaluating things like print statements at compile
@@ -126,6 +128,14 @@ let rec run frame =
run (Interpreter.eval_frame frame)
| Interpreter.Break frame ->
run (Interpreter.eval_frame frame)
+ | Interpreter.Effect_request (st, Interpreter.Read_reg (reg, cont)) ->
+ (* return a dummy value to read_reg requests which we handle above
+ if an expression finally evals to it, but the interpreter
+ will fail if it tries to actually use. See value.ml *)
+ prerr_endline ("constant_fold returned V_attempted_read " ^ reg ^ "\n");
+ run (cont (Value.V_attempted_read reg) st)
+ | Interpreter.Effect_request _ ->
+ assert false (* effectful, raise exception to abort constant folding *)
(** This rewriting pass looks for function applications (E_app)
expressions where every argument is a literal. It passes these