Skip to content
This repository
tree: 007c8b0036
Fetching contributors…

Cannot retrieve contributors at this time

file 180 lines (146 sloc) 5.237 kb
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
(*
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/>.
*)

(**
Provides all check on QML for pre/post conditions.

@author Esther Baruk
@author Mathieu Barbin
@author Quentin Bourgerie
*)

(** {6 Guidelines} *)
(**
If you write a new implementation of a checker :

+ USE [QmlError.check_fail] or [QmlError.scheck_fail]
+ DO NOT USE [scond_violation], [cond_violation], [i_error] and [i_serror],
those are for passes only (not checkers)
+ All checks in this module should use the internal error system
with warning related to conditions.
+ There is no interaction between [OManager] and this module.
Function there should not perform direct call to OManager, but
to the overlayer defined in QmlError.
+ You should never use :[flush_errors] like function.
+ please, order modules alphabetically,
+ and functions inside module.
+ You should necessarily export the id of conditions.

Follow this schema :

in WarningClass :

{[
val cond_category_subcategory_name : wclass
]}

There :
{[
module Category =
struct
module Subcategory =
struct
let name_id = PassHandler.define_cond WarningClass.cond_category_subcategory_name
let name = .... PassHandler.make_condition name_id ...
end
end
]}

For more informations, you can refer to [passlib/passdesign.ml] which contains a reference
implementation for this module.
*)


(**
The type of all checkers. Take an extractor and compute some checks in it.
In case of errors, the check should use functions from [QmlError] only.

@see "WarningClass" for the corresponding definitions of warning classes
*)
type ('env, 'a) checker = ('env -> 'a) -> 'env PassHandler.cond

(** Checks related to [QmlAst.annotation] (types, pos, unicity, etc..) *)
module Annot :
sig
  (**
The id of all cond related to annot
*)
  val id : PassHandler.cond_id

  (** {6 Find} *)

  (**
Given an annotmap and a code, checks if every annotation is present in the annotmap.
- Condition name : ["cond.annot.find"]
- Warning class : [cond_annot_find]
*)
  val find : ('env , (QmlAst.annotmap * QmlAst.code)) checker
  val find_id : PassHandler.cond_id

  (** {6 Unicity} *)

  (**
Checks that annotation are unique in a given code
- Condition name : ["cond.annot.unicity"]
- Warning class : [cond_annot_unicity]
*)
  val unicity : ('env, QmlAst.code) checker
  val unicity_id : PassHandler.cond_id
end

(** Checks related to [QmlAst.Bypass] *)
module Bypass :
sig
  (**
The id of all cond related to bypass
*)
  val id : PassHandler.cond_id

  (** {6 Applied } *)

  (**
Checks that every bypass is totally applied with respect to its
arity and to the number of arguments which it is applied on.
Example :
{[ let x = %%plus%% 2 3 ]} is ok.
{[ let x = %%minus%% 4 6 7 ]} is not ok.
- Condition name : ["cond.bypass.applied"]
- Warning class : [cond_bypass_applied]
*)
  val applied : ('env, (QmlTypes.bypass_typer * QmlAst.code)) checker
  val applied_id : PassHandler.cond_id
end

(** General checks on the code *)
module Code :
sig
  (**
The id of all cond related to code
*)
  val id : PassHandler.cond_id

  (** {6 Recursives Values} *)

  (** the core checking function
undot -> tolerate `module directive
second bool arg -> do checking instead of making error
called by both S2 and S3
CLEANING S2 : DELETE THE PREVIOUS LINE
*)
  val check_valrec : undot:bool -> bool -> (QmlAst.annotmap * QmlAst.code) -> unit


  (** {6 Kind of code-elt } *)

  (**
The type to express what kind of code_elt are still in the code.
A code elt tagged 'false' should no more appear in the code.
*)
  type contents_code_elt = {
    c_Database : bool ;
    c_NewDbValue : bool ;
    c_NewType : bool ;
    c_NewVal : bool ;
    c_NewValRec : bool ;
  }

  (** check the kind of code_elt in the code *)
  val contents_all : contents_code_elt
  val contents_id : PassHandler.cond_id
  val contents : contents_code_elt -> ('env, (QmlAst.annotmap * QmlAst.code)) checker

  (** Checks that the defininition of recursives values are
avialable.
- Condition name : ["cond.code.valrec"]
- Warning class : [cond_code_valrec]
*)
  val valrec : ('env, (QmlAst.annotmap * QmlAst.code)) checker
  val valrec_id : PassHandler.cond_id

  (** Like [valrec] but bool argument indicates if the checker make
condition error or user error. [true] indicates condition
error. *)
  val valrec_user : undot:bool -> ('env, (QmlAst.annotmap * QmlAst.code)) checker

end
Something went wrong with that request. Please try again.