Skip to content

Stream

stream

T = TypeVar('T') module-attribute

TCov = TypeVar('TCov', covariant=True) module-attribute

TCon = TypeVar('TCon', contravariant=True) module-attribute

ReadableStream

Bases: ABC, Generic[TCov]

Abstract base class for readable stream interpreter model objects.

Source code in xdsl/interpreters/utils/stream.py
class ReadableStream(abc.ABC, Generic[TCov]):
    """
    Abstract base class for readable stream interpreter model objects.
    """

    @abc.abstractmethod
    def read(self) -> TCov:
        raise NotImplementedError()

read() -> TCov abstractmethod

Source code in xdsl/interpreters/utils/stream.py
@abc.abstractmethod
def read(self) -> TCov:
    raise NotImplementedError()

WritableStream

Bases: ABC, Generic[TCon]

Abstract base class for readable stream interpreter model objects.

Source code in xdsl/interpreters/utils/stream.py
class WritableStream(abc.ABC, Generic[TCon]):
    """
    Abstract base class for readable stream interpreter model objects.
    """

    @abc.abstractmethod
    def write(self, value: TCon) -> None:
        raise NotImplementedError()

write(value: TCon) -> None abstractmethod

Source code in xdsl/interpreters/utils/stream.py
@abc.abstractmethod
def write(self, value: TCon) -> None:
    raise NotImplementedError()

Nats dataclass

Bases: ReadableStream[IntegerAttr[I32]]

A stream designed for testing, outputs the next natural number each time it's read.

Source code in xdsl/interpreters/utils/stream.py
@dataclass
class Nats(ReadableStream[IntegerAttr[I32]]):
    """
    A stream designed for testing, outputs the next natural number each time it's read.
    """

    index = 0

    def read(self) -> IntegerAttr[I32]:
        self.index += 1
        return IntegerAttr(self.index, i32)

index = 0 class-attribute instance-attribute

__init__() -> None

read() -> IntegerAttr[I32]

Source code in xdsl/interpreters/utils/stream.py
def read(self) -> IntegerAttr[I32]:
    self.index += 1
    return IntegerAttr(self.index, i32)

Acc dataclass

Bases: WritableStream[IntegerAttr[I32]]

A stream designed for testing, appends the next natural number written.

Source code in xdsl/interpreters/utils/stream.py
@dataclass
class Acc(WritableStream[IntegerAttr[I32]]):
    """
    A stream designed for testing, appends the next natural number written.
    """

    values: list[IntegerAttr[I32]] = field(default_factory=list[IntegerAttr[I32]])

    def write(self, value: IntegerAttr[I32]) -> None:
        return self.values.append(value)

values: list[IntegerAttr[I32]] = field(default_factory=list[IntegerAttr[I32]]) class-attribute instance-attribute

__init__(values: list[IntegerAttr[I32]] = list[IntegerAttr[I32]]()) -> None

write(value: IntegerAttr[I32]) -> None

Source code in xdsl/interpreters/utils/stream.py
def write(self, value: IntegerAttr[I32]) -> None:
    return self.values.append(value)