The Smallfoot Intermediate Language: Expressions
type closure
=
{
name : InferIR.Typ.Procname.t; |
captured_vars : (t * InferIR.Pvar.t * InferIR.Typ.t) list; |
}
type sizeof_data
=
{
typ : InferIR.Typ.t; |
nbytes : int option; |
dynamic_length : t option; |
subtype : InferIR.Subtype.t; |
}
This records information about a sizeof(typ)
expression.
nbytes
represents the result of the evaluation of sizeof(typ)
if it is statically known.
If typ
is of the form Tarray elt (Some static_length)
, then dynamic_length
is the number
of elements of type elt
in the array. The dynamic_length
, tracked by symbolic execution, may
differ from the static_length
obtained from the type definition, e.g. when an array is
over-allocated.
If typ
is a struct type, the dynamic_length
is that of the final extensible array, if any.
type t
=
| Var of InferIR.Ident.t | (** Pure variable: it is not an lvalue *) |
| UnOp of InferIR.Unop.t * t * InferIR.Typ.t option | (** Unary operator with type of the result if known *) |
| BinOp of InferIR.Binop.t * t * t | (** Binary operator *) |
| Exn of t | (** Exception *) |
| Closure of closure | (** Anonymous function *) |
| Const of InferIR.Const.t | (** Constants *) |
| Cast of InferIR.Typ.t * t | (** Type cast *) |
| Lvar of InferIR.Pvar.t | (** The address of a program variable *) |
| Lfield of t * InferIR.Typ.Fieldname.t * InferIR.Typ.t | (** A field offset, the type is the surrounding struct type *) |
| Lindex of t * t | (** An array index offset: |
| Sizeof of sizeof_data |
Program expressions.
include sig ... end
val compare_sizeof_data : sizeof_data ‑> sizeof_data ‑> int
val is_null_literal : t ‑> bool
val is_zero : t ‑> bool
val texp_to_typ : InferIR.Typ.t option ‑> t ‑> InferIR.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 ai
only.
val free_vars : t ‑> InferIR.Ident.t InferStdlib.IStd.Sequence.t
all the idents appearing in the expression
val gen_free_vars : t ‑> (unit, InferIR.Ident.t) InferStdlib.IStd.Sequence.Generator.t
val program_vars : t ‑> InferIR.Pvar.t InferStdlib.IStd.Sequence.t
all the program variables appearing in the expression
val pp_printenv : InferStdlib.Pp.env ‑> (InferStdlib.Pp.env ‑> F.formatter ‑> InferIR.Typ.t ‑> unit) ‑> F.formatter ‑> t ‑> unit
val to_string : t ‑> string
val is_objc_block_closure : t ‑> bool
val zero_of_type : InferIR.Typ.t ‑> t option
Returns the zero value of a type, for int, float and ptr types
val zero_of_type_exn : InferIR.Typ.t ‑> t