Skip to content

astx

Modules:

Classes:

Functions:

AddBinOp

AddBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ArrayInt32ArrayLength

ArrayInt32ArrayLength(values: list[AST])

Bases: DataType

Build an int32 array using the IRx builtin array runtime, then return its length. attributes: values: type: list[astx.AST] type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/array.py
34
35
36
37
38
39
40
41
42
43
def __init__(self, values: list[astx.AST]) -> None:
    """
    title: Initialize ArrayInt32ArrayLength.
    parameters:
      values:
        type: list[astx.AST]
    """
    super().__init__()
    self.values = values
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/array.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the array helper.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = cast(
        astx.base.ReprStruct,
        [item.get_struct(simplified) for item in self.values],
    )
    return self._prepare_struct(
        "ArrayInt32ArrayLength",
        value,
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

AssertStmt

AssertStmt(
    condition: Expr,
    message: Expr | None = None,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: ASTNodes[AST] | None = None,
)

Bases: StatementType

Represent one fatal assertion statement with an optional failure message. attributes: condition: type: astx.Expr message: type: astx.Expr | None loc: type: astx.SourceLocation

Methods:

Source code in packages/irx/src/irx/astx/system.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def __init__(
    self,
    condition: astx.Expr,
    message: astx.Expr | None = None,
    loc: astx.SourceLocation = astx.base.NO_SOURCE_LOCATION,
    parent: astx.ASTNodes[astx.AST] | None = None,
) -> None:
    """
    title: Initialize AssertStmt.
    parameters:
      condition:
        type: astx.Expr
      message:
        type: astx.Expr | None
      loc:
        type: astx.SourceLocation
      parent:
        type: astx.ASTNodes[astx.AST] | None
    """
    super().__init__(loc=loc, parent=parent)
    self.loc: astx.SourceLocation = loc
    self.condition: astx.Expr = condition
    self.message: astx.Expr | None = message

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/system.py
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the AST structure of the assertion statement.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"ASSERT[{id(self)}]" if simplified else "ASSERT"
    value: astx.base.DictDataTypesStruct = {
        "condition": self.condition.get_struct(simplified),
    }
    if self.message is not None:
        value["message"] = self.message.get_struct(simplified)
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

AssignmentBinOp

AssignmentBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BaseFieldAccess

BaseFieldAccess(
    receiver: AST, base_class_name: str, field_name: str
)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/classes.py
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
def __init__(
    self,
    receiver: astx.AST,
    base_class_name: str,
    field_name: str,
) -> None:
    """
    title: Initialize one base-qualified field access expression.
    parameters:
      receiver:
        type: astx.AST
      base_class_name:
        type: str
      field_name:
        type: str
    """
    super().__init__()
    self.receiver = receiver
    self.base_class_name = base_class_name
    self.field_name = field_name
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a base-qualified field access.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"BASE-FIELD-ACCESS[{self.base_class_name}.{self.field_name}]"
    value = {
        "receiver": self.receiver.get_struct(simplified),
    }
    return self._prepare_struct(
        key,
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BaseMethodCall

BaseMethodCall(
    receiver: AST,
    base_class_name: str,
    method_name: str,
    args: Iterable[DataType],
)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/classes.py
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
def __init__(
    self,
    receiver: astx.AST,
    base_class_name: str,
    method_name: str,
    args: Iterable[astx.DataType],
) -> None:
    """
    title: Initialize one base-qualified method call expression.
    parameters:
      receiver:
        type: astx.AST
      base_class_name:
        type: str
      method_name:
        type: str
      args:
        type: Iterable[astx.DataType]
    """
    super().__init__()
    self.receiver = receiver
    self.base_class_name = base_class_name
    self.method_name = method_name
    self.args = tuple(args)
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a base-qualified method call.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"BASE-METHOD-CALL[{self.base_class_name}.{self.method_name}]"
    arg_nodes = astx.ASTNodes[astx.DataType]("args")
    for arg in self.args:
        arg_nodes.append(arg)
    value = {
        "receiver": self.receiver.get_struct(simplified),
        "args": arg_nodes.get_struct(simplified),
    }
    return self._prepare_struct(
        key,
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BitAndBinOp

BitAndBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BitOrBinOp

BitOrBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BitXorBinOp

BitXorBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferOwnerType

BufferOwnerType()

Bases: OpaqueHandleType

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
28
29
30
31
32
def __init__(self) -> None:
    """
    title: Initialize the buffer owner handle type.
    """
    super().__init__("irx_buffer_owner_handle")

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/ffi.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for an opaque-handle type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        f"OPAQUE-HANDLE[{self.handle_name}]",
        self.handle_name,
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferViewDescriptor

BufferViewDescriptor(
    metadata: BufferViewMetadata,
    element_type: DataType | None = None,
)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
def __init__(
    self,
    metadata: BufferViewMetadata,
    element_type: astx.DataType | None = None,
) -> None:
    """
    title: Initialize one buffer view descriptor.
    parameters:
      metadata:
        type: BufferViewMetadata
      element_type:
        type: astx.DataType | None
    """
    super().__init__()
    self.metadata = metadata
    self.type_ = BufferViewType(element_type)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/buffer.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    _ = simplified
    return self._prepare_struct(
        "BufferViewDescriptor",
        cast(astx.base.ReprStruct, repr(self.metadata)),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferViewIndex

BufferViewIndex(base: AST, indices: Sequence[AST])

Bases: DataType

Reads one scalar element by computing offset_bytes plus the sum of index*stride byte offsets over the canonical buffer view descriptor. attributes: base: type: astx.AST indices: type: list[astx.AST] type_: type: astx.DataType

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
def __init__(
    self,
    base: astx.AST,
    indices: Sequence[astx.AST],
) -> None:
    """
    title: Initialize one low-level indexed read.
    parameters:
      base:
        type: astx.AST
      indices:
        type: Sequence[astx.AST]
    """
    super().__init__()
    if not indices:
        raise ValueError(
            "buffer view indexing requires at least one index"
        )
    self.base = base
    self.indices = list(indices)
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/buffer.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "indices": [
            index.get_struct(simplified) for index in self.indices
        ],
    }
    return self._prepare_struct(
        "BufferViewIndex",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferViewRelease

BufferViewRelease(view: AST)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
381
382
383
384
385
386
387
388
389
390
def __init__(self, view: astx.AST) -> None:
    """
    title: Initialize one buffer release helper call.
    parameters:
      view:
        type: astx.AST
    """
    super().__init__()
    self.view = view
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/buffer.py
392
393
394
395
396
397
398
399
400
401
402
403
404
405
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(
        "BufferViewRelease",
        self.view.get_struct(simplified),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferViewRetain

BufferViewRetain(view: AST)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
340
341
342
343
344
345
346
347
348
349
def __init__(self, view: astx.AST) -> None:
    """
    title: Initialize one buffer retain helper call.
    parameters:
      view:
        type: astx.AST
    """
    super().__init__()
    self.view = view
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/buffer.py
351
352
353
354
355
356
357
358
359
360
361
362
363
364
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(
        "BufferViewRetain",
        self.view.get_struct(simplified),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferViewStore

BufferViewStore(
    base: AST, indices: Sequence[AST], value: AST
)

Bases: DataType

Stores one scalar element by computing the canonical descriptor element address. This is not a user-facing array mutation API. attributes: base: type: astx.AST indices: type: list[astx.AST] value: type: astx.AST type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
def __init__(
    self,
    base: astx.AST,
    indices: Sequence[astx.AST],
    value: astx.AST,
) -> None:
    """
    title: Initialize one low-level indexed store.
    parameters:
      base:
        type: astx.AST
      indices:
        type: Sequence[astx.AST]
      value:
        type: astx.AST
    """
    super().__init__()
    if not indices:
        raise ValueError(
            "buffer view indexing requires at least one index"
        )
    self.base = base
    self.indices = list(indices)
    self.value = value
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/buffer.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "indices": [
            index.get_struct(simplified) for index in self.indices
        ],
        "value": self.value.get_struct(simplified),
    }
    return self._prepare_struct(
        "BufferViewStore",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferViewType

BufferViewType(element_type: DataType | None = None)

Bases: AnyType

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
54
55
56
57
58
59
60
61
62
def __init__(self, element_type: astx.DataType | None = None) -> None:
    """
    title: Initialize a buffer view descriptor type.
    parameters:
      element_type:
        type: astx.DataType | None
    """
    super().__init__()
    self.element_type = element_type

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/base.py
685
686
687
688
689
690
691
692
693
694
695
696
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return a simple structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"DATA-TYPE[{self.__class__.__name__}]"
    value = self.name
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

BufferViewWrite

BufferViewWrite(
    view: AST, value: AST, *, byte_offset: int = 0
)

Bases: DataType

Writes one 8-bit integer at offset_bytes + byte_offset. This is not a generic typed element store or user-facing array mutation API. attributes: view: type: astx.AST value: type: astx.AST byte_offset: type: int type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/buffer.py
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
def __init__(
    self,
    view: astx.AST,
    value: astx.AST,
    *,
    byte_offset: int = 0,
) -> None:
    """
    title: Initialize one low-level view write.
    parameters:
      view:
        type: astx.AST
      value:
        type: astx.AST
      byte_offset:
        type: int
    """
    super().__init__()
    self.view = view
    self.value = value
    self.byte_offset = byte_offset
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/buffer.py
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "view": self.view.get_struct(simplified),
        "value": self.value.get_struct(simplified),
        "byte_offset": self.byte_offset,
    }
    return self._prepare_struct(
        "BufferViewWrite",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

Cast

Cast(value: DataType, target_type: Any)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/system.py
145
146
147
148
149
150
151
152
153
154
155
156
def __init__(self, value: astx.DataType, target_type: Any) -> None:
    """
    title: Initialize Cast.
    parameters:
      value:
        type: astx.DataType
      target_type:
        type: Any
    """
    super().__init__()
    self.value = value
    self.target_type = target_type

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/system.py
158
159
160
161
162
163
164
165
166
167
168
169
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the cast expression.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"Cast[{self.target_type}]"
    value = self.value.get_struct(simplified)
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ClassConstruct

ClassConstruct(class_name: str)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/classes.py
263
264
265
266
267
268
269
270
271
272
273
274
275
def __init__(
    self,
    class_name: str,
) -> None:
    """
    title: Initialize one default class construction expression.
    parameters:
      class_name:
        type: str
    """
    super().__init__()
    self.class_name = class_name
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
285
286
287
288
289
290
291
292
293
294
295
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for class construction.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"CLASS-CONSTRUCT[{self.class_name}]"
    return self._prepare_struct(key, self.class_name, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ClassDefStmt

ClassDefStmt(
    name: str,
    *,
    bases: Iterable[ClassType] | ASTNodes[ClassType] = (),
    attributes: Iterable[VariableDeclaration]
    | ASTNodes[VariableDeclaration] = (),
    decorators: Iterable[Expr] | ASTNodes[Expr] = (),
    methods: Iterable[FunctionDef]
    | ASTNodes[FunctionDef] = (),
    visibility: VisibilityKind = public,
    is_abstract: bool = False,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: ASTNodes[AST] | None = None,
)

Bases: StructDeclStmt

Represent one top-level class declaration with explicit base-class references and inherited struct-like member containers. attributes: bases: type: astx.ASTNodes[ClassType] is_abstract: type: bool kind: type: astx.ASTKind

Methods:

Source code in packages/irx/src/irx/astx/classes.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
def __init__(
    self,
    name: str,
    *,
    bases: Iterable[ClassType] | astx.ASTNodes[ClassType] = (),
    attributes: (
        Iterable[astx.VariableDeclaration]
        | astx.ASTNodes[astx.VariableDeclaration]
    ) = (),
    decorators: Iterable[astx.Expr] | astx.ASTNodes[astx.Expr] = (),
    methods: Iterable[astx.FunctionDef]
    | astx.ASTNodes[astx.FunctionDef] = (),
    visibility: astx.VisibilityKind = astx.VisibilityKind.public,
    is_abstract: bool = False,
    loc: astx.SourceLocation = astx.base.NO_SOURCE_LOCATION,
    parent: astx.ASTNodes[astx.AST] | None = None,
) -> None:
    """
    title: Initialize one class definition statement.
    parameters:
      name:
        type: str
      bases:
        type: Iterable[ClassType] | astx.ASTNodes[ClassType]
      attributes:
        type: >-
          Iterable[astx.VariableDeclaration] |
          astx.ASTNodes[astx.VariableDeclaration]
      decorators:
        type: Iterable[astx.Expr] | astx.ASTNodes[astx.Expr]
      methods:
        type: Iterable[astx.FunctionDef] | astx.ASTNodes[astx.FunctionDef]
      visibility:
        type: astx.VisibilityKind
      is_abstract:
        type: bool
      loc:
        type: astx.SourceLocation
      parent:
        type: astx.ASTNodes[astx.AST] | None
    """
    super().__init__(
        name=name,
        attributes=attributes,
        decorators=decorators,
        methods=methods,
        visibility=visibility,
        loc=loc,
        parent=parent,
    )
    self.is_abstract = is_abstract
    if isinstance(bases, astx.ASTNodes):
        self.bases = bases
    else:
        self.bases = astx.ASTNodes[ClassType]()
        for base in bases:
            self.bases.append(base)
    self.kind = astx.ASTKind.StructDefStmtKind

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a class definition.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    vis = dict(zip(("public", "private", "protected"), ("+", "-", "#")))
    key = f"CLASS-DEF[{vis[self.visibility.name]}{self.name}]"

    bases_dict: astx.base.ReprStruct = {}
    if self.bases:
        bases_dict = {"bases": self.bases.get_struct(simplified)}

    decorators_dict: astx.base.ReprStruct = {}
    if self.decorators:
        decorators_dict = {
            "decorators": self.decorators.get_struct(simplified)
        }

    abstract_dict: astx.base.ReprStruct = {}
    if self.is_abstract:
        abstract_dict = {"abstract": self.is_abstract}

    attrs_dict: astx.base.ReprStruct = {}
    if self.attributes:
        attrs_dict = {"attributes": self.attributes.get_struct(simplified)}

    methods_dict: astx.base.ReprStruct = {}
    if self.methods:
        methods_dict = {"methods": self.methods.get_struct(simplified)}

    value = {
        **cast(dict[str, astx.base.ReprStruct], bases_dict),
        **cast(dict[str, astx.base.ReprStruct], decorators_dict),
        **cast(dict[str, astx.base.ReprStruct], abstract_dict),
        **cast(dict[str, astx.base.ReprStruct], attrs_dict),
        **cast(dict[str, astx.base.ReprStruct], methods_dict),
    }
    return self._prepare_struct(
        key,
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ClassType

ClassType(
    name: str,
    *,
    resolved_name: str | None = None,
    module_key: str | None = None,
    qualified_name: str | None = None,
    ancestor_qualified_names: tuple[str, ...] = (),
)

Bases: AnyType

Methods:

Source code in packages/irx/src/irx/astx/classes.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def __init__(
    self,
    name: str,
    *,
    resolved_name: str | None = None,
    module_key: str | None = None,
    qualified_name: str | None = None,
    ancestor_qualified_names: tuple[str, ...] = (),
) -> None:
    """
    title: Initialize one named class type reference.
    parameters:
      name:
        type: str
      resolved_name:
        type: str | None
      module_key:
        type: str | None
      qualified_name:
        type: str | None
      ancestor_qualified_names:
        type: tuple[str, Ellipsis]
    """
    super().__init__()
    self.name = name
    self.resolved_name = resolved_name
    self.module_key = module_key
    self.qualified_name = qualified_name
    self.ancestor_qualified_names = ancestor_qualified_names

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
81
82
83
84
85
86
87
88
89
90
91
92
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a class type reference.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"CLASS-TYPE[{self.name}]"
    value = self.qualified_name or self.name
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

CollectionContains

CollectionContains(base: AST, value: AST)

Bases: DataType

Return whether a list, tuple, or set contains a value, or whether a dictionary contains a key. attributes: base: type: astx.AST value: type: astx.AST type_: type: astx.Boolean

Methods:

Source code in packages/irx/src/irx/astx/collections/common.py
131
132
133
134
135
136
137
138
139
140
141
142
143
def __init__(self, base: astx.AST, value: astx.AST) -> None:
    """
    title: Initialize one collection containment query.
    parameters:
      base:
        type: astx.AST
      value:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.value = value
    self.type_ = astx.Boolean()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/collections/common.py
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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(
        "CollectionContains",
        cast(
            astx.base.ReprStruct,
            {
                "base": self.base.get_struct(simplified),
                "value": self.value.get_struct(simplified),
            },
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

CollectionCount

CollectionCount(base: AST, value: AST)

Bases: DataType

Return how many times a value appears in a list or tuple as an Int32 value. attributes: base: type: astx.AST value: type: astx.AST type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/collections/common.py
243
244
245
246
247
248
249
250
251
252
253
254
255
def __init__(self, base: astx.AST, value: astx.AST) -> None:
    """
    title: Initialize one sequence count query.
    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 packages/irx/src/irx/astx/collections/common.py
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
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(
        "CollectionCount",
        cast(
            astx.base.ReprStruct,
            {
                "base": self.base.get_struct(simplified),
                "value": self.value.get_struct(simplified),
            },
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

CollectionIndex

CollectionIndex(base: AST, value: AST)

Bases: DataType

Return the first zero-based index of a value in a list or tuple. The initial IRx contract returns -1 when the value is not found. attributes: base: type: astx.AST value: type: astx.AST type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/collections/common.py
187
188
189
190
191
192
193
194
195
196
197
198
199
def __init__(self, base: astx.AST, value: astx.AST) -> None:
    """
    title: Initialize one sequence index query.
    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 packages/irx/src/irx/astx/collections/common.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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(
        "CollectionIndex",
        cast(
            astx.base.ReprStruct,
            {
                "base": self.base.get_struct(simplified),
                "value": self.value.get_struct(simplified),
            },
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

CollectionIsEmpty

CollectionIsEmpty(base: AST)

Bases: DataType

Return whether a list, tuple, set, or dictionary has no logical entries. attributes: base: type: astx.AST type_: type: astx.Boolean

Methods:

Source code in packages/irx/src/irx/astx/collections/common.py
81
82
83
84
85
86
87
88
89
90
def __init__(self, base: astx.AST) -> None:
    """
    title: Initialize one collection emptiness query.
    parameters:
      base:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.type_ = astx.Boolean()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/collections/common.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
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(
        "CollectionIsEmpty",
        cast(
            astx.base.ReprStruct,
            {"base": self.base.get_struct(simplified)},
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

CollectionLength

CollectionLength(base: AST)

Bases: DataType

Return the logical length of a list, tuple, set, or dictionary as an Int32 value. attributes: base: type: astx.AST type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/collections/common.py
35
36
37
38
39
40
41
42
43
44
def __init__(self, base: astx.AST) -> None:
    """
    title: Initialize one collection length query.
    parameters:
      base:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/collections/common.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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(
        "CollectionLength",
        cast(
            astx.base.ReprStruct,
            {"base": self.base.get_struct(simplified)},
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

DictComprehension

DictComprehension(
    key: Expr,
    value: Expr,
    generators: ASTNodes[ComprehensionClause]
    | Iterable[ComprehensionClause] = (),
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: ASTNodes | None = None,
)

Bases: Comprehension

Represent {key: value for ...} until upstream ASTx exposes a canonical dictionary-comprehension expression node. attributes: key: type: astx.Expr value: type: astx.Expr

Methods:

Source code in packages/irx/src/irx/astx/iterables.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def __init__(
    self,
    key: astx.Expr,
    value: astx.Expr,
    generators: (
        astx.ASTNodes[astx.ComprehensionClause]
        | Iterable[astx.ComprehensionClause]
    ) = (),
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: astx.ASTNodes | None = None,
) -> None:
    """
    title: Initialize one dictionary comprehension.
    parameters:
      key:
        type: astx.Expr
      value:
        type: astx.Expr
      generators:
        type: >-
          astx.ASTNodes[astx.ComprehensionClause] |
          Iterable[astx.ComprehensionClause]
      loc:
        type: SourceLocation
      parent:
        type: astx.ASTNodes | None
    """
    super().__init__(generators=generators, loc=loc, parent=parent)
    self.key = key
    self.value = value

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/iterables.py
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"{self}#{id(self)}" if simplified else str(self)
    generators = (
        {"generators": self.generators.get_struct(simplified)}
        if self.generators.nodes
        else {}
    )
    value = cast(
        ReprStruct,
        {
            "key": self.key.get_struct(simplified),
            "value": self.value.get_struct(simplified),
            **generators,
        },
    )
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

DivBinOp

DivBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

EqBinOp

EqBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

FieldAccess

FieldAccess(value: AST, field_name: str)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/structs.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
def __init__(self, value: astx.AST, field_name: str) -> None:
    """
    title: Initialize one field access expression.
    parameters:
      value:
        type: astx.AST
      field_name:
        type: str
    """
    super().__init__()
    self.value = value
    self.field_name = field_name
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/structs.py
121
122
123
124
125
126
127
128
129
130
131
132
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a field access expression.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"FIELD-ACCESS[{self.field_name}]"
    value = self.value.get_struct(simplified)
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ForInLoopStmt

ForInLoopStmt(
    target: AST,
    iterable: AST,
    body: Block,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: ASTNodes | None = None,
)

Bases: StatementType

Model source forms equivalent to for target in iterable: body while preserving ASTx-compatible target, iterable, and body child nodes. attributes: target: type: astx.AST iterable: type: astx.AST body: type: astx.Block

Methods:

Source code in packages/irx/src/irx/astx/iterables.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def __init__(
    self,
    target: astx.AST,
    iterable: astx.AST,
    body: astx.Block,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: astx.ASTNodes | None = None,
) -> None:
    """
    title: Initialize one for-in statement.
    parameters:
      target:
        type: astx.AST
      iterable:
        type: astx.AST
      body:
        type: astx.Block
      loc:
        type: SourceLocation
      parent:
        type: astx.ASTNodes | None
    """
    super().__init__(loc=loc, parent=parent)
    self.target = target
    self.iterable = iterable
    self.body = body

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/iterables.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = (
        f"FOR-IN-LOOP-STMT[{id(self)}]"
        if simplified
        else "FOR-IN-LOOP-STMT"
    )
    value = cast(
        ReprStruct,
        {
            "target": self.target.get_struct(simplified),
            "iterable": self.iterable.get_struct(simplified),
            "body": self.body.get_struct(simplified),
        },
    )
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

GeBinOp

GeBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

GeneratorType

GeneratorType(yield_type: DataType)

Bases: AnyType

Represent one stateful generator value that yields values of one statically known element type when iterated. attributes: yield_type: type: astx.DataType

Methods:

Source code in packages/irx/src/irx/astx/types.py
153
154
155
156
157
158
159
160
161
def __init__(self, yield_type: astx.DataType) -> None:
    """
    title: Initialize one generator type.
    parameters:
      yield_type:
        type: astx.DataType
    """
    super().__init__()
    self.yield_type = yield_type

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/types.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a generator type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "GENERATOR-TYPE",
        cast(
            astx.base.ReprStruct,
            {"yield_type": self.yield_type.get_struct(simplified)},
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

GtBinOp

GtBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

LeBinOp

LeBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

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 packages/irx/src/irx/astx/collections/list.py
140
141
142
143
144
145
146
147
148
149
150
151
152
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 packages/irx/src/irx/astx/collections/list.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ListCreate

ListCreate(element_type: DataType)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/collections/list.py
34
35
36
37
38
39
40
41
42
43
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 packages/irx/src/irx/astx/collections/list.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ListIndex

ListIndex(base: AST, index: AST)

Bases: DataType

Read one element from a list-valued expression using one integer index. attributes: base: type: astx.AST index: type: astx.AST type_: type: astx.DataType

Methods:

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

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/collections/list.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(
        "ListIndex",
        cast(
            astx.base.ReprStruct,
            {
                "base": self.base.get_struct(simplified),
                "index": self.index.get_struct(simplified),
            },
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ListLength

ListLength(base: AST)

Bases: DataType

Return the current logical length of one list-valued expression as an int32 value. The runtime stores list lengths as int64, but the current IRx language-level contract intentionally truncates that representation to Int32. attributes: base: type: astx.AST type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/collections/list.py
195
196
197
198
199
200
201
202
203
204
def __init__(self, base: astx.AST) -> None:
    """
    title: Initialize one list length query.
    parameters:
      base:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/collections/list.py
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
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(
        "ListLength",
        cast(
            astx.base.ReprStruct,
            {"base": self.base.get_struct(simplified)},
        ),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

LogicalAndBinOp

LogicalAndBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

LogicalOrBinOp

LogicalOrBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

LtBinOp

LtBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

MethodCall

MethodCall(
    receiver: AST,
    method_name: str,
    args: Iterable[DataType],
)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/classes.py
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
def __init__(
    self,
    receiver: astx.AST,
    method_name: str,
    args: Iterable[astx.DataType],
) -> None:
    """
    title: Initialize one instance method call expression.
    parameters:
      receiver:
        type: astx.AST
      method_name:
        type: str
      args:
        type: Iterable[astx.DataType]
    """
    super().__init__()
    self.receiver = receiver
    self.method_name = method_name
    self.args = tuple(args)
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for an instance method call.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"METHOD-CALL[{self.method_name}]"
    arg_nodes = astx.ASTNodes[astx.DataType]("args")
    for arg in self.args:
        arg_nodes.append(arg)
    value = {
        "receiver": self.receiver.get_struct(simplified),
        "args": arg_nodes.get_struct(simplified),
    }
    return self._prepare_struct(
        key,
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

ModBinOp

ModBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

MulBinOp

MulBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

NamespaceKind

Bases: str, Enum

Distinguish the semantic origin of one namespace-valued binding while keeping the user-facing expression model uniform.

NamespaceType

NamespaceType(
    namespace_key: str,
    *,
    namespace_kind: NamespaceKind = MODULE,
    display_name: str | None = None,
)

Bases: AnyType

Represent one imported namespace value during semantic analysis and lowering without modeling it as a user-defined runtime aggregate. attributes: namespace_key: type: str namespace_kind: type: NamespaceKind display_name: type: str | None

Methods:

Attributes:

Source code in packages/irx/src/irx/astx/modules.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def __init__(
    self,
    namespace_key: str,
    *,
    namespace_kind: NamespaceKind = NamespaceKind.MODULE,
    display_name: str | None = None,
) -> None:
    """
    title: Initialize one namespace type.
    parameters:
      namespace_key:
        type: str
      namespace_kind:
        type: NamespaceKind
      display_name:
        type: str | None
    """
    super().__init__()
    self.namespace_key = namespace_key
    self.namespace_kind = namespace_kind
    self.display_name = display_name

module_key property

module_key: str

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/modules.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a namespace type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    visible_name = self.display_name or self.namespace_key
    key = f"NAMESPACE[{self.namespace_kind.value}:{visible_name}]"
    return self._prepare_struct(key, visible_name, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

NeBinOp

NeBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

OpaqueHandleType

OpaqueHandleType(handle_name: str)

Bases: AnyType

Methods:

Source code in packages/irx/src/irx/astx/ffi.py
83
84
85
86
87
88
89
90
91
def __init__(self, handle_name: str) -> None:
    """
    title: Initialize one opaque-handle type.
    parameters:
      handle_name:
        type: str
    """
    super().__init__()
    self.handle_name = handle_name

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/ffi.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for an opaque-handle type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        f"OPAQUE-HANDLE[{self.handle_name}]",
        self.handle_name,
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

PointerType

PointerType(pointee_type: DataType | None = None)

Bases: AnyType

Methods:

Source code in packages/irx/src/irx/astx/ffi.py
30
31
32
33
34
35
36
37
38
def __init__(self, pointee_type: astx.DataType | None = None) -> None:
    """
    title: Initialize one pointer type.
    parameters:
      pointee_type:
        type: astx.DataType | None
    """
    super().__init__()
    self.pointee_type = pointee_type

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/ffi.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a pointer type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = "POINTER-TYPE"
    value = (
        None
        if self.pointee_type is None
        else self.pointee_type.get_struct(simplified)
    )
    return self._prepare_struct(
        key,
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

PrintExpr

PrintExpr(message: Expr)

Bases: Expr

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

Methods:

Source code in packages/irx/src/irx/astx/system.py
105
106
107
108
109
110
111
112
113
114
def __init__(self, message: astx.Expr) -> None:
    """
    title: Initialize the PrintExpr.
    parameters:
      message:
        type: astx.Expr
    """
    super().__init__()
    self.message = message
    self._name = f"print_msg_{next(PrintExpr._counter)}"

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/system.py
116
117
118
119
120
121
122
123
124
125
126
127
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the AST structure of the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"FunctionCall[{self}]"
    value = self.message.get_struct(simplified)
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

StaticFieldAccess

StaticFieldAccess(class_name: str, field_name: str)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/classes.py
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
def __init__(
    self,
    class_name: str,
    field_name: str,
) -> None:
    """
    title: Initialize one static field access expression.
    parameters:
      class_name:
        type: str
      field_name:
        type: str
    """
    super().__init__()
    self.class_name = class_name
    self.field_name = field_name
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a static field access.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"STATIC-FIELD-ACCESS[{self.class_name}.{self.field_name}]"
    return self._prepare_struct(
        key,
        f"{self.class_name}.{self.field_name}",
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

StaticMethodCall

StaticMethodCall(
    class_name: str,
    method_name: str,
    args: Iterable[DataType],
)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/classes.py
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
def __init__(
    self,
    class_name: str,
    method_name: str,
    args: Iterable[astx.DataType],
) -> None:
    """
    title: Initialize one static method call expression.
    parameters:
      class_name:
        type: str
      method_name:
        type: str
      args:
        type: Iterable[astx.DataType]
    """
    super().__init__()
    self.class_name = class_name
    self.method_name = method_name
    self.args = tuple(args)
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/classes.py
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a static method call.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"STATIC-METHOD-CALL[{self.class_name}.{self.method_name}]"
    arg_nodes = astx.ASTNodes[astx.DataType]("args")
    for arg in self.args:
        arg_nodes.append(arg)
    value = {
        "args": arg_nodes.get_struct(simplified),
    }
    return self._prepare_struct(
        key,
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

StructType

StructType(
    name: str,
    *,
    resolved_name: str | None = None,
    module_key: str | None = None,
    qualified_name: str | None = None,
)

Bases: AnyType

Methods:

Source code in packages/irx/src/irx/astx/structs.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def __init__(
    self,
    name: str,
    *,
    resolved_name: str | None = None,
    module_key: str | None = None,
    qualified_name: str | None = None,
) -> None:
    """
    title: Initialize one named struct type reference.
    parameters:
      name:
        type: str
      resolved_name:
        type: str | None
      module_key:
        type: str | None
      qualified_name:
        type: str | None
    """
    super().__init__()
    self.name = name
    self.resolved_name = resolved_name
    self.module_key = module_key
    self.qualified_name = qualified_name

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/structs.py
68
69
70
71
72
73
74
75
76
77
78
79
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a struct type reference.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"STRUCT-TYPE[{self.name}]"
    value = self.qualified_name or self.name
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

SubBinOp

SubBinOp(
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
)

Bases: BinaryOp

Methods:

Source code in packages/astx/src/astx/types/operators.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
def __init__(
    self,
    op_code: str,
    lhs: DataType,
    rhs: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: Optional[ASTNodes] = None,
) -> None:
    """
    title: Initialize the BinaryOp instance.
    parameters:
      op_code:
        type: str
      lhs:
        type: DataType
      rhs:
        type: DataType
      loc:
        type: SourceLocation
      parent:
        type: Optional[ASTNodes]
    """
    super().__init__(loc=loc, parent=parent)

    self.op_code = op_code
    self.lhs = lhs
    self.rhs = rhs
    self.kind = ASTKind.BinaryOpKind

    if not (
        isinstance(lhs.type_, DataType) and isinstance(rhs.type_, DataType)
    ):
        raise Exception(
            "For now, binary operators are just allowed for `DataType`."
            f"LHS: {lhs.type_}, RHS: {rhs.type_}"
        )

    if lhs.type_ == rhs.type_:
        self.type_ = lhs.type_
    else:
        # type inference
        self.type_ = max([lhs.type_, rhs.type_], key=lambda v: v.nbytes)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/types/operators.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the AST structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"BINARY[{self.op_code}]"
    lhs = {"lhs": self.lhs.get_struct(simplified)}
    rhs = {"rhs": self.rhs.get_struct(simplified)}

    content: ReprStruct = {**lhs, **rhs}
    return self._prepare_struct(key, content, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TemplateParam dataclass

TemplateParam(
    name: str,
    bound: DataType,
    loc: SourceLocation = NO_SOURCE_LOCATION,
)

Describe one bounded template variable attached to a function or method declaration. attributes: name: type: str bound: type: astx.DataType loc: type: astx.SourceLocation

TemplateTypeVar

TemplateTypeVar(name: str, *, bound: DataType)

Bases: AnyType

Represent one unresolved template type parameter inside function signatures or local declared types before specialization. attributes: name: type: str bound: type: astx.DataType

Methods:

Source code in packages/irx/src/irx/astx/types.py
 98
 99
100
101
102
103
104
105
106
107
108
109
def __init__(self, name: str, *, bound: astx.DataType) -> None:
    """
    title: Initialize one template type variable.
    parameters:
      name:
        type: str
      bound:
        type: astx.DataType
    """
    super().__init__()
    self.name = name
    self.bound = bound

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/types.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a template type variable.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"TEMPLATE_TYPE_VAR[{self.name}]"
    value = cast(
        astx.base.DataTypesStruct,
        {
            "name": self.name,
            "bound": self.bound.get_struct(simplified),
        },
    )
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorByteOffset

TensorByteOffset(base: AST, indices: Sequence[AST])

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
def __init__(
    self,
    base: astx.AST,
    indices: Sequence[astx.AST],
) -> None:
    """
    title: Initialize one Tensor byte-offset query.
    parameters:
      base:
        type: astx.AST
      indices:
        type: Sequence[astx.AST]
    """
    super().__init__()
    if not indices:
        raise ValueError("tensor indexing requires at least one index")
    self.base = base
    self.indices = list(indices)
    self.type_ = astx.Int64()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the byte-offset query.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "indices": [
            index.get_struct(simplified) for index in self.indices
        ],
    }
    return self._prepare_struct(
        "TensorByteOffset",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorElementCount

TensorElementCount(base: AST)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
500
501
502
503
504
505
506
507
508
509
def __init__(self, base: astx.AST) -> None:
    """
    title: Initialize one Tensor element-count query.
    parameters:
      base:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.type_ = astx.Int64()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
511
512
513
514
515
516
517
518
519
520
521
522
523
524
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the element-count query.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "TensorElementCount",
        self.base.get_struct(simplified),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorIndex

TensorIndex(base: AST, indices: Sequence[AST])

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
def __init__(
    self,
    base: astx.AST,
    indices: Sequence[astx.AST],
) -> None:
    """
    title: Initialize one Tensor indexed read.
    parameters:
      base:
        type: astx.AST
      indices:
        type: Sequence[astx.AST]
    """
    super().__init__()
    if not indices:
        raise ValueError("tensor indexing requires at least one index")
    self.base = base
    self.indices = list(indices)
    self.type_ = AnyType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the indexed read.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "indices": [
            index.get_struct(simplified) for index in self.indices
        ],
    }
    return self._prepare_struct(
        "TensorIndex",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorLiteral

TensorLiteral(
    values: Sequence[AST],
    *,
    element_type: DataType,
    shape: Sequence[int],
    strides: Sequence[int] | None = None,
    offset_bytes: int = 0,
)

Bases: DataType

Build one Arrow C++ tensor value from scalar values plus shape and stride metadata. attributes: values: type: list[astx.AST] element_type: type: astx.DataType shape: type: tuple[int, Ellipsis] strides: type: tuple[int, Ellipsis] | None offset_bytes: type: int type_: type: TensorType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def __init__(
    self,
    values: Sequence[astx.AST],
    *,
    element_type: astx.DataType,
    shape: Sequence[int],
    strides: Sequence[int] | None = None,
    offset_bytes: int = 0,
) -> None:
    """
    title: Initialize one Tensor literal.
    parameters:
      values:
        type: Sequence[astx.AST]
      element_type:
        type: astx.DataType
      shape:
        type: Sequence[int]
      strides:
        type: Sequence[int] | None
      offset_bytes:
        type: int
    """
    super().__init__()
    self.values = list(values)
    self.element_type = element_type
    self.shape = tuple(shape)
    self.strides = None if strides is None else tuple(strides)
    self.offset_bytes = offset_bytes
    self.type_ = TensorType(element_type)

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the Tensor literal.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "values": [item.get_struct(simplified) for item in self.values],
        "element_type": self.element_type.get_struct(simplified),
        "shape": list(self.shape),
        "strides": (None if self.strides is None else list(self.strides)),
        "offset_bytes": self.offset_bytes,
    }
    return self._prepare_struct(
        "TensorLiteral",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorNDim

TensorNDim(base: AST)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
357
358
359
360
361
362
363
364
365
366
def __init__(self, base: astx.AST) -> None:
    """
    title: Initialize one Tensor rank query.
    parameters:
      base:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
368
369
370
371
372
373
374
375
376
377
378
379
380
381
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the rank query.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "TensorNDim",
        self.base.get_struct(simplified),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorRelease

TensorRelease(base: AST)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
641
642
643
644
645
646
647
648
649
650
def __init__(self, base: astx.AST) -> None:
    """
    title: Initialize one Tensor release helper.
    parameters:
      base:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
652
653
654
655
656
657
658
659
660
661
662
663
664
665
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the release helper.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "TensorRelease",
        self.base.get_struct(simplified),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorRetain

TensorRetain(base: AST)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
600
601
602
603
604
605
606
607
608
609
def __init__(self, base: astx.AST) -> None:
    """
    title: Initialize one Tensor retain helper.
    parameters:
      base:
        type: astx.AST
    """
    super().__init__()
    self.base = base
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
611
612
613
614
615
616
617
618
619
620
621
622
623
624
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the retain helper.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    return self._prepare_struct(
        "TensorRetain",
        self.base.get_struct(simplified),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorShape

TensorShape(base: AST, axis: int)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
401
402
403
404
405
406
407
408
409
410
411
412
413
def __init__(self, base: astx.AST, axis: int) -> None:
    """
    title: Initialize one Tensor shape query.
    parameters:
      base:
        type: astx.AST
      axis:
        type: int
    """
    super().__init__()
    self.base = base
    self.axis = axis
    self.type_ = astx.Int64()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the shape query.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "axis": self.axis,
    }
    return self._prepare_struct(
        "TensorShape",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorStore

TensorStore(base: AST, indices: Sequence[AST], value: AST)

Bases: DataType

Stores one scalar through tensor shape and stride metadata. Arrow C++ backed tensors remain readonly in this phase, but the node keeps the surface aligned with future writable views. attributes: base: type: astx.AST indices: type: list[astx.AST] value: type: astx.AST type_: type: astx.Int32

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
def __init__(
    self,
    base: astx.AST,
    indices: Sequence[astx.AST],
    value: astx.AST,
) -> None:
    """
    title: Initialize one Tensor indexed store.
    parameters:
      base:
        type: astx.AST
      indices:
        type: Sequence[astx.AST]
      value:
        type: astx.AST
    """
    super().__init__()
    if not indices:
        raise ValueError("tensor indexing requires at least one index")
    self.base = base
    self.indices = list(indices)
    self.value = value
    self.type_ = astx.Int32()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the indexed store.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "indices": [
            index.get_struct(simplified) for index in self.indices
        ],
        "value": self.value.get_struct(simplified),
    }
    return self._prepare_struct(
        "TensorStore",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorStride

TensorStride(base: AST, axis: int)

Bases: DataType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
452
453
454
455
456
457
458
459
460
461
462
463
464
def __init__(self, base: astx.AST, axis: int) -> None:
    """
    title: Initialize one Tensor stride query.
    parameters:
      base:
        type: astx.AST
      axis:
        type: int
    """
    super().__init__()
    self.base = base
    self.axis = axis
    self.type_ = astx.Int64()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the stride query.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "axis": self.axis,
    }
    return self._prepare_struct(
        "TensorStride",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorType

TensorType(element_type: DataType | None = None)

Bases: AnyType

Represent the homogeneous N-dimensional tensor abstraction while reusing the canonical buffer/view representation during lowering. attributes: element_type: type: astx.DataType | None

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
34
35
36
37
38
39
40
41
42
def __init__(self, element_type: astx.DataType | None = None) -> None:
    """
    title: Initialize one Tensor type.
    parameters:
      element_type:
        type: astx.DataType | None
    """
    super().__init__()
    self.element_type = element_type

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/astx/src/astx/base.py
685
686
687
688
689
690
691
692
693
694
695
696
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return a simple structure that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"DATA-TYPE[{self.__class__.__name__}]"
    value = self.name
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

TensorView

TensorView(
    base: AST,
    *,
    shape: Sequence[int],
    strides: Sequence[int] | None = None,
    offset_bytes: int = 0,
)

Bases: DataType

Build one shallow tensor view by reusing the base storage and replacing the logical shape, strides, and offset metadata. attributes: base: type: astx.AST shape: type: tuple[int, Ellipsis] strides: type: tuple[int, Ellipsis] | None offset_bytes: type: int type_: type: TensorType

Methods:

Source code in packages/irx/src/irx/astx/tensor.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
def __init__(
    self,
    base: astx.AST,
    *,
    shape: Sequence[int],
    strides: Sequence[int] | None = None,
    offset_bytes: int = 0,
) -> None:
    """
    title: Initialize one Tensor view.
    parameters:
      base:
        type: astx.AST
      shape:
        type: Sequence[int]
      strides:
        type: Sequence[int] | None
      offset_bytes:
        type: int
    """
    super().__init__()
    self.base = base
    self.shape = tuple(shape)
    self.strides = None if strides is None else tuple(strides)
    self.offset_bytes = offset_bytes
    self.type_ = TensorType()

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/tensor.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Return the structured representation of the Tensor view.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    value = {
        "base": self.base.get_struct(simplified),
        "shape": list(self.shape),
        "strides": (None if self.strides is None else list(self.strides)),
        "offset_bytes": self.offset_bytes,
    }
    return self._prepare_struct(
        "TensorView",
        cast(astx.base.ReprStruct, value),
        simplified,
    )

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

UnionType

UnionType(
    members: Iterable[DataType],
    *,
    alias_name: str | None = None,
)

Bases: AnyType

Represent one union of concrete type references that semantic analysis may enumerate as a finite type domain. attributes: members: type: tuple[astx.DataType, Ellipsis] alias_name: type: str | None

Methods:

Source code in packages/irx/src/irx/astx/types.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def __init__(
    self,
    members: Iterable[astx.DataType],
    *,
    alias_name: str | None = None,
) -> None:
    """
    title: Initialize one finite union type.
    parameters:
      members:
        type: Iterable[astx.DataType]
      alias_name:
        type: str | None
    """
    super().__init__()
    self.members = tuple(members)
    self.alias_name = alias_name

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/types.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def get_struct(self, simplified: bool = False) -> astx.base.ReprStruct:
    """
    title: Build one repr structure for a finite union type.
    parameters:
      simplified:
        type: bool
    returns:
      type: astx.base.ReprStruct
    """
    key = f"UNION[{self.alias_name or id(self)}]"
    value = cast(
        astx.base.DataTypesStruct,
        [member.get_struct(simplified) for member in self.members],
    )
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

WithStmt

WithStmt(
    manager: AST,
    body: Block,
    target: AST | None = None,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: ASTNodes | None = None,
)

Bases: StatementType

Model source forms equivalent to with manager as target: body while keeping the manager expression, optional target, and body as regular ASTx child nodes. attributes: manager: type: astx.AST body: type: astx.Block target: type: astx.AST | None

Methods:

Source code in packages/irx/src/irx/astx/context.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def __init__(
    self,
    manager: astx.AST,
    body: astx.Block,
    target: astx.AST | None = None,
    loc: SourceLocation = NO_SOURCE_LOCATION,
    parent: astx.ASTNodes | None = None,
) -> None:
    """
    title: Initialize one with statement.
    parameters:
      manager:
        type: astx.AST
      body:
        type: astx.Block
      target:
        type: astx.AST | None
      loc:
        type: SourceLocation
      parent:
        type: astx.ASTNodes | None
    """
    super().__init__(loc=loc, parent=parent)
    self.manager = manager
    self.body = body
    self.target = target

get_struct

get_struct(simplified: bool = False) -> ReprStruct
Source code in packages/irx/src/irx/astx/context.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def get_struct(self, simplified: bool = False) -> ReprStruct:
    """
    title: Return the structured representation.
    parameters:
      simplified:
        type: bool
    returns:
      type: ReprStruct
    """
    key = f"WITH-STMT[{id(self)}]" if simplified else "WITH-STMT"
    target = (
        {"target": self.target.get_struct(simplified)}
        if self.target is not None
        else {}
    )
    value = cast(
        ReprStruct,
        {
            "manager": self.manager.get_struct(simplified),
            **target,
            "body": self.body.get_struct(simplified),
        },
    )
    return self._prepare_struct(key, value, simplified)

to_json

to_json(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
400
401
402
403
404
405
406
407
408
409
def to_json(self, simplified: bool = False) -> str:
    """
    title: Return an json string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return json.dumps(self.get_struct(simplified=simplified), indent=2)

to_yaml

to_yaml(simplified: bool = False) -> str
Source code in packages/astx/src/astx/base.py
387
388
389
390
391
392
393
394
395
396
397
398
def to_yaml(self, simplified: bool = False) -> str:
    """
    title: Return an yaml string that represents the object.
    parameters:
      simplified:
        type: bool
    returns:
      type: str
    """
    return str(
        yaml.dump(self.get_struct(simplified=simplified), sort_keys=False)
    )

add_generated_template_node

add_generated_template_node(
    module: Module, node: AST
) -> None
Source code in packages/irx/src/irx/astx/templates.py
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
@typechecked
def add_generated_template_node(
    module: astx.Module,
    node: astx.AST,
) -> None:
    """
    title: Attach one generated template node to a module.
    parameters:
      module:
        type: astx.Module
      node:
        type: astx.AST
    """
    nodes = list(getattr(module, _GENERATED_TEMPLATE_NODES_ATTR, ()))
    nodes.append(node)
    setattr(module, _GENERATED_TEMPLATE_NODES_ATTR, tuple(nodes))

binary_op_type_for_opcode

binary_op_type_for_opcode(op_code: str) -> type[BinaryOp]
Source code in packages/irx/src/irx/astx/binary_op.py
156
157
158
159
160
161
162
163
164
165
166
@typechecked
def binary_op_type_for_opcode(op_code: str) -> type[astx.BinaryOp]:
    """
    title: Return the specialized BinaryOp subclass for an opcode.
    parameters:
      op_code:
        type: str
    returns:
      type: type[astx.BinaryOp]
    """
    return _BINARY_OP_TYPES.get(op_code, astx.BinaryOp)

clear_generated_template_nodes

clear_generated_template_nodes(module: Module) -> None
Source code in packages/irx/src/irx/astx/templates.py
185
186
187
188
189
190
191
192
193
@typechecked
def clear_generated_template_nodes(module: astx.Module) -> None:
    """
    title: Remove generated template nodes attached to one module.
    parameters:
      module:
        type: astx.Module
    """
    setattr(module, _GENERATED_TEMPLATE_NODES_ATTR, ())

generated_template_nodes

generated_template_nodes(module: Module) -> tuple[AST, ...]
Source code in packages/irx/src/irx/astx/templates.py
196
197
198
199
200
201
202
203
204
205
206
207
@typechecked
def generated_template_nodes(module: astx.Module) -> tuple[astx.AST, ...]:
    """
    title: Return the generated template nodes attached to a module.
    parameters:
      module:
        type: astx.Module
    returns:
      type: tuple[astx.AST, Ellipsis]
    """
    value = getattr(module, _GENERATED_TEMPLATE_NODES_ATTR, ())
    return tuple(value)

get_template_args

get_template_args(node: AST) -> tuple[DataType, ...] | None
Source code in packages/irx/src/irx/astx/templates.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@typechecked
def get_template_args(node: astx.AST) -> tuple[astx.DataType, ...] | None:
    """
    title: Return the explicit template arguments attached to one AST node.
    parameters:
      node:
        type: astx.AST
    returns:
      type: tuple[astx.DataType, Ellipsis] | None
    """
    value = getattr(node, _TEMPLATE_ARGS_ATTR, None)
    if value is None:
        return None
    return tuple(value)

get_template_params

get_template_params(node: AST) -> tuple[TemplateParam, ...]
Source code in packages/irx/src/irx/astx/templates.py
62
63
64
65
66
67
68
69
70
71
72
73
@typechecked
def get_template_params(node: astx.AST) -> tuple[TemplateParam, ...]:
    """
    title: Return the template parameters attached to one AST node.
    parameters:
      node:
        type: astx.AST
    returns:
      type: tuple[TemplateParam, Ellipsis]
    """
    value = getattr(node, _TEMPLATE_PARAMS_ATTR, ())
    return tuple(value)

is_template_node

is_template_node(node: AST) -> bool
Source code in packages/irx/src/irx/astx/templates.py
76
77
78
79
80
81
82
83
84
85
86
@typechecked
def is_template_node(node: astx.AST) -> bool:
    """
    title: Return whether one AST node carries template parameters.
    parameters:
      node:
        type: astx.AST
    returns:
      type: bool
    """
    return bool(get_template_params(node))

is_template_specialization

is_template_specialization(node: AST) -> bool
Source code in packages/irx/src/irx/astx/templates.py
154
155
156
157
158
159
160
161
162
163
164
@typechecked
def is_template_specialization(node: astx.AST) -> bool:
    """
    title: Return whether one AST node is a generated specialization.
    parameters:
      node:
        type: astx.AST
    returns:
      type: bool
    """
    return template_specialization_name(node) is not None

mark_template_specialization

mark_template_specialization(
    node: AST, specialization_name: str
) -> None
Source code in packages/irx/src/irx/astx/templates.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@typechecked
def mark_template_specialization(
    node: astx.AST,
    specialization_name: str,
) -> None:
    """
    title: Mark one AST node as a generated template specialization.
    parameters:
      node:
        type: astx.AST
      specialization_name:
        type: str
    """
    setattr(node, _TEMPLATE_SPECIALIZATION_ATTR, specialization_name)

set_template_args

set_template_args(
    node: AST, args: Iterable[DataType] | None
) -> None
Source code in packages/irx/src/irx/astx/templates.py
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
@typechecked
def set_template_args(
    node: astx.AST,
    args: Iterable[astx.DataType] | None,
) -> None:
    """
    title: Attach explicit template arguments to one call-like AST node.
    parameters:
      node:
        type: astx.AST
      args:
        type: Iterable[astx.DataType] | None
    """
    if args is None:
        setattr(node, _TEMPLATE_ARGS_ATTR, None)
        return
    setattr(node, _TEMPLATE_ARGS_ATTR, tuple(args))

set_template_params

set_template_params(
    node: AST, params: Iterable[TemplateParam]
) -> None
Source code in packages/irx/src/irx/astx/templates.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@typechecked
def set_template_params(
    node: astx.AST,
    params: Iterable[TemplateParam],
) -> None:
    """
    title: Attach template parameters to one AST node.
    parameters:
      node:
        type: astx.AST
      params:
        type: Iterable[TemplateParam]
    """
    setattr(node, _TEMPLATE_PARAMS_ATTR, tuple(params))

specialize_binary_op

specialize_binary_op(node: BinaryOp) -> BinaryOp
Source code in packages/irx/src/irx/astx/binary_op.py
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
@typechecked
def specialize_binary_op(node: astx.BinaryOp) -> astx.BinaryOp:
    """
    title: Return a specialized BinaryOp instance for the given opcode.
    parameters:
      node:
        type: astx.BinaryOp
    returns:
      type: astx.BinaryOp
    """
    target_type = binary_op_type_for_opcode(node.op_code)
    if target_type is astx.BinaryOp or isinstance(node, target_type):
        return node

    specialized = target_type(
        node.op_code,
        node.lhs,
        node.rhs,
        loc=node.loc,
        parent=node.parent,
    )
    specialized.__dict__.update(vars(node))
    return specialized

template_specialization_name

template_specialization_name(node: AST) -> str | None
Source code in packages/irx/src/irx/astx/templates.py
140
141
142
143
144
145
146
147
148
149
150
151
@typechecked
def template_specialization_name(node: astx.AST) -> str | None:
    """
    title: Return the generated specialization name for one AST node.
    parameters:
      node:
        type: astx.AST
    returns:
      type: str | None
    """
    value = getattr(node, _TEMPLATE_SPECIALIZATION_ATTR, None)
    return value if isinstance(value, str) else None