From a5d09658b0c15862b609226d18f072c5d9f1e953 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 12 Dec 2022 13:25:37 +0100 Subject: Make progress on Interpreter.ml --- compiler/ValuesUtils.ml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/ValuesUtils.ml') diff --git a/compiler/ValuesUtils.ml b/compiler/ValuesUtils.ml index 470f40ac..adeb105f 100644 --- a/compiler/ValuesUtils.ml +++ b/compiler/ValuesUtils.ml @@ -37,6 +37,13 @@ let as_mut_borrow (v : typed_value) : BorrowId.id * typed_value = | Borrow (MutBorrow (bid, bv)) -> (bid, bv) | _ -> raise (Failure "Unexpected") +let is_unit (v : typed_value) : bool = + ty_is_unit v.ty + && + match v.value with + | Adt av -> av.variant_id = None && av.field_values = [] + | _ -> false + (** Check if a value contains a *concrete* borrow (i.e., a [Borrow] value - we don't check if there are borrows hidden in symbolic values). *) -- cgit v1.2.3