forked from ocaml-flambda/flambda-backend
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix computation of extra_args during CPS conversion of Lstaticraise (o…
- Loading branch information
Showing
2 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
middle_end/flambda2/tests/mlexamples/extra_args_and_staticraise.ml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(* After [Base.Hashtbl.fold]. | ||
This example produces the following lambda code: | ||
(let | ||
(f/9 = | ||
(function x/11[int] init/12[int] : int | ||
(let (m/13 =v[int] init/12) | ||
(catch | ||
(try (exit 1 (for i/14 0 to x/11 (assign m/13 (+ m/13 i/14)))) | ||
with exn/23 0) | ||
with (1 val/22[int]) m/13)))) | ||
(makeblock 0 f/9)) | ||
which is interesting because of the for-loop as an argument to | ||
[exit], in conjunction with the mutable variable [m]. *) | ||
|
||
type 'a ref = { mutable contents : 'a } | ||
external ref : 'a -> 'a ref = "%makemutable" | ||
external ( ! ) : 'a ref -> 'a = "%field0" | ||
external ( := ) : 'a ref -> 'a -> unit = "%setfield0" | ||
external ( + ) : int -> int -> int = "%addint" | ||
let f x init = | ||
let m = ref init in | ||
match | ||
for i = 0 to x do | ||
m := !m + i | ||
done | ||
with | ||
| () -> !m | ||
| exception _ -> 0 |