Template Class stack_operations#

Class Documentation#

template<class params>
class stack_operations#

The stack operations class. Contains all the operations that can be performed on the stack.

  • POP 50: POP

  • PUSH0 5F: PUSH0

  • PUSHX 60s & 70s: Push Operations

  • DUPX 80s: Duplication Operations

  • SWAPX 90s: Exchange Operations

Public Types

typedef arith_env_t<params> arith_t#

The arithmetical environment used by the arbitrary length integer library.

typedef arith_t::bn_t bn_t#

The arbitrary length integer type.

typedef stack_t<params> stack_t#

The stackk class.

Public Static Functions

static inline __host__ __device__ __forceinline__ void operation_POP (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The POP operation implementation. It pops the top element from the stack.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[out] The stack.

static inline __host__ __device__ __forceinline__ void operation_PUSH0 (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack)

The PUSH0 operation implementation. Pushes a zero value to the stack.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[inout] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[inout] The error code.

  • pc[inout] The program counter.

  • stack[inout] The stack.

static inline __host__ __device__ __forceinline__ void operation_PUSHX (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, uint8_t *bytecode, uint32_t &code_size, uint8_t &opcode)

The PUSHX operation implementation. Pushes a value from the bytecode to the stack. If the bytecode is not long enough to provide the value, the operation completes with zero bytes for the least significant bytes.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[inout] The stack.

  • bytecode[in] The bytecode.

  • code_size[in] The size of the bytecode.

  • opcode[in] The opcode.

static inline __host__ __device__ __forceinline__ void operation_DUPX (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, uint8_t &opcode)

The DUPX operation implementation. Duplicates a value from the stack and pushes it back to the stack. The value to be duplicated is given by the opcode. The opcode is in the range 0x80 - 0x8F. The index of the value to be duplicated is given by the opcode - 0x80 + 1. We consider the least 4 significant bits of the opcode + 1. The index is from the top of the stack. 1 is the top of the stack. 2 is the second value from the top of the stack and so on.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[inout] The stack.

  • opcode[in] The opcode.

static inline __host__ __device__ __forceinline__ void operation_SWAPX (arith_t &arith, bn_t &gas_limit, bn_t &gas_used, uint32_t &error_code, uint32_t &pc, stack_t &stack, uint8_t &opcode)

The SWAPX operation implementation. Swaps the top of the stack with a value from the stack. The index of the value to be swapped is given by the opcode - 0x90 + 1. We consider the least 4 significant bits of the opcode + 1. The index is starts from the first value under the top of the stack. 1 is the second value from the top of the stack, 2 is the third value from the top of the stack and so on.

Parameters
  • arith[in] The arithmetical environment.

  • gas_limit[in] The gas limit.

  • gas_used[inout] The gas used.

  • error_code[out] The error code.

  • pc[inout] The program counter.

  • stack[inout] The stack.

  • opcode[in] The opcode.