Example #1
0
    def push_bytes(self, value: bytes) -> None:
        if len(self.values) > 1023:
            raise FullStack('Stack limit reached')

        validate_stack_bytes(value)

        self._append((bytes, value))
Example #2
0
    def push_int(self, value: int) -> None:
        if len(self.values) > 1023:
            raise FullStack('Stack limit reached')

        validate_stack_int(value)

        self._append((int, value))
Example #3
0
    def push_bytes(self, value: bytes) -> None:
        """
        Push a bytes item onto the stack.
        """
        if len(self.values) > 1023:
            raise FullStack('Stack limit reached')

        validate_stack_bytes(value)

        self._append((bytes, value))
Example #4
0
    def push_int(self, value: int) -> None:
        """
        Push an integer item onto the stack.
        """
        if len(self.values) > 1023:
            raise FullStack('Stack limit reached')

        validate_stack_int(value)

        self._append((int, value))
Example #5
0
File: stack.py Project: sjyi/py-evm
    def push(self, value):
        """
        Push an item onto the stack.
        """
        if len(self.values) > 1023:
            raise FullStack('Stack limit reached')

        validate_stack_item(value)

        self.values.append(value)
Example #6
0
    def dup(self, position: int) -> None:
        if len(self.values) > 1023:
            raise FullStack('Stack limit reached')

        peek_index = -1 * position
        try:
            self._append(self.values[peek_index])
        except IndexError:
            raise InsufficientStack(
                f"Insufficient stack items for DUP{position}")
Example #7
0
    def dup(self, position: int) -> None:
        """
        Perform a DUP operation on the stack.
        """
        if len(self.values) > 1023:
            raise FullStack('Stack limit reached')

        peek_index = -1 * position
        try:
            self._append(self.values[peek_index])
        except IndexError:
            raise InsufficientStack(
                "Insufficient stack items for DUP{0}".format(position))