Module Ast.Expr

Syntax tree for program expressions (both IMP and SSA ones).

The main expression type is the unary expr, which is hashconsed version of expr_node. expr_node is private to avoid breaking hash-consing: it can be inspected, but must be built using the constructors in provided by the Make functor.

type binop = Frama_c_kernel.Cil_types.binop =
  1. | PlusA
    (*

    arithmetic +

    *)
  2. | PlusPI
    (*

    pointer + integer, unsupported

    *)
  3. | MinusA
    (*

    arithmetic -

    *)
  4. | MinusPI
    (*

    pointer - integer, unsupported

    *)
  5. | MinusPP
    (*

    pointer - pointer, unsupported

    *)
  6. | Mult
    (*

    *

    *)
  7. | Div
    (*

    /

    *)
  8. | Mod
    (*

    %

    *)
  9. | Shiftlt
    (*

    shift left

    *)
  10. | Shiftrt
    (*

    shift right

    *)
  11. | Lt
    (*

    < (arithmetic comparison)

    *)
  12. | Gt
    (*

    > (arithmetic comparison)

    *)
  13. | Le
    (*

    <= (arithmetic comparison)

    *)
  14. | Ge
    (*

    >= (arithmetic comparison)

    *)
  15. | Eq
    (*

    == (arithmetic comparison)

    *)
  16. | Ne
    (*

    != (arithmetic comparison)

    *)
  17. | BAnd
    (*

    bitwise and

    *)
  18. | BXor
    (*

    exclusive-or

    *)
  19. | BOr
    (*

    inclusive-or

    *)
  20. | LAnd
    (*

    logical and.

    *)
  21. | LOr
    (*

    logical or.

    *)

Binary operators

type unop = Frama_c_kernel.Cil_types.unop =
  1. | Neg
    (*

    Arithmetic negation

    *)
  2. | BNot
    (*

    Bitwise not

    *)
  3. | LNot
    (*

    Logical negation (non-zero -> zero, zero -> 1)

    *)

Unary operators

type 'var expr_node = private
  1. | E_Var of 'var
  2. | E_Const of Z.t
  3. | E_Binop of 'var expr * binop * 'var expr
  4. | E_Unop of unop * 'var expr
  5. | E_IfThenElse of 'var expr * 'var expr * 'var expr

Expressions are parametrized by the type of variable so we can reuse them for SSA. They are also hashconsed, hence the private type Use the Make(Var) functor's smart constructors to build expressions

and 'var expr = 'var expr_node Hashconsing.hash_consed
module type S = sig ... end
module Binop : Std_extra.Types.TYPE with type t = binop
module Unop : Std_extra.Types.TYPE with type t = unop
val bind : ('b expr_node -> 'b expr) -> ('a -> 'b expr) -> 'a expr -> 'b expr

The first argument of bind and map is of_node to turn an element into it's hashconsed version

val map : ('b expr_node -> 'b expr) -> ('a -> 'b) -> 'a expr -> 'b expr
val is_const : 'a expr -> bool

true if the expression contains no variables

val size : 'a expr -> int

Expression size (number of nodes)

val depth : 'a expr -> int

Expression depth

val is_constant : 'a expr -> Z.t option
module Make (Var : Std_extra.Types.TYPE) : S with type var = Var.t

Create an expression domain with the given variable type, provide smart constructors for it and manage the hashconsing