opcode

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Type

type Type uint8
const (

	// Pop the first two items in the stack.
	// Add popped two items and push to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a+b]
	// [x]      [x]
	//
	Add Type = 0x01

	// Pop the first two items in the stack.
	// Multiply popped two items and push to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a*b]
	// [x]      [x]
	//
	Mul Type = 0x02

	// Pop the first two items in the stack.
	// Subtract popped two items and push to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a-b]
	// [x]      [x]
	//
	Sub Type = 0x03

	// Pop the first two items in the stack.
	// Divide popped two items and push to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a/b]
	// [x]      [x]
	//
	Div Type = 0x04

	// Pop the first two items in the stack.
	// Mod popped two items and push to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a%b]
	// [x]      [x]
	//
	Mod Type = 0x05

	// Pop the first two items in the stack.
	// Calculate bit-and popped two items and push to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a&b]
	// [x]      [x]
	//
	And Type = 0x06

	// Pop the first two items in the stack.
	// Calculate bit-or popped two items and push to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a|b]
	// [x]      [x]
	//
	Or Type = 0x07

	// Pop the first two items in the stack.
	// Check if the left operand(first popped item) is less than the right operand(second popped item).
	// If it is true, push true to the stack. If not push false to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a<b]
	// [x]      [x]
	//
	LT Type = 0x10

	// Pop the first two items in the stack.
	// Check if the left operand(first popped item) is equal to or less than the right operand(second popped item).
	// If it is true, push true to the stack. If not push false to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a<=b]
	// [x]      [x]
	//
	LTE Type = 0x11

	// Pop the first two items in the stack.
	// Check if the left operand(first popped item) is greater than the right operand(second popped item).
	// If it is true, push true to the stack. If not push false to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a>b]
	// [x]      [x]
	//
	GT Type = 0x12

	// Pop the first two items in the stack.
	// Check if the left operand(first popped item) is equal to or greater than the right operand(second popped item).
	// If it is true, push true to the stack. If not push false to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a>=b]
	// [x]      [x]
	//
	GTE Type = 0x13

	// Pop the first two items in the stack.
	// Check if the left operand(first popped item) is equal to the right operand(second popped item).
	// If it is true, push true to the stack. If not push false to the stack.
	//
	// Ex)
	// [a]
	// [b]  ==> [a == b]
	// [x]      [x]
	//
	EQ Type = 0x14

	// Pop the first item in the stack.
	// Reverse the sign and push it to the stack.
	//
	// Ex)
	// [a]       [~a]
	// [b]  ==>  [b]
	// [x]       [x]
	//
	NOT Type = 0x15

	// Pop the first item in the stack.
	// minus the value and push it to the stack.
	//
	// Ex)
	// [a]       [-a]
	// [b]  ==>  [b]
	// [x]       [x]
	//
	Minus Type = 0x16

	// Pop the first item in the stack.
	//
	// Ex)
	// [a]
	// [b]  ==>  [b]
	// [x]       [x]
	//
	Pop Type = 0x20

	// Push the 32bits(uint32) item .
	//
	// Ex)
	//           [a]
	// [b]  ==>  [b]
	// [x]       [x]
	//
	Push Type = 0x21

	// Pop the first item in the stack.
	// Load a value from memory and push it to the stack
	//
	// Ex)
	// [offset]
	// [size]         [memory[offset:offset+size]]
	// [x]       ==>  [x]
	// [y]            [y]
	//
	Mload Type = 0x22

	// Pop the first two items in the stack.
	// Store the value with the first item(offset) as the offset of the memory.
	//
	// Ex)
	// [offset]
	// [size]
	// [value]   ==>
	// [y]            [y]
	//
	// memory[offset:offset+size] = value
	Mstore Type = 0x23

	// Set memory size
	//
	// Ex)
	//
	// [size]  ==>
	// [y]            [y]
	//
	// memory[offset:offset+size] = value
	Msize Type = 0x24

	// Get the function selector information in the CallFunc.
	// `Func` data is 4bytes of Keccak(function(params))
	//
	// Ex)
	//           [CallFunc.Func]
	// [x]  ==>  [x]
	// [y]       [y]
	// [x] is 4byte which encoded as function selector
	LoadFunc Type = 0x25

	// Get the function arguments in the CallFunc.
	// 'Args' is arguments encoded as a bytes value according to abi.
	// Args's first 4 bytes is pointing to encoded size and value.
	// Ex)
	//
	// [index]  ==>  [Callfunc.Args[index]]
	// [y]           [y]
	LoadArgs Type = 0x26

	// Jump to position at which function was called
	// Ex)
	// [value]
	// [funcSel]
	// [position]  ==>  [value]
	// [y]              [y]
	Returning Type = 0x27

	// pop the data which present specific pc to jump
	// The opcode pointed to by pc must be JumpDst.
	Jump Type = 0x28

	// jumpDst should be where the jump will be.
	JumpDst Type = 0x29

	// Pop the first two items in the stack.
	// First item pointed to where to jump.
	// Second item should be bool data that decide to jump.
	// If second item is false, jump to first item(pc) pointed to
	Jumpi Type = 0x30

	// Duplicate data that exists at the top of the stack.
	//
	// Ex)
	//           [a]
	// [a]  ==>  [a]
	// [b]       [b]
	DUP Type = 0x31

	// Swap the first two items in the stack
	//
	// Ex)
	//
	// [a]       [b]
	// [b]  ==>  [a]
	// [c]       [c]
	SWAP Type = 0x32

	// Jump to last position (Terminate the contract)
	Exit Type = 0x33
)

func (Type) String

func (p Type) String() (string, error)

Change the bytecode of an opcode to string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL