Module IR__Exp
The Smallfoot Intermediate Language: Expressions
NOTE: For doing substitutionson expressions, there are some functions in Sil
.
type closure
=
{
name : IR.Procname.t;
captured_vars : (t * IR.Pvar.t * IR.Typ.t) list;
}
and sizeof_data
=
{
typ : IR.Typ.t;
nbytes : int option;
dynamic_length : t option;
subtype : IR.Subtype.t;
}
This records information about a
sizeof(typ)
expression.nbytes
represents the result of the evaluation ofsizeof(typ)
if it is statically known.If
typ
is of the formTarray elt (Some static_length)
, thendynamic_length
is the number of elements of typeelt
in the array. Thedynamic_length
, tracked by symbolic execution, may differ from thestatic_length
obtained from the type definition, e.g. when an array is over-allocated.If
typ
is a struct type, thedynamic_length
is that of the final extensible array, if any.
and t
=
|
Var of IR.Ident.t
Pure variable: it is not an lvalue
|
UnOp of IR.Unop.t * t * IR.Typ.t option
Unary operator with type of the result if known
|
BinOp of IR.Binop.t * t * t
Binary operator
|
Exn of t
Exception
|
Closure of closure
Anonymous function
|
Const of IR.Const.t
Constants
|
Cast of IR.Typ.t * t
Type cast
|
Lvar of IR.Pvar.t
The address of a program variable
|
Lfield of t * IR.Fieldname.t * IR.Typ.t
A field offset, the type is the surrounding struct type
|
Lindex of t * t
An array index offset:
exp1[exp2]
|
Sizeof of sizeof_data
Program expressions.
val compare_closure : closure -> closure -> int
val compare_sizeof_data : sizeof_data -> sizeof_data -> int
val compare : t -> t -> int
module Set : IStdlib.IStd.Caml.Set.S with type Set.elt = t
Set of expressions.
module Map : IStdlib.IStd.Caml.Map.S with type Map.key = t
Map with expression keys.
module Hash : IStdlib.IStd.Caml.Hashtbl.S with type Hash.key = t
Hashtable with expression keys.
val is_null_literal : t -> bool
val is_this : t -> bool
return true if
exp
is the special this/self expression
Utility Functions for Expressions
val texp_to_typ : IR.Typ.t option -> t -> IR.Typ.t
Turn an expression representing a type into the type it represents If not a sizeof, return the default type if given, otherwise raise an exception
val get_undefined : bool -> t
Get an expression "undefined", the boolean indicates whether the undefined value goest into the footprint
val pointer_arith : t -> bool
Checks whether an expression denotes a location using pointer arithmetic. Currently, catches array - indexing expressions such as a
i
only.
val has_local_addr : t -> bool
returns true if the expression operates on address of local variable
val zero : t
Integer constant 0
val null : t
Null constant
val one : t
Integer constant 1
val minus_one : t
Integer constant -1
val int : IR.IntLit.t -> t
Create integer constant
val float : float -> t
Create float constant
val bool : bool -> t
Create integer constant corresponding to the boolean value
val free_vars : t -> IR.Ident.t IStdlib.IStd.Sequence.t
all the idents appearing in the expression
val gen_free_vars : t -> (unit, IR.Ident.t) IStdlib.IStd.Sequence.Generator.t
val ident_mem : t -> IR.Ident.t -> bool
true if the identifier appears in the expression
val program_vars : t -> IR.Pvar.t IStdlib.IStd.Sequence.t
all the program variables appearing in the expression
val rename_pvars : f:(string -> string) -> t -> t
Rename all Pvars according to the function
f
. WARNING: You want to rename pvars before you combine expressions from different symbolic states, which you RARELY want to.
val fold_captured : f:('a -> t -> 'a) -> t -> 'a -> 'a
Fold over the expressions captured by this expression.
val pp_diff : ?print_types:bool -> IStdlib.Pp.env -> F.formatter -> t -> unit
val pp : F.formatter -> t -> unit
val to_string : t -> string
val d_exp : t -> unit
dump an expression.
val pp_texp : IStdlib.Pp.env -> F.formatter -> t -> unit
Pretty print a type.
val pp_texp_full : IStdlib.Pp.env -> F.formatter -> t -> unit
Pretty print a type with all the details.
val d_texp_full : t -> unit
Dump a type expression with all the details.
val d_list : t list -> unit
Dump a list of expressions.