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

Classes

class  _QualifyImportedNestedClasses

Functions

list[ast.AST] _binders (ast.AST tree, str name)
bool _imports_module (ast.AST binder, set[int] imports, str root, str module_name)
set[str] _module_paths (ast.Module tree, str module_name)
dict[str, tuple[str, ast.ImportFrom]] _from_imported (ast.Module tree, str module_name, set[str] outers)
bool _has_star_import (ast.AST tree)
set[str] _identifiers (ast.AST tree)
set[str]|None _stored_attributes (list[tuple[str|None, ast.Module]] importers)
dict[str, dict] _safe_renames (dict[str, dict] hoisted, list[tuple[str|None, ast.Module]] importers)
dict qualify_imported_nested_classes (dict[str, dict] hoisted, Iterable[tuple[str|None, ast.Module]] importers)

Detailed Description

Name an imported module's nested class by the name it was hoisted to.

The preprocessor lifts a class nested in a module-level class to module level
as ``Outer__Inner`` and rewrites ``Outer.Inner`` within that module (#8256).
An importing module still reads ``mod.Outer.Inner``, or ``Outer.Inner`` after
``from mod import Outer``, so those reads are rewritten here too (#9047). Only
names bound by nothing but the import are rewritten, and only classes that no
module stores to through an attribute or names otherwise.

Function Documentation

◆ _binders()

list[ast.AST] parser.nested_class_imports._binders ( ast.AST tree,
str name )
protected
The nodes of ``tree`` that bind ``name``.

◆ _from_imported()

dict[str, tuple[str, ast.ImportFrom]] parser.nested_class_imports._from_imported ( ast.Module tree,
str module_name,
set[str] outers )
protected
The names ``tree`` binds to a class in ``outers`` by
``from module_name import``, and only so.

◆ _has_star_import()

bool parser.nested_class_imports._has_star_import ( ast.AST tree)
protected

◆ _identifiers()

set[str] parser.nested_class_imports._identifiers ( ast.AST tree)
protected

◆ _imports_module()

bool parser.nested_class_imports._imports_module ( ast.AST binder,
set[int] imports,
str root,
str module_name )
protected
Whether ``binder`` is an ``import`` binding ``root`` to ``module_name``
or to the package it is in.

◆ _module_paths()

set[str] parser.nested_class_imports._module_paths ( ast.Module tree,
str module_name )
protected
The dotted names through which ``tree`` reaches ``module_name`` by
``import``, when nothing else in ``tree`` binds their first part.

◆ _safe_renames()

dict[str, dict] parser.nested_class_imports._safe_renames ( dict[str, dict] hoisted,
list[tuple[str | None, ast.Module]] importers )
protected
The renames in ``hoisted`` whose classes no module stores to through
an attribute, and whose hoisted name no other module mentions: that name
could resolve to the other module's binding, since ESBMC keys a class by
its name alone.

◆ _stored_attributes()

set[str] | None parser.nested_class_imports._stored_attributes ( list[tuple[str | None, ast.Module]] importers)
protected
The attribute names the modules store to or delete, or None when one
may name an attribute only at run time, through setattr or delattr.

◆ qualify_imported_nested_classes()

dict parser.nested_class_imports.qualify_imported_nested_classes ( dict[str, dict] hoisted,
Iterable[tuple[str | None, ast.Module]] importers )
Rewrite each importer's reads of a class hoisted out of a module;
``hoisted`` maps a module to its ``(outer, inner) -> name`` renames.
Returns the hoisted names each module must now export, per module.