Sequence expression.
| 3871 | |
| 3872 | |
| 3873 | class SeqRef(ExprRef): |
| 3874 | """Sequence expression.""" |
| 3875 | |
| 3876 | __slots__ = () |
| 3877 | |
| 3878 | def __init__( |
| 3879 | self, |
| 3880 | ast: ASTNode, |
| 3881 | sort: SeqSortRef, |
| 3882 | vars: frozenset[tuple[str, ASTSort]] = frozenset(), |
| 3883 | ) -> None: |
| 3884 | super().__init__(ast, sort, vars) |
| 3885 | |
| 3886 | def __add__(self, other: SeqRef) -> SeqRef: |
| 3887 | if not isinstance(other, SeqRef): |
| 3888 | return NotImplemented |
| 3889 | return SeqRef( |
| 3890 | SeqConcatNode(self._ast, other._ast), |
| 3891 | self._sort, # type: ignore[arg-type] |
| 3892 | _merge(self._vars, other._vars), |
| 3893 | ) |
| 3894 | |
| 3895 | def __getitem__(self, idx: ArithRef | int) -> ExprRef: |
| 3896 | if isinstance(idx, int): |
| 3897 | idx = IntVal(idx) |
| 3898 | sort = self._sort |
| 3899 | elem_sort = sort._elem if isinstance(sort, SeqSortRef) else IntSort() |
| 3900 | return ExprRef( |
| 3901 | SeqNthNode(self._ast, idx._ast), |
| 3902 | elem_sort, |
| 3903 | _merge(self._vars, idx._vars), |
| 3904 | ) |
| 3905 | |
| 3906 | def at(self, idx: ArithRef | int) -> ExprRef: |
| 3907 | """Return a unit sequence at the given index.""" |
| 3908 | elem = self[idx] |
| 3909 | return Unit(elem) |
| 3910 | |
| 3911 | def is_string(self) -> bool: |
| 3912 | sort = self._sort |
| 3913 | return isinstance(sort, SeqSortRef) and sort.is_string() |
| 3914 | |
| 3915 | |
| 3916 | def SeqSort(s: SortRef) -> SeqSortRef | StringSortRef: |
no outgoing calls
no test coverage detected