-
Notifications
You must be signed in to change notification settings - Fork 125
/
w_Exceptions.ml
71 lines (58 loc) · 2.77 KB
/
w_Exceptions.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(*
Copyright © 2011 MLstate
This file is part of OPA.
OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.
OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.
You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(*
@author Fran�ois Pessaux
*)
let (reset_type_exception, enrich_type_exception, type_exception) =
let seed_type = ref None in
(
(* ********************************************************************** *)
(** {b Descr}: Effective body of the function [reset_type_exception].
See .mli file for documentation.
{b Visibility}: Exported outside this module. *)
(* ********************************************************************** *)
(fun () ->
(* Exceptions are an opened sum. Initially, it contains no case. We
create a local type to accumulate cases encountered while
typechecking the program. *)
let opened_column =
{ W_Algebra.ct_value =
([], (W_CoreTypes.column_ending_variable ())) } in
let ty =
{ W_Algebra.sty_desc = W_Algebra.SType_sum_of_records opened_column ;
W_Algebra.sty_link = None ;
W_Algebra.sty_mark = W_Algebra.TM_not_seen } in
seed_type := Some ty),
(* ********************************************************************** *)
(** {b Descr}: Effective body of the function [enrich_type_exception].
See .mli file for documentation.
{b Visibility}: Exported outside this module. *)
(* ********************************************************************** *)
(fun env ty ->
match !seed_type with
| None -> assert false
| Some exn_ty -> W_Unify.unify_simple_type env exn_ty ty),
(* ********************************************************************** *)
(** {b Descr}: Effective body of the function [type_exception].
See .mli file for documentation.
{b Visibility}: Exported outside this module. *)
(* ********************************************************************** *)
(fun () ->
(* Each time a type exception is created, we give the same physical
type, hence known cases of exceptions will be accumulated in this
unique type. *)
match !seed_type with
| None -> assert false
| Some exn_ty -> exn_ty)
)