qupla

package
v0.0.0-...-ff01800 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BOOL_TRUE  = 1
	BOOL_FALSE = -1
)

Variables

This section is empty.

Functions

func CharEncodeLutOutTrit

func CharEncodeLutOutTrit(trit []int8) byte

func GetConstValue

func GetConstValue(expr ExpressionInterface) (int, error)

func IsNullExpr

func IsNullExpr(e interface{}) bool

func MatchSizes

func MatchSizes(e1, e2 ExpressionInterface) error

func NewFunctionEntity

func NewFunctionEntity(sv *Supervisor, function *Function) (*Entity, error)

func RequireSize

func RequireSize(e ExpressionInterface, size int) error

func Trits3ToLutIdx

func Trits3ToLutIdx(trits Trits) int

Types

type ConcatExpr

type ConcatExpr struct {
	ExpressionBase
	// contains filtered or unexported fields
}

func NewConcatExpression

func NewConcatExpression(src string, args []ExpressionInterface) *ConcatExpr

func (*ConcatExpr) Copy

func (e *ConcatExpr) Copy() ExpressionInterface

func (*ConcatExpr) Eval

func (e *ConcatExpr) Eval(frame *EvalFrame, result Trits) bool

func (*ConcatExpr) GetAbraSite

func (e *ConcatExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*ConcatExpr) Size

func (e *ConcatExpr) Size() int

type CondExpr

type CondExpr struct {
	ExpressionBase
}

func (*CondExpr) Copy

func (e *CondExpr) Copy() ExpressionInterface

func (*CondExpr) Eval

func (e *CondExpr) Eval(frame *EvalFrame, result Trits) bool

func (*CondExpr) GetAbraSite

func (e *CondExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*CondExpr) Size

func (e *CondExpr) Size() int

type ConstExpression

type ConstExpression interface {
	ExpressionInterface
	GetConstValue() int
	GetConstName() string
}

type ConstTypeFieldInfo

type ConstTypeFieldInfo struct {
	Offset int
	Size   int
}

type ConstTypeInfo

type ConstTypeInfo struct {
	Fields map[string]*ConstTypeFieldInfo
	// contains filtered or unexported fields
}

func NewConstTypeInfo

func NewConstTypeInfo(name string, size int) *ConstTypeInfo

func (*ConstTypeInfo) Copy

func (*ConstTypeInfo) Eval

func (e *ConstTypeInfo) Eval(_ *EvalFrame, _ Trits) bool

func (*ConstTypeInfo) GetAbraSite

func (e *ConstTypeInfo) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*ConstTypeInfo) GetConstName

func (e *ConstTypeInfo) GetConstName() string

func (*ConstTypeInfo) GetConstValue

func (e *ConstTypeInfo) GetConstValue() int

func (*ConstTypeInfo) GetFieldInfo

func (e *ConstTypeInfo) GetFieldInfo(fldname string) (*ConstTypeFieldInfo, error)

func (*ConstTypeInfo) GetSource

func (e *ConstTypeInfo) GetSource() string

func (*ConstTypeInfo) GetSubexpressions

func (e *ConstTypeInfo) GetSubexpressions() []ExpressionInterface

func (*ConstTypeInfo) HasState

func (e *ConstTypeInfo) HasState() bool

func (*ConstTypeInfo) References

func (e *ConstTypeInfo) References(_ string) bool

func (*ConstTypeInfo) SetSubexpressions

func (e *ConstTypeInfo) SetSubexpressions(_ []ExpressionInterface)

func (*ConstTypeInfo) Size

func (e *ConstTypeInfo) Size() int

type ConstValue

type ConstValue struct {
	ExpressionBase
	// contains filtered or unexported fields
}

func NewConstValue

func NewConstValue(name string, value int) *ConstValue

func (*ConstValue) Copy

func (e *ConstValue) Copy() ExpressionInterface

func (*ConstValue) Eval

func (_ *ConstValue) Eval(_ *EvalFrame, _ Trits) bool

func (*ConstValue) GetAbraSite

func (e *ConstValue) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*ConstValue) GetConstName

func (e *ConstValue) GetConstName() string

func (*ConstValue) GetConstValue

func (e *ConstValue) GetConstValue() int

func (*ConstValue) GetTrits

func (e *ConstValue) GetTrits() Trits

func (*ConstValue) Size

func (e *ConstValue) Size() int

type EvalFrame

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

func (*EvalFrame) SaveStateVariables

func (frame *EvalFrame) SaveStateVariables()

type ExecStmt

type ExecStmt struct {
	ExpressionBase

	Expr ExpressionInterface // *FunctionExpr
	// contains filtered or unexported fields
}

func NewExecStmt

func NewExecStmt(src string, expr ExpressionInterface, isTest, isFloat bool, expected Trits, module *QuplaModule) *ExecStmt

func (*ExecStmt) GetIdx

func (ex *ExecStmt) GetIdx() int

func (*ExecStmt) GetName

func (ex *ExecStmt) GetName() string

func (*ExecStmt) GetRunResults

func (ex *ExecStmt) GetRunResults() *runSummary

func (*ExecStmt) HasState

func (ex *ExecStmt) HasState() bool

func (*ExecStmt) Run

func (ex *ExecStmt) Run(disp *Supervisor, repeat int) error

type ExpressionBase

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

func NewExpressionBase

func NewExpressionBase(source string) ExpressionBase

func (*ExpressionBase) AppendSubExpr

func (e *ExpressionBase) AppendSubExpr(se ExpressionInterface)

func (*ExpressionBase) GetSource

func (e *ExpressionBase) GetSource() string

func (*ExpressionBase) GetSubExpr

func (e *ExpressionBase) GetSubExpr(idx int) ExpressionInterface

func (*ExpressionBase) GetSubexpressions

func (e *ExpressionBase) GetSubexpressions() []ExpressionInterface

func (*ExpressionBase) HasState

func (e *ExpressionBase) HasState() bool

func (*ExpressionBase) HasSubExpr

func (e *ExpressionBase) HasSubExpr() bool

func (*ExpressionBase) NumSubExpr

func (e *ExpressionBase) NumSubExpr() int

func (*ExpressionBase) References

func (e *ExpressionBase) References(funName string) bool

func (*ExpressionBase) ReferencesSubExprs

func (e *ExpressionBase) ReferencesSubExprs(funName string) bool

func (*ExpressionBase) SetSubexpressions

func (e *ExpressionBase) SetSubexpressions(subExpr []ExpressionInterface)

type ExpressionInterface

type ExpressionInterface interface {
	Size() int
	Eval(*EvalFrame, Trits) bool
	References(string) bool
	HasState() bool
	Copy() ExpressionInterface // shallow copy
	GetSubexpressions() []ExpressionInterface
	SetSubexpressions([]ExpressionInterface)
	GetSource() string
	GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site
}

type FieldExpr

type FieldExpr struct {
	Offset int
	Size   int
}

type Function

type Function struct {
	Analyzed bool // finished analysis
	Joins    map[string]int
	Affects  map[string]int
	Name     string

	RetExpr           ExpressionInterface
	Sites             []*QuplaSite
	NumParams         int  // idx < NumParams represents parameter, idx >= represents local var (assign)
	BufLen            int  // total length of the local var buffer
	HasStateVariables bool // if has state vars itself

	InSize     int
	ParamSizes []int

	StateHashMap *StateHashMap
	// contains filtered or unexported fields
}

func NewFunction

func NewFunction(name string, size int, module *QuplaModule) *Function

func (*Function) AppendInline

func (def *Function) AppendInline(s string)

func (*Function) ArgSize

func (def *Function) ArgSize() int

func (*Function) CheckArgSizes

func (def *Function) CheckArgSizes(args []ExpressionInterface) error

func (*Function) Eval

func (def *Function) Eval(frame *EvalFrame, result Trits) bool

func (*Function) GetAbraBranchBlock

func (def *Function) GetAbraBranchBlock(codeUnit *abra.CodeUnit) *abra.Block

func (*Function) GetAffectEnv

func (def *Function) GetAffectEnv() map[string]int

func (*Function) GetJoinEnv

func (def *Function) GetJoinEnv() map[string]int

func (*Function) GetLookupName

func (def *Function) GetLookupName() string

func (*Function) GetVarIdx

func (def *Function) GetVarIdx(name string) int

func (*Function) HasEnvStmt

func (def *Function) HasEnvStmt() bool

func (*Function) HasState

func (def *Function) HasState() bool

func (*Function) NewFuncExpressionWithNulls

func (def *Function) NewFuncExpressionWithNulls(callIndex byte) *FunctionExpr

mock expression with all null arguments

func (*Function) NextCallIndex

func (def *Function) NextCallIndex() byte

func (*Function) References

func (def *Function) References(funName string) bool

func (*Function) SetTraceLevel

func (def *Function) SetTraceLevel(traceLevel int)

func (*Function) Size

func (def *Function) Size() int

func (*Function) Stats

func (def *Function) Stats() map[string]int

func (*Function) VarByIdx

func (def *Function) VarByIdx(idx int) (*QuplaSite, error)

func (*Function) VarByName

func (def *Function) VarByName(name string) (*QuplaSite, error)

func (*Function) WasInline

func (def *Function) WasInline(s string) bool

type FunctionCalculator

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

func NewFunctionCalculator

func NewFunctionCalculator(function *Function) *FunctionCalculator

type FunctionExpr

type FunctionExpr struct {
	ExpressionBase
	FuncDef *Function
	// contains filtered or unexported fields
}

func NewFunctionExpr

func NewFunctionExpr(src string, funcDef *Function, callIndex uint8) *FunctionExpr

func (*FunctionExpr) Copy

func (*FunctionExpr) Eval

func (e *FunctionExpr) Eval(frame *EvalFrame, result Trits) bool

func (*FunctionExpr) GetAbraSite

func (e *FunctionExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*FunctionExpr) HasState

func (e *FunctionExpr) HasState() bool

func (*FunctionExpr) References

func (e *FunctionExpr) References(funName string) bool

func (*FunctionExpr) Size

func (e *FunctionExpr) Size() int

type LutDef

type LutDef struct {
	Name      string
	InputSize int
	// contains filtered or unexported fields
}

func NewLUTDef

func NewLUTDef(name string, inSize int, outSize int, lookupTable []Trits) *LutDef

func (*LutDef) GetBranch

func (lutDef *LutDef) GetBranch(numInputs int)

func (*LutDef) GetStringRepr

func (lutDef *LutDef) GetStringRepr() string

func (*LutDef) GetTritcode

func (lutDef *LutDef) GetTritcode() Trits

func (*LutDef) Lookup

func (lutDef *LutDef) Lookup(res, args Trits) bool

func (*LutDef) LookupTable

func (lutDef *LutDef) LookupTable() [27]Trits

lookup table adjusted for 3 inputs

func (*LutDef) Size

func (lutDef *LutDef) Size() int

type LutExpr

type LutExpr struct {
	ExpressionBase
	LutDef *LutDef
}

func (*LutExpr) Copy

func (e *LutExpr) Copy() ExpressionInterface

func (*LutExpr) Eval

func (e *LutExpr) Eval(frame *EvalFrame, result Trits) bool

func (*LutExpr) GetAbraSite

func (e *LutExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*LutExpr) Size

func (e *LutExpr) Size() int

type MergeExpr

type MergeExpr struct {
	ExpressionBase
}

func NewMergeExpression

func NewMergeExpression(src string, args []ExpressionInterface) *MergeExpr

func (*MergeExpr) Copy

func (e *MergeExpr) Copy() ExpressionInterface

func (*MergeExpr) Eval

func (e *MergeExpr) Eval(frame *EvalFrame, result Trits) bool

func (*MergeExpr) GetAbraSite

func (e *MergeExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*MergeExpr) Size

func (e *MergeExpr) Size() int

type NullExpr

type NullExpr struct {
	ExpressionBase
	// contains filtered or unexported fields
}

func NewNullExpr

func NewNullExpr(size int) *NullExpr

func (*NullExpr) Copy

func (e *NullExpr) Copy() ExpressionInterface

func (*NullExpr) Eval

func (e *NullExpr) Eval(_ *EvalFrame, _ Trits) bool

func (*NullExpr) GetAbraSite

func (e *NullExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*NullExpr) SetSize

func (e *NullExpr) SetSize(size int)

func (*NullExpr) Size

func (e *NullExpr) Size() int

type QuplaFieldExpr

type QuplaFieldExpr struct {
	ExpressionBase
}

TODO with fields expressions

func NewFieldExpr

func NewFieldExpr(src string, condExpr ExpressionInterface) *QuplaFieldExpr

func (*QuplaFieldExpr) Copy

func (*QuplaFieldExpr) Eval

func (e *QuplaFieldExpr) Eval(_ *EvalFrame, _ Trits) bool

func (*QuplaFieldExpr) GetAbraSite

func (e *QuplaFieldExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*QuplaFieldExpr) Size

func (e *QuplaFieldExpr) Size() int

type QuplaModule

type QuplaModule struct {
	Luts      map[string]*LutDef
	Functions map[string]*Function
	Execs     []*ExecStmt

	Environments StringSet
	// contains filtered or unexported fields
}

func NewQuplaModule

func NewQuplaModule(name string) *QuplaModule

func (*QuplaModule) AddExec

func (module *QuplaModule) AddExec(exec *ExecStmt)

func (*QuplaModule) AddFuncDef

func (module *QuplaModule) AddFuncDef(name string, funcDef *Function) error

func (*QuplaModule) AddLutDef

func (module *QuplaModule) AddLutDef(name string, lutDef *LutDef)

func (*QuplaModule) AttachExecs

func (module *QuplaModule) AttachExecs(disp *supervisor.Supervisor, fromIdx int, toIdx int, chain bool) []*ExecStmt

func (*QuplaModule) AttachToSupervisor

func (module *QuplaModule) AttachToSupervisor(sv *supervisor.Supervisor) bool

func (*QuplaModule) ExecByIdx

func (module *QuplaModule) ExecByIdx(idx int) *ExecStmt

func (*QuplaModule) FindExecs

func (module *QuplaModule) FindExecs(filterSubstr string) []*ExecStmt

func (*QuplaModule) FindFuncDef

func (module *QuplaModule) FindFuncDef(name string) *Function

func (*QuplaModule) FindFuncs

func (module *QuplaModule) FindFuncs(filterSubstr string) []*Function

func (*QuplaModule) FindLUTDef

func (module *QuplaModule) FindLUTDef(name string) (*LutDef, error)

func (*QuplaModule) GetAbra

func (module *QuplaModule) GetAbra(codeUnit *abra.CodeUnit)

func (*QuplaModule) GetName

func (module *QuplaModule) GetName() string

func (*QuplaModule) GetStat

func (module *QuplaModule) GetStat(key string) int

func (*QuplaModule) GetStateHashMap

func (module *QuplaModule) GetStateHashMap() *StateHashMap

func (*QuplaModule) GetTypeFieldInfo

func (module *QuplaModule) GetTypeFieldInfo(typeName, fldName string) (int64, int64, error)

func (*QuplaModule) IncStat

func (module *QuplaModule) IncStat(key string)

func (*QuplaModule) MarkStateful

func (module *QuplaModule) MarkStateful() (int, int)

func (*QuplaModule) PrintStats

func (module *QuplaModule) PrintStats()

func (*QuplaModule) RunExec

func (module *QuplaModule) RunExec(disp *supervisor.Supervisor, idx int, repeat int) error

func (*QuplaModule) RunExecs

func (module *QuplaModule) RunExecs(disp *supervisor.Supervisor, fromIdx int, toIdx int, chain bool) error

func (*QuplaModule) SetTraceLevel

func (module *QuplaModule) SetTraceLevel(traceLevel int, filterSubstr string) []*Function

type QuplaSite

type QuplaSite struct {
	Name     string
	Analyzed bool
	Idx      int
	Offset   int
	Size     int
	SliceEnd int // Offset + size precalculated
	IsState  bool
	IsParam  bool
	Assign   ExpressionInterface
	NumUses  int  // number of times referenced in the scope (by slice expressions)
	NotUsed  bool // optimized away
}

func (*QuplaSite) Eval

func (vi *QuplaSite) Eval(frame *EvalFrame) (Trits, bool)

func (*QuplaSite) GetAbraLookupName

func (vi *QuplaSite) GetAbraLookupName() string

func (*QuplaSite) IncNumUses

func (vi *QuplaSite) IncNumUses()

type QuplaTypeDef

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

type QuplaTypeField

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

type SizeofExpr

type SizeofExpr struct {
	ExpressionBase
	Value     int64
	TritValue Trits
}

func NewQuplaSizeofExpr

func NewQuplaSizeofExpr(value int64, tritValue Trits) *SizeofExpr

func (*SizeofExpr) Copy

func (e *SizeofExpr) Copy() ExpressionInterface

func (*SizeofExpr) Eval

func (e *SizeofExpr) Eval(_ *EvalFrame, result Trits) bool

func (*SizeofExpr) GetAbraSite

func (e *SizeofExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, _ string) *abra.Site

func (*SizeofExpr) Size

func (e *SizeofExpr) Size() int

type SliceExpr

type SliceExpr struct {
	ExpressionBase
	// contains filtered or unexported fields
}

func NewQuplaSliceExpr

func NewQuplaSliceExpr(site *QuplaSite, src string, offset, size int) *SliceExpr

func (*SliceExpr) Copy

func (e *SliceExpr) Copy() ExpressionInterface

func (*SliceExpr) Eval

func (e *SliceExpr) Eval(frame *EvalFrame, result Trits) bool

func (*SliceExpr) GetAbraSite

func (e *SliceExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*SliceExpr) GetAbraSiteForNonparamVar

func (e *SliceExpr) GetAbraSiteForNonparamVar(branch *abra.Branch, codeUnit *abra.CodeUnit, vi *QuplaSite) *abra.Site

func (*SliceExpr) Site

func (e *SliceExpr) Site() *QuplaSite

func (*SliceExpr) Size

func (e *SliceExpr) Size() int

type SliceInline

type SliceInline struct {
	ExpressionBase
	OrigSiteName string // original name
	Offset       int

	SliceEnd int
	NoSlice  bool
	// contains filtered or unexported fields
}

func NewSliceInline

func NewSliceInline(sliceExpr *SliceExpr, expr ExpressionInterface) *SliceInline

func (*SliceInline) Copy

func (e *SliceInline) Copy() ExpressionInterface

func (*SliceInline) Eval

func (e *SliceInline) Eval(frame *EvalFrame, result Trits) bool

func (*SliceInline) GetAbraSite

func (e *SliceInline) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*SliceInline) Size

func (e *SliceInline) Size() int

type StateHashMap

type StateHashMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type TypeExpr

type TypeExpr struct {
	ExpressionBase

	Fields []*FieldExpr
	// contains filtered or unexported fields
}

func NewQuplaTypeExpr

func NewQuplaTypeExpr(src string, size int) *TypeExpr

func (*TypeExpr) Copy

func (e *TypeExpr) Copy() ExpressionInterface

func (*TypeExpr) Eval

func (e *TypeExpr) Eval(frame *EvalFrame, result Trits) bool

func (*TypeExpr) GetAbraSite

func (e *TypeExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, lookupName string) *abra.Site

func (*TypeExpr) Size

func (e *TypeExpr) Size() int

type ValueExpr

type ValueExpr struct {
	ExpressionBase
	TritValue Trits
}

func NewValueExpr

func NewValueExpr(t Trits) *ValueExpr

func (*ValueExpr) Copy

func (e *ValueExpr) Copy() ExpressionInterface

func (*ValueExpr) Eval

func (e *ValueExpr) Eval(_ *EvalFrame, result Trits) bool

func (*ValueExpr) GetAbraSite

func (e *ValueExpr) GetAbraSite(branch *abra.Branch, codeUnit *abra.CodeUnit, _ string) *abra.Site

func (*ValueExpr) Size

func (e *ValueExpr) Size() int

Jump to

Keyboard shortcuts

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