Skip to content

Commit a892f9f

Browse files
goldfirereriaqn
authored andcommitted
ocamlformat in JS-only files in lambda/
1 parent f79daef commit a892f9f

12 files changed

+642
-646
lines changed

ocaml/lambda/.ocamlformat

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
profile=conventional
2-
if-then-else=k-r
3-
indicate-multiline-delimiters=closing-on-separate-line
4-
break-cases=all
1+
# Please make a pull request to change this file.
52
disable=true
3+
# There is an .ocamlformat-enable file in this directory.
4+
# Keep the remainder of this file in sync with other .ocamlformat files in this repo.
5+
assignment-operator=begin-line
6+
cases-exp-indent=2
7+
doc-comments=before
8+
dock-collection-brackets=false
9+
if-then-else=keyword-first
10+
module-item-spacing=sparse
11+
parens-tuple=multi-line-only
12+
sequence-blank-line=compact
13+
space-around-lists=false
14+
space-around-variants=false
15+
type-decl=sparse
16+
wrap-comments=true
17+
version=0.24.1

ocaml/lambda/.ocamlformat-enable

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
assume_info.ml
22
assume_info.mli
3+
transl_array_comprehension.ml
4+
transl_array_comprehension.mli
5+
transl_comprehension_utils.ml
6+
transl_comprehension_utils.mli
7+
transl_list_comprehension.ml
8+
transl_list_comprehension.mli
9+
translmode.ml
10+
translmode.mli

ocaml/lambda/assume_info.ml

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,56 @@
1-
(*
1+
(* The meaning of keywords [strict] and [never_returns_normally] is defined in
2+
terms of abstract values as follows:
23
3-
The meaning of keywords [strict] and [never_returns_normally]
4-
is defined in terms of abstract values as follows:
4+
relaxed (default): nor = Safe and exn = Top and div = Top strict: nor = Safe
5+
and exn = Safe and div = Safe never_returns_normally: nor = Bot and exn = Top
6+
and div = Top
57
6-
relaxed (default): nor = Safe and exn = Top and div = Top
7-
strict: nor = Safe and exn = Safe and div = Safe
8-
never_returns_normally: nor = Bot and exn = Top and div = Top
8+
where [nor] means normal return of the call, [exn] means return via an
9+
exception, [div] means diverging (non-terminating) executions, and the
10+
meaning and order of elements is:
911
10-
where [nor] means normal return of the call, [exn] means return via an exception,
11-
[div] means diverging (non-terminating) executions,
12-
and the meaning and order of elements is:
12+
Top may allocate Safe does not allocate on any execution paths Bot
13+
unreachable
1314
14-
Top may allocate
15-
Safe does not allocate on any execution paths
16-
Bot unreachable
17-
18-
Using more than one keyword means intersection (i.e., meet of the elements,
15+
Using more than one keyword means intersection (i.e., meet of the elements,
1916
pointwise lifted to tuples), so we get the following:
2017
21-
[@zero_alloc assume] nor = Safe and exn = Top and div = Top
22-
[@zero_alloc assume strict] nor = Safe and exn = Safe and div = Safe
23-
[@zero_alloc assume strict never_returns_normally] nor = Bot and exn = Safe and div = Safe
24-
[@zero_alloc assume never_returns_normally] nor = Bot and exn = Top and div = Top
18+
[@zero_alloc assume] nor = Safe and exn = Top and div = Top [@zero_alloc
19+
assume strict] nor = Safe and exn = Safe and div = Safe [@zero_alloc assume
20+
strict never_returns_normally] nor = Bot and exn = Safe and div = Safe
21+
[@zero_alloc assume never_returns_normally] nor = Bot and exn = Top and div =
22+
Top
2523
26-
See [Value] and [Annotation] in [backend/checkmach.ml].
27-
*)
28-
(* CR gyorsh: should we move [Value] and [Annotation] here or maybe "utils" and use them
29-
directly, instead of the weird compare function that abstracts them? Perhaps we
30-
should translate "strict" and "never_returns_normally" directly into (nor,exn,div)
31-
*)
24+
See [Value] and [Annotation] in [backend/checkmach.ml]. *)
25+
(* CR gyorsh: should we move [Value] and [Annotation] here or maybe "utils" and
26+
use them directly, instead of the weird compare function that abstracts them?
27+
Perhaps we should translate "strict" and "never_returns_normally" directly
28+
into (nor,exn,div) *)
3229

3330
module Witnesses = struct
3431
type t = unit
3532

3633
let join _ _ = ()
34+
3735
let lessequal _ _ = true
36+
3837
let meet _ _ = ()
38+
3939
let print _ _ = ()
40+
4041
let empty = ()
42+
4143
let compare _ _ = 0
4244
end
4345

4446
include Zero_alloc_utils.Make (Witnesses)
4547

46-
type t = No_assume | Assume of Value.t
48+
type t =
49+
| No_assume
50+
| Assume of Value.t
4751

4852
let compare t1 t2 =
49-
match (t1, t2) with
53+
match t1, t2 with
5054
| No_assume, No_assume -> 0
5155
| Assume v1, Assume v2 -> Value.compare v1 v2
5256
| No_assume, Assume _ -> -1
@@ -61,44 +65,24 @@ let print ppf = function
6165
let to_string v = Format.asprintf "%a" print v
6266

6367
let join t1 t2 =
64-
match (t1, t2) with
68+
match t1, t2 with
6569
| No_assume, No_assume -> No_assume
66-
| No_assume, Assume _
67-
| Assume _, No_assume ->
68-
No_assume
70+
| No_assume, Assume _ | Assume _, No_assume -> No_assume
6971
| Assume t1, Assume t2 -> Assume (Value.join t1 t2)
7072

7173
let meet t1 t2 =
72-
match (t1, t2) with
74+
match t1, t2 with
7375
| No_assume, No_assume -> No_assume
74-
| No_assume, (Assume _ as t)
75-
| (Assume _ as t), No_assume ->
76-
t
76+
| No_assume, (Assume _ as t) | (Assume _ as t), No_assume -> t
7777
| Assume t1, Assume t2 -> Assume (Value.meet t1 t2)
7878

7979
let none = No_assume
8080

8181
let create ~strict ~never_returns_normally =
82-
let res =
83-
if strict then
84-
Value.safe
85-
else
86-
Value.relaxed Witnesses.empty
87-
in
88-
let res =
89-
if never_returns_normally then
90-
{ res with nor = V.Bot }
91-
else
92-
res
93-
in
82+
let res = if strict then Value.safe else Value.relaxed Witnesses.empty in
83+
let res = if never_returns_normally then { res with nor = V.Bot } else res in
9484
Assume res
9585

96-
let get_value t =
97-
match t with
98-
| No_assume -> None
99-
| Assume v -> Some v
86+
let get_value t = match t with No_assume -> None | Assume v -> Some v
10087

101-
let is_none t =
102-
match t with
103-
| No_assume -> true
104-
| Assume _ -> false
88+
let is_none t = match t with No_assume -> true | Assume _ -> false

ocaml/lambda/assume_info.mli

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
11
type t
22

33
val none : t
4+
45
val create : strict:bool -> never_returns_normally:bool -> t
6+
57
val compare : t -> t -> int
8+
69
val equal : t -> t -> bool
10+
711
val join : t -> t -> t
12+
813
val meet : t -> t -> t
14+
915
val to_string : t -> string
16+
1017
val print : Format.formatter -> t -> unit
18+
1119
val is_none : t -> bool
1220

1321
module Witnesses : sig
1422
type t = unit
1523

1624
val join : t -> t -> t
25+
1726
val meet : t -> t -> t
27+
1828
val lessequal : t -> t -> bool
29+
1930
val print : Format.formatter -> t -> unit
31+
2032
val compare : t -> t -> int
2133
end
2234

0 commit comments

Comments
 (0)