Skip to content

NativeCall

Bases: Unknown

Class for calling native code.

Since we cannot analyze native code, we mark it as unknown.

Attributes:

Name Type Description
expression Expression

The expression that is called.

origin Symbol | NodeID | None

The origin of the call.

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
@dataclass
class NativeCall(Unknown):  # ExternalCall
    """Class for calling native code.

    Since we cannot analyze native code, we mark it as unknown.

    Attributes
    ----------
    expression :
        The expression that is called.
    origin :
        The origin of the call.
    """

    expression: Expression
    origin: Symbol | NodeID | None = field(default=None)

    def __hash__(self) -> int:
        return hash(str(self))

    def __str__(self) -> str:
        return f"{self.__class__.__name__}: {self.expression.__str__()}"

    def to_dict(self) -> dict[str, Any]:
        origin = (
            self.origin.id if isinstance(self.origin, Symbol) else (self.origin if self.origin is not None else None)
        )
        return {
            "origin": f"{origin}",
            "reason": f"{self.expression.__str__()}",
        }

expression: Expression instance-attribute

origin: Symbol | NodeID | None = field(default=None) class-attribute instance-attribute

__hash__()

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
def __hash__(self) -> int:
    return hash(str(self))

__init__(expression, origin=None)

__str__()

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
def __str__(self) -> str:
    return f"{self.__class__.__name__}: {self.expression.__str__()}"

to_dict()

Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
def to_dict(self) -> dict[str, Any]:
    origin = (
        self.origin.id if isinstance(self.origin, Symbol) else (self.origin if self.origin is not None else None)
    )
    return {
        "origin": f"{origin}",
        "reason": f"{self.expression.__str__()}",
    }