Skip to content

Commit 91519f6

Browse files
committed
exception less api
1 parent 9de83bb commit 91519f6

31 files changed

+1030
-719
lines changed

jscomp/all.depend

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ core/lam_compile_const.cmx : core/lam_compile_util.cmx \
370370
core/lam_inner.cmx : core/lam.cmx core/lam_inner.cmi
371371
core/lam_util.cmx : ext/literals.cmx core/lam_stats.cmx core/lam_print.cmx \
372372
core/lam_module_ident.cmx core/lam_analysis.cmx core/lam.cmx \
373-
core/js_fold_basic.cmx common/js_config.cmx ext/ident_set.cmx \
374-
ext/ident_map.cmx ext/ident_hashtbl.cmx ext/ext_list.cmx \
375-
ext/ext_filename.cmx core/lam_util.cmi
373+
common/js_config.cmx ext/ident_set.cmx ext/ident_map.cmx \
374+
ext/ident_hashtbl.cmx ext/ext_list.cmx ext/ext_filename.cmx \
375+
core/lam_util.cmi
376376
core/lam_group.cmx : core/lam_util.cmx core/lam_print.cmx core/lam.cmx \
377377
core/js_number.cmx ext/ident_set.cmx core/lam_group.cmi
378378
core/js_stmt_make.cmx : core/lam_util.cmx core/lam.cmx core/js_exp_make.cmx \

jscomp/bin/all_ounit_tests.ml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4706,7 +4706,8 @@ module type S =
47064706
val find_exn: key -> 'a t -> 'a
47074707
(** [find x m] returns the current binding of [x] in [m],
47084708
or raises [Not_found] if no such binding exists. *)
4709-
4709+
val find_opt: key -> 'a t -> 'a option
4710+
val find_default: key -> 'a t -> 'a -> 'a
47104711
val map: ('a -> 'b) -> 'a t -> 'b t
47114712
(** [map f m] returns a map with same domain as [m], where the
47124713
associated value [a] of all bindings of [m] has been
@@ -4811,6 +4812,20 @@ let rec find_exn x (tree : _ Map_gen.t ) = match tree with
48114812
if c = 0 then d
48124813
else find_exn x (if c < 0 then l else r)
48134814

4815+
let rec find_opt x (tree : _ Map_gen.t ) = match tree with
4816+
| Empty -> None
4817+
| Node(l, v, d, r, _) ->
4818+
let c = compare_key x v in
4819+
if c = 0 then Some d
4820+
else find_opt x (if c < 0 then l else r)
4821+
4822+
let rec find_default x (tree : _ Map_gen.t ) default = match tree with
4823+
| Empty -> default
4824+
| Node(l, v, d, r, _) ->
4825+
let c = compare_key x v in
4826+
if c = 0 then d
4827+
else find_default x (if c < 0 then l else r) default
4828+
48144829
let rec mem x (tree : _ Map_gen.t ) = match tree with
48154830
| Empty ->
48164831
false
@@ -6388,6 +6403,20 @@ let rec find_exn x (tree : _ Map_gen.t ) = match tree with
63886403
if c = 0 then d
63896404
else find_exn x (if c < 0 then l else r)
63906405

6406+
let rec find_opt x (tree : _ Map_gen.t ) = match tree with
6407+
| Empty -> None
6408+
| Node(l, v, d, r, _) ->
6409+
let c = compare_key x v in
6410+
if c = 0 then Some d
6411+
else find_opt x (if c < 0 then l else r)
6412+
6413+
let rec find_default x (tree : _ Map_gen.t ) default = match tree with
6414+
| Empty -> default
6415+
| Node(l, v, d, r, _) ->
6416+
let c = compare_key x v in
6417+
if c = 0 then d
6418+
else find_default x (if c < 0 then l else r) default
6419+
63916420
let rec mem x (tree : _ Map_gen.t ) = match tree with
63926421
| Empty ->
63936422
false

jscomp/bin/bsb.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,8 @@ module type S =
17381738
val find_exn: key -> 'a t -> 'a
17391739
(** [find x m] returns the current binding of [x] in [m],
17401740
or raises [Not_found] if no such binding exists. *)
1741-
1741+
val find_opt: key -> 'a t -> 'a option
1742+
val find_default: key -> 'a t -> 'a -> 'a
17421743
val map: ('a -> 'b) -> 'a t -> 'b t
17431744
(** [map f m] returns a map with same domain as [m], where the
17441745
associated value [a] of all bindings of [m] has been
@@ -1843,6 +1844,20 @@ let rec find_exn x (tree : _ Map_gen.t ) = match tree with
18431844
if c = 0 then d
18441845
else find_exn x (if c < 0 then l else r)
18451846

1847+
let rec find_opt x (tree : _ Map_gen.t ) = match tree with
1848+
| Empty -> None
1849+
| Node(l, v, d, r, _) ->
1850+
let c = compare_key x v in
1851+
if c = 0 then Some d
1852+
else find_opt x (if c < 0 then l else r)
1853+
1854+
let rec find_default x (tree : _ Map_gen.t ) default = match tree with
1855+
| Empty -> default
1856+
| Node(l, v, d, r, _) ->
1857+
let c = compare_key x v in
1858+
if c = 0 then d
1859+
else find_default x (if c < 0 then l else r) default
1860+
18461861
let rec mem x (tree : _ Map_gen.t ) = match tree with
18471862
| Empty ->
18481863
false

jscomp/bin/bsb_helper.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,8 @@ module type S =
17041704
val find_exn: key -> 'a t -> 'a
17051705
(** [find x m] returns the current binding of [x] in [m],
17061706
or raises [Not_found] if no such binding exists. *)
1707-
1707+
val find_opt: key -> 'a t -> 'a option
1708+
val find_default: key -> 'a t -> 'a -> 'a
17081709
val map: ('a -> 'b) -> 'a t -> 'b t
17091710
(** [map f m] returns a map with same domain as [m], where the
17101711
associated value [a] of all bindings of [m] has been
@@ -1809,6 +1810,20 @@ let rec find_exn x (tree : _ Map_gen.t ) = match tree with
18091810
if c = 0 then d
18101811
else find_exn x (if c < 0 then l else r)
18111812

1813+
let rec find_opt x (tree : _ Map_gen.t ) = match tree with
1814+
| Empty -> None
1815+
| Node(l, v, d, r, _) ->
1816+
let c = compare_key x v in
1817+
if c = 0 then Some d
1818+
else find_opt x (if c < 0 then l else r)
1819+
1820+
let rec find_default x (tree : _ Map_gen.t ) default = match tree with
1821+
| Empty -> default
1822+
| Node(l, v, d, r, _) ->
1823+
let c = compare_key x v in
1824+
if c = 0 then d
1825+
else find_default x (if c < 0 then l else r) default
1826+
18121827
let rec mem x (tree : _ Map_gen.t ) = match tree with
18131828
| Empty ->
18141829
false

jscomp/bin/bsdep.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22559,7 +22559,8 @@ module type S =
2255922559
val find_exn: key -> 'a t -> 'a
2256022560
(** [find x m] returns the current binding of [x] in [m],
2256122561
or raises [Not_found] if no such binding exists. *)
22562-
22562+
val find_opt: key -> 'a t -> 'a option
22563+
val find_default: key -> 'a t -> 'a -> 'a
2256322564
val map: ('a -> 'b) -> 'a t -> 'b t
2256422565
(** [map f m] returns a map with same domain as [m], where the
2256522566
associated value [a] of all bindings of [m] has been
@@ -22664,6 +22665,20 @@ let rec find_exn x (tree : _ Map_gen.t ) = match tree with
2266422665
if c = 0 then d
2266522666
else find_exn x (if c < 0 then l else r)
2266622667

22668+
let rec find_opt x (tree : _ Map_gen.t ) = match tree with
22669+
| Empty -> None
22670+
| Node(l, v, d, r, _) ->
22671+
let c = compare_key x v in
22672+
if c = 0 then Some d
22673+
else find_opt x (if c < 0 then l else r)
22674+
22675+
let rec find_default x (tree : _ Map_gen.t ) default = match tree with
22676+
| Empty -> default
22677+
| Node(l, v, d, r, _) ->
22678+
let c = compare_key x v in
22679+
if c = 0 then d
22680+
else find_default x (if c < 0 then l else r) default
22681+
2266722682
let rec mem x (tree : _ Map_gen.t ) = match tree with
2266822683
| Empty ->
2266922684
false

jscomp/bin/bsppx.ml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4417,7 +4417,8 @@ module type S =
44174417
val find_exn: key -> 'a t -> 'a
44184418
(** [find x m] returns the current binding of [x] in [m],
44194419
or raises [Not_found] if no such binding exists. *)
4420-
4420+
val find_opt: key -> 'a t -> 'a option
4421+
val find_default: key -> 'a t -> 'a -> 'a
44214422
val map: ('a -> 'b) -> 'a t -> 'b t
44224423
(** [map f m] returns a map with same domain as [m], where the
44234424
associated value [a] of all bindings of [m] has been
@@ -4522,6 +4523,20 @@ let rec find_exn x (tree : _ Map_gen.t ) = match tree with
45224523
if c = 0 then d
45234524
else find_exn x (if c < 0 then l else r)
45244525

4526+
let rec find_opt x (tree : _ Map_gen.t ) = match tree with
4527+
| Empty -> None
4528+
| Node(l, v, d, r, _) ->
4529+
let c = compare_key x v in
4530+
if c = 0 then Some d
4531+
else find_opt x (if c < 0 then l else r)
4532+
4533+
let rec find_default x (tree : _ Map_gen.t ) default = match tree with
4534+
| Empty -> default
4535+
| Node(l, v, d, r, _) ->
4536+
let c = compare_key x v in
4537+
if c = 0 then d
4538+
else find_default x (if c < 0 then l else r) default
4539+
45254540
let rec mem x (tree : _ Map_gen.t ) = match tree with
45264541
| Empty ->
45274542
false

jscomp/bin/whole_compiler.d

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,10 @@ bin/whole_compiler.ml : core/config_util.ml
198198
bin/whole_compiler.ml : core/config_util.mli
199199
bin/whole_compiler.ml : ext/ident_hashtbl.ml
200200
bin/whole_compiler.ml : ext/ident_hashtbl.mli
201-
bin/whole_compiler.ml : ext/hash_set_poly.ml
202-
bin/whole_compiler.ml : ext/hash_set_poly.mli
203-
bin/whole_compiler.ml : core/lam_module_ident.ml
204-
bin/whole_compiler.ml : core/lam_module_ident.mli
205-
bin/whole_compiler.ml : core/js_fold_basic.ml
206-
bin/whole_compiler.ml : core/js_fold_basic.mli
207201
bin/whole_compiler.ml : core/lam_analysis.ml
208202
bin/whole_compiler.ml : core/lam_analysis.mli
203+
bin/whole_compiler.ml : core/lam_module_ident.ml
204+
bin/whole_compiler.ml : core/lam_module_ident.mli
209205
bin/whole_compiler.ml : core/lam_print.ml
210206
bin/whole_compiler.ml : core/lam_print.mli
211207
bin/whole_compiler.ml : ext/int_hash_set.ml
@@ -216,6 +212,8 @@ bin/whole_compiler.ml : core/lam_util.ml
216212
bin/whole_compiler.ml : core/lam_util.mli
217213
bin/whole_compiler.ml : core/js_stmt_make.ml
218214
bin/whole_compiler.ml : core/js_stmt_make.mli
215+
bin/whole_compiler.ml : ext/hash_set_poly.ml
216+
bin/whole_compiler.ml : ext/hash_set_poly.mli
219217
bin/whole_compiler.ml : core/type_int_to_string.ml
220218
bin/whole_compiler.ml : core/type_util.ml
221219
bin/whole_compiler.ml : core/type_util.mli
@@ -225,6 +223,8 @@ bin/whole_compiler.ml : core/js_program_loader.ml
225223
bin/whole_compiler.ml : core/js_program_loader.mli
226224
bin/whole_compiler.ml : core/js_dump.ml
227225
bin/whole_compiler.ml : core/js_dump.mli
226+
bin/whole_compiler.ml : core/js_fold_basic.ml
227+
bin/whole_compiler.ml : core/js_fold_basic.mli
228228
bin/whole_compiler.ml : core/lam_compile_defs.ml
229229
bin/whole_compiler.ml : core/lam_compile_defs.mli
230230
bin/whole_compiler.ml : core/js_output.ml

0 commit comments

Comments
 (0)