|
| 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) |
0 commit comments