vm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: Apache-2.0 Imports: 12 Imported by: 7

Documentation

Index

Constants

View Source
const CodeSaveFrequency = 2
View Source
const MaxAuxStackPops = 1
View Source
const MaxStackPops = 3

Variables

View Source
var HashOfHaltedMachine [32]byte
View Source
var HashOfLastInstruction [32]byte
View Source
var HashOfSizeExceptionMachine [32]byte
View Source
var Instructions = []Instruction(nil)

Functions

func Equal

func Equal(x, y *Machine) (bool, string)

Types

type DivideByZeroError

type DivideByZeroError struct {
}

func (DivideByZeroError) Error

func (w DivideByZeroError) Error() string

type EmptyStackError

type EmptyStackError struct {
	// contains filtered or unexported fields
}

func (EmptyStackError) Error

func (w EmptyStackError) Error() string

type ErrorInstructionError

type ErrorInstructionError struct {
}

func (ErrorInstructionError) Error

func (w ErrorInstructionError) Error() string

type Instruction

type Instruction struct {
	// contains filtered or unexported fields
}

func (Instruction) GetCode

func (insn Instruction) GetCode() code.Opcode

func (Instruction) GetName

func (insn Instruction) GetName() string

type Machine

type Machine struct {
	// contains filtered or unexported fields
}

func NewMachine

func NewMachine(opCodes []value.Operation, staticVal value.Value, warn bool, sizeLimit int64) *Machine

func RestoreMachine

func RestoreMachine(opCodes []value.Operation, stackVal, auxStackVal, registerVal, staticVal, pcVal, errHandlerVal value.CodePointValue, sizeLimit int64) *Machine

func (*Machine) AuxStack

func (m *Machine) AuxStack() stack.Stack

func (*Machine) Clone

func (m *Machine) Clone() *Machine

func (*Machine) Context

func (m *Machine) Context() MachineContext

func (*Machine) ErrorStop

func (m *Machine) ErrorStop()

func (*Machine) GetAllOperations

func (m *Machine) GetAllOperations() []value.Operation

func (*Machine) GetErrHandler

func (m *Machine) GetErrHandler() value.CodePointValue

func (*Machine) GetOperation

func (m *Machine) GetOperation() value.Operation

func (*Machine) GetPC

func (m *Machine) GetPC() value.Value

func (*Machine) GetSizeLimit

func (m *Machine) GetSizeLimit() int64

func (*Machine) Halt

func (m *Machine) Halt()

func (*Machine) Hash

func (m *Machine) Hash() [32]byte

func (*Machine) HaveSizeException

func (m *Machine) HaveSizeException() bool

func (*Machine) IncrPC

func (m *Machine) IncrPC()

func (*Machine) IsErrored

func (m *Machine) IsErrored() bool

func (*Machine) IsHalted

func (m *Machine) IsHalted() bool

func (*Machine) Log

func (m *Machine) Log(val value.Value)

func (*Machine) MarshalForProof

func (m *Machine) MarshalForProof(wr io.Writer) error

func (*Machine) PrintState

func (m *Machine) PrintState()

func (*Machine) Register

func (m *Machine) Register() *MachineValue

func (*Machine) Run

func (m *Machine) Run(maxSteps int32) int32

run up to maxSteps steps, stop earlier if halt or advise instruction, return number of insns actually run, and advise string or ""

func (*Machine) RunUntilStop

func (m *Machine) RunUntilStop()

func (*Machine) SetContext

func (m *Machine) SetContext(mc MachineContext)

func (*Machine) SetPC

func (m *Machine) SetPC(iv value.Value) error

func (*Machine) Stack

func (m *Machine) Stack() stack.Stack

func (*Machine) Static

func (m *Machine) Static() *MachineValue

func (*Machine) Warn

func (m *Machine) Warn(str string)

type MachineContext

type MachineContext interface {
	CanSpend(tokenType value.IntValue, currency value.IntValue) bool
	Send(data value.Value, tokenType value.IntValue, currency value.IntValue, dest value.IntValue) error
	ReadInbox() value.Value
	GetTimeBounds() value.Value
	NotifyStep()
	LoggedValue(value.Value) error

	OutMessageCount() int
}

type MachineNoContext

type MachineNoContext struct{}

func (*MachineNoContext) CanSpend

func (m *MachineNoContext) CanSpend(tokenType value.IntValue, currency value.IntValue) bool

func (*MachineNoContext) GetTimeBounds

func (m *MachineNoContext) GetTimeBounds() value.Value

func (*MachineNoContext) LoggedValue

func (m *MachineNoContext) LoggedValue(data value.Value) error

func (*MachineNoContext) NotifyStep

func (m *MachineNoContext) NotifyStep()

func (*MachineNoContext) OutMessageCount

func (m *MachineNoContext) OutMessageCount() int

func (*MachineNoContext) ReadInbox

func (m *MachineNoContext) ReadInbox() value.Value

func (*MachineNoContext) Send

func (m *MachineNoContext) Send(data value.Value, tokenType value.IntValue, currency value.IntValue, dest value.IntValue) error

type MachinePC

type MachinePC struct {
	// contains filtered or unexported fields
}

func NewMachinePC

func NewMachinePC(insns []value.Operation, handler WarningHandler) *MachinePC

func (*MachinePC) Equal

func (s *MachinePC) Equal(y *MachinePC) (bool, string)

func (MachinePC) GetCurrentCodePointHash

func (m MachinePC) GetCurrentCodePointHash() [32]byte

func (MachinePC) GetCurrentInsn

func (m MachinePC) GetCurrentInsn() value.Operation

func (MachinePC) GetCurrentInsnName

func (m MachinePC) GetCurrentInsnName() string

func (MachinePC) GetPC

func (m MachinePC) GetPC() value.CodePointValue

func (*MachinePC) IncrPC

func (m *MachinePC) IncrPC() error

func (*MachinePC) SetPCForced

func (m *MachinePC) SetPCForced(iv value.Value) error

type MachineStatus

type MachineStatus int
const (
	MACHINE_EXTENSIVE MachineStatus = iota
	MACHINE_ERRORSTOP
	MACHINE_HALT
)

type MachineValue

type MachineValue struct {
	// contains filtered or unexported fields
}

func NewMachineValue

func NewMachineValue(val value.Value) *MachineValue

func (*MachineValue) Clone

func (r *MachineValue) Clone() *MachineValue

func (*MachineValue) Equal

func (r *MachineValue) Equal(comp *MachineValue) (bool, string)

func (*MachineValue) Get

func (r *MachineValue) Get() value.Value

func (*MachineValue) ProofValue

func (r *MachineValue) ProofValue() value.Value

func (*MachineValue) Set

func (r *MachineValue) Set(value value.Value)

func (*MachineValue) Size

func (r *MachineValue) Size() int64

func (*MachineValue) StateValue

func (r *MachineValue) StateValue() value.Value

type PopTypeWarning

type PopTypeWarning struct {
	// contains filtered or unexported fields
}

func (PopTypeWarning) Error

func (w PopTypeWarning) Error() string

type SilentWarningHandler

type SilentWarningHandler struct {
	// contains filtered or unexported fields
}

func NewSilentWarningHandler

func NewSilentWarningHandler() *SilentWarningHandler

func (*SilentWarningHandler) AnyWarnings

func (hand *SilentWarningHandler) AnyWarnings() bool

func (*SilentWarningHandler) Clone

func (hand *SilentWarningHandler) Clone() WarningHandler

func (*SilentWarningHandler) SwitchMachinePC

func (hand *SilentWarningHandler) SwitchMachinePC(m *MachinePC)

func (*SilentWarningHandler) Warn

func (hand *SilentWarningHandler) Warn(wstr string)

type StackMods

type StackMods struct {
	// contains filtered or unexported fields
}

func NewStackMods

func NewStackMods(pops, pushes int) StackMods

func PopAuxStack

func PopAuxStack(m *Machine, mods StackMods) (value.Value, StackMods, error)

func PopStackBox

func PopStackBox(m *Machine, mods StackMods) (value.Value, StackMods, error)

func PopStackCodePoint

func PopStackCodePoint(m *Machine, mods StackMods) (value.CodePointValue, StackMods, error)

func PopStackInt

func PopStackInt(m *Machine, mods StackMods) (value.IntValue, StackMods, error)

func PopStackTuple

func PopStackTuple(m *Machine, mods StackMods) (value.TupleValue, StackMods, error)

func PopStackValue

func PopStackValue(m *Machine, mods StackMods) (value.Value, StackMods, error)

func PushStackBox

func PushStackBox(m *Machine, mods StackMods, b value.Value) StackMods

func PushStackCodePoint

func PushStackCodePoint(m *Machine, mods StackMods, v value.CodePointValue) StackMods

func PushStackInt

func PushStackInt(m *Machine, mods StackMods, v value.IntValue) StackMods

func PushStackTuple

func PushStackTuple(m *Machine, mods StackMods, v value.TupleValue) StackMods

func RunInstruction

func RunInstruction(m *Machine, op value.Operation) (StackMods, error)

type VMBlockedError

type VMBlockedError struct{}

func (VMBlockedError) Error

func (w VMBlockedError) Error() string

type VerboseWarningHandler

type VerboseWarningHandler struct {
	// contains filtered or unexported fields
}

func NewVerboseWarningHandler

func NewVerboseWarningHandler(m *MachinePC) *VerboseWarningHandler

func (*VerboseWarningHandler) AnyWarnings

func (hand *VerboseWarningHandler) AnyWarnings() bool

func (*VerboseWarningHandler) Clone

func (hand *VerboseWarningHandler) Clone() WarningHandler

func (*VerboseWarningHandler) SwitchMachinePC

func (hand *VerboseWarningHandler) SwitchMachinePC(m *MachinePC)

func (*VerboseWarningHandler) Warn

func (hand *VerboseWarningHandler) Warn(wstr string)

type WarningHandler

type WarningHandler interface {
	AnyWarnings() bool
	Warn(string)
	Clone() WarningHandler
	SwitchMachinePC(stack *MachinePC)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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