maat.Value class

A generic class representing a value that can be either concrete or an abstract expression. Abstract expressions are made of constant values and/or abstract variables, optionally combined using standard arithmetic and logic operators.

❱   Constructors

Cst(int size, int val)

Create a constant expression

Parameters
size Size of the expression in bits
val Constant value of the expression

Cst(int size, str val, int base=10)

Create a constant expression specified by a string. Warning: this constructor only works if size is bigger than 64 bits

Parameters
size Size of the expression in bits
val Constant value of the expression as a string
base Numerical base of val

Var(int size, str name)

Create an abstract variable

Parameters
size Size of the expression in bits
name Unique name identifying the variable

❱   Attributes

int size
Expression size in bits

❱   Methods

int as_float(Optional[ VarContext ctx])

Returns the concrete value of the expression interpreted as a floating point value

Parameters
ctx Optional context to use to concretize the expression, instead of the default one

int as_int(Optional[ VarContext ctx])

Returns the concrete value of the expression interpreted as a signed integer

Parameters
ctx Optional context to use to concretize the expression, instead of the default one

int as_uint(Optional[ VarContext ctx])

Returns the concrete value of the expression interpreted as an unsigned integer

Parameters
ctx Optional context to use to concretize the expression, instead of the default one  

bool is_concolic( Optional[ VarContext ctx])

Returns True if the expression is concolic

Parameters
ctx Optional context to use to check the expression status 

bool is_symbolic( Optional[ VarContext ctx])

Returns True if the expression is fully symbolic

Parameters
ctx Optional context to use to check the expression status

bool is_concrete( Optional[ VarContext ctx])

Returns True if the expression is concrete

Parameters
ctx Optional context to use to check the expression status

❱   Operators

Value __add__(e1, e2)

Addition operator. Parameters can be Value or int

Value __sub__(e1, e2)

Subtraction operator. Parameters can be Value or int

Value __mul__(e1, e2)

Multiplication operator. Parameters can be Value or int

Value __floordiv__(e1, e2)

Integer division operator. Parameters can be Value or int

Value __and__(e1, e2)

Logical AND operator. Parameters can be Value or int

Value __or__(e1, e2)

Logical OR operator. Parameters can be Value or int

Value __xor__(e1, e2)

Logical XOR operator. Parameters can be Value or int

Value __mod__(e1, e2)

Division remainder operator. Parameters can be Value or int

Value __lshift__(e1, e2)

Left shift operator. Parameters can be Value or int

Value __rshift__(e1, e2)

Right shift operator. Parameters can be Value or int

Value __inv__(e1)

Logical invert (bitwise) operator. Parameters can be Value or int

Value __neg__(e1)

Integer negation operator. Parameters can be Value or int

Value Concat( Value upper, Value lower)

Create a new expression by concatenating two expressions

Parameters
upper Expression placed at the upper bits of the result
lower Expression placed at the lower bits of the result

Value Extract( Value expr, int upper_bit, int lower_bit)

Create a new expression by extracting a bit field from an expression

Parameters
expr Expression to extract from
upper_bit Upper bit to extract (included)param lower_bit Lower bit to extract (included)

Constraint __eq__(e1, e2)

Create the constraint e1 == e2. Parameters can be Value or int

Constraint __ne__(e1, e2)

Create the constraint e1 != e2. Parameters can be Value or int

Constraint __lt__(e1, e2)

Create the constraint e1 < e2. Parameters can be Value or int

Constraint __le__(e1, e2)

Create the constraint e1 <= e2. Parameters can be Value or int

Constraint __gt__(e1, e2)

Create the constraint e1 > e2. Parameters can be Value or int

Constraint __ge__(e1, e2)

Create the constraint e1 >= e2. Parameters can be Value or int