exec

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package exec defines execution state

Index

Constants

View Source
const (
	//PathwayUndefined represents non Selector component
	PathwayUndefined = Pathway(0)
	//PathwayDirect a path Selector has no pointer, nor slices nor map, precomputed Offset can be used for the fastest access
	PathwayDirect = Pathway(1)
	//PathwayRef a path Selector has at least on pointer or slice
	PathwayRef = Pathway(2)
)

Variables

This section is empty.

Functions

func RegisterSignature

func RegisterSignature(p reflect.Type)

RegisterSignature register caller or func signature type adapter

Types

type Caller

type Caller interface {
	Call(ptr unsafe.Pointer, args []*Operand) unsafe.Pointer
}

Caller converts internal call node to actual func call

func AsCaller

func AsCaller(fn interface{}) Caller

AsCaller returns a caller or nil

type Executor

type Executor struct {
	In  []string //params variable identity
	Out []string //result variable identity

	Init []interface{}
	// contains filtered or unexported fields
}

Executor abstraction holding execution plan (execution syntax tree) to execute it

func NewExecution

func NewExecution(compute internal.Compute, pool *sync.Pool, in []*Selector, out []*Selector) *Executor

NewExecution creates a new execution

func (*Executor) Exec

func (e *Executor) Exec(state *State)

Exec executes execution plan

func (*Executor) Func

func (e *Executor) Func() (interface{}, error)

func (*Executor) InAt

func (e *Executor) InAt(i int) *Selector

InAt returns in selector at position i

func (*Executor) NewState

func (e *Executor) NewState() *State

func (*Executor) OutAt

func (e *Executor) OutAt(i int) *Selector

OutAt returns out selector at position i

func (*Executor) Signature

func (e *Executor) Signature() reflect.Type

type Func

type Func interface {
	New(exec *Executor) interface{}
}

Func converts executor state to actual function

func AsFunc

func AsFunc(fn interface{}) Func

AsFunc returns func or nil

type New

type New func() *State

New function to create variable

func StateNew

func StateNew(dest reflect.Type, selectors []*Selector, tracker *Tracker, pool *sync.Pool) New

StateNew creates variables

type Operand

type Operand struct {
	*xunsafe.Type //result pointer type
	Offset        uintptr
	// contains filtered or unexported fields
}

Operand represents typed compute

func NewOperand

func NewOperand(xType *xunsafe.Type, offset uintptr, compute func(ptr unsafe.Pointer) unsafe.Pointer, selector *Selector, ptr unsafe.Pointer) *Operand

NewOperand creates an operand

func (*Operand) Compute

func (o *Operand) Compute(ptr unsafe.Pointer) unsafe.Pointer

Compute compute operan value

func (*Operand) SetValue

func (o *Operand) SetValue(ptr unsafe.Pointer, src interface{})

SetValue sets value

func (*Operand) SetValuePtr

func (o *Operand) SetValuePtr(ptr unsafe.Pointer, src unsafe.Pointer)

SetValuePtr set value ptr

func (*Operand) Validate

func (o *Operand) Validate() error

Validate checks if operand is valid

type Pathway

type Pathway uint8

Pathway defines Selector leaf more complex pathway

func NewPathway

func NewPathway(p Pathway) Pathway

NewPathway returns a pathway for bitmas

func SelectorPathway

func SelectorPathway(s *Selector) Pathway

SelectorPathway sets Selector pathway to pre computer fixed Offset as long it's not pointer,slice or map

func (Pathway) IsDirect

func (p Pathway) IsDirect() bool

IsDirect returns true if path can be access without pointer/slices

func (Pathway) IsRef

func (p Pathway) IsRef() bool

IsRef returns true if path has ancestor with pointer/slice

type Selector

type Selector struct {
	ID string
	*xunsafe.Field
	Pathway
	Slice       *xunsafe.Slice
	Index       *Operand
	IsErrorType bool
	//and Ancestors lookup need to take place to resolve data address
	Ancestors []*Selector
	Pos       uint16
	// contains filtered or unexported fields
}

Selector represent data selector

func (*Selector) Addr

func (s *Selector) Addr(pointer unsafe.Pointer) unsafe.Pointer

Addr returns Selector address

func (*Selector) IndexPointer

func (s *Selector) IndexPointer(ptr unsafe.Pointer, index int) unsafe.Pointer

IndexPointer returns slice item pointer

func (*Selector) Interface

func (s *Selector) Interface(ptr unsafe.Pointer) interface{}

Interface return an interface,

func (*Selector) Offset

func (s *Selector) Offset() uintptr

Offset returns Selector Offset

func (*Selector) SetInterface

func (s *Selector) SetInterface(ptr unsafe.Pointer, value interface{})

SetInterface sets interface, it takes a state pointer

func (*Selector) SetInterfaces added in v0.2.0

func (s *Selector) SetInterfaces(ptr unsafe.Pointer, value []interface{})

func (*Selector) SetValue

func (s *Selector) SetValue(ptr unsafe.Pointer, value interface{})

SetValue sets value, tt takes an upstream pointer

func (*Selector) Upstream

func (s *Selector) Upstream(ptr unsafe.Pointer) unsafe.Pointer

Upstream returns Ancestors pointer, excluding current Selector ogf

func (*Selector) UpstreamOffset

func (s *Selector) UpstreamOffset() uintptr

UpstreamOffset returns Selector Offset

func (*Selector) XPos

func (s *Selector) XPos() []uint16

XPos returns selector position including with ancestor

type Selectors

type Selectors []*Selector

Selectors represents selectors

func (Selectors) IDs

func (s Selectors) IDs() []string

IDs returns selector IDs

type State

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

State represents execution plan variables

func (*State) Bool

func (s *State) Bool(name string) (bool, error)

Bool returns boolean value or error for supplied variable name

func (*State) Float64

func (s *State) Float64(name string) (float64, error)

Float64 returns float64 value or error for supplied variable name

func (*State) Index

func (s *State) Index(name string) (int, error)

Index returns variable index for specified name

func (*State) Int

func (s *State) Int(name string) (int, error)

Int returns int or error for supplied variable name

func (*State) Interface

func (s *State) Interface() interface{}

func (*State) Pointer

func (s *State) Pointer() unsafe.Pointer

Pointer returns variables pointer

func (*State) Release

func (s *State) Release()

func (*State) Selector

func (s *State) Selector(name string) (*Selector, error)

Selector returns selector for a supploed name or error

func (*State) SetBool

func (s *State) SetBool(name string, value bool) error

SetBool set boolean value for supplied variable name or error if variable name is invalid

func (*State) SetBoolAt

func (s *State) SetBoolAt(idx int, value bool)

SetBoolAt set boolean value at selor position

func (*State) SetFloat64

func (s *State) SetFloat64(name string, value float64) error

SetFloat64 set float64 value for supplied variable name or error if variable name is invalid

func (*State) SetInt

func (s *State) SetInt(name string, value int) error

SetInt set int value

func (*State) SetString

func (s *State) SetString(name string, value string) error

SetString set value for supplied variable name or error if variable name is invalid

func (*State) SetStringAt

func (s *State) SetStringAt(index int, value string) error

SetStringAt set value for supplied variable index

func (*State) SetValue

func (s *State) SetValue(name string, value interface{}) error

SetValue sets value for

func (*State) SetValueAt

func (s *State) SetValueAt(idx int, value interface{})

SetValueAt set values at position

func (*State) String

func (s *State) String(name string) (string, error)

String set string value for supplied variable name or error if variable name is invalid

func (*State) Tracker

func (s *State) Tracker() *Tracker

func (*State) Value

func (s *State) Value(name string) (interface{}, error)

Value returns value for supplied name or error

func (*State) ValueAt

func (s *State) ValueAt(idx int) interface{}

ValueAt returns value for variable index

type Tracker

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

Tracker abstraction to track mutation

func NewTracker

func NewTracker(maxPos int) *Tracker

NewTracker creates a tracker

func (*Tracker) Any

func (t *Tracker) Any(mask Uint64s) bool

Any returns true if mask contain any changes

func (*Tracker) Clone

func (t *Tracker) Clone() *Tracker

func (*Tracker) Count

func (t *Tracker) Count() int

func (*Tracker) Has

func (t *Tracker) Has(pos uint16) bool

Has returns true if changes

func (*Tracker) Reset

func (t *Tracker) Reset()

Reset reset modification status

func (*Tracker) Set

func (t *Tracker) Set(positions []uint16)

Set sets mutation for filed pos

type Uint64s

type Uint64s []uint64

func (Uint64s) ClearBit

func (o Uint64s) ClearBit(pos int)

ClearBit clears bit at position in set

func (Uint64s) Count

func (o Uint64s) Count() int

Count return bit population count

func (Uint64s) HasBit

func (o Uint64s) HasBit(pos uint16) bool

HasBit returns true if a bit at position in set

func (Uint64s) Matches

func (o Uint64s) Matches(u Uint64s) bool

func (Uint64s) Or

func (o Uint64s) Or(set Uint64s) Uint64s

Or applies logical OR

func (*Uint64s) SetBit

func (o *Uint64s) SetBit(pos int)

SetBit sets bit at position in set

func (*Uint64s) SetBits

func (o *Uint64s) SetBits(positions []uint16)

SetBits sets bit at position in set

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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