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

Functions

set[str] top_level_classes (ast.Module tree)
str qualified_name (str name, str module_name)
str|None _dotted (ast.AST node)
set[str] _module_aliases (ast.AST tree, str module_name)
Iterator[ast.ImportFrom] _from_imports (ast.AST tree, str module_name)
Iterator[ast.AST] _annotations (ast.AST tree)
bool _import_binds (ast.AST node, str name, str|None allowed_module)
bool _non_class_binds (ast.AST node, str name)
bool _binds_otherwise (ast.Module tree, str name, bool own_class, str|None allowed_module=None)
bool _reads (Iterable[ast.AST] nodes, str name)
bool _importer_is_plain (ast.Module tree, str module_name, str name)
bool _own_class_shadows (ast.Module tree, str name, list[ast.ImportFrom] named)
None _rename_references (ast.AST tree, dict[str, str] renames)
None _rewrite_importer (ast.Module tree, str module_name, str name, str new)
dict[str, dict[str, str]] separate_colliding_classes (ast.Module entry_tree, dict[str, ast.Module] trees, Iterable[str] skip)

Variables

tuple _NAMED_BINDERS

Detailed Description

Separate an imported module's class from a same-named program class.

ESBMC keys a class symbol by its name alone, so a class in the program file and
a same-named class in an imported module would share one symbol (#7397). The
imported module's class is renamed to ``<name>$<module>`` throughout that module
and at every reference to it from an importing module, before any JSON is
emitted. A collision is renamed only in the shapes whose scoping is plain;
any other shape keeps the shared name and the converter refuses it.

Function Documentation

◆ _annotations()

Iterator[ast.AST] parser.class_collision._annotations ( ast.AST tree)
protected

◆ _binds_otherwise()

bool parser.class_collision._binds_otherwise ( ast.Module tree,
str name,
bool own_class,
str | None allowed_module = None )
protected
Whether ``tree`` binds ``name`` other than by a plain read.

``own_class`` allows the one top-level ``class name``; imports from
``allowed_module`` are judged by the caller.

◆ _dotted()

str | None parser.class_collision._dotted ( ast.AST node)
protected

◆ _from_imports()

Iterator[ast.ImportFrom] parser.class_collision._from_imports ( ast.AST tree,
str module_name )
protected

◆ _import_binds()

bool parser.class_collision._import_binds ( ast.AST node,
str name,
str | None allowed_module )
protected

◆ _importer_is_plain()

bool parser.class_collision._importer_is_plain ( ast.Module tree,
str module_name,
str name )
protected
Whether ``tree``'s references to ``module_name``'s ``name`` can be renamed.

◆ _module_aliases()

set[str] parser.class_collision._module_aliases ( ast.AST tree,
str module_name )
protected

◆ _non_class_binds()

bool parser.class_collision._non_class_binds ( ast.AST node,
str name )
protected

◆ _own_class_shadows()

bool parser.class_collision._own_class_shadows ( ast.Module tree,
str name,
list[ast.ImportFrom] named )
protected
The importer's own class shadows the import only if every import of the
name runs, at module level, before the class and nothing reads it between.

◆ _reads()

bool parser.class_collision._reads ( Iterable[ast.AST] nodes,
str name )
protected
Whether ``name`` is read anywhere in ``nodes``, function bodies included:
a function defined before the class may run before it too.

◆ _rename_references()

None parser.class_collision._rename_references ( ast.AST tree,
dict[str, str] renames )
protected

◆ _rewrite_importer()

None parser.class_collision._rewrite_importer ( ast.Module tree,
str module_name,
str name,
str new )
protected

◆ qualified_name()

str parser.class_collision.qualified_name ( str name,
str module_name )
The name an imported module's colliding class is converted under.

◆ separate_colliding_classes()

dict[str, dict[str, str]] parser.class_collision.separate_colliding_classes ( ast.Module entry_tree,
dict[str, ast.Module] trees,
Iterable[str] skip )
Rename each imported module's classes that the program file also defines.

``trees`` maps module name to AST; modules in ``skip`` (operational models)
are left alone. Returns the renames applied, per module.

◆ top_level_classes()

set[str] parser.class_collision.top_level_classes ( ast.Module tree)
Names of the classes defined directly in a module's body.

Variable Documentation

◆ _NAMED_BINDERS

tuple parser.class_collision._NAMED_BINDERS
protected
Initial value:
1= (ast.ExceptHandler, ast.MatchAs, ast.MatchStar) + tuple(
2 getattr(ast, n) for n in ("TypeVar", "ParamSpec", "TypeVarTuple") if hasattr(ast, n))