From 5209cea7012cfa3b39a5a289e65e2ea5e166d730 Mon Sep 17 00:00:00 2001 From: Escherichia Date: Thu, 21 Mar 2024 12:34:40 +0100 Subject: WIP: translate.ml and extract.ml do not compile. Some assert left to do and we need to see how translate_crate can give meta to the functions it calls --- compiler/ValuesUtils.ml | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'compiler/ValuesUtils.ml') diff --git a/compiler/ValuesUtils.ml b/compiler/ValuesUtils.ml index 2c7d213f..51c9e8cc 100644 --- a/compiler/ValuesUtils.ml +++ b/compiler/ValuesUtils.ml @@ -2,6 +2,7 @@ open Utils open TypesUtils open Types open Values +open Errors include Charon.ValuesUtils (** Utility exception *) @@ -10,34 +11,34 @@ exception FoundSymbolicValue of symbolic_value let mk_unit_value : typed_value = { value = VAdt { variant_id = None; field_values = [] }; ty = mk_unit_ty } -let mk_typed_value (ty : ty) (value : value) : typed_value = - assert (ty_is_ety ty); +let mk_typed_value (meta : Meta.meta) (ty : ty) (value : value) : typed_value = + cassert (ty_is_ety ty) meta "TODO: error message"; { value; ty } -let mk_typed_avalue (ty : ty) (value : avalue) : typed_avalue = - assert (ty_is_rty ty); +let mk_typed_avalue (meta : Meta.meta) (ty : ty) (value : avalue) : typed_avalue = + cassert (ty_is_rty ty) meta "TODO: error message"; { value; ty } -let mk_bottom (ty : ty) : typed_value = - assert (ty_is_ety ty); +let mk_bottom (meta : Meta.meta) (ty : ty) : typed_value = + cassert (ty_is_ety ty) meta "TODO: error message"; { value = VBottom; ty } -let mk_abottom (ty : ty) : typed_avalue = - assert (ty_is_rty ty); +let mk_abottom (meta : Meta.meta) (ty : ty) : typed_avalue = + cassert (ty_is_rty ty) meta "TODO: error message"; { value = ABottom; ty } -let mk_aignored (ty : ty) : typed_avalue = - assert (ty_is_rty ty); +let mk_aignored (meta : Meta.meta) (ty : ty) : typed_avalue = + cassert (ty_is_rty ty) meta "TODO: error message"; { value = AIgnored; ty } -let value_as_symbolic (v : value) : symbolic_value = - match v with VSymbolic v -> v | _ -> raise (Failure "Unexpected") +let value_as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = + match v with VSymbolic v -> v | _ -> craise meta "Unexpected" (** Box a value *) -let mk_box_value (v : typed_value) : typed_value = +let mk_box_value (meta : Meta.meta) (v : typed_value) : typed_value = let box_ty = mk_box_ty v.ty in let box_v = VAdt { variant_id = None; field_values = [ v ] } in - mk_typed_value box_ty box_v + mk_typed_value meta box_ty box_v let is_bottom (v : value) : bool = match v with VBottom -> true | _ -> false @@ -47,13 +48,13 @@ let is_aignored (v : avalue) : bool = let is_symbolic (v : value) : bool = match v with VSymbolic _ -> true | _ -> false -let as_symbolic (v : value) : symbolic_value = - match v with VSymbolic s -> s | _ -> raise (Failure "Unexpected") +let as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = + match v with VSymbolic s -> s | _ -> craise meta "Unexpected" -let as_mut_borrow (v : typed_value) : BorrowId.id * typed_value = +let as_mut_borrow (meta : Meta.meta) (v : typed_value) : BorrowId.id * typed_value = match v.value with | VBorrow (VMutBorrow (bid, bv)) -> (bid, bv) - | _ -> raise (Failure "Unexpected") + | _ -> craise meta "Unexpected" let is_unit (v : typed_value) : bool = ty_is_unit v.ty -- cgit v1.2.3 From 5ad671a0960692af1c00609fa6864c6f44ca299c Mon Sep 17 00:00:00 2001 From: Escherichia Date: Thu, 28 Mar 2024 13:56:31 +0100 Subject: Should answer all comments, there are still some TODO: error message left --- compiler/ValuesUtils.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'compiler/ValuesUtils.ml') diff --git a/compiler/ValuesUtils.ml b/compiler/ValuesUtils.ml index 51c9e8cc..9c4b8b45 100644 --- a/compiler/ValuesUtils.ml +++ b/compiler/ValuesUtils.ml @@ -12,23 +12,23 @@ let mk_unit_value : typed_value = { value = VAdt { variant_id = None; field_values = [] }; ty = mk_unit_ty } let mk_typed_value (meta : Meta.meta) (ty : ty) (value : value) : typed_value = - cassert (ty_is_ety ty) meta "TODO: error message"; + sanity_check (ty_is_ety ty) meta; { value; ty } let mk_typed_avalue (meta : Meta.meta) (ty : ty) (value : avalue) : typed_avalue = - cassert (ty_is_rty ty) meta "TODO: error message"; + sanity_check (ty_is_rty ty) meta; { value; ty } let mk_bottom (meta : Meta.meta) (ty : ty) : typed_value = - cassert (ty_is_ety ty) meta "TODO: error message"; + sanity_check (ty_is_ety ty) meta; { value = VBottom; ty } let mk_abottom (meta : Meta.meta) (ty : ty) : typed_avalue = - cassert (ty_is_rty ty) meta "TODO: error message"; + sanity_check (ty_is_rty ty) meta; { value = ABottom; ty } let mk_aignored (meta : Meta.meta) (ty : ty) : typed_avalue = - cassert (ty_is_rty ty) meta "TODO: error message"; + sanity_check (ty_is_rty ty) meta; { value = AIgnored; ty } let value_as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = -- cgit v1.2.3 From 64666edb3c10cd42e15937ac4038b83def630e35 Mon Sep 17 00:00:00 2001 From: Escherichia Date: Thu, 28 Mar 2024 17:14:27 +0100 Subject: formatting --- compiler/ValuesUtils.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'compiler/ValuesUtils.ml') diff --git a/compiler/ValuesUtils.ml b/compiler/ValuesUtils.ml index 9c4b8b45..d2c48d13 100644 --- a/compiler/ValuesUtils.ml +++ b/compiler/ValuesUtils.ml @@ -15,7 +15,8 @@ let mk_typed_value (meta : Meta.meta) (ty : ty) (value : value) : typed_value = sanity_check (ty_is_ety ty) meta; { value; ty } -let mk_typed_avalue (meta : Meta.meta) (ty : ty) (value : avalue) : typed_avalue = +let mk_typed_avalue (meta : Meta.meta) (ty : ty) (value : avalue) : typed_avalue + = sanity_check (ty_is_rty ty) meta; { value; ty } @@ -51,7 +52,8 @@ let is_symbolic (v : value) : bool = let as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = match v with VSymbolic s -> s | _ -> craise meta "Unexpected" -let as_mut_borrow (meta : Meta.meta) (v : typed_value) : BorrowId.id * typed_value = +let as_mut_borrow (meta : Meta.meta) (v : typed_value) : + BorrowId.id * typed_value = match v.value with | VBorrow (VMutBorrow (bid, bv)) -> (bid, bv) | _ -> craise meta "Unexpected" -- cgit v1.2.3 From 786c54c01ea98580374638c0ed92d19dfae19b1f Mon Sep 17 00:00:00 2001 From: Escherichia Date: Fri, 29 Mar 2024 13:21:08 +0100 Subject: added file and line arg to craise and cassert --- compiler/ValuesUtils.ml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'compiler/ValuesUtils.ml') diff --git a/compiler/ValuesUtils.ml b/compiler/ValuesUtils.ml index d2c48d13..980ebef7 100644 --- a/compiler/ValuesUtils.ml +++ b/compiler/ValuesUtils.ml @@ -12,28 +12,28 @@ let mk_unit_value : typed_value = { value = VAdt { variant_id = None; field_values = [] }; ty = mk_unit_ty } let mk_typed_value (meta : Meta.meta) (ty : ty) (value : value) : typed_value = - sanity_check (ty_is_ety ty) meta; + sanity_check __FILE__ __LINE__ (ty_is_ety ty) meta; { value; ty } let mk_typed_avalue (meta : Meta.meta) (ty : ty) (value : avalue) : typed_avalue = - sanity_check (ty_is_rty ty) meta; + sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta; { value; ty } let mk_bottom (meta : Meta.meta) (ty : ty) : typed_value = - sanity_check (ty_is_ety ty) meta; + sanity_check __FILE__ __LINE__ (ty_is_ety ty) meta; { value = VBottom; ty } let mk_abottom (meta : Meta.meta) (ty : ty) : typed_avalue = - sanity_check (ty_is_rty ty) meta; + sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta; { value = ABottom; ty } let mk_aignored (meta : Meta.meta) (ty : ty) : typed_avalue = - sanity_check (ty_is_rty ty) meta; + sanity_check __FILE__ __LINE__ (ty_is_rty ty) meta; { value = AIgnored; ty } let value_as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = - match v with VSymbolic v -> v | _ -> craise meta "Unexpected" + match v with VSymbolic v -> v | _ -> craise __FILE__ __LINE__ meta "Unexpected" (** Box a value *) let mk_box_value (meta : Meta.meta) (v : typed_value) : typed_value = @@ -50,13 +50,13 @@ let is_symbolic (v : value) : bool = match v with VSymbolic _ -> true | _ -> false let as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = - match v with VSymbolic s -> s | _ -> craise meta "Unexpected" + match v with VSymbolic s -> s | _ -> craise __FILE__ __LINE__ meta "Unexpected" let as_mut_borrow (meta : Meta.meta) (v : typed_value) : BorrowId.id * typed_value = match v.value with | VBorrow (VMutBorrow (bid, bv)) -> (bid, bv) - | _ -> craise meta "Unexpected" + | _ -> craise __FILE__ __LINE__ meta "Unexpected" let is_unit (v : typed_value) : bool = ty_is_unit v.ty -- cgit v1.2.3 From 8f969634f3f192a9282a21a1ca2a1b6a676984ca Mon Sep 17 00:00:00 2001 From: Escherichia Date: Fri, 29 Mar 2024 14:07:36 +0100 Subject: formatting and changed save_error condition for failing from b to not b --- compiler/ValuesUtils.ml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'compiler/ValuesUtils.ml') diff --git a/compiler/ValuesUtils.ml b/compiler/ValuesUtils.ml index 980ebef7..91010e07 100644 --- a/compiler/ValuesUtils.ml +++ b/compiler/ValuesUtils.ml @@ -33,7 +33,9 @@ let mk_aignored (meta : Meta.meta) (ty : ty) : typed_avalue = { value = AIgnored; ty } let value_as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = - match v with VSymbolic v -> v | _ -> craise __FILE__ __LINE__ meta "Unexpected" + match v with + | VSymbolic v -> v + | _ -> craise __FILE__ __LINE__ meta "Unexpected" (** Box a value *) let mk_box_value (meta : Meta.meta) (v : typed_value) : typed_value = @@ -50,7 +52,9 @@ let is_symbolic (v : value) : bool = match v with VSymbolic _ -> true | _ -> false let as_symbolic (meta : Meta.meta) (v : value) : symbolic_value = - match v with VSymbolic s -> s | _ -> craise __FILE__ __LINE__ meta "Unexpected" + match v with + | VSymbolic s -> s + | _ -> craise __FILE__ __LINE__ meta "Unexpected" let as_mut_borrow (meta : Meta.meta) (v : typed_value) : BorrowId.id * typed_value = -- cgit v1.2.3