ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
python_builtins.cpp File Reference
#include <goto-symex/engine/goto_symex.h>
#include <string>
#include <util/arith/arith_tools.h>
#include <util/expr/base_type.h>
#include <util/lang/c_types.h>
#include <util/expr/expr_util.h>
#include <irep2/irep2.h>
#include <util/irep/migrate.h>
#include <util/irep/std_types.h>
#include <algorithm>
Include dependency graph for python_builtins.cpp:

Functions

static bool null_is_none (const type2tc &subt, const namespacet &ns)
 Whether a NULL pointer to subt is how the frontend spells Python None.
static bool class_has_method (const irep_idt &tag, const std::string &name, const namespacet &ns)
 Whether the Python class tag, or one of its bases, defines a method name.
static bool is_python_scalar_instance (const type2tc &type, const type2tc &expected, const namespacet &ns)
 Whether a scalar of type type is an instance of the Python type that expected represents.
static bool has_python_attribute (type2tc type, const std::string &name, const namespacet &ns)
 Whether an object of type type has the attribute name: an instance member or a method of its class.
static bool same_class (const type2tc &expected, const type2tc &value, const namespacet &ns)
 Whether value is exactly class expected.
static bool is_python_number_type (const type2tc &type)
 Whether type is how a Python int, float or bool is held.
static expr2tc isinstance_subject (expr2tc value, const expr2tc &operand)
 The value isinstance inspects: the one traced from operand, with its casts stripped to reach the object a pointer refers to.
static bool is_tuple_element (const expr2tc &value)
 Whether value is an element of a tuple, whose static type is exact.
static expr2tc points_to_object (const expr2tc &value, const expr2tc &object, const expr2tc &current)
 The object a value set names for value, or current when value is a tuple element and the object is its NULL-object, which says nothing.

Function Documentation

◆ class_has_method()

bool class_has_method ( const irep_idt & tag,
const std::string & name,
const namespacet & ns )
static

Whether the Python class tag, or one of its bases, defines a method name.

The class type does not keep its method list, so this looks for the method's function symbol, which the frontend names py:<module>@C<class>@F<method>. The constructor is named after the class.

◆ has_python_attribute()

bool has_python_attribute ( type2tc type,
const std::string & name,
const namespacet & ns )
static

Whether an object of type type has the attribute name: an instance member or a method of its class.

◆ is_python_number_type()

bool is_python_number_type ( const type2tc & type)
static

Whether type is how a Python int, float or bool is held.

◆ is_python_scalar_instance()

bool is_python_scalar_instance ( const type2tc & type,
const type2tc & expected,
const namespacet & ns )
static

Whether a scalar of type type is an instance of the Python type that expected represents.

bool is a subclass of int.

◆ is_tuple_element()

bool is_tuple_element ( const expr2tc & value)
static

Whether value is an element of a tuple, whose static type is exact.

◆ isinstance_subject()

expr2tc isinstance_subject ( expr2tc value,
const expr2tc & operand )
static

The value isinstance inspects: the one traced from operand, with its casts stripped to reach the object a pointer refers to.

A number converted to another number is answered from operand's own type instead: a = float(x) holds (double)x, whose operand is an int.

◆ null_is_none()

bool null_is_none ( const type2tc & subt,
const namespacet & ns )
static

Whether a NULL pointer to subt is how the frontend spells Python None.

◆ points_to_object()

expr2tc points_to_object ( const expr2tc & value,
const expr2tc & object,
const expr2tc & current )
static

The object a value set names for value, or current when value is a tuple element and the object is its NULL-object, which says nothing.

◆ same_class()

bool same_class ( const type2tc & expected,
const type2tc & value,
const namespacet & ns )
static

Whether value is exactly class expected.

Classes are told apart by name, as two distinct classes may share a layout (both empty, say).