Skip to content

Commit 877e969

Browse files
authored
chore: Check formatting in ci (#238)
* feat: Check formatting in ci * chore: Run formatter & scope to ubuntu runner
1 parent 7e51d5d commit 877e969

File tree

7 files changed

+89
-39
lines changed

7 files changed

+89
-39
lines changed

.github/workflows/esy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,10 @@ jobs:
8383
- name: Run tests
8484
run: |
8585
esy test
86+
87+
# Check formatting
88+
- name: Check format
89+
if: inputs.os == 'ubuntu-latest'
90+
run: |
91+
esy format
92+
git diff --exit-code --name-only

dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
(dirs :standard)
22

3-
(data_only_dirs node_modules)
3+
(data_only_dirs node_modules)

src/expression.ml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ end
480480
module Switch = struct
481481
external make : Module.t -> string list -> string -> t -> t -> t
482482
= "caml_binaryen_switch"
483-
(** Module, branch names, default branch name, condition, value. Value may be null. *)
483+
(** Module, branch names, default branch name, condition, value. Value may be
484+
null. *)
484485

485486
external get_num_names : t -> int = "caml_binaryen_switch_get_num_names"
486487
external get_name_at : t -> int -> string = "caml_binaryen_switch_get_name_at"
@@ -544,7 +545,8 @@ module Call_indirect = struct
544545

545546
external make_return :
546547
Module.t -> string -> t -> t list -> Type.t -> Type.t -> t
547-
= "caml_binaryen_return_call_indirect__bytecode" "caml_binaryen_return_call_indirect"
548+
= "caml_binaryen_return_call_indirect__bytecode"
549+
"caml_binaryen_return_call_indirect"
548550
(** Module, table, function value, params, params type, return type. *)
549551

550552
external get_target : t -> t = "caml_binaryen_call_indirect_get_target"
@@ -705,10 +707,13 @@ end
705707
module Memory_init = struct
706708
external make : Module.t -> string -> t -> t -> t -> string -> t
707709
= "caml_binaryen_memory_init__bytecode" "caml_binaryen_memory_init"
708-
(** Module, segment, destination, offset, size, memory_name *)
710+
709711
external get_segment : t -> string = "caml_binaryen_memory_init_get_segment"
712+
(** Module, segment, destination, offset, size, memory_name *)
713+
710714
external set_segment : t -> string -> unit
711715
= "caml_binaryen_memory_init_set_segment"
716+
712717
external get_dest : t -> t = "caml_binaryen_memory_init_get_dest"
713718
external set_dest : t -> t -> unit = "caml_binaryen_memory_init_set_dest"
714719
external get_offset : t -> t = "caml_binaryen_memory_init_get_offset"
@@ -719,8 +724,10 @@ end
719724

720725
module Data_drop = struct
721726
external make : Module.t -> string -> t = "caml_binaryen_data_drop"
722-
(** Module, segment. *)
727+
723728
external get_segment : t -> string = "caml_binaryen_data_drop_get_segment"
729+
(** Module, segment. *)
730+
724731
external set_segment : t -> string -> unit
725732
= "caml_binaryen_data_drop_set_segment"
726733
end

src/import.ml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
external add_function_import :
22
Module.t -> string -> string -> string -> Type.t -> Type.t -> unit
3-
= "caml_binaryen_add_function_import__bytecode" "caml_binaryen_add_function_import"
4-
(** Module, internal name, external module name, external base name, params type, results type. *)
3+
= "caml_binaryen_add_function_import__bytecode"
4+
"caml_binaryen_add_function_import"
5+
(** Module, internal name, external module name, external base name, params
6+
type, results type. *)
57

68
external add_table_import : Module.t -> string -> string -> string -> unit
79
= "caml_binaryen_add_table_import"
@@ -14,8 +16,10 @@ external add_memory_import :
1416

1517
external add_global_import :
1618
Module.t -> string -> string -> string -> Type.t -> bool -> unit
17-
= "caml_binaryen_add_global_import__bytecode" "caml_binaryen_add_global_import"
18-
(** Module, internal name, external module name, external base name, type, mutable. *)
19+
= "caml_binaryen_add_global_import__bytecode"
20+
"caml_binaryen_add_global_import"
21+
(** Module, internal name, external module name, external base name, type,
22+
mutable. *)
1923

2024
external function_import_get_module : Function.t -> string
2125
= "caml_binaryen_function_import_get_module"

src/memory.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ external set_memory :
1616
type segment = { name : string; data : bytes; kind : segment_kind; size : int }
1717
and segment_kind = Passive | Active of { offset : Expression.t }
1818

19-
(** Module, initial size, maximum size, export name, segments, shared, memory64, moduleName . *)
19+
(** Module, initial size, maximum size, export name, segments, shared, memory64,
20+
moduleName . *)
2021
let set_memory wasm_mod initial maximum export_name (segments : segment list)
2122
shared memory64 moduleName =
2223
let split_segments segments =

src/passes.ml

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ let avoid_reinterprets = "avoid-reinterprets"
1212
(** removes arguments to calls in an lto-like manner *)
1313
let dae = "dae"
1414

15-
(** removes arguments to calls in an lto-like manner, and optimizes where we removed *)
15+
(** removes arguments to calls in an lto-like manner, and optimizes where we
16+
removed *)
1617
let dae_optimizing = "dae-optimizing"
1718

1819
(** refine and merge abstract (never-created) types *)
@@ -75,7 +76,8 @@ let extract_function_index = "extract-function-index"
7576
(** flattens out code, removing nesting *)
7677
let flatten = "flatten"
7778

78-
(** emulates function pointer casts, allowing incorrect indirect calls to (sometimes) work *)
79+
(** emulates function pointer casts, allowing incorrect indirect calls to
80+
(sometimes) work *)
7981
let fpcast_emu = "fpcast-emu"
8082

8183
(** reports function metrics *)
@@ -84,7 +86,9 @@ let func_metrics = "func-metrics"
8486
(** generate dynCall fuctions used by emscripten ABI *)
8587
let generate_dyncalls = "generate-dyncalls"
8688

87-
(** generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support). *)
89+
(** generate dynCall functions used by emscripten ABI, but only for functions
90+
with i64 in their signature (which cannot be invoked via the wasm table
91+
without JavaScript BigInt support). *)
8892
let generate_i64_dyncalls = "generate-i64-dyncalls"
8993

9094
(** generate global effect info (helps later passes) *)
@@ -102,7 +106,8 @@ let gsi = "gsi"
102106
(** globally optimize GC types *)
103107
let gto = "gto"
104108

105-
(** Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location *)
109+
(** Grand Unified Flow Analysis: optimize the entire program using information
110+
about what content can actually appear in each location *)
106111
let gufa = "gufa"
107112

108113
(** GUFA plus local optimizations in functions we modified *)
@@ -132,7 +137,8 @@ let jspi = "jspi"
132137
(** legalizes i64 types on the import/export boundary *)
133138
let legalize_js_interface = "legalize-js-interface"
134139

135-
(** legalizes i64 types on the import/export boundary in a minimal manner, only on things only JS will call *)
140+
(** legalizes i64 types on the import/export boundary in a minimal manner, only
141+
on things only JS will call *)
136142
let legalize_js_interface_minimally = "legalize-js-interface-minimally"
137143

138144
(** common subexpression elimination inside basic blocks *)
@@ -177,17 +183,21 @@ let merge_locals = "merge-locals"
177183
(** reports metrics *)
178184
let metrics = "metrics"
179185

180-
(** minifies import names (only those, and not export names), and emits a mapping to the minified ones *)
186+
(** minifies import names (only those, and not export names), and emits a
187+
mapping to the minified ones *)
181188
let minify_imports = "minify-imports"
182189

183-
(** minifies both import and export names, and emits a mapping to the minified ones *)
190+
(** minifies both import and export names, and emits a mapping to the minified
191+
ones *)
184192
let minify_imports_and_exports = "minify-imports-and-exports"
185193

186-
(** minifies both import and export names, and emits a mapping to the minified ones, and minifies the modules as well *)
194+
(** minifies both import and export names, and emits a mapping to the minified
195+
ones, and minifies the modules as well *)
187196
let minify_imports_and_exports_and_modules =
188197
"minify-imports-and-exports-and-modules"
189198

190-
(** apply the assumption that asyncify imports always unwind, and we never rewind *)
199+
(** apply the assumption that asyncify imports always unwind, and we never
200+
rewind *)
191201
let mod_asyncify_always_and_only_unwind = "mod-asyncify-always-and-only-unwind"
192202

193203
(** apply the assumption that asyncify never unwinds *)
@@ -202,7 +212,8 @@ let monomorphize_always = "monomorphize-always"
202212
(** combines multiple memories into a single memory *)
203213
let multi_memory_lowering = "multi-memory-lowering"
204214

205-
(** combines multiple memories into a single memory, trapping if the read or write is larger than the length of the memory's data *)
215+
(** combines multiple memories into a single memory, trapping if the read or
216+
write is larger than the length of the memory's data *)
206217
let multi_memory_lowering_with_bounds_checks =
207218
"multi-memory-lowering-with-bounds-checks"
208219

@@ -218,7 +229,8 @@ let once_reduction = "once-reduction"
218229
(** optimizes added constants into load/store offsets *)
219230
let optimize_added_constants = "optimize-added-constants"
220231

221-
(** optimizes added constants into load/store offsets, propagating them across locals too *)
232+
(** optimizes added constants into load/store offsets, propagating them across
233+
locals too *)
222234
let optimize_added_constants_propagate = "optimize-added-constants-propagate"
223235

224236
(** eliminate and reuse casts *)
@@ -245,7 +257,8 @@ let optimize_for_js = "optimize-for-js"
245257
(** computes compile-time evaluatable expressions *)
246258
let precompute = "precompute"
247259

248-
(** computes compile-time evaluatable expressions and propagates them through locals *)
260+
(** computes compile-time evaluatable expressions and propagates them through
261+
locals *)
249262
let precompute_propagate = "precompute-propagate"
250263

251264
(** print in s-expression format *)
@@ -330,19 +343,22 @@ let signature_pruning = "signature-pruning"
330343
(** apply more specific subtypes to signature types where possible *)
331344
let signature_refining = "signature-refining"
332345

333-
(** lower sign-ext operations to wasm mvp and disable the sign extension feature *)
346+
(** lower sign-ext operations to wasm mvp and disable the sign extension feature
347+
*)
334348
let signext_lowering = "signext-lowering"
335349

336350
(** miscellaneous globals-related optimizations *)
337351
let simplify_globals = "simplify-globals"
338352

339-
(** miscellaneous globals-related optimizations, and optimizes where we replaced global.gets with constants *)
353+
(** miscellaneous globals-related optimizations, and optimizes where we replaced
354+
global.gets with constants *)
340355
let simplify_globals_optimizing = "simplify-globals-optimizing"
341356

342357
(** miscellaneous locals-related optimizations *)
343358
let simplify_locals = "simplify-locals"
344359

345-
(** miscellaneous locals-related optimizations (no nesting at all; preserves flatness) *)
360+
(** miscellaneous locals-related optimizations (no nesting at all; preserves
361+
flatness) *)
346362
let simplify_locals_nonesting = "simplify-locals-nonesting"
347363

348364
(** miscellaneous locals-related optimizations (no tees) *)

src/passes.mli

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ val dae : t
1313
(** removes arguments to calls in an lto-like manner *)
1414

1515
val dae_optimizing : t
16-
(** removes arguments to calls in an lto-like manner, and optimizes where we removed *)
16+
(** removes arguments to calls in an lto-like manner, and optimizes where we
17+
removed *)
1718

1819
val abstract_type_refining : t
1920
(** refine and merge abstract (never-created) types *)
@@ -76,7 +77,8 @@ val flatten : t
7677
(** flattens out code, removing nesting *)
7778

7879
val fpcast_emu : t
79-
(** emulates function pointer casts, allowing incorrect indirect calls to (sometimes) work *)
80+
(** emulates function pointer casts, allowing incorrect indirect calls to
81+
(sometimes) work *)
8082

8183
val func_metrics : t
8284
(** reports function metrics *)
@@ -85,7 +87,9 @@ val generate_dyncalls : t
8587
(** generate dynCall fuctions used by emscripten ABI *)
8688

8789
val generate_i64_dyncalls : t
88-
(** generate dynCall functions used by emscripten ABI, but only for functions with i64 in their signature (which cannot be invoked via the wasm table without JavaScript BigInt support). *)
90+
(** generate dynCall functions used by emscripten ABI, but only for functions
91+
with i64 in their signature (which cannot be invoked via the wasm table
92+
without JavaScript BigInt support). *)
8993

9094
val generate_global_effects : t
9195
(** generate global effect info (helps later passes) *)
@@ -103,7 +107,8 @@ val gto : t
103107
(** globally optimize GC types *)
104108

105109
val gufa : t
106-
(** Grand Unified Flow Analysis: optimize the entire program using information about what content can actually appear in each location *)
110+
(** Grand Unified Flow Analysis: optimize the entire program using information
111+
about what content can actually appear in each location *)
107112

108113
val gufa_optimizing : t
109114
(** GUFA plus local optimizations in functions we modified *)
@@ -133,7 +138,8 @@ val legalize_js_interface : t
133138
(** legalizes i64 types on the import/export boundary *)
134139

135140
val legalize_js_interface_minimally : t
136-
(** legalizes i64 types on the import/export boundary in a minimal manner, only on things only JS will call *)
141+
(** legalizes i64 types on the import/export boundary in a minimal manner, only
142+
on things only JS will call *)
137143

138144
val local_cse : t
139145
(** common subexpression elimination inside basic blocks *)
@@ -178,16 +184,20 @@ val metrics : t
178184
(** reports metrics *)
179185

180186
val minify_imports : t
181-
(** minifies import names (only those, and not export names), and emits a mapping to the minified ones *)
187+
(** minifies import names (only those, and not export names), and emits a
188+
mapping to the minified ones *)
182189

183190
val minify_imports_and_exports : t
184-
(** minifies both import and export names, and emits a mapping to the minified ones *)
191+
(** minifies both import and export names, and emits a mapping to the minified
192+
ones *)
185193

186194
val minify_imports_and_exports_and_modules : t
187-
(** minifies both import and export names, and emits a mapping to the minified ones, and minifies the modules as well *)
195+
(** minifies both import and export names, and emits a mapping to the minified
196+
ones, and minifies the modules as well *)
188197

189198
val mod_asyncify_always_and_only_unwind : t
190-
(** apply the assumption that asyncify imports always unwind, and we never rewind *)
199+
(** apply the assumption that asyncify imports always unwind, and we never
200+
rewind *)
191201

192202
val mod_asyncify_never_unwind : t
193203
(** apply the assumption that asyncify never unwinds *)
@@ -202,7 +212,8 @@ val multi_memory_lowering : t
202212
(** combines multiple memories into a single memory *)
203213

204214
val multi_memory_lowering_with_bounds_checks : t
205-
(** combines multiple memories into a single memory, trapping if the read or write is larger than the length of the memory's data *)
215+
(** combines multiple memories into a single memory, trapping if the read or
216+
write is larger than the length of the memory's data *)
206217

207218
val nm : t
208219
(** name list *)
@@ -217,7 +228,8 @@ val optimize_added_constants : t
217228
(** optimizes added constants into load/store offsets *)
218229

219230
val optimize_added_constants_propagate : t
220-
(** optimizes added constants into load/store offsets, propagating them across locals too *)
231+
(** optimizes added constants into load/store offsets, propagating them across
232+
locals too *)
221233

222234
val optimize_casts : t
223235
(** eliminate and reuse casts *)
@@ -244,7 +256,8 @@ val precompute : t
244256
(** computes compile-time evaluatable expressions *)
245257

246258
val precompute_propagate : t
247-
(** computes compile-time evaluatable expressions and propagates them through locals *)
259+
(** computes compile-time evaluatable expressions and propagates them through
260+
locals *)
248261

249262
val print : t
250263
(** print in s-expression format *)
@@ -334,13 +347,15 @@ val simplify_globals : t
334347
(** miscellaneous globals-related optimizations *)
335348

336349
val simplify_globals_optimizing : t
337-
(** miscellaneous globals-related optimizations, and optimizes where we replaced global.gets with constants *)
350+
(** miscellaneous globals-related optimizations, and optimizes where we replaced
351+
global.gets with constants *)
338352

339353
val simplify_locals : t
340354
(** miscellaneous locals-related optimizations *)
341355

342356
val simplify_locals_nonesting : t
343-
(** miscellaneous locals-related optimizations (no nesting at all; preserves flatness) *)
357+
(** miscellaneous locals-related optimizations (no nesting at all; preserves
358+
flatness) *)
344359

345360
val simplify_locals_notee : t
346361
(** miscellaneous locals-related optimizations (no tees) *)

0 commit comments

Comments
 (0)