Skip to content

Commit 568527d

Browse files
committed
simulations: add a definition for write
1 parent d9b317a commit 568527d

File tree

607 files changed

+597145
-608982
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

607 files changed

+597145
-608982
lines changed

CoqOfRust/M.v

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ Module LowM.
303303
| Pure (value : A)
304304
| CallPrimitive (primitive : Primitive.t) (k : Value.t -> t A)
305305
| CallClosure (ty : Ty.t) (closure : Value.t) (args : list Value.t) (k : A -> t A)
306-
| Let (ty : Ty.t) (e : t A) (k : A -> t A)
306+
| LetAlloc (ty : Ty.t) (e : t A) (k : A -> t A)
307307
| Loop (ty : Ty.t) (body : t A) (k : A -> t A)
308308
| Impossible (message : string).
309309
Arguments Pure {_}.
310310
Arguments CallPrimitive {_}.
311311
Arguments CallClosure {_}.
312-
Arguments Let {_}.
312+
Arguments LetAlloc {_}.
313313
Arguments Loop {_}.
314314
Arguments Impossible {_}.
315315

@@ -320,8 +320,8 @@ Module LowM.
320320
CallPrimitive primitive (fun v => let_ (k v) e2)
321321
| CallClosure ty f args k =>
322322
CallClosure ty f args (fun v => let_ (k v) e2)
323-
| Let ty e k =>
324-
Let ty e (fun v => let_ (k v) e2)
323+
| LetAlloc ty e k =>
324+
LetAlloc ty e (fun v => let_ (k v) e2)
325325
| Loop ty body k =>
326326
Loop ty body (fun v => let_ (k v) e2)
327327
| Impossible message => Impossible message
@@ -364,7 +364,7 @@ Definition let_user (ty : Ty.t) (e1 : Value.t) (e2 : Value.t -> Value.t) : Value
364364
e2 e1.
365365

366366
Definition let_user_monadic (ty : Ty.t) (e1 : M) (e2 : Value.t -> M) : M :=
367-
LowM.Let ty e1 (fun v1 =>
367+
LowM.LetAlloc ty e1 (fun v1 =>
368368
match v1 with
369369
| inl v1 => e2 v1
370370
| inr error => LowM.Pure (inr error)
@@ -695,9 +695,14 @@ Definition get_trait_method
695695

696696
Definition catch (ty : option Ty.t) (body : M) (handler : Exception.t -> M) : M :=
697697
(match ty with
698-
| Some ty => LowM.Let ty
698+
| Some ty => LowM.LetAlloc ty
699699
| None => LowM.let_
700-
end) body (fun result =>
700+
end)
701+
(match ty with
702+
| Some _ => let* body := body in M.read body
703+
| None => body
704+
end)
705+
(fun result =>
701706
match result with
702707
| inl v => LowM.Pure (inl v)
703708
| inr exception => handler exception
@@ -927,7 +932,7 @@ Fixpoint run_constant (constant : M) : Value.t :=
927932
end in
928933
run_constant (k value)
929934
| LowM.CallClosure _ _ _ _ => Value.Error "unexpected closure call"
930-
| LowM.Let _ _ _ => Value.Error "unexpected let"
935+
| LowM.LetAlloc _ _ _ => Value.Error "unexpected let-alloc"
931936
| LowM.Loop _ _ _ => Value.Error "unexpected loop"
932937
| LowM.Impossible _ => Value.Error "impossible"
933938
end.

CoqOfRust/alloc/alloc.v

Lines changed: 424 additions & 438 deletions
Large diffs are not rendered by default.

CoqOfRust/alloc/borrow.v

Lines changed: 229 additions & 253 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)