Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 181 lines (146 sloc) 5.237 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (**
20 Provides all check on QML for pre/post conditions.
21
22 @author Esther Baruk
23 @author Mathieu Barbin
24 @author Quentin Bourgerie
25 *)
26
27 (** {6 Guidelines} *)
28 (**
29 If you write a new implementation of a checker :
30
31 + USE [QmlError.check_fail] or [QmlError.scheck_fail]
32 + DO NOT USE [scond_violation], [cond_violation], [i_error] and [i_serror],
33 those are for passes only (not checkers)
34 + All checks in this module should use the internal error system
35 with warning related to conditions.
36 + There is no interaction between [OManager] and this module.
37 Function there should not perform direct call to OManager, but
38 to the overlayer defined in QmlError.
39 + You should never use :[flush_errors] like function.
40 + please, order modules alphabetically,
41 + and functions inside module.
42 + You should necessarily export the id of conditions.
43
44 Follow this schema :
45
46 in WarningClass :
47
48 {[
49 val cond_category_subcategory_name : wclass
50 ]}
51
52 There :
53 {[
54 module Category =
55 struct
56 module Subcategory =
57 struct
58 let name_id = PassHandler.define_cond WarningClass.cond_category_subcategory_name
59 let name = .... PassHandler.make_condition name_id ...
60 end
61 end
62 ]}
63
64 For more informations, you can refer to [passlib/passdesign.ml] which contains a reference
65 implementation for this module.
66 *)
67
68
69 (**
70 The type of all checkers. Take an extractor and compute some checks in it.
71 In case of errors, the check should use functions from [QmlError] only.
72
73 @see "WarningClass" for the corresponding definitions of warning classes
74 *)
75 type ('env, 'a) checker = ('env -> 'a) -> 'env PassHandler.cond
76
77 (** Checks related to [QmlAst.annotation] (types, pos, unicity, etc..) *)
78 module Annot :
79 sig
80 (**
81 The id of all cond related to annot
82 *)
83 val id : PassHandler.cond_id
84
85 (** {6 Find} *)
86
87 (**
88 Given an annotmap and a code, checks if every annotation is present in the annotmap.
89 - Condition name : ["cond.annot.find"]
90 - Warning class : [cond_annot_find]
91 *)
92 val find : ('env , (QmlAst.annotmap * QmlAst.code)) checker
93 val find_id : PassHandler.cond_id
94
95 (** {6 Unicity} *)
96
97 (**
98 Checks that annotation are unique in a given code
99 - Condition name : ["cond.annot.unicity"]
100 - Warning class : [cond_annot_unicity]
101 *)
102 val unicity : ('env, QmlAst.code) checker
103 val unicity_id : PassHandler.cond_id
104 end
105
106 (** Checks related to [QmlAst.Bypass] *)
107 module Bypass :
108 sig
109 (**
110 The id of all cond related to bypass
111 *)
112 val id : PassHandler.cond_id
113
114 (** {6 Applied } *)
115
116 (**
117 Checks that every bypass is totally applied with respect to its
118 arity and to the number of arguments which it is applied on.
119 Example :
120 {[ let x = %%plus%% 2 3 ]} is ok.
121 {[ let x = %%minus%% 4 6 7 ]} is not ok.
122 - Condition name : ["cond.bypass.applied"]
123 - Warning class : [cond_bypass_applied]
124 *)
125 val applied : ('env, (QmlTypes.bypass_typer * QmlAst.code)) checker
126 val applied_id : PassHandler.cond_id
127 end
128
129 (** General checks on the code *)
130 module Code :
131 sig
132 (**
133 The id of all cond related to code
134 *)
135 val id : PassHandler.cond_id
136
137 (** {6 Recursives Values} *)
138
139 (** the core checking function
140 undot -> tolerate `module directive
141 second bool arg -> do checking instead of making error
142 called by both S2 and S3
143 CLEANING S2 : DELETE THE PREVIOUS LINE
144 *)
145 val check_valrec : undot:bool -> bool -> (QmlAst.annotmap * QmlAst.code) -> unit
146
147
148 (** {6 Kind of code-elt } *)
149
150 (**
151 The type to express what kind of code_elt are still in the code.
152 A code elt tagged 'false' should no more appear in the code.
153 *)
154 type contents_code_elt = {
155 c_Database : bool ;
156 c_NewDbValue : bool ;
157 c_NewType : bool ;
158 c_NewVal : bool ;
159 c_NewValRec : bool ;
160 }
161
162 (** check the kind of code_elt in the code *)
163 val contents_all : contents_code_elt
164 val contents_id : PassHandler.cond_id
165 val contents : contents_code_elt -> ('env, (QmlAst.annotmap * QmlAst.code)) checker
166
167 (** Checks that the defininition of recursives values are
168 avialable.
169 - Condition name : ["cond.code.valrec"]
170 - Warning class : [cond_code_valrec]
171 *)
172 val valrec : ('env, (QmlAst.annotmap * QmlAst.code)) checker
173 val valrec_id : PassHandler.cond_id
174
175 (** Like [valrec] but bool argument indicates if the checker make
176 condition error or user error. [true] indicates condition
177 error. *)
178 val valrec_user : undot:bool -> ('env, (QmlAst.annotmap * QmlAst.code)) checker
179
180 end
Something went wrong with that request. Please try again.