Skip to content

Commit

Permalink
Merge branch 'develop/mochi-backend' of github.com:SoftwareFoundation…
Browse files Browse the repository at this point in the history
…GroupAtKyotoU/consort into feature/call-mochi
  • Loading branch information
artoy committed Mar 21, 2024
2 parents 70d776e + c44a49a commit 426c77d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/ownershipInference.ml
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,9 @@ let rec process_expr ~output ((e_id,_),expr) ~o_arity =
split_loop r (o1 :: ol1) (o2 :: ol2)
in
let%bind (ol1, ol2) = split_loop ol [] [] in
return (IntList ol1, Ref(IntList((List.tl ol2) @ [(List.hd @@ List.rev ol2)]), List.hd ol2))
let%bind o_copied = alloc_ovar (MGen e_id) (P.var v) in
add_constraint (Eq (o_copied, List.hd @@ List.rev ol2)) >>
return (IntList ol1, Ref(IntList((List.tl ol2) @ [o_copied]), List.hd ol2))
| _ -> failwith "The value pattern matched must be IntList"
in
process_pattern_matching ~e_id ~output v type_of_v e2 h r type_of_r e3 ~o_arity
Expand Down
32 changes: 32 additions & 0 deletions src/test/list/reverse2-debug.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
_reverse(l, l_next) {
match l_next with
Nil -> {
// alias(*(l.Cons.2) = l_next);
return l
}
| Cons(h, t) -> {
let t_deref = *t in {
t := l;
alias(l_next.Cons.2 = t);
let reversed = _reverse(l_next, t_deref) in
reversed
}
}
}

reverse(l) {
match l with
Nil -> l
| Cons(h, r) -> {
let reversed = _reverse(Nil, l) in
reversed
}
}

{
let n = mkref Nil in
let m = mkref Cons(1, n) in
let l = Cons(2, m) in
let rev_l = reverse(l) in
()
}
2 changes: 1 addition & 1 deletion src/test/list/reverse2.imp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mklist(n) {
_reverse(l, l_next) {
match l_next with
Nil -> {
alias(*(l.Cons.2) = l_next);
// alias(*(l.Cons.2) = l_next);
return l
}
| Cons(h, t) -> {
Expand Down

0 comments on commit 426c77d

Please sign in to comment.