Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit 21de4ce

Browse files
committed
Nouveau module de gestion des anomalies
1 parent 1e690fd commit 21de4ce

3 files changed

Lines changed: 493 additions & 451 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
open Types
2+
3+
let raise ctx err v_opt =
4+
(match err.Com.Error.typ with
5+
| Com.Error.Anomaly -> ctx.ctx_nb_anos <- ctx.ctx_nb_anos + 1
6+
| Com.Error.Discordance -> ctx.ctx_nb_discos <- ctx.ctx_nb_discos + 1
7+
| Com.Error.Information -> ctx.ctx_nb_infos <- ctx.ctx_nb_infos + 1);
8+
let is_blocking =
9+
err.typ = Com.Error.Anomaly && Pos.unmark err.is_isf = "N"
10+
in
11+
ctx.ctx_nb_bloquantes <- (ctx.ctx_nb_bloquantes + if is_blocking then 1 else 0);
12+
ctx.ctx_anos <- ctx.ctx_anos @ [ (err, v_opt) ];
13+
is_blocking
14+
15+
let clean (ctx : 'a ctx) =
16+
ctx.ctx_anos <- [];
17+
ctx.ctx_nb_anos <- 0;
18+
ctx.ctx_nb_discos <- 0;
19+
ctx.ctx_nb_infos <- 0;
20+
ctx.ctx_nb_bloquantes <- 0
21+
22+
let clean_finalized (ctx : 'a ctx) = ctx.ctx_finalized_anos <- []
23+
24+
let finalize ~mode_corr (ctx : 'a ctx) =
25+
let mem (ano : Com.Error.t) anos =
26+
List.fold_left
27+
(fun res ((a : Com.Error.t), _) ->
28+
res || Pos.unmark a.name = Pos.unmark ano.name)
29+
false anos
30+
in
31+
if mode_corr then
32+
let rec merge_anos () =
33+
match ctx.ctx_anos with
34+
| [] -> ()
35+
| ((ano : Com.Error.t), arg) :: discos ->
36+
let cont =
37+
if not (mem ano ctx.ctx_finalized_anos) then (
38+
ctx.ctx_finalized_anos <- ctx.ctx_finalized_anos @ [ (ano, arg) ];
39+
ano.typ <> Com.Error.Anomaly)
40+
else true
41+
in
42+
ctx.ctx_anos <- discos;
43+
if cont then merge_anos ()
44+
in
45+
merge_anos ()
46+
else (
47+
clean_finalized ctx;
48+
let rec merge_anos () =
49+
match ctx.ctx_anos with
50+
| [] -> ctx.ctx_finalized_anos <- List.rev ctx.ctx_finalized_anos
51+
| ((ano : Com.Error.t), arg) :: discos ->
52+
if not (StrSet.mem (Pos.unmark ano.name) ctx.ctx_archived_anos) then (
53+
ctx.ctx_archived_anos <-
54+
StrSet.add (Pos.unmark ano.name) ctx.ctx_archived_anos;
55+
ctx.ctx_finalized_anos <- (ano, arg) :: ctx.ctx_finalized_anos);
56+
ctx.ctx_anos <- discos;
57+
merge_anos ()
58+
in
59+
merge_anos ())
60+
61+
let export ~mode_corr (ctx : 'a ctx) =
62+
if mode_corr then
63+
let rec merge_anos () =
64+
match ctx.ctx_finalized_anos with
65+
| [] -> ()
66+
| ((ano : Com.Error.t), arg) :: fins ->
67+
if not (StrSet.mem (Pos.unmark ano.name) ctx.ctx_archived_anos) then (
68+
ctx.ctx_archived_anos <-
69+
StrSet.add (Pos.unmark ano.name) ctx.ctx_archived_anos;
70+
ctx.ctx_exported_anos <- ctx.ctx_exported_anos @ [ (ano, arg) ]);
71+
ctx.ctx_finalized_anos <- fins;
72+
merge_anos ()
73+
in
74+
merge_anos ()
75+
else (
76+
ctx.ctx_exported_anos <- ctx.ctx_exported_anos @ ctx.ctx_finalized_anos;
77+
clean_finalized ctx)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
val raise : 'a Types.ctx -> M_ir.Com.Error.t -> string option -> bool
2+
(** Adds the anomaly to the context and returns [true] if the said anomaly
3+
is blocking, [false] otherwise. *)
4+
5+
val clean : 'a Types.ctx -> unit
6+
(** Cleans the context from its unfinalized and unarchived
7+
anomalies. *)
8+
9+
val clean_finalized : 'a Types.ctx -> unit
10+
(** Cleans the context from its finalized anomalies. *)
11+
12+
val finalize : mode_corr:bool -> 'a Types.ctx -> unit
13+
(** Moves the raised anomalies to the finalized anomalies (and the
14+
archived anomalies if [mode_corr] is [true]). *)
15+
16+
val export : mode_corr:bool -> 'a Types.ctx -> unit
17+
(** Moves the finalized anomalies to the exported anomalies (and the
18+
archived anomalies if [mode_corr] is [true]). *)

0 commit comments

Comments
 (0)