Module Wp.Sigs.Compiler.L

module L: Wp.Sigs.LogicSemantics  with module M = M

module M: Wp.Sigs.Model 
Underlying memory model
type loc = M.loc 
type value = M.loc Wp.Sigs.value 
type logic = M.loc Wp.Sigs.logic 
type region = M.loc Wp.Sigs.region 
type result = M.loc Wp.Sigs.result 
type sigma = M.Sigma.t 

Frames

Frames are compilation environment for ACSL. A frame typically manages the current function, formal paramters, the memory environments at different labels and the \result and \exit_status values.

The frame also holds the gamma environment responsible for accumulating typing constraints, and the pool for generating fresh logic variables.

Notice that a frame is not responsible for holding the environment at label Here, since this is managed by a specific compilation environment, see Wp.Sigs.LogicSemantics.env below.

type frame 
val pp_frame : Format.formatter -> frame -> unit
val get_frame : unit -> frame
Get the current frame, or raise a fatal error if none.
val in_frame : frame -> ('a -> 'b) -> 'a -> 'b
Execute the given closure with the specified current frame. The Lang.gamma and Lang.pool contexts are also set accordingly.
val mem_at_frame : frame ->
Wp.Clabels.c_label -> sigma
Get the memory environment at the given label. A fresh environment is created lazily if required. The label must not be Here.
val set_at_frame : frame ->
Wp.Clabels.c_label -> sigma -> unit
Update a frame with a specific environment for the given label.
val mem_frame : Wp.Clabels.c_label -> sigma
Same as mem_at_frame but for the current frame.
val mk_frame : ?kf:Cil_types.kernel_function ->
?result:result ->
?status:Wp.Lang.F.var ->
?formals:value Cil_datatype.Varinfo.Map.t ->
?labels:sigma Wp.Clabels.LabelMap.t ->
?descr:string -> unit -> frame
Full featured constructor for frames, with fresh pool and gamma.
val local : descr:string -> frame
Make a local frame reusing the current pool and gamma.
val frame : Cil_types.kernel_function -> frame
Make a fresh frame with the given function.
type call 
Internal call data.
val call : ?result:M.loc ->
Cil_types.kernel_function ->
value list -> call
Create call data from the callee point of view, deriving data (gamma and pools) from the current frame. If result is specified, the called function will stored its result at the provided location in the current frame (the callee).
val call_pre : sigma ->
call ->
sigma -> frame
Derive a frame from the call data suitable for compiling the called function contracts in the provided pre-state.
val call_post : sigma ->
call ->
sigma Wp.Sigs.sequence -> frame
Derive a frame from the call data suitable for compiling the called function contracts in the provided pre-state and post-state.
val return : unit -> Cil_types.typ
Result type of the current function in the current frame.
val result : unit -> result
Result location of the current function in the current frame.
val status : unit -> Wp.Lang.F.var
Exit status for the current frame.
val guards : frame -> Wp.Lang.F.pred list
Returns the current gamma environment from the current frame.

Compilation Environment


type env 
Compilation environment for terms and predicates. Manages the current memory state and the memory state at Here.

Remark: don't confuse the current memory state with the memory state at label Here. The current memory state is the one we have at hand when compiling a term or a predicate. Hence, inside \at(e,L) the current memory state when compiling e is the one at L.

val mk_env : ?here:sigma ->
?lvars:Cil_types.logic_var list -> unit -> env
Create a new environment.

Current and Here memory points are initialized to ~here, if provided.

The logic variables stand for formal parameters of ACSL logic function and ACSL predicates.

val current : env -> sigma
The current memory state. Must be propertly initialized with a specific move before.
val move_at : env ->
sigma -> env
Move the compilation environment to the specified Here memory state. This memory state becomes also the new current one.
val mem_at : env ->
Wp.Clabels.c_label -> sigma
Returns the memory state at the requested label. Uses the local environment for Here and the current frame otherwize.
val env_at : env ->
Wp.Clabels.c_label -> env
Returns a new environment where the current memory state is moved to to the corresponding label. Suitable for compiling e inside \at(e,L) ACSL construct.

Compilers


val lval : env -> Cil_types.term_lval -> Cil_types.typ * M.loc
Compile a term l-value into a (typed) abstract location
val term : env -> Cil_types.term -> Wp.Lang.F.term
Compile a term expression.
val pred : Wp.Sigs.polarity ->
env -> Cil_types.predicate -> Wp.Lang.F.pred
Compile a predicate. The polarity is used to generate a weaker or stronger predicate in case of unsupported feature from WP or the underlying memory model.
val region : env ->
unfold:bool -> Cil_types.term -> region
Compile a term representing a set of memory locations into an abstract region. When ~unfold:true, compound memory locations are expanded field-by-field.
val assigned_of_froms : env ->
unfold:bool -> Cil_types.from list -> region
Computes the region assigned by a list of froms.
val assigned_of_assigns : env ->
unfold:bool -> Cil_types.assigns -> region option
Computes the region assigned by an assigns clause. None means everyhting is assigned.
val val_of_term : env -> Cil_types.term -> Wp.Lang.F.term
Same as term above but reject any set of locations.
val loc_of_term : env -> Cil_types.term -> loc
Same as term above but expects a single loc or a single pointer value.
val lemma : Wp.LogicUsage.logic_lemma -> Wp.Definitions.dlemma
Compile a lemma definition.

Regions


val vars : region -> Wp.Lang.F.Vars.t
Qed variables appearing in a region expression.
val occurs : Wp.Lang.F.var -> region -> bool
Member of vars.
val check_assigns : sigma ->
written:region ->
assignable:region -> Wp.Lang.F.pred
Check assigns inclusion. Compute a formula that checks whether written locations are either invalid (at the given memory location) or included in some assignable region.