Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #5
0
    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)
Beispiel #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}")
Beispiel #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))