From c80141a9874345b71ee5e6c37947e1f0825698a7 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 8 Feb 2022 13:58:57 +0100 Subject: Start adding more assumed types and functions --- src/Expressions.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Expressions.ml') diff --git a/src/Expressions.ml b/src/Expressions.ml index 816870cd..9c6b8490 100644 --- a/src/Expressions.ml +++ b/src/Expressions.ml @@ -3,6 +3,8 @@ open Values type field_proj_kind = | ProjAdt of TypeDefId.id * VariantId.id option + | ProjOption of VariantId.id + (** Option is an assumed type, coming from the standard library *) | ProjTuple of int [@@deriving show] (* arity of the tuple *) @@ -73,6 +75,8 @@ let all_binops = constants when generating MIR: - an enumeration with one variant and no fields is a constant. - a structure with no field is a constant. + - sometimes, Rust stores the initialization of an ADT as a constant + (if all the fields are constant) rather than as an aggregated value For our translation, we use the following enumeration to encode those special cases in assignments. They are converted to "normal" values @@ -81,8 +85,7 @@ let all_binops = *) type operand_constant_value = | ConstantValue of constant_value - | ConstantAdt of TypeDefId.id - | Unit + | ConstantAdt of VariantId.id option * operand_constant_value list [@@deriving show] type operand = -- cgit v1.2.3