Skip to content

wake.ir.meta.pragma_directive module #

PragmaDirective class #

Bases: SolidityAbc

Source code in wake/ir/meta/pragma_directive.py
class PragmaDirective(SolidityAbc):
    _ast_node: SolcPragmaDirective
    _parent: weakref.ReferenceType[SourceUnit]

    _literals: List[str]

    def __init__(
        self, init: IrInitTuple, pragma: SolcPragmaDirective, parent: SolidityAbc
    ):
        super().__init__(init, pragma, parent)
        self._literals = list(pragma.literals)

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

    @property
    def literals(self) -> Tuple[str, ...]:
        """
        !!! example
            `:::py ('solidity', '^', '0.8', '||', '0.7', '.1', '-', '0.7', '.6')` for the following pragma:
            ```solidity
            pragma solidity ^0.8 || 0.7.1 - 0.7.6;
            ```
        !!! example
            `:::py ('abicoder', 'v2')` for the following pragma:
            ```solidity
            pragma abicoder v2;
            ```
        !!! example
            `:::py ('experimental', 'SMTChecker')` for the following pragma:
            ```solidity
            pragma experimental SMTChecker;
            ```

        Returns:
            Literals of the pragma directive.
        """
        return tuple(self._literals)

literals: Tuple[str, ...] property #

Example

('solidity', '^', '0.8', '||', '0.7', '.1', '-', '0.7', '.6') for the following pragma:

pragma solidity ^0.8 || 0.7.1 - 0.7.6;

Example

('abicoder', 'v2') for the following pragma:

pragma abicoder v2;

Example

('experimental', 'SMTChecker') for the following pragma:

pragma experimental SMTChecker;

Returns:

Type Description
Tuple[str, ...]

Literals of the pragma directive.

parent: SourceUnit property #

Returns:

Type Description
SourceUnit

Parent IR node.