class documentation

class DUC: (source)

Constructor: DUC(cfg)

View In Hierarchy

Definition-use chain (DUC). This class provides methods to query the definitions and references for a name in a lexical scope.

Method __init__ Constructs a def-use chain.
Method ast_node_for_reference Retrieves the AST node for a reference from this DUC.
Method container_relationships Undocumented
Method get_all_definitions Retrieves the definitions for a variable in a lexical scope.
Method get_all_definitions_and_references Retrieves all the definitions and references for a lexical scope.
Method get_all_references Retrieves the references for a variable in a lexical scope.
Method get_definitions Retrieves all the definitions in a lexical scope.
Method get_lexical_scopes Iterates the names of all the lexical scopes. Returns: An iterator of the lexical scope names.
Method get_references Retrieves all the references in a lexical scope.
Class Variable __slots__ Undocumented
Instance Variable cfgs Undocumented
Instance Variable const_dicts Undocumented
Instance Variable ssa_results Undocumented
Method _ast_node Undocumented
def __init__(self, cfg: CFG): (source)

Constructs a def-use chain.

Parameters
cfg:CFGThe control flow graph.
def ast_node_for_reference(self, reference: Reference, scope: str = MODULE_SCOPE) -> ast.stmt: (source)

Retrieves the AST node for a reference from this DUC.

Returns: An AST statement node.

Parameters
reference:ReferenceThe reference. This must be a valid reference from this
scope:strThe name of the scope (defaults to "mod", the scope of the
DUC.
module).
Returns
ast.stmtUndocumented
def container_relationships(self, scope: str = MODULE_SCOPE) -> Iterator[ContainerRelationship]: (source)

Undocumented

def get_all_definitions(self, scope: str = MODULE_SCOPE) -> Iterator[Definition]: (source)

Retrieves the definitions for a variable in a lexical scope.

Returns: A iterator of definitions.

Parameters
scope:strThe name of the scope (defaults to "mod", the scope of the
module).
Returns
Iterator[Definition]Undocumented
def get_all_definitions_and_references(self, scope: str = MODULE_SCOPE) -> Tuple[Iterator[Definition], Iterator[Reference]]: (source)

Retrieves all the definitions and references for a lexical scope.

Parameters
scope:strThe name of the scope (defaults to "mod", the scope of the
module).
Returns
Tuple[Iterator[Definition], Iterator[Reference]]A tuple of (definitions, references). definitions is an iterator of all the definitions (AST nodes) in the lexical scope scope, and references is a iterator of all the references (AST nodes) in the scope.
def get_all_references(self, scope: str = MODULE_SCOPE) -> Iterator[Reference]: (source)

Retrieves the references for a variable in a lexical scope.

Returns: An iterator of references.

Parameters
scope:strThe name of the scope (defaults to "mod", the scope of the
module).
Returns
Iterator[Reference]Undocumented
def get_definitions(self, name: str, scope: str = MODULE_SCOPE) -> Iterator[Definition]: (source)

Retrieves all the definitions in a lexical scope.

Returns: An iterator of definitions.

Parameters
name:strThe name of the variable (string).
scope:strThe name of the scope (defaults to "mod", the scope of the
module).
Returns
Iterator[Definition]Undocumented
def get_lexical_scopes(self) -> Iterator[str]: (source)

Iterates the names of all the lexical scopes. Returns: An iterator of the lexical scope names.

def get_references(self, name: str, scope: str = MODULE_SCOPE) -> Iterator[Reference]: (source)

Retrieves all the references in a lexical scope.

Returns: An iterator of references.

Parameters
name:strThe name of the variable (string).
scope:strThe name of the scope (defaults to "mod", the scope of the
module).
Returns
Iterator[Reference]Undocumented
__slots__: list[str] = (source)

Undocumented

Undocumented

Undocumented

ssa_results: Dict[str, Dict[int, List[Dict[str, Set[int]]]]] = (source)

Undocumented

def _ast_node(self, scope: str, block_id: int, stmt_idx: int) -> ast.stmt: (source)

Undocumented