~ubuntu-branches/debian/sid/frama-c/sid

« back to all changes in this revision

Viewing changes to src/memory_state/lmap.mli

  • Committer: Bazaar Package Importer
  • Author(s): Mehdi Dogguy
  • Date: 2009-06-03 08:19:25 UTC
  • Revision ID: james.westby@ubuntu.com-20090603081925-kihvxvt0wy3zc4ar
Tags: upstream-20081201.dfsg
Import upstream version 20081201.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(**************************************************************************)
 
2
(*                                                                        *)
 
3
(*  This file is part of Frama-C.                                         *)
 
4
(*                                                                        *)
 
5
(*  Copyright (C) 2007-2008                                               *)
 
6
(*    CEA (Commissariat � l'�nergie Atomique)                             *)
 
7
(*                                                                        *)
 
8
(*  you can redistribute it and/or modify it under the terms of the GNU   *)
 
9
(*  Lesser General Public License as published by the Free Software       *)
 
10
(*  Foundation, version 2.1.                                              *)
 
11
(*                                                                        *)
 
12
(*  It is distributed in the hope that it will be useful,                 *)
 
13
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *)
 
14
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *)
 
15
(*  GNU Lesser General Public License for more details.                   *)
 
16
(*                                                                        *)
 
17
(*  See the GNU Lesser General Public License version 2.1                 *)
 
18
(*  for more details (enclosed in the file licenses/LGPLv2.1).            *)
 
19
(*                                                                        *)
 
20
(**************************************************************************)
 
21
 
 
22
(*i $Id: lmap.mli,v 1.71 2008/11/18 12:13:41 uid568 Exp $ i*)
 
23
 
 
24
(** Functors making map indexed by locations.
 
25
    @plugin development guide *)
 
26
 
 
27
open Abstract_interp
 
28
open Abstract_value
 
29
open Locations
 
30
open BaseUtils
 
31
 
 
32
exception Cannot_copy
 
33
 
 
34
module type Location_map =
 
35
sig
 
36
  type y (** type of the values associated to the locations *)
 
37
  type loffset
 
38
  type widen_hint_offsetmap
 
39
(*  module LOffset : Offsetmap.S with type y = y
 
40
                               and type widen_hint = widen_hint_offsetmap
 
41
*)
 
42
  module Make
 
43
    (Default_offsetmap: sig val default_offsetmap : Base.t -> loffset end):
 
44
  sig
 
45
    type t (** the type of a map *)
 
46
 
 
47
    type widen_hint = bool * BaseSet.t * (Base.t -> widen_hint_offsetmap)
 
48
 
 
49
    type instanciation = Location_Bytes.t BaseMap.t
 
50
 
 
51
    module Datatype : Project.Datatype.S with type t = t
 
52
 
 
53
    val inject : Base.t -> loffset -> t
 
54
 
 
55
    val add_offsetmap :  Base.t -> loffset -> t -> t
 
56
 
 
57
    val pretty : Format.formatter -> t -> unit
 
58
    val pretty_without_null : Format.formatter -> t -> unit
 
59
    val pretty_filter: Format.formatter -> t -> Locations.Zone.t -> unit
 
60
    val add_binding: 
 
61
      with_alarms:CilE.warn_mode -> exact:bool -> t -> location -> y -> t
 
62
 
 
63
    val find : with_alarms:CilE.warn_mode -> t -> location -> y
 
64
 
 
65
    val join : t -> t -> t
 
66
    val is_included : t -> t -> bool
 
67
    val equal : t -> t -> bool
 
68
    val hash : t -> int
 
69
    val is_included_actual_generic :
 
70
      Zone.t -> t -> t -> instanciation
 
71
 
 
72
    (** Every location is associated to [VALUE.top] in [empty].*)
 
73
    val empty : t
 
74
    val is_empty : t -> bool
 
75
 
 
76
    (** Every location is associated to [VALUE.bottom] in [bottom].
 
77
        This state can be reached only in dead code. *)
 
78
    val bottom : t
 
79
    val is_reachable : t -> bool
 
80
 
 
81
    val widen : widen_hint-> t -> t -> (bool * t)
 
82
 
 
83
 
 
84
    val filter_base : (Base.t -> bool) -> t -> t
 
85
 
 
86
    (** @raise Not_found if the varid is not present in the map. *)
 
87
    val find_base : Base.t -> t -> loffset
 
88
 
 
89
    (** Removes the base if it is present. Does nothing otherwise. *)
 
90
    val remove_base : Base.t -> t -> t
 
91
      
 
92
 
 
93
    (** [copy_paste src dst state] returns a modified version of [state] in
 
94
        which everything present in [src] has been copied onto [dst]. [src] and
 
95
        [dst] must have the same size. The write operation is exact iff [dst]
 
96
        is exact. 
 
97
        @raise Cannot_copy if copy is not possible. *)
 
98
    val copy_paste : location -> location -> t -> t
 
99
 
 
100
    (** @raise Cannot_copy if copy is not possible. *)
 
101
    val paste_offsetmap :
 
102
      loffset -> Location_Bits.t -> Int.t -> Int.t -> t -> t
 
103
 
 
104
    (** May return [None] as a bottom loffset.
 
105
        @raise Cannot_copy if copy is not possible. *)
 
106
    val copy_offsetmap : Locations.location -> t -> loffset option
 
107
 
 
108
    val compute_actual_final_from_generic :
 
109
      t -> t -> Locations.Zone.t -> instanciation -> t*Location_Bits.Top_Param.t
 
110
 
 
111
    val is_included_by_location_enum :  t -> t -> Locations.Zone.t -> bool
 
112
 
 
113
    (** @raise Invalid_argument if one location is not aligned or of size
 
114
        different of [size].
 
115
        @raise Error_Bottom if [m] is bottom. *)
 
116
    val fold : size:Int.t -> (location -> y -> 'a -> 'a) -> t -> 'a -> 'a
 
117
 
 
118
 
 
119
    (** [fold_base f m] calls [f] on all bases bound to non top
 
120
        offsetmaps in the non bottom map [m].
 
121
        @raise Error_Bottom if [m] is bottom. *)
 
122
    val fold_base : (Base.t -> 'a -> 'a) -> t -> 'a -> 'a
 
123
 
 
124
    (** [fold_base_offsetmap f m] calls [f] on all bases bound to non
 
125
        top offsetmaps in the non bottom map [m].
 
126
        @raise Error_Bottom if [m] is bottom.*)
 
127
    val fold_base_offsetmap : (Base.t -> loffset -> 'a -> 'a) -> t -> 'a -> 'a
 
128
 
 
129
    val find_offsetmap_for_location : Location_Bits.t -> t -> loffset
 
130
    val add_whole: location -> y -> t -> t
 
131
    val remove_whole: location -> t -> t
 
132
 
 
133
    (** [reciprocal_image m b] is the set of bits in the map [m] that may lead
 
134
        to Top([b]) and  the location in [m] where one may read an address
 
135
        [b]+_ *)
 
136
    val reciprocal_image : Base.t -> t -> Zone.t*Location_Bits.t
 
137
      (*
 
138
        val create_initialized_var :
 
139
        Cil_types.varinfo -> Base.validity -> loffset -> Base.t
 
140
      *)
 
141
    val create_initial :
 
142
      base:Base.t ->
 
143
      v:y ->
 
144
      modu:Int.t ->
 
145
      state:t -> t
 
146
    exception Error_Bottom
 
147
 
 
148
    val cached_fold :
 
149
      f:(Base.t -> loffset -> 'a) ->
 
150
      cache:string * int -> joiner:('a -> 'a -> 'a) -> empty:'a -> t -> 'a
 
151
 
 
152
    val cached_map :
 
153
      f:(Base.t -> loffset -> loffset) ->
 
154
      cache:string * int ->
 
155
      t -> t
 
156
  end
 
157
end
 
158
 
 
159
module Make_LOffset
 
160
  (VALUE:Lattice_With_Isotropy.S) 
 
161
  (LOffset:Offsetmap.S with type y = VALUE.t 
 
162
                       and type widen_hint = VALUE.widen_hint) :
 
163
  Location_map with type y = VALUE.t
 
164
               and type widen_hint_offsetmap = VALUE.widen_hint
 
165
               and type loffset = LOffset.t