Skip to content

wake.ir.yul.expression_statement module #

YulExpressionStatement class #

Bases: YulStatementAbc

The underlying expression can only be a YulFunctionCall.

Example

assembly {
    stop()
}
Source code in wake/ir/yul/expression_statement.py
class YulExpressionStatement(YulStatementAbc):
    """
    The underlying expression can only be a [YulFunctionCall][wake.ir.yul.function_call.YulFunctionCall].

    !!! example
        ```solidity
        assembly {
            stop()
        }
        ```
    """

    _parent: weakref.ReferenceType[YulBlock]
    _expression: YulFunctionCall

    def __init__(
        self,
        init: IrInitTuple,
        expression_statement: SolcYulExpressionStatement,
        parent: YulAbc,
    ):
        super().__init__(init, expression_statement, parent)
        assert isinstance(
            expression_statement.expression, SolcYulFunctionCall
        ), f"Unexpected type: {type(expression_statement.expression)}"
        self._expression = YulFunctionCall(init, expression_statement.expression, self)

    def __iter__(self) -> Iterator[YulAbc]:
        yield self
        yield from self._expression

    @property
    def parent(self) -> YulBlock:
        """
        Returns:
            Parent IR node.
        """
        return super().parent

    @property
    def children(self) -> Iterator[YulFunctionCall]:
        """
        Yields:
            Direct children of this node.
        """
        yield self._expression

    @property
    def expression(self) -> YulFunctionCall:
        """
        Returns:
            Underlying expression.
        """
        return self._expression

    @property
    def modifies_state(
        self,
    ) -> Set[Tuple[Union[ExpressionAbc, StatementAbc, YulAbc], ModifiesStateFlag]]:
        return self._expression.modifies_state

children: Iterator[YulFunctionCall] property #

Yields:

Type Description
YulFunctionCall

Direct children of this node.

expression: YulFunctionCall property #

Returns:

Type Description
YulFunctionCall

Underlying expression.

parent: YulBlock property #

Returns:

Type Description
YulBlock

Parent IR node.