Skip to content

collections

Provide the smallest explicit list-construction API that host frontends can target when they need to build list values incrementally in non-literal control-flow contexts.

Classes:

ListAppend

ListAppend(base: AST, value: AST)

Bases: DataType

Append one value to an existing mutable list variable or field. This node models incremental list growth and is not a user-facing collection API by itself. attributes: base: type: astx.AST value: type: astx.AST type_: type: astx.Int32

Methods:

Source code in src/irx/astx/collections.py
83
84
85
86
87
88
89
90
91
92
93
94
95
def __init__(self, base: astx.AST, value: astx.AST) -> None:
    """
    title: Initialize one list append node.
    parameters:
      base:
        type: astx.AST
      value:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.value = value
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/collections.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "ListAppend",
        cast(
            astx.base.ReprStruct,
            {
                "base": self.base.get_struct(simplified),
                "value": self.value.get_struct(simplified),
            },
        ),
        simplified,
    )

ListCreate

ListCreate(element_type: DataType)

Bases: DataType

Methods:

Source code in src/irx/astx/collections.py
32
33
34
35
36
37
38
39
40
41
def __init__(self, element_type: astx.DataType) -> None:
    """
    title: Initialize one empty-list constructor.
    parameters:
      element_type:
        type: astx.DataType
    """
    super().__init__()
    self.element_type = element_type
    self.type_ = astx.ListType([element_type])

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in src/irx/astx/collections.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "ListCreate",
        cast(
            astx.base.ReprStruct,
            {"element_type": self.element_type.get_struct(simplified)},
        ),
        simplified,
    )