From 8a1caeb5205c644019204d6ac27d286fba705841 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 25 Nov 2021 14:55:46 +0100 Subject: Start working on eval_statement --- src/Interpreter.ml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/Interpreter.ml') diff --git a/src/Interpreter.ml b/src/Interpreter.ml index 55045cf5..25ba60f5 100644 --- a/src/Interpreter.ml +++ b/src/Interpreter.ml @@ -1653,6 +1653,8 @@ let eval_binary_op (config : config) (ctx : eval_ctx) (binop : binop) match res with Error _ -> Error Panic | Ok v -> Ok (ctx2, v)) | _ -> failwith "Invalid inputs for binop" +(** Evaluate an rvalue in a given context: return the updated context and + the computed value *) let eval_rvalue (config : config) (ctx : eval_ctx) (rvalue : rvalue) : (eval_ctx * typed_value) eval_result = match rvalue with @@ -1755,3 +1757,21 @@ let eval_rvalue (config : config) (ctx : eval_ctx) (rvalue : rvalue) : in let aty = Types.Adt (def_id, regions, types) in Ok (ctx1, { value = Adt av; ty = aty })) + +(** Result of evaluating a statement *) +type statement_eval_res = Unit | Break of int | Continue of int | Panic + +let rec eval_statement (ctx : eval_ctx) (st : statement) : + eval_ctx * statement_eval_res = + match st with + | Assign (p, rvalue) -> raise Unimplemented + | FakeRead p -> raise Unimplemented + | SetDiscriminant (p, variant_id) -> raise Unimplemented + | Drop p -> raise Unimplemented + | Assert assertion -> raise Unimplemented + | Call call -> raise Unimplemented + | Panic -> raise Unimplemented + | Return -> raise Unimplemented + | Break i -> raise Unimplemented + | Continue -> raise Unimplemented + | Nop -> (ctx, Unit) -- cgit v1.2.3