diff options
author | Son Ho | 2021-11-25 14:55:46 +0100 |
---|---|---|
committer | Son Ho | 2021-11-25 14:55:46 +0100 |
commit | 8a1caeb5205c644019204d6ac27d286fba705841 (patch) | |
tree | 7a2467319b0cb441e7d67a1e1a3c79acdf82e1f4 | |
parent | ce37ae98ecd5297c5588d88e2c64fbb8bc56adeb (diff) |
Start working on eval_statement
-rw-r--r-- | src/Interpreter.ml | 20 |
1 files changed, 20 insertions, 0 deletions
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) |