summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Interpreter.ml26
-rw-r--r--src/Print.ml11
-rw-r--r--src/Values.ml6
3 files changed, 11 insertions, 32 deletions
diff --git a/src/Interpreter.ml b/src/Interpreter.ml
index c574ace4..90f5a30e 100644
--- a/src/Interpreter.ml
+++ b/src/Interpreter.ml
@@ -1191,16 +1191,7 @@ let compute_expanded_bottom_adt_value (tyctx : T.type_def list)
in
(* Initialize the expanded value *)
let fields = List.map (fun ty -> { V.value = Bottom; ty }) field_types in
- let av =
- V.Adt
- {
- def_id;
- variant_id = opt_variant_id;
- regions;
- types;
- field_values = fields;
- }
- in
+ let av = V.Adt { variant_id = opt_variant_id; field_values = fields } in
let ty = T.Adt (def_id, regions, types) in
{ V.value = av; V.ty }
@@ -1600,10 +1591,7 @@ let constant_value_to_typed_value (ctx : C.eval_ctx) (ty : T.ety)
assert (List.length variant.fields = 0);
Some variant_id
in
- let value =
- V.Adt
- { def_id; variant_id; regions = []; types = []; field_values = [] }
- in
+ let value = V.Adt { variant_id; field_values = [] } in
{ value; ty }
(* Scalar, boolean... *)
| T.Bool, ConstantValue (Bool v) -> { V.value = V.Concrete (Bool v); ty }
@@ -1860,15 +1848,7 @@ let eval_rvalue (config : C.config) (ctx : C.eval_ctx) (rvalue : E.rvalue) :
in
assert (expected_field_types = List.map (fun v -> v.V.ty) values);
(* Construct the value *)
- let av =
- {
- V.def_id;
- V.variant_id = opt_variant_id;
- V.regions;
- V.types;
- V.field_values = values;
- }
- in
+ let av = { V.variant_id = opt_variant_id; V.field_values = values } in
let aty = T.Adt (def_id, regions, types) in
Ok (ctx, { V.value = Adt av; ty = aty }))
diff --git a/src/Print.ml b/src/Print.ml
index 99788123..3e769796 100644
--- a/src/Print.ml
+++ b/src/Print.ml
@@ -205,16 +205,21 @@ module Values = struct
match v.value with
| Concrete cv -> constant_value_to_string cv
| Adt av ->
+ let def_id =
+ match v.ty with
+ | Adt (def_id, _, _) -> def_id
+ | _ -> failwith "Inconsistent value"
+ in
let adt_ident =
match av.variant_id with
- | Some vid -> fmt.adt_variant_to_string av.def_id vid
- | None -> fmt.type_def_id_to_string av.def_id
+ | Some vid -> fmt.adt_variant_to_string def_id vid
+ | None -> fmt.type_def_id_to_string def_id
in
let field_values =
List.map (typed_value_to_string fmt) av.field_values
in
if List.length field_values > 0 then
- match fmt.adt_field_names av.V.def_id av.V.variant_id with
+ match fmt.adt_field_names def_id av.V.variant_id with
| None ->
let field_values = String.concat ", " field_values in
adt_ident ^ " (" ^ field_values ^ ")"
diff --git a/src/Values.ml b/src/Values.ml
index cb8a1200..92f1491b 100644
--- a/src/Values.ml
+++ b/src/Values.ml
@@ -82,13 +82,7 @@ type value =
[@@deriving show]
and adt_value = {
- def_id : TypeDefId.id;
- (* TODO: remove *)
variant_id : VariantId.id option;
- regions : erased_region list;
- (* TODO: remove *)
- types : ety list;
- (* TODO: remove *)
field_values : typed_value list;
}
[@@deriving show]