Skip to content

Commit 7cb6e5b

Browse files
committed
Update ML
1 parent 557d588 commit 7cb6e5b

7 files changed

Lines changed: 27 additions & 24 deletions

File tree

charon-ml/src/CharonVersion.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(* This is an automatically generated file, generated from `charon/Cargo.toml`. *)
22
(* To re-generate this file, rune `make` in the root directory *)
3-
let supported_charon_version = "0.1.169"
3+
let supported_charon_version = "0.1.170"

charon-ml/src/PrintExpressions.ml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ and nullop_to_string (env : 'a fmt_env) (op : nullop) : string =
8787
| SizeOf -> "size_of"
8888
| AlignOf -> "align_of"
8989
| OffsetOf _ -> "offset_of(?)"
90-
| UbChecks -> "ub_checks"
91-
| ContractChecks -> "contract_checks"
92-
| OverflowChecks -> "overflow_checks"
9390

9491
and unop_to_string (env : 'a fmt_env) (unop : unop) : string =
9592
match unop with
@@ -127,11 +124,18 @@ and binop_to_string (binop : binop) : string =
127124
| Cmp -> "cmp"
128125
| Offset -> "offset"
129126

127+
and runtime_check_to_string (check : runtime_check) : string =
128+
match check with
129+
| UbChecks -> "ub_checks"
130+
| ContractChecks -> "contract_checks"
131+
| OverflowChecks -> "overflow_checks"
132+
130133
and operand_to_string (env : 'a fmt_env) (op : operand) : string =
131134
match op with
132135
| Copy p -> "copy " ^ place_to_string env p
133136
| Move p -> "move " ^ place_to_string env p
134137
| Constant cv -> constant_expr_to_string env cv
138+
| RuntimeCheck ck -> "check " ^ runtime_check_to_string ck
135139

136140
and aggregate_to_string (env : 'a fmt_env) (agg : aggregate_kind)
137141
(fields : operand list) : string =
@@ -222,6 +226,4 @@ and rvalue_to_string (env : 'a fmt_env) (rv : rvalue) : string =
222226
"[" ^ operand_to_string env v ^ ";"
223227
^ constant_expr_to_string env len
224228
^ "]"
225-
| ShallowInitBox (op, _) ->
226-
"shallow-init-box(" ^ operand_to_string env op ^ ")"
227229
| Aggregate (akind, ops) -> aggregate_to_string env akind ops

charon-ml/src/generated/Generated_Expressions.ml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,14 @@ and nullop =
167167
| SizeOf
168168
| AlignOf
169169
| OffsetOf of type_decl_ref * variant_id option * field_id
170-
| UbChecks
171-
| OverflowChecks
172-
| ContractChecks
173170

174171
and operand =
175172
| Copy of place
176173
| Move of place
177174
| Constant of constant_expr
178175
(** Constant value (including constant and static variables) *)
176+
| RuntimeCheck of runtime_check
177+
(** Whether a particular runtime check should be performed or not. *)
179178

180179
and overflow_mode =
181180
| OPanic
@@ -240,6 +239,8 @@ and projection_elem =
240239
- [to]
241240
- [from_end] *)
242241

242+
and runtime_check = UbChecks | OverflowChecks | ContractChecks
243+
243244
(** TODO: we could factor out [Rvalue] and function calls (for LLBC, not ULLBC).
244245
We can also factor out the unops, binops with the function calls. TODO: move
245246
the aggregate kind to operands TODO: we should prefix the type variants with
@@ -310,11 +311,6 @@ and rvalue =
310311
(** [Repeat(x, n)] creates an array where [x] is copied [n] times.
311312
312313
We translate this to a function call for LLBC. *)
313-
| ShallowInitBox of operand * ty
314-
(** Transmutes a [*mut u8] (obtained from [malloc]) into
315-
shallow-initialized [Box<T>]. This only appears as part of lowering
316-
[Box::new()] in some cases. We reconstruct the original [Box::new()]
317-
call, but sometimes may fail to do so, leaking the expression. *)
318314

319315
(** Unary operation *)
320316
and unop =

charon-ml/src/generated/Generated_GAstOfJson.ml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,9 +1454,6 @@ and nullop_of_json (ctx : of_json_ctx) (js : json) : (nullop, string) result =
14541454
let* x_1 = option_of_json variant_id_of_json ctx x_1 in
14551455
let* x_2 = field_id_of_json ctx x_2 in
14561456
Ok (OffsetOf (x_0, x_1, x_2))
1457-
| `String "UbChecks" -> Ok UbChecks
1458-
| `String "OverflowChecks" -> Ok OverflowChecks
1459-
| `String "ContractChecks" -> Ok ContractChecks
14601457
| _ -> Error "")
14611458

14621459
and operand_of_json (ctx : of_json_ctx) (js : json) : (operand, string) result =
@@ -1471,6 +1468,9 @@ and operand_of_json (ctx : of_json_ctx) (js : json) : (operand, string) result =
14711468
| `Assoc [ ("Const", const) ] ->
14721469
let* const = box_of_json constant_expr_of_json ctx const in
14731470
Ok (Constant const)
1471+
| `Assoc [ ("RuntimeCheck", runtime_check) ] ->
1472+
let* runtime_check = runtime_check_of_json ctx runtime_check in
1473+
Ok (RuntimeCheck runtime_check)
14741474
| _ -> Error "")
14751475

14761476
and outlives_pred_of_json :
@@ -1700,6 +1700,15 @@ and repr_options_of_json (ctx : of_json_ctx) (js : json) :
17001700
: repr_options)
17011701
| _ -> Error "")
17021702

1703+
and runtime_check_of_json (ctx : of_json_ctx) (js : json) :
1704+
(runtime_check, string) result =
1705+
combine_error_msgs js __FUNCTION__
1706+
(match js with
1707+
| `String "UbChecks" -> Ok UbChecks
1708+
| `String "OverflowChecks" -> Ok OverflowChecks
1709+
| `String "ContractChecks" -> Ok ContractChecks
1710+
| _ -> Error "")
1711+
17031712
and rvalue_of_json (ctx : of_json_ctx) (js : json) : (rvalue, string) result =
17041713
combine_error_msgs js __FUNCTION__
17051714
(match js with
@@ -1760,10 +1769,6 @@ and rvalue_of_json (ctx : of_json_ctx) (js : json) : (rvalue, string) result =
17601769
let* x_1 = ty_of_json ctx x_1 in
17611770
let* x_2 = box_of_json constant_expr_of_json ctx x_2 in
17621771
Ok (Repeat (x_0, x_1, x_2))
1763-
| `Assoc [ ("ShallowInitBox", `List [ x_0; x_1 ]) ] ->
1764-
let* x_0 = operand_of_json ctx x_0 in
1765-
let* x_1 = ty_of_json ctx x_1 in
1766-
Ok (ShallowInitBox (x_0, x_1))
17671772
| _ -> Error "")
17681773

17691774
and scalar_value_of_json (ctx : of_json_ctx) (js : json) :

charon/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charon/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "charon"
3-
version = "0.1.169"
3+
version = "0.1.170"
44
authors = [
55
"Son Ho <hosonmarc@gmail.com>",
66
"Guillaume Boisseau <nadrieril+git@gmail.com>",

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
rust-overlay = {
99
# We pin a specific commit because we require a relatively recent version
1010
# and flake dependents don't look at our flake.lock.
11-
url = "github:oxalica/rust-overlay/ab726555a9a72e6dc80649809147823a813fa95b";
11+
url = "github:oxalica/rust-overlay/085bdbf5dde5477538e4c87d1684b6c6df56c0ad";
1212
inputs.nixpkgs.follows = "nixpkgs";
1313
};
1414
crane.url = "github:ipetkov/crane";

0 commit comments

Comments
 (0)