ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
preprocessor.vararg_mixin.VarargMixin Class Reference
Inheritance diagram for preprocessor.vararg_mixin.VarargMixin:
[legend]

Public Attributes

 generator_func_defs

Protected Member Functions

 _scan_module_vararg_defs (self, node)
 _scan_vararg_alias_calls (self, module)
 _vararg_alias_name (self, stmt, variadic)
 _resolve_vararg_alias_call (self, node)
 _drop_unused_vararg_aliases (self, module)
 _enter_vararg_scope (self, node)
 _exit_vararg_scope (self, node, saved_func_defs)
 _enclosing_vararg_scope (self)
 _record_vararg_function (self, node, qualified_name)
 _is_specializable_vararg_call (self, node, func_def)
 _is_specializable_vararg_arity (self, func_def, arity)
 _specialize_vararg_call (self, node)
 _call_imported_vararg_spec (self, node)
 _specialize_external_varargs (self)
 _import_used_vararg_specs (self, module)
 _specialized_vararg_def (self, name)
 _packed_params (self, func_def)
 _specialize_vararg_arguments (self, node)
 _param_call_arity (self, func_def, param)
 _vararg_specialization (self, func_def, extra, kwnames=())
 _build_vararg_specialization (self, func_def, spec_name, extra, kwnames)
 _forwards_own_varargs (self, node)
 _names_bound_in (self, body)
 _spell_out_forwarded_varargs (self, spec, vararg_name, pad)
 _inject_vararg_specializations (self, node, owner_key=None)
 _scan_fixed_length_starred (self, module)
 _fixed_length_starred_params (self, scope, calls, parents, bind_counts, unsafe)
 _passed_display (self, call, index)
 _record_fixed_length_starred (self, stmt, later, bind_counts, unsafe, fixed)
 _expand_starred_call_args (self, node)

Static Protected Member Functions

 _has_star_import (module)
 _name_is_used (body, name)
 _sequence_display_length (value)
 _bound_names (node)
 _is_length_preserving_use (name, parent, grandparent, len_bound)
 _called_only_by (scope, calls, parents, bind_counts)
 _starred_reads (scope, name, parents, bind_counts)

Protected Attributes

dict _vararg_module_defs
dict _vararg_once_bound = {name for name, count in bind_counts.items() if count == 1}
dict _vararg_callee_defs
list _vararg_alias_stmts = []
 _vararg_func_defs
 _vararg_scope_stack
 _vararg_specializations
 _fixed_length_starred

Member Function Documentation

◆ _bound_names()

preprocessor.vararg_mixin.VarargMixin._bound_names ( node)
staticprotected
Names `node` binds or rebinds without being a plain Name store.

◆ _build_vararg_specialization()

preprocessor.vararg_mixin.VarargMixin._build_vararg_specialization ( self,
func_def,
spec_name,
extra,
kwnames )
protected

◆ _call_imported_vararg_spec()

preprocessor.vararg_mixin.VarargMixin._call_imported_vararg_spec ( self,
node )
protected
Call the fixed-arity copy the module of an imported variadic def built.

Each module is preprocessed on its own, so the copy is requested by the
importer's call arities before that module is finalized (#8480).

◆ _called_only_by()

preprocessor.vararg_mixin.VarargMixin._called_only_by ( scope,
calls,
parents,
bind_counts )
staticprotected
Whether `scope` is bound once and read only as the callee of `calls`.

◆ _drop_unused_vararg_aliases()

preprocessor.vararg_mixin.VarargMixin._drop_unused_vararg_aliases ( self,
module )
protected
Drop an alias no call reads any more, so it keeps no variadic def alive.

◆ _enclosing_vararg_scope()

preprocessor.vararg_mixin.VarargMixin._enclosing_vararg_scope ( self)
protected
The def enclosing the one being visited, which is itself on top.

◆ _enter_vararg_scope()

preprocessor.vararg_mixin.VarargMixin._enter_vararg_scope ( self,
node )
protected
Open the scope of `node`, returning the def table to restore on exit.

A variadic def nested in `node` is visible only while that scope is
open, so a sibling function cannot resolve a call against it.

◆ _exit_vararg_scope()

preprocessor.vararg_mixin.VarargMixin._exit_vararg_scope ( self,
node,
saved_func_defs )
protected

◆ _expand_starred_call_args()

preprocessor.vararg_mixin.VarargMixin._expand_starred_call_args ( self,
node )
protected
Splice `*seq` into the call when `seq` has a statically known length.

◆ _fixed_length_starred_params()

preprocessor.vararg_mixin.VarargMixin._fixed_length_starred_params ( self,
scope,
calls,
parents,
bind_counts,
unsafe )
protected
Map each `g(..., *p)` on a parameter p of `scope` that every one of
its `calls` passes the same kind and length of display for (#8959).

Every read of the def's name must be one of those calls, so it is never
called through another name. A list at one call and a tuple at another
give p no single type, and `g` must be bound once, since the frontend
binds a call by its callee's bare name.

◆ _forwards_own_varargs()

preprocessor.vararg_mixin.VarargMixin._forwards_own_varargs ( self,
node )
protected
Whether each `*x` in call `node` forwards the visited def's own *args.

Each fixed-arity copy of the def spells such a call out, since the
copy knows how many arguments `x` packs (#8480).

◆ _has_star_import()

preprocessor.vararg_mixin.VarargMixin._has_star_import ( module)
staticprotected

◆ _import_used_vararg_specs()

preprocessor.vararg_mixin.VarargMixin._import_used_vararg_specs ( self,
module )
protected
Import each called copy alongside the variadic def it stands for.

◆ _inject_vararg_specializations()

preprocessor.vararg_mixin.VarargMixin._inject_vararg_specializations ( self,
node,
owner_key = None )
protected
Put the specializations owned by `node` where their originals sat.

A nested def is copied into the function that encloses it rather than
into the module, so the copy keeps the scope it closes over, and it
takes the original's position so the names it reads are already bound
there (#6800).

◆ _is_length_preserving_use()

preprocessor.vararg_mixin.VarargMixin._is_length_preserving_use ( name,
parent,
grandparent,
len_bound )
staticprotected
A load of `name` under `parent` that can neither resize nor alias it.

◆ _is_specializable_vararg_arity()

preprocessor.vararg_mixin.VarargMixin._is_specializable_vararg_arity ( self,
func_def,
arity )
protected

◆ _is_specializable_vararg_call()

preprocessor.vararg_mixin.VarargMixin._is_specializable_vararg_call ( self,
node,
func_def )
protected

◆ _name_is_used()

preprocessor.vararg_mixin.VarargMixin._name_is_used ( body,
name )
staticprotected

◆ _names_bound_in()

preprocessor.vararg_mixin.VarargMixin._names_bound_in ( self,
body )
protected

◆ _packed_params()

preprocessor.vararg_mixin.VarargMixin._packed_params ( self,
func_def )
protected
The *args and **kwargs names `func_def`'s body reads.

◆ _param_call_arity()

preprocessor.vararg_mixin.VarargMixin._param_call_arity ( self,
func_def,
param )
protected
The positional arity of every call of `param` in `func_def`'s body.

None unless each read of `param` is the callee of such a call, all of
the same arity, and nothing in the body rebinds or shadows `param`.

◆ _passed_display()

preprocessor.vararg_mixin.VarargMixin._passed_display ( self,
call,
index )
protected
The kind and length of the display `call` passes at `index`, or None.

◆ _record_fixed_length_starred()

preprocessor.vararg_mixin.VarargMixin._record_fixed_length_starred ( self,
stmt,
later,
bind_counts,
unsafe,
fixed )
protected

◆ _record_vararg_function()

preprocessor.vararg_mixin.VarargMixin._record_vararg_function ( self,
node,
qualified_name )
protected

◆ _resolve_vararg_alias_call()

preprocessor.vararg_mixin.VarargMixin._resolve_vararg_alias_call ( self,
node )
protected

◆ _scan_fixed_length_starred()

preprocessor.vararg_mixin.VarargMixin._scan_fixed_length_starred ( self,
module )
protected
Map each `f(*xs)` argument whose `xs` has a statically known length.

`xs` qualifies when it is bound once in the whole module, by a direct
statement of its scope, to a list or tuple display, and every read of
the name only indexes, iterates, measures, compares or unpacks it. An
unpacking is mapped only below that statement, where `xs` is bound.

◆ _scan_module_vararg_defs()

preprocessor.vararg_mixin.VarargMixin._scan_module_vararg_defs ( self,
node )
protected
Mark the variadic defs that live directly in the module body.

◆ _scan_vararg_alias_calls()

preprocessor.vararg_mixin.VarargMixin._scan_vararg_alias_calls ( self,
module )
protected
Map each call through a module-level alias of a variadic def to the def.

`f = my_sum` qualifies when it is a statement of the module body below
the def and both names are bound once in the whole module, so a call of
`f` below it calls `my_sum` (#8959). A star import can rebind either
name unseen, and another module can import the alias, so only the entry
module without star imports qualifies.

◆ _sequence_display_length()

preprocessor.vararg_mixin.VarargMixin._sequence_display_length ( value)
staticprotected

◆ _specialize_external_varargs()

preprocessor.vararg_mixin.VarargMixin._specialize_external_varargs ( self)
protected
Build the copies of this module's variadic defs that an importer calls.

◆ _specialize_vararg_arguments()

preprocessor.vararg_mixin.VarargMixin._specialize_vararg_arguments ( self,
node )
protected
Pass a fixed-arity copy of a variadic def handed to a module function.

`call(s)` qualifies when `call` reads its parameter only to call it,
always with the same number of positional arguments, so the copy for
that arity behaves as `s` does at every call (#8498).

◆ _specialize_vararg_call()

preprocessor.vararg_mixin.VarargMixin._specialize_vararg_call ( self,
node )
protected

◆ _specialized_vararg_def()

preprocessor.vararg_mixin.VarargMixin._specialized_vararg_def ( self,
name )
protected

◆ _spell_out_forwarded_varargs()

preprocessor.vararg_mixin.VarargMixin._spell_out_forwarded_varargs ( self,
spec,
vararg_name,
pad )
protected
Pass each `*vararg_name` in `spec` as the names it packs, then bind the call.

◆ _starred_reads()

preprocessor.vararg_mixin.VarargMixin._starred_reads ( scope,
name,
parents,
bind_counts )
staticprotected
Each `*name` in `scope` passed to a callee bound once.

◆ _vararg_alias_name()

preprocessor.vararg_mixin.VarargMixin._vararg_alias_name ( self,
stmt,
variadic )
protected
The name `stmt` binds once to one of the `variadic` defs, or None.

◆ _vararg_specialization()

preprocessor.vararg_mixin.VarargMixin._vararg_specialization ( self,
func_def,
extra,
kwnames = () )
protected
The name of `func_def`'s copy taking `extra` packed arguments.

`kwnames` are the keywords packed into **kwargs, in call order, which
is the order the dict iterates in.

Member Data Documentation

◆ _fixed_length_starred

preprocessor.vararg_mixin.VarargMixin._fixed_length_starred
protected

◆ _vararg_alias_stmts

list preprocessor.vararg_mixin.VarargMixin._vararg_alias_stmts = []
protected

◆ _vararg_callee_defs

dict preprocessor.vararg_mixin.VarargMixin._vararg_callee_defs
protected
Initial value:
= {
stmt.name: stmt
for stmt in node.body
if isinstance(stmt, ast.FunctionDef) and bind_counts.get(stmt.name) == 1
}

◆ _vararg_func_defs

preprocessor.vararg_mixin.VarargMixin._vararg_func_defs
protected

◆ _vararg_module_defs

preprocessor.vararg_mixin.VarargMixin._vararg_module_defs
protected
Initial value:
= {
id(stmt)
for stmt in node.body
if isinstance(stmt, ast.FunctionDef) and (stmt.args.vararg or stmt.args.kwarg)
}

◆ _vararg_once_bound

preprocessor.vararg_mixin.VarargMixin._vararg_once_bound = {name for name, count in bind_counts.items() if count == 1}
protected

◆ _vararg_scope_stack

preprocessor.vararg_mixin.VarargMixin._vararg_scope_stack
protected

◆ _vararg_specializations

preprocessor.vararg_mixin.VarargMixin._vararg_specializations
protected

◆ generator_func_defs

preprocessor.vararg_mixin.VarargMixin.generator_func_defs

The documentation for this class was generated from the following file: