ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
preprocessor.bound_method_values Namespace Reference

Classes

class  _Reads

Functions

 _plain_method (method)
 _instance (stmt, classes)
 _receivers (module, fixed_receivers)
 _parents (module)
 _passed_on (node, parents, functions)
 _held (container, parents, functions)
 _inside_class (node, parents)
 _functions (module)
 _helper (receiver, method, returns)
 _declared_return (method, analysis)
 _read_sites (module, receivers)
 lower_method_values (module, fixed_receivers)

Variables

dict _KNOWN_RETURNS = {"int", "str", "float", "bool"}

Detailed Description

Pass a bound method of a fixed instance on as a function (#8957).

Where `o` is bound once to an instance of a top-level class, `o.m` names the
same method of the same object wherever it is evaluated. A module-level
`def ESBMC_bound_o_m(x): return o.m(x)` is then the same callable, and unlike
a bound method it is a function value, which lists, returns and parameters
carry and calls through a value resolve.

Only a read whose value flows where function_value_types follows it is
rewritten: an argument of a function the module defines, a return of such a
function, or a value bound to a name, directly or as an element of a container
or a branch of a conditional expression. Any other read, such as a comparison,
an argument of a method or a value stored in an attribute, is refused as
before, and so is a method that takes defaults, `*args`, keyword-only
parameters or decorators, or that yields.

Function Documentation

◆ _declared_return()

preprocessor.bound_method_values._declared_return ( method,
analysis )
protected

◆ _functions()

preprocessor.bound_method_values._functions ( module)
protected
The names bound once in `module`, by a function it defines at the top.

◆ _held()

preprocessor.bound_method_values._held ( container,
parents,
functions )
protected

◆ _helper()

preprocessor.bound_method_values._helper ( receiver,
method,
returns )
protected

◆ _inside_class()

preprocessor.bound_method_values._inside_class ( node,
parents )
protected

◆ _instance()

preprocessor.bound_method_values._instance ( stmt,
classes )
protected
`(o, C)` for a statement `o = C(...)` of a class in `classes`, else None.

◆ _parents()

preprocessor.bound_method_values._parents ( module)
protected

◆ _passed_on()

preprocessor.bound_method_values._passed_on ( node,
parents,
functions )
protected
Whether the value of `node` flows where function_value_types follows it:
to a name, to a parameter of one of `functions`, or out of one of them as a
return, directly or as an element of a container or branch of a
conditional expression.

◆ _plain_method()

preprocessor.bound_method_values._plain_method ( method)
protected

◆ _read_sites()

preprocessor.bound_method_values._read_sites ( module,
receivers )
protected

◆ _receivers()

preprocessor.bound_method_values._receivers ( module,
fixed_receivers )
protected
For each `o` of `fixed_receivers`, the index of the statement that builds
it and the plain methods of its class that `o.m` may name.

◆ lower_method_values()

preprocessor.bound_method_values.lower_method_values ( module,
fixed_receivers )
Replace each read of a method of a fixed instance whose value is passed
on with the function that calls it, defined right after the statement that
builds the instance, so a read that runs before it is a NameError as in
CPython.

Variable Documentation

◆ _KNOWN_RETURNS

dict preprocessor.bound_method_values._KNOWN_RETURNS = {"int", "str", "float", "bool"}
protected