Skip to content

statement

AsmDeclaration

Bases: Statement

AsmDeclaration is used to define an assembly declaration statement in the IR.

Parameters:

Name Type Description Default
backend_name SupportsStr

Name of the backend that is to process the provided backend code.

required
backend_code SupportsStr

Assembly code to be processed by the specified backend.

required
Source code in opensquirrel/ir/statement.py
class AsmDeclaration(Statement):
    """``AsmDeclaration`` is used to define an assembly declaration statement in the IR.

    Args:
        backend_name (SupportsStr): Name of the backend that is to process the provided backend code.
        backend_code (SupportsStr): Assembly code to be processed by the specified backend.
    """

    def __init__(
        self,
        backend_name: SupportsStr,
        backend_code: SupportsStr,
    ) -> None:
        self.backend_name = String(backend_name)
        self.backend_code = String(backend_code)
        Statement.__init__(self)

    def accept(self, visitor: IRVisitor) -> Any:
        """Accepts visitor and processes this IR node."""
        visitor.visit_statement(self)
        return visitor.visit_asm_declaration(self)

accept

accept(visitor: IRVisitor) -> Any

Accepts visitor and processes this IR node.

Source code in opensquirrel/ir/statement.py
def accept(self, visitor: IRVisitor) -> Any:
    """Accepts visitor and processes this IR node."""
    visitor.visit_statement(self)
    return visitor.visit_asm_declaration(self)

Instruction

Bases: Statement, ABC

Source code in opensquirrel/ir/statement.py
class Instruction(Statement, ABC):
    def __init__(self, name: str) -> None:
        self.name = name

    @property
    @abstractmethod
    def arguments(self) -> tuple[Expression, ...]: ...

    @property
    @abstractmethod
    def qubit_operands(self) -> tuple[Qubit, ...]: ...

    @property
    @abstractmethod
    def bit_operands(self) -> tuple[Bit, ...]: ...

    @property
    def qubit_indices(self) -> list[int]:
        return [qubit.index for qubit in self.qubit_operands]

    def accept(self, visitor: IRVisitor) -> Any:
        """Accepts visitor and processes this IR node."""
        return visitor.visit_instruction(self)

accept

accept(visitor: IRVisitor) -> Any

Accepts visitor and processes this IR node.

Source code in opensquirrel/ir/statement.py
def accept(self, visitor: IRVisitor) -> Any:
    """Accepts visitor and processes this IR node."""
    return visitor.visit_instruction(self)