evm-opcodes-0.1.0: Opcode types for Ethereum Virtual Machine (EVM)
Copyright2018 Simon Shine
LicenseMIT
MaintainerSimon Shine <shreddedglory@gmail.com>
Safe HaskellNone
LanguageHaskell2010

EVM.Opcode.Internal

Description

This module exposes the Opcode' abstract type.

Synopsis

Documentation

data Opcode' j Source #

An Opcode' is an Ethereum VM Opcode with parameterised jumps.

For a plain opcode using the basic EVM stack-based jumps, use Opcode instead.

This type is used for defining and translating from annotated opcodes, e.g. with labelled jumps.

Instances

Instances details
Functor Opcode' Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

fmap :: (a -> b) -> Opcode' a -> Opcode' b #

(<$) :: a -> Opcode' b -> Opcode' a #

Show Opcode Source #

Show PUSH as the Haskell data constructor

Instance details

Defined in EVM.Opcode

Eq j => Eq (Opcode' j) Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

(==) :: Opcode' j -> Opcode' j -> Bool #

(/=) :: Opcode' j -> Opcode' j -> Bool #

Ord j => Ord (Opcode' j) Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

compare :: Opcode' j -> Opcode' j -> Ordering #

(<) :: Opcode' j -> Opcode' j -> Bool #

(<=) :: Opcode' j -> Opcode' j -> Bool #

(>) :: Opcode' j -> Opcode' j -> Bool #

(>=) :: Opcode' j -> Opcode' j -> Bool #

max :: Opcode' j -> Opcode' j -> Opcode' j #

min :: Opcode' j -> Opcode' j -> Opcode' j #

Show a => Show (Opcode' a) Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

showsPrec :: Int -> Opcode' a -> ShowS #

show :: Opcode' a -> String #

showList :: [Opcode' a] -> ShowS #

concrete :: Opcode' a -> Opcode' () Source #

Convert any Opcode' a into an Opcode' ().

jumpAnnot :: Opcode' a -> Maybe a Source #

Extract the a from a JUMP a or a JUMPI a.

jumpdestAnnot :: Opcode' a -> Maybe a Source #

Extract the a from a JUMPDEST a.

toWord8 :: Enum e => e -> Word8 Source #

Convert an Ord5 or an Ord16 to a Word8.

fromWord8 :: Enum e => Word8 -> e Source #

Convert a Word8 to an Ord5 or an Ord16.

data Ord5 Source #

Convenience type of cardinality 5 for LOG.

Constructors

Ord5_0 
Ord5_1 
Ord5_2 
Ord5_3 
Ord5_4 

Instances

Instances details
Bounded Ord5 Source # 
Instance details

Defined in EVM.Opcode.Internal

Enum Ord5 Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

succ :: Ord5 -> Ord5 #

pred :: Ord5 -> Ord5 #

toEnum :: Int -> Ord5 #

fromEnum :: Ord5 -> Int #

enumFrom :: Ord5 -> [Ord5] #

enumFromThen :: Ord5 -> Ord5 -> [Ord5] #

enumFromTo :: Ord5 -> Ord5 -> [Ord5] #

enumFromThenTo :: Ord5 -> Ord5 -> Ord5 -> [Ord5] #

Eq Ord5 Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

(==) :: Ord5 -> Ord5 -> Bool #

(/=) :: Ord5 -> Ord5 -> Bool #

Ord Ord5 Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

compare :: Ord5 -> Ord5 -> Ordering #

(<) :: Ord5 -> Ord5 -> Bool #

(<=) :: Ord5 -> Ord5 -> Bool #

(>) :: Ord5 -> Ord5 -> Bool #

(>=) :: Ord5 -> Ord5 -> Bool #

max :: Ord5 -> Ord5 -> Ord5 #

min :: Ord5 -> Ord5 -> Ord5 #

data Ord16 Source #

Convenience type of cardinality 16 for DUP and SWAP.

Instances

Instances details
Bounded Ord16 Source # 
Instance details

Defined in EVM.Opcode.Internal

Enum Ord16 Source # 
Instance details

Defined in EVM.Opcode.Internal

Eq Ord16 Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

(==) :: Ord16 -> Ord16 -> Bool #

(/=) :: Ord16 -> Ord16 -> Bool #

Ord Ord16 Source # 
Instance details

Defined in EVM.Opcode.Internal

Methods

compare :: Ord16 -> Ord16 -> Ordering #

(<) :: Ord16 -> Ord16 -> Bool #

(<=) :: Ord16 -> Ord16 -> Bool #

(>) :: Ord16 -> Ord16 -> Bool #

(>=) :: Ord16 -> Ord16 -> Bool #

max :: Ord16 -> Ord16 -> Ord16 #

min :: Ord16 -> Ord16 -> Ord16 #

data OpcodeSpec Source #

An OpcodeSpec for a given Opcode contains the numeric encoding of the opcode, the number of items that this opcode removes from the stack (α), and the number of items added to the stack (δ). These values are documented in the Ethereum Yellow Paper.

Examples of OpcodeSpecs:

--         Hex  α δ
OpcodeSpec 0x01 2 1 "add"
OpcodeSpec 0x60 0 1 "push1 255"
OpcodeSpec 0x61 0 1 "push2 256"

Constructors

OpcodeSpec 

Fields

Instances

Instances details
Eq OpcodeSpec Source # 
Instance details

Defined in EVM.Opcode.Internal

Show OpcodeSpec Source # 
Instance details

Defined in EVM.Opcode.Internal

opcodeSpec :: Opcode' j -> OpcodeSpec Source #

Given an Opcode', produce its OpcodeSpec.

For DUP, SWAP and LOG this depends on the specific variant, and for PUSH it depends on the size of the constant being pushed.

push' :: Word256 -> (Word8, [Word8]) Source #

Convert the constant argument of a PUSH to the opcode encoding (0x60--0x7f) and its constant split into Word8 segments.

pattern DUP1 :: forall j. Opcode' j Source #

Use DUP1 instead of DUP Ord16_1.

pattern DUP2 :: forall j. Opcode' j Source #

Use DUP2 instead of DUP Ord16_2.

pattern DUP3 :: forall j. Opcode' j Source #

Use DUP3 instead of DUP Ord16_3.

pattern DUP4 :: forall j. Opcode' j Source #

Use DUP4 instead of DUP Ord16_4.

pattern DUP5 :: forall j. Opcode' j Source #

Use DUP5 instead of DUP Ord16_5.

pattern DUP6 :: forall j. Opcode' j Source #

Use DUP6 instead of DUP Ord16_6.

pattern DUP7 :: forall j. Opcode' j Source #

Use DUP7 instead of DUP Ord16_7.

pattern DUP8 :: forall j. Opcode' j Source #

Use DUP8 instead of DUP Ord16_8.

pattern DUP9 :: forall j. Opcode' j Source #

Use DUP9 instead of DUP Ord16_9.

pattern DUP10 :: forall j. Opcode' j Source #

Use DUP10 instead of DUP Ord16_10.

pattern DUP11 :: forall j. Opcode' j Source #

Use DUP11 instead of DUP Ord16_11.

pattern DUP12 :: forall j. Opcode' j Source #

Use DUP12 instead of DUP Ord16_12.

pattern DUP13 :: forall j. Opcode' j Source #

Use DUP13 instead of DUP Ord16_13.

pattern DUP14 :: forall j. Opcode' j Source #

Use DUP14 instead of DUP Ord16_14.

pattern DUP15 :: forall j. Opcode' j Source #

Use DUP15 instead of DUP Ord16_15.

pattern DUP16 :: forall j. Opcode' j Source #

Use DUP16 instead of DUP Ord16_16.

pattern SWAP1 :: forall j. Opcode' j Source #

Use SWAP1 instead of SWAP Ord16_1, etc.

pattern SWAP2 :: forall j. Opcode' j Source #

Use SWAP2 instead of SWAP Ord16_2, etc.

pattern SWAP3 :: forall j. Opcode' j Source #

Use SWAP3 instead of SWAP Ord16_3, etc.

pattern SWAP4 :: forall j. Opcode' j Source #

Use SWAP4 instead of SWAP Ord16_4, etc.

pattern SWAP5 :: forall j. Opcode' j Source #

Use SWAP5 instead of SWAP Ord16_5, etc.

pattern SWAP6 :: forall j. Opcode' j Source #

Use SWAP6 instead of SWAP Ord16_6, etc.

pattern SWAP7 :: forall j. Opcode' j Source #

Use SWAP7 instead of SWAP Ord16_7, etc.

pattern SWAP8 :: forall j. Opcode' j Source #

Use SWAP8 instead of SWAP Ord16_8, etc.

pattern SWAP9 :: forall j. Opcode' j Source #

Use SWAP9 instead of SWAP Ord16_9, etc.

pattern SWAP10 :: forall j. Opcode' j Source #

Use SWAP10 instead of SWAP Ord16_10, etc.

pattern SWAP11 :: forall j. Opcode' j Source #

Use SWAP11 instead of SWAP Ord16_11, etc.

pattern SWAP12 :: forall j. Opcode' j Source #

Use SWAP12 instead of SWAP Ord16_12, etc.

pattern SWAP13 :: forall j. Opcode' j Source #

Use SWAP13 instead of SWAP Ord16_13, etc.

pattern SWAP14 :: forall j. Opcode' j Source #

Use SWAP14 instead of SWAP Ord16_14, etc.

pattern SWAP15 :: forall j. Opcode' j Source #

Use SWAP15 instead of SWAP Ord16_15, etc.

pattern SWAP16 :: forall j. Opcode' j Source #

Use SWAP16 instead of SWAP Ord16_16, etc.

pattern LOG0 :: forall j. Opcode' j Source #

Use LOG0 instead of LOG Ord5_0.

pattern LOG1 :: forall j. Opcode' j Source #

Use LOG1 instead of LOG Ord5_1.

pattern LOG2 :: forall j. Opcode' j Source #

Use LOG2 instead of LOG Ord5_2.

pattern LOG3 :: forall j. Opcode' j Source #

Use LOG3 instead of LOG Ord5_3.

pattern LOG4 :: forall j. Opcode' j Source #

Use LOG4 instead of LOG Ord5_4.