evm-opcodes-0.1.0: Opcode types for Ethereum Virtual Machine (EVM)
Copyright 2018 Simon Shine MIT Simon Shine None Haskell2010

EVM.Opcode.Positional

Description

This module exposes the PositionalOpcode type for expressing Ethereum VM opcodes where jumps and jumpdests are annotated with the byte position of the translated opcode.

This representation is useful for when generating code that refers to the size of itself or other chunks of code. E.g. the CODECOPY segment of an Ethereum contract must refer to the size of the code being copied, and determining the size of a jump is trivial when it's annotated with the destination address.

Synopsis

# Documentation

type Position = Word Source #

The position of an Opcode.

A PositionalOpcode has byte positions annotated at JUMP, JUMPI and JUMPDEST; on JUMP and JUMPI the positions denote where they jump to, and on JUMPDEST they denote the position of the opcode itself.

translate :: [PositionalOpcode] -> [Opcode] Source #

Translate a PositionalOpcode into an Opcode by converting the position into a PUSH instruction.

jumpSize :: Num i => Position -> i Source #

The size of a jump to some absolute position.