state

package
v0.0.9-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FLAG_READIN = iota
	FLAG_INMATCH
	FLAG_TERMINATE
	FLAG_DIRTY
	FLAG_WAIT
	FLAG_LOADFAIL
	FLAG_USERSTART = 8
)

Variables

This section is empty.

Functions

func IsWriteableFlag

func IsWriteableFlag(flag uint32) bool

Types

type FlagDebugger

type FlagDebugger struct {
}

type IndexError

type IndexError struct {
}

func (*IndexError) Error

func (err *IndexError) Error() string

type State

type State struct {
	Code     []byte   // Pending bytecode to execute
	ExecPath []string // Command symbols stack
	BitSize  uint32   // size of (32-bit capacity) bit flag byte array
	SizeIdx  uint16
	Flags    []byte // Error state
	Moves    uint32 // Number of times navigation has been performed
	// contains filtered or unexported fields
}

State holds the command stack, error condition of a unique execution session.

It also holds cached values for all results of executed symbols.

Cached values are linked to the command stack level it which they were loaded. When they go out of scope they are freed.

Values must be mapped to a level in order to be available for retrieval and count towards size

It can hold a single argument, which is freed once it is read

Symbols are loaded with individual size limitations. The limitations apply if a load symbol is updated. Symbols may be added with a 0-value for limits, called a "sink." If mapped, the sink will consume all net remaining size allowance unused by other symbols. Only one sink may be mapped per level.

Symbol keys do not count towards cache size limitations.

8 first flags are reserved.

func NewState

func NewState(BitSize uint32) State

NewState creates a new State object with BitSize number of error condition states in ADDITION to the 8 builtin flags.

func (*State) AppendCode

func (st *State) AppendCode(b []byte) error

Appendcode adds the given bytecode to the end of the existing code.

func (*State) Depth

func (st *State) Depth() uint8

Depth returns the current call stack depth.

func (*State) Down

func (st *State) Down(input string) error

Down adds the given symbol to the command stack.

Clears mapping and sink.

func (*State) FlagBitSize

func (st *State) FlagBitSize() uint32

FlagBitSize reports the amount of bits available in the bit field index.

func (*State) FlagByteSize

func (st *State) FlagByteSize() uint8

FlagBitSize reports the amount of bits available in the bit field index.

func (*State) GetCode

func (st *State) GetCode() ([]byte, error)

Get the remaning cached bytecode

func (*State) GetFlag

func (st *State) GetFlag(bitIndex uint32) (bool, error)

GetFlag returns the state of the flag at the given bit field index.

Fails if bit field index is out of range.

func (*State) GetIndex

func (st *State) GetIndex(flags []byte) bool

GetIndex scans a byte slice in same order as in storage, and returns the index of the first set bit.

If the given byte slice is too small for the bit field bitsize, the check will terminate at end-of-data without error.

func (*State) GetInput

func (st *State) GetInput() ([]byte, error)

GetInput gets the most recent client input.

func (*State) MatchFlag

func (st *State) MatchFlag(sig uint32, invertMatch bool) (bool, error)

MatchFlag matches the current state of the given flag.

The flag is specified given its bit index in the bit field.

If invertMatch is set, a positive result will be returned if the flag is not set.

func (*State) Next

func (st *State) Next() (uint16, error)

Next moves to the next sink page index.

func (*State) Previous

func (st *State) Previous() (uint16, error)

Previous moves to the next sink page index.

Fails if try to move beyond index 0.

func (*State) ResetFlag

func (st *State) ResetFlag(bitIndex uint32) (bool, error)

ResetFlag resets the flag at the given bit field index.

Returns true if bit state was changed.

Fails if bitindex is out of range.

func (*State) Restart

func (st *State) Restart() error

Reset re-initializes the state to run from top node with accumulated client state.

func (*State) Same

func (st *State) Same()

func (*State) SetCode

func (st *State) SetCode(b []byte)

SetCode replaces the current bytecode with the given bytecode.

func (*State) SetFlag

func (st *State) SetFlag(bitIndex uint32) (bool, error)

SetFlag sets the flag at the given bit field index

Returns true if bit state was changed.

Fails if bitindex is out of range.

func (*State) SetInput

func (st *State) SetInput(input []byte) error

SetInput is used to record the latest client input.

func (*State) Sides

func (st *State) Sides() (bool, bool)

Sides informs the caller which index page options will currently succeed.

Two values are returned, for the "next" and "previous" options in that order. A false value means the option is not available in the current state.

func (State) String

func (st State) String() string

String implements String interface

func (*State) Top

func (st *State) Top() (bool, error)

Top returns true if currently at topmode node.

Fails if first Down() was never called.

func (*State) Up

func (st *State) Up() (string, error)

Up removes the latest symbol to the command stack, and make the previous symbol current.

Frees all symbols and associated values loaded at the previous stack level. Cache capacity is increased by the corresponding amount.

Clears mapping and sink.

Fails if called at top frame.

func (*State) Where

func (st *State) Where() (string, uint16)

Where returns the current active rendering symbol.

Jump to

Keyboard shortcuts

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