Skip to content

FunctionScope

Bases: Scope

Represents a Scope that defines the scope of a function.

Attributes:

Name Type Description
target_symbols dict[str, list[Symbol]]

The dict of all target nodes used inside the corresponding function. Target nodes are specified as all nodes that can be written to and which can be represented as a Symbol. This includes assignments, parameters,

value_references dict[str, list[Reference]]

The dict of all value nodes used inside the corresponding function.

call_references dict[str, list[Reference]]

The dict of all function calls inside the corresponding function. The key is the name of the call node, the value is a list of all References of call nodes with that name.

parameters dict[str, Parameter]

The parameters of the function.

globals_used dict[str, list[GlobalVariable]]

The global variables used inside the function. It stores the globally assigned nodes (Assignment of the used variable).

Source code in src/library_analyzer/processing/api/purity_analysis/model/_module_data.py
@dataclass
class FunctionScope(Scope):
    """Represents a Scope that defines the scope of a function.

    Attributes
    ----------
    target_symbols :
        The dict of all target nodes used inside the corresponding function.
        Target nodes are specified as all nodes that can be written to and which can be represented as a Symbol.
        This includes assignments, parameters,
    value_references :
        The dict of all value nodes used inside the corresponding function.
    call_references :
        The dict of all function calls inside the corresponding function.
        The key is the name of the call node, the value is a list of all References of call nodes with that name.
    parameters :
        The parameters of the function.
    globals_used :
        The global variables used inside the function.
        It stores the globally assigned nodes (Assignment of the used variable).
    """

    target_symbols: dict[str, list[Symbol]] = field(default_factory=dict)
    value_references: dict[str, list[Reference]] = field(default_factory=dict)
    call_references: dict[str, list[Reference]] = field(default_factory=dict)
    parameters: dict[str, Parameter] = field(default_factory=dict)
    globals_used: dict[str, list[GlobalVariable]] = field(default_factory=dict)

    def remove_call_reference_by_id(self, call_id: str) -> None:
        """Remove a call node by name.

        Removes a call node from the dict of call nodes by name.
        This is used to remove cyclic calls from the dict of call nodes after the call graph has been built.

        Parameters
        ----------
        call_id :
            The name of the call node to remove.
        """
        self.call_references.pop(call_id, None)

call_references: dict[str, list[Reference]] = field(default_factory=dict) class-attribute instance-attribute

globals_used: dict[str, list[GlobalVariable]] = field(default_factory=dict) class-attribute instance-attribute

parameters: dict[str, Parameter] = field(default_factory=dict) class-attribute instance-attribute

target_symbols: dict[str, list[Symbol]] = field(default_factory=dict) class-attribute instance-attribute

value_references: dict[str, list[Reference]] = field(default_factory=dict) class-attribute instance-attribute

__init__(_symbol, _children=list(), _parent=None, target_symbols=dict(), value_references=dict(), call_references=dict(), parameters=dict(), globals_used=dict())

remove_call_reference_by_id(call_id)

Remove a call node by name.

Removes a call node from the dict of call nodes by name. This is used to remove cyclic calls from the dict of call nodes after the call graph has been built.

Parameters:

Name Type Description Default
call_id str

The name of the call node to remove.

required
Source code in src/library_analyzer/processing/api/purity_analysis/model/_module_data.py
def remove_call_reference_by_id(self, call_id: str) -> None:
    """Remove a call node by name.

    Removes a call node from the dict of call nodes by name.
    This is used to remove cyclic calls from the dict of call nodes after the call graph has been built.

    Parameters
    ----------
    call_id :
        The name of the call node to remove.
    """
    self.call_references.pop(call_id, None)