Skip to content

Commit

Permalink
Preview: Upgrade to ocamlformat 0.26.0 (unreleased)
Browse files Browse the repository at this point in the history
The aim of this commit is to gather feedback.

Changelog can be found here: https://github.com/ocaml-ppx/ocamlformat/blob/main/CHANGES.md
  • Loading branch information
Julow committed Jun 27, 2023
1 parent d658772 commit a036f05
Show file tree
Hide file tree
Showing 52 changed files with 7,030 additions and 7,569 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ break-separators=before
dock-collection-brackets=false
margin=90
module-item-spacing=sparse
version=0.25.1
version = 0.26.0
ocaml-version=4.08.0
2 changes: 1 addition & 1 deletion compiler/lib/base64.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let unsafe_get_uint8 t off = Char.code (String.unsafe_get t off)
let unsafe_set_uint8 t off v = Bytes.unsafe_set t off (Char.chr v)

external unsafe_set_uint16 : bytes -> int -> int -> unit = "%caml_bytes_set16u"
[@@noalloc]
[@@noalloc]

external unsafe_get_uint16 : string -> int -> int = "%caml_string_get16u" [@@noalloc]

Expand Down
22 changes: 12 additions & 10 deletions compiler/lib/dgraph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
*)
open! Stdlib

module Make (N : sig
type t
end)
(NSet : Set.S with type elt = N.t)
(NMap : Map.S with type key = N.t) =
module Make
(N : sig
type t
end)
(NSet : Set.S with type elt = N.t)
(NMap : Map.S with type key = N.t) =
struct
type t =
{ domain : NSet.t
Expand Down Expand Up @@ -175,11 +176,12 @@ module type Tbl = sig
val make : size -> 'a -> 'a t
end

module Make_Imperative (N : sig
type t
end)
(NSet : ISet with type elt = N.t)
(NTbl : Tbl with type key = N.t) =
module Make_Imperative
(N : sig
type t
end)
(NSet : ISet with type elt = N.t)
(NTbl : Tbl with type key = N.t) =
struct
type t =
{ domain : NSet.t
Expand Down
22 changes: 12 additions & 10 deletions compiler/lib/dgraph.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
module Make (N : sig
type t
end)
(NSet : Set.S with type elt = N.t)
(NMap : Map.S with type key = N.t) : sig
module Make
(N : sig
type t
end)
(NSet : Set.S with type elt = N.t)
(NMap : Map.S with type key = N.t) : sig
type t =
{ domain : NSet.t
; fold_children : 'a. (N.t -> 'a -> 'a) -> N.t -> 'a -> 'a
Expand Down Expand Up @@ -72,11 +73,12 @@ module type Tbl = sig
val make : size -> 'a -> 'a t
end

module Make_Imperative (N : sig
type t
end)
(NSet : ISet with type elt = N.t)
(NTbl : Tbl with type key = N.t) : sig
module Make_Imperative
(N : sig
type t
end)
(NSet : ISet with type elt = N.t)
(NTbl : Tbl with type key = N.t) : sig
type t =
{ domain : NSet.t
; iter_children : (N.t -> unit) -> N.t -> unit
Expand Down
58 changes: 29 additions & 29 deletions compiler/lib/js_output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -856,35 +856,35 @@ struct
| CoverInitializedName (e, _, _) -> early_error e

and method_ : 'a. _ -> (PP.t -> 'a -> unit) -> 'a -> method_ -> unit =
fun (type a) f (name : PP.t -> a -> unit) (n : a) (m : method_) ->
match m with
| MethodGet (k, l, b, loc') | MethodSet (k, l, b, loc') ->
(match k with
| { async = false; generator = false } -> ()
| _ -> assert false);
let prefix =
match m with
| MethodGet _ -> "get"
| MethodSet _ -> "set"
| _ -> assert false
in
function_declaration f prefix name (Some n) l b loc'
| Method (k, l, b, loc') ->
let fpn f () =
(match k with
| { async = false; generator = false } -> ()
| { async = false; generator = true } ->
PP.string f "*";
PP.space f
| { async = true; generator = false } ->
PP.string f "async";
PP.space f
| { async = true; generator = true } ->
PP.string f "async*";
PP.space f);
name f n
in
function_declaration f "" fpn (Some ()) l b loc'
fun (type a) f (name : PP.t -> a -> unit) (n : a) (m : method_) ->
match m with
| MethodGet (k, l, b, loc') | MethodSet (k, l, b, loc') ->
(match k with
| { async = false; generator = false } -> ()
| _ -> assert false);
let prefix =
match m with
| MethodGet _ -> "get"
| MethodSet _ -> "set"
| _ -> assert false
in
function_declaration f prefix name (Some n) l b loc'
| Method (k, l, b, loc') ->
let fpn f () =
(match k with
| { async = false; generator = false } -> ()
| { async = false; generator = true } ->
PP.string f "*";
PP.space f
| { async = true; generator = false } ->
PP.string f "async";
PP.space f
| { async = true; generator = true } ->
PP.string f "async*";
PP.space f);
name f n
in
function_declaration f "" fpn (Some ()) l b loc'

and element_list f el = comma_list f element el

Expand Down
137 changes: 67 additions & 70 deletions compiler/lib/js_traverse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,57 +20,56 @@
open! Stdlib
open Javascript

class type mapper =
object
method loc : Javascript.location -> Javascript.location
class type mapper = object
method loc : Javascript.location -> Javascript.location

method expression : Javascript.expression -> Javascript.expression
method expression : Javascript.expression -> Javascript.expression

method expression_o : Javascript.expression option -> Javascript.expression option
method expression_o : Javascript.expression option -> Javascript.expression option

method switch_case : Javascript.expression -> Javascript.expression
method switch_case : Javascript.expression -> Javascript.expression

method block : Javascript.statement_list -> Javascript.statement_list
method block : Javascript.statement_list -> Javascript.statement_list

method fun_decl : Javascript.function_declaration -> Javascript.function_declaration
method fun_decl : Javascript.function_declaration -> Javascript.function_declaration

method class_decl : Javascript.class_declaration -> Javascript.class_declaration
method class_decl : Javascript.class_declaration -> Javascript.class_declaration

method initialiser :
Javascript.expression * Javascript.location
-> Javascript.expression * Javascript.location
method initialiser :
Javascript.expression * Javascript.location
-> Javascript.expression * Javascript.location

method initialiser_o :
(Javascript.expression * Javascript.location) option
-> (Javascript.expression * Javascript.location) option
method initialiser_o :
(Javascript.expression * Javascript.location) option
-> (Javascript.expression * Javascript.location) option

method for_binding :
Javascript.variable_declaration_kind
-> Javascript.for_binding
-> Javascript.for_binding
method for_binding :
Javascript.variable_declaration_kind
-> Javascript.for_binding
-> Javascript.for_binding

method variable_declaration :
Javascript.variable_declaration_kind
-> Javascript.variable_declaration
-> Javascript.variable_declaration
method variable_declaration :
Javascript.variable_declaration_kind
-> Javascript.variable_declaration
-> Javascript.variable_declaration

method statement : Javascript.statement -> Javascript.statement
method statement : Javascript.statement -> Javascript.statement

method statement_o :
(Javascript.statement * Javascript.location) option
-> (Javascript.statement * Javascript.location) option
method statement_o :
(Javascript.statement * Javascript.location) option
-> (Javascript.statement * Javascript.location) option

method statements : Javascript.statement_list -> Javascript.statement_list
method statements : Javascript.statement_list -> Javascript.statement_list

method formal_parameter_list :
Javascript.formal_parameter_list -> Javascript.formal_parameter_list
method formal_parameter_list :
Javascript.formal_parameter_list -> Javascript.formal_parameter_list

method ident : Javascript.ident -> Javascript.ident
method ident : Javascript.ident -> Javascript.ident

method program : Javascript.program -> Javascript.program
method program : Javascript.program -> Javascript.program

method function_body : statement_list -> statement_list
end
method function_body : statement_list -> statement_list
end

(* generic js ast walk/map *)
class map : mapper =
Expand Down Expand Up @@ -303,42 +302,41 @@ class map : mapper =
method function_body x = m#statements x
end

class type iterator =
object
method fun_decl : Javascript.function_declaration -> unit
class type iterator = object
method fun_decl : Javascript.function_declaration -> unit

method early_error : Javascript.early_error -> unit
method early_error : Javascript.early_error -> unit

method expression : Javascript.expression -> unit
method expression : Javascript.expression -> unit

method expression_o : Javascript.expression option -> unit
method expression_o : Javascript.expression option -> unit

method switch_case : Javascript.expression -> unit
method switch_case : Javascript.expression -> unit

method block : Javascript.statement_list -> unit
method block : Javascript.statement_list -> unit

method initialiser : Javascript.expression * Javascript.location -> unit
method initialiser : Javascript.expression * Javascript.location -> unit

method initialiser_o : (Javascript.expression * Javascript.location) option -> unit
method initialiser_o : (Javascript.expression * Javascript.location) option -> unit

method for_binding :
Javascript.variable_declaration_kind -> Javascript.for_binding -> unit
method for_binding :
Javascript.variable_declaration_kind -> Javascript.for_binding -> unit

method variable_declaration :
Javascript.variable_declaration_kind -> Javascript.variable_declaration -> unit
method variable_declaration :
Javascript.variable_declaration_kind -> Javascript.variable_declaration -> unit

method statement : Javascript.statement -> unit
method statement : Javascript.statement -> unit

method statement_o : (Javascript.statement * Javascript.location) option -> unit
method statement_o : (Javascript.statement * Javascript.location) option -> unit

method statements : Javascript.statement_list -> unit
method statements : Javascript.statement_list -> unit

method ident : Javascript.ident -> unit
method ident : Javascript.ident -> unit

method program : Javascript.program -> unit
method program : Javascript.program -> unit

method function_body : Javascript.statement_list -> unit
end
method function_body : Javascript.statement_list -> unit
end

(* generic js ast iterator *)
class iter : iterator =
Expand Down Expand Up @@ -717,32 +715,31 @@ type block =
| Params of formal_parameter_list
| Normal

class type freevar =
object ('a)
inherit mapper
class type freevar = object ('a)
inherit mapper

method merge_info : 'a -> unit
method merge_info : 'a -> unit

method merge_block_info : 'a -> unit
method merge_block_info : 'a -> unit

method record_block : block -> unit
method record_block : block -> unit

method state : t
method state : t

method def_var : Javascript.ident -> unit
method def_var : Javascript.ident -> unit

method def_local : Javascript.ident -> unit
method def_local : Javascript.ident -> unit

method use_var : Javascript.ident -> unit
method use_var : Javascript.ident -> unit

method get_count : int Javascript.IdentMap.t
method get_count : int Javascript.IdentMap.t

method get_free : IdentSet.t
method get_free : IdentSet.t

method get_def : IdentSet.t
method get_def : IdentSet.t

method get_use : IdentSet.t
end
method get_use : IdentSet.t
end

class free =
object (m : 'test)
Expand Down
Loading

0 comments on commit a036f05

Please sign in to comment.