Skip to content

system

Collection of system classes and functions.

Classes:

  • Cast

    Cast AST node for type conversions.

  • PrintExpr

    PrintExpr AST class.

Cast

Cast(value: AST, target_type: Any)

Bases: Expr

Cast AST node for type conversions.

Represents a cast of value to a specified target_type.

Methods:

  • get_struct

    Return the structured representation of the cast expression.

Source code in src/irx/system.py
41
42
43
def __init__(self, value: astx.AST, target_type: Any) -> None:
    self.value = value
    self.target_type = target_type

get_struct

get_struct(simplified: bool = False) -> ReprStruct

Return the structured representation of the cast expression.

Source code in src/irx/system.py
45
46
47
48
49
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """Return the structured representation of the cast expression."""
    key = f"Cast[{self.target_type}]"
    value = self.value.get_struct(simplified)
    return self._prepare_struct(key, value, simplified)

PrintExpr

PrintExpr(message: LiteralUTF8String)

Bases: Expr

PrintExpr AST class.

Note: it would be nice to support more arguments similar to the ones supported by Python (*args, sep=' ', end='', file=None, flush=False).

Methods:

  • get_struct

    Return the AST structure of the object.

Source code in src/irx/system.py
21
22
23
24
def __init__(self, message: astx.LiteralUTF8String) -> None:
    """Initialize the PrintExpr."""
    self.message = message
    self._name = f"print_msg_{next(PrintExpr._counter)}"

get_struct

get_struct(simplified: bool = False) -> ReprStruct

Return the AST structure of the object.

Source code in src/irx/system.py
26
27
28
29
30
31
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """Return the AST structure of the object."""
    key = f"FunctionCall[{self}]"
    value = self.message.get_struct(simplified)

    return self._prepare_struct(key, value, simplified)