core

package
v0.0.0-...-f022186 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	EACH0 = 1
	EACH1 = 2
)

values for ArgSpec.Each

View Source
const (
	Sig0 byte = iota + 1
	Sig1
	Sig2
	Sig3
	Sig4
)
View Source
const (
	AsEach = iota + 5
	AsEach1
	AsBlock
)
View Source
const (
	TsInitialBatch = 5
	TsThreshold    = 500
)

For timestamps with milliseconds up to TsThreshold, a client is allowed to increment the milliseconds TsInitialBatch times before requesting another timestamp. For timestamps with milliseconds >= TsThreshold, a client should use SuTimestamp incrementing extra. These values must match jSuneido.

View Source
const (
	PackFalse = iota
	PackTrue
	PackMinus
	PackPlus
	PackString
	PackDate
	PackObject
	PackRecord
)

Packed values start with one of the following type tags, except for the special case of a zero length string which is encoded as a zero length buffer. NOTE: this order is significant, it determines sorting

View Source
const E10 = uint64(1e10)
View Source
const E12 = uint64(1e12)
View Source
const E14 = uint64(1e14)
View Source
const E2 = uint64(1e2)
View Source
const E4 = uint64(1e4)
View Source
const E6 = uint64(1e6)
View Source
const E8 = uint64(1e8)
View Source
const GnSuneido = 1
View Source
const MaxArgs = 200

MaxArgs is the maximum number of arguments allowed

View Source
const MaxInstantiate = MaxSuInt
View Source
const MaxSuInt = math.MaxInt16
View Source
const MaxValues = 0x3fff
View Source
const MinSuInt = math.MinInt16

Variables

View Source
var ArgSpec0 = ArgSpec{Nargs: 0, Signature: Sig0}
View Source
var ArgSpec1 = ArgSpec{Nargs: 1, Signature: Sig1}
View Source
var ArgSpec2 = ArgSpec{Nargs: 2, Signature: Sig2}
View Source
var ArgSpec3 = ArgSpec{Nargs: 3, Signature: Sig3}
View Source
var ArgSpec4 = ArgSpec{Nargs: 4, Signature: Sig4}
View Source
var ArgSpecBlock = ArgSpec{Nargs: 1,
	Spec: []byte{0}, Names: []Value{SuStr("block")}}
View Source
var ArgSpecEach0 = ArgSpec{Nargs: 1, Each: EACH0}
View Source
var ArgSpecEach1 = ArgSpec{Nargs: 1, Each: EACH1}
View Source
var BlockBreak = BuiltinSuExcept("block:break")
View Source
var BlockContinue = BuiltinSuExcept("block:continue")
View Source
var BlockReturn = BuiltinSuExcept("block return")
View Source
var DateBegin = NewDate(1700, 1, 1, 0, 0, 0, 0)
View Source
var DateEnd = NewDate(3000, 1, 1, 0, 0, 0, 0)
View Source
var DbmsAuth = false
View Source
var DefaultNewMethod = &SuBuiltin0{func() Value { return nil },
	BuiltinParams{ParamSpec: ParamSpec0}}
View Source
var DefaultSingleQuotes = false
View Source
var EmptyObject = &SuObject{readonly: true}

EmptyObject is a readonly empty SuObject

View Source
var Exit func(code int)

Exit is injected by gSuneido

View Source
var GetDbms func() IDbms

GetDbms requires dependency injection

View Source
var Global typeGlobal

Global is used to group the global methods Would be cleaner to use a package but awkward dependencies. This approach doesn't seem to add any overhead.

View Source
var Interrupt func() bool // injected
View Source
var Libload = func(*Thread, string) (Value, any) { return nil, nil }

Libload requires dependency injection

View Source
var LibraryOverrides = &libraryOverrides{
	overrides: make(map[string]libOver),
	originals: make(map[string]Value)}
View Source
var LibsList atomics.Value[[]string]

LibsList is used by libload

View Source
var ParamSpec0 = ParamSpec{Nparams: 0, Signature: ^Sig0}
View Source
var ParamSpec1 = ParamSpec{Nparams: 1, Signature: ^Sig1}
View Source
var ParamSpec2 = ParamSpec{Nparams: 2, Signature: ^Sig2}
View Source
var ParamSpecAt = ParamSpec{Nparams: 1, Flags: []Flag{AtParam}}
View Source
var ParamSpecOptionalBlock = ParamSpec{Nparams: 1, Ndefaults: 1,
	Flags: []Flag{0}, Names: []string{"block"}, Values: []Value{False}}
View Source
var RunOnGoSide func() // injected

Functions

func AddInfo

func AddInfo(name string, ref any) struct{}

AddInfo registers a reference to a value. It is NOT thread-safe and should only be called during initialization. ref's should be thread-safe. The return type is to allow var _ = AddInfo("name", ref)

func Alert

func Alert(args ...any)

func AlertCancel

func AlertCancel(args ...any) bool

func AsStr

func AsStr(x Value) string

AsStr converts SuBool, SuInt, SuDnum, SuStr, SuConcat, SuExcept to string. Calls Value.AsStr and panics if it fails

func CompareSuTimestamp

func CompareSuTimestamp(d1, d2 SuTimestamp) int

func Disasm

func Disasm(fn *SuFunc, out outfn)

Disasm calls out for each disassembled byte code instruction in fn

func DisasmMixed

func DisasmMixed(fn *SuFunc, src string) string

DisasmMixed returns a listing of the source and its disassembled byte code

func DisasmOps

func DisasmOps(fn *SuFunc) string

DisasmOps returns the disassembled byte code for fn

func DisasmRaw

func DisasmRaw(code string, fn func(i int))

func Display

func Display(th *Thread, val Value) string

func EqualRows

func EqualRows(hdr1 *Header, r1 Row, hdr2 *Header, r2 Row, cols []string,
	th *Thread, st *SuTran) bool

EqualRows is used by Compatible

func ErrType

func ErrType(x Value) string

ErrType tweaks the Type to match cSuneido

func Fatal

func Fatal(args ...any)

func Fatal2

func Fatal2(string)

func IfInt

func IfInt(x Value) int

IfInt converts SuInt, SuDnum to int. Calls Value.IfInt and panics if it fails

func InfoList

func InfoList() []string

func InstantiateMax

func InstantiateMax(n int)

func LogInternalError

func LogInternalError(th *Thread, from string, e any)

LogInternalError logs the error and the call stacks, if an InternalError. It is used by dbmsserver

func LogUncaught

func LogUncaught(th *Thread, where string, e any)

func OpBool

func OpBool(x Value) bool

func Pack

func Pack(x Packable) string

Pack is a convenience function that packs a single Packable.

WARNING: It's possible to get a buffer overflow if a mutable value (e.g. object) is modified between/during PackSize and Pack.

func Pack2

func Pack2(x Packable) *pack.Encoder

func PackSize

func PackSize(v Value) int

PackSize returns the pack size of the value if it is Packable, else it panics

func PackValue

func PackValue(v Value) string

PackValue packs a Value if it is Packable, else it panics

func PackedCmpLower

func PackedCmpLower(s1, s2 string) int

PackedCmpLower compares strings with str.CmpLower and other values with strings.Compare

func PackedToLower

func PackedToLower(s string) string

PackedToLower applies str.ToLower to packed strings. Other types of values are unchanged.

func PrintStack

func PrintStack(cs *SuObject)

func RecLen

func RecLen(r []byte) int

func Show

func Show(v Value) string

Show is .String() plus for classes it shows their contents for functions it shows their parameters for containers it sorts by member

func SuInt

func SuInt(n int) *smi

SuInt converts an int to *smi which implements Value will panic if out of int16 range

Example
v := SuInt(123)
fmt.Printf("%d %s\n", v.toInt(), v.String())
Output:

123 123

func SuIntToInt

func SuIntToInt(x any) (int, bool)

SuIntToInt converts to int if its argument is *smi

func ToBool

func ToBool(x Value) bool

func ToDnum

func ToDnum(x Value) dnum.Dnum

ToDnum converts false (SuBool), "" (SuStr), SuInt, SuDnum to Dnum. Calls Value.ToDnum and panics if it fails

func ToIndex

func ToIndex(key Value) int

ToIndex is used by ranges and string[i]

func ToInt

func ToInt(x Value) int

ToInt converts false (SuBool), "" (SuStr), SuInt, SuDnum to int. Calls Value.ToInt and panics if it fails

func ToInt64

func ToInt64(x Value) int64

ToInt64 does ToDnum and ToInt64 and panics if it fails

func ToStr

func ToStr(x Value) string

ToStr converts SuStr, SuConcat, SuExcept to string. Calls Value.ToStr and panics if it fails

func ToStrOrString

func ToStrOrString(x Value) string

ToStrOrString returns either ToStr() or String() i.e. strings won't have quotes

func Unquoted

func Unquoted(k Value) string

func Warning

func Warning(args ...any)

func WithType

func WithType(x Value) string

WithType is used by the repl

func WrapPanic

func WrapPanic(e any, suffix string)

Types

type ActiveObserverList

type ActiveObserverList = list.List[activeObserver]

type ArgSpec

type ArgSpec struct {

	// Spec has one entry per named argument, indexing into Names
	Spec []byte

	// Names is the argument names from the calling function
	Names []Value

	// Nargs is the number of values on the stack.
	// Because of @args (each) it may not be the actual number of arguments.
	Nargs byte

	// Each is 1 for @args, 2 for @+1args, 0 otherwise
	Each byte

	// Signature is used for fast matching of simple Argspec to ParamSpec
	Signature byte
}

ArgSpec describes the arguments on the stack for a call See also ParamSpec

func (*ArgSpec) DropFirst

func (as *ArgSpec) DropFirst() *ArgSpec

func (*ArgSpec) Equal

func (as *ArgSpec) Equal(a2 *ArgSpec) bool

func (*ArgSpec) String

func (as *ArgSpec) String() string

func (*ArgSpec) Unnamed

func (as *ArgSpec) Unnamed() int

Unnamed returns the total number of un-named arguments. Not applicable with @args (each)

type ArgsIter

type ArgsIter func() (Value, Value)

func NewArgsIter

func NewArgsIter(as *ArgSpec, args []Value) ArgsIter

NewArgsIter returns an iterator function that can be called to return successive name,value pairs with name = nil for unnamed values It returns nil,nil when there are no more values

type BuiltinParams

type BuiltinParams struct {
	ParamSpec
}

func (*BuiltinParams) String

func (ps *BuiltinParams) String() string

func (*BuiltinParams) Type

func (*BuiltinParams) Type() types.Type

type Callable

type Callable interface {
	Call(th *Thread, this Value, as *ArgSpec) Value
}

Callable is returned by Lookup

func Lookup

func Lookup(th *Thread, methods Methods, gnUserDef int, method string) Callable

Lookup looks for a method first in a methods map, and then in a global user defined class returning nil if not found in either place

func UserDef

func UserDef(th *Thread, gnUserDef int, method string) Callable

type Container

type Container interface {
	Value
	Add(val Value)
	ListSize() int
	ListGet(i int) Value
	NamedSize() int
	Copy() Container
	Slice(n int) Container
	DeleteAll()
	Insert(at int, val Value)
	Erase(th *Thread, key Value) bool
	Delete(th *Thread, key Value) bool
	GetIfPresent(th *Thread, key Value) Value
	IsReadOnly() bool
	SetReadOnly()
	ArgsIter() func() (Value, Value)
	Iter2(list bool, named bool) func() (Value, Value)
	HasKey(key Value) bool
	ToObject() *SuObject
	ToRecord(th *Thread, hdr *Header) Record
	IsConcurrent() Value
}

Container is an interface to objects and records

func ToContainer

func ToContainer(x Value) Container

ToContainer converts to a Container or panics

type DbRec

type DbRec struct {
	Record
	Off uint64
}

DbRec is a Record along with its offset

type Dir

type Dir byte
const (
	Only Dir = '1'
	Next Dir = '+'
	Prev Dir = '-'
)

func (Dir) Reverse

func (dir Dir) Reverse() Dir

func (Dir) String

func (dir Dir) String() string

type Displayable

type Displayable interface {
	Display(th *Thread) string
}

type Findable

type Findable interface {
	// Finder applies fn to a MemBase and all its parents
	// stopping if fn returns something other than nil, and returning that value.
	// Implemented by SuClass and SuInstance
	Finder(th *Thread, fn func(v Value, mb *MemBase) Value) Value
}

type Flag

type Flag byte

Flag is a bit set of parameter options

const (
	AtParam Flag = 1 << iota
	DynParam
	DotParam
	PubParam
)

type Frame

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

Frame is the context for a function/method/block invocation.

type Gnum

type Gnum = int

Gnum is a reference to a global name/value 0 is invalid

type Header struct {

	// Fields is the physical fields, including deleted ("-")
	Fields [][]string
	// Columns is the logical fields
	Columns []string
	// contains filtered or unexported fields
}

Header specifies the fields (physical) and columns (logical) for a query

func JoinHeaders

func JoinHeaders(x, y *Header) *Header

JoinHeaders appends the fields, and unions the columns. It is used by Join and Union. WARNING: if field on one and rule on the other, the result will look like it's a field. See also: Header.Rules

func NewHeader

func NewHeader(fields [][]string, columns []string) *Header

func SimpleHeader

func SimpleHeader(fields []string) *Header

func (*Header) AppendDerived

func (hdr *Header) AppendDerived(fields []string) []string

func (*Header) Dup

func (hdr *Header) Dup() *Header

func (*Header) EqualRows

func (hdr *Header) EqualRows(r1, r2 Row, th *Thread, st *SuTran) bool

EqualRows is used by Project

func (*Header) GetFields

func (hdr *Header) GetFields() []string

GetFields returns a list of the fields, including deleted ("-"), without duplicates (e.g. from Join or Union)

func (*Header) HasDeleted

func (hdr *Header) HasDeleted() bool

func (*Header) HasField

func (hdr *Header) HasField(col string) bool

func (*Header) Physical

func (hdr *Header) Physical() []string

Physical is the fields without deleted ("-")

func (*Header) Rules

func (hdr *Header) Rules() []string

Rules is a list of the derived columns. i.e. columns that are not fields. WARNING: This is not exact after JoinHeaders (Join and Union). Rules will *not* include columns that are fields on one source and rules on the other source.

func (*Header) Schema

func (hdr *Header) Schema() []string

Schema is GetFields() plus derived columns with rules capitalized WARNING: This is not exact with Query2. Rules will *not* include columns that are rules on one source but fields on the other source.

type HmapValue

type HmapValue = hmap.Hmap[Value, Value, hmap.Meth[Value]]

type ICursor

type ICursor interface {
	IQueryCursor

	// Get returns the next or previous row from a cursor
	// and its table if the query is updateable
	Get(th *Thread, tran ITran, dir Dir) (Row, string)
}

ICursor is the interface to a database query, either local or client

type IDbms

type IDbms interface {
	// Admin executes a schema change (create, alter, drop)
	Admin(string, *Sviews)

	// Auth authorizes the connection with the server
	Auth(*Thread, string) bool

	// Check checks the database like -check
	// It returns "" or an error message.
	Check() string

	// Close ends a dbms connection
	Close()

	// Connections returns a list of the current server connections
	Connections() Value

	// Cursor is like a query but independent of any one transaction
	Cursor(query string, sv *Sviews) ICursor

	// Cursors returns the current number of cursors
	Cursors() int

	DisableTrigger(table string)
	EnableTrigger(table string)

	// Exec is used by the new style ServerEval(...)
	Exec(th *Thread, args Value) Value

	// Final returns the current number of final transactions
	Final() int

	// Get returns a single record, for Query1 (dir = One),
	// QueryFirst (dir = Next), or QueryLast (dir = Prev)
	Get(th *Thread, query string, dir Dir) (Row, *Header, string)

	// Info returns an object containing database information
	Info() Value

	// Kill terminates connections with the given session id.
	// It returns the count of connections ended.
	Kill(string) int

	// LibGet returns a list of definitions for name
	// alternating library name and definition
	// in Libraries() order
	LibGet(name string) []string

	// Libraries returns a list of the libraries currently in use
	Libraries() []string

	// Log writes to the server's error.log
	Log(string)

	// Nonce returns a random string from the server
	Nonce(*Thread) string

	// Run is used by the old style string.ServerEval()
	Run(th *Thread, code string) Value

	Schema(table string) string

	// SessionId sets and/or returns the session id for the current connection
	SessionId(th *Thread, id string) string

	// Size returns the current database size
	Size() uint64

	// Timestamp returns a guaranteed unique date/time
	Timestamp() SuDate

	// Token returns data to use with Auth
	Token() string

	// Transaction starts a transaction
	Transaction(update bool) ITran

	// Transactions returns a list of the outstanding transactions
	Transactions() *SuObject

	// Use removes a library from those in use
	Unuse(lib string) bool

	// Use adds a library to those in use
	Use(lib string) bool

	// Unwrap removes DbmsUnauth if DbmsAuth
	Unwrap() IDbms
}

IDbms is the interface to the dbms package. The two implementations, DbmsLocal and DbmsClient, are in the dbms package

type IQuery

type IQuery interface {
	IQueryCursor

	// Get returns the next or previous row from a query
	// and its table if the query is updateable
	Get(th *Thread, dir Dir) (Row, string)

	// Output outputs a record to a query
	Output(th *Thread, rec Record)
}

IQuery is the interface to a database query, either local or client

type IQueryCursor

type IQueryCursor interface {
	// Close ends a query
	Close()

	// Header returns the header (columns and fields) for the query
	Header() *Header

	// Keys returns the keys for the query (a list of comma separated strings)
	Keys() []string

	// Order returns the order for the query (a list of columns)
	Order() []string

	// Rewind resets the query to the beginning/end
	Rewind()

	// Strategy returns a description of the optimized query
	Strategy(formatted bool) string
}

type ISuQueryCursor

type ISuQueryCursor interface {
	Close()
	Columns() Value
	Keys() Value
	Order() Value
	Rewind()
	RuleColumns() Value
	Strategy(formatted bool) Value
}

ISuQueryCursor is the common interface to SuQuery and SuCursor

type ITran

type ITran interface {
	String() string

	// Abort rolls back the transaction
	Abort() string

	// Complete commits the transaction.
	// It returns "" on success, otherwise the conflict.
	Complete() string

	// Delete deletes a record
	Delete(th *Thread, table string, off uint64)

	// Get returns a single record, for Query1 (dir = One),
	// QueryFirst (dir = Next), or QueryLast (dir = Prev)
	Get(th *Thread, query string, dir Dir) (Row, *Header, string)

	// Query starts a query
	Query(query string, sv *Sviews) IQuery

	// Action executes an insert, update, or delete
	// and returns the number of records processed
	Action(th *Thread, action string) int

	// Update modifies a record
	Update(th *Thread, table string, off uint64, rec Record) uint64

	// ReadCount returns the number of reads done by the transaction
	ReadCount() int

	// WriteCount returns the number of writes done by the transaction
	WriteCount() int

	// Asof sets the date-time for the transaction if asof is non-zero,
	// and returns the date-time for the transaction,
	// with the date-times as unix milli
	Asof(int64) int64

	Num() int
}

ITran is the interface to a dbms transaction, either local (not implemented yet) or TranClient.

type Iter

type Iter interface {
	// Next returns nil when there are no more values
	Next() Value
	// Dup returns a copy of this Iter that starts at the beginning
	Dup() Iter
	Infinite() bool
	SetConcurrent()
	IsConcurrent() Value
	Instantiate() *SuObject
}

Iter is the internal type for iterators. See also: SuIter and wrapIter.

func IterAssocs

func IterAssocs(ob Container, list, named bool) Iter

func IterMembers

func IterMembers(ob Container, list, named bool) Iter

func IterValues

func IterValues(ob Container, list, named bool) Iter

type MayLock

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

MayLock can be embedded to provide locking. concurrent is set *before* an object is shared and doesn't change after that so it should not require atomic or locked access. Before concurrent is set, no locking is done.

func (*MayLock) IsConcurrent

func (x *MayLock) IsConcurrent() Value

func (*MayLock) Lock

func (x *MayLock) Lock() bool

func (*MayLock) SetConc

func (x *MayLock) SetConc() bool

SetConc returns true if it sets concurrent

func (*MayLock) SetConcurrent

func (x *MayLock) SetConcurrent()

func (*MayLock) Unlock

func (x *MayLock) Unlock() bool

type MemBase

type MemBase struct {
	Data map[string]Value
	MayLock
}

MemBase is the shared base for SuClass and SuInstance

func NewMemBase

func NewMemBase() MemBase

func (*MemBase) AddMembersTo

func (mb *MemBase) AddMembersTo(ob *SuObject)

func (*MemBase) Copy

func (mb *MemBase) Copy() MemBase

func (*MemBase) Has

func (mb *MemBase) Has(m string) bool

func (*MemBase) Size

func (mb *MemBase) Size() int

type Methods

type Methods = map[string]Callable

Methods is a map of method name strings to Values

var BaseMethods Methods

BaseMethods is initialized by the builtin package

var ClassMethods Methods

ClassMethods is initialized by the builtin package

var CursorMethods Methods

CursorMethods is initialized by the builtin package

var DateMethods Methods

DateMethods is initialized by the builtin package

var InstanceMethods Methods

InstanceMethods is initialized by the builtin package

var IntMethods Methods

IntMethods is initialized by the builtin package

var IterMethods Methods

IterMethods is set by builtin/iter.go

var NumMethods Methods

NumMethods is initialized by the builtin package

var ObjectMethods Methods

ObjectMethods is initialized by the builtin package

var ParamsMethods Methods

ParamsMethods is initialized by the builtin package

var QueryMethods Methods

QueryMethods is initialized by the builtin package

var RecordMethods Methods

RecordMethods is initialized by the builtin package

var RegexMethods Methods

RegexMethods is initialized by the builtin package

var SequenceMethods Methods

SequenceMethods is initialized by the builtin package

var StringMethods Methods

StringMethods is initialized by the builtin package

var SuExceptMethods Methods

SuExceptMethods is initialized by the builtin package

var SuFuncMethods Methods

SuFuncMethods is initialized by the builtin package

var SuneidoObjectMethods Methods

SuneidoObjectMethods is initialized by builtin/suneido.go

var TranMethods Methods

TranMethods is initialized by the builtin package

type Named

type Named interface {
	GetName() string
}

type Ord

type Ord int
const (
	OrdOther Ord
)

must match types

func Order

func Order(x Value) Ord

func PackedOrd

func PackedOrd(s string) Ord

func (Ord) String

func (o Ord) String() string

type Packable

type Packable interface {
	// PackSize returns the size (in bytes) of the packed value.
	// object/record set hash to detect nested changes.
	PackSize(hash *uint32) int
	// PackSize2 is used by object/record to handle nesting
	PackSize2(hash *uint32, stack packStack) int
	// Pack appends the value to the Encoder
	Pack(hash *uint32, buf *pack.Encoder)
}

Packable is the interface to packable values PackSize should be called prior to Pack since Pack methods assume capacity is sufficient and because PackSize does nesting limit check

type PackableValue

type PackableValue interface {
	Value
	Packable
}

func DateFromLiteral

func DateFromLiteral(s string) PackableValue

DateFromLiteral returns an SuDate or an SuTimestamp from the Suneido literal format yyyymmdd[.hhmm[ss[mmm[ccc]]]] It returns NilDate if the string is invalid.

func Int64Val

func Int64Val(n int64) PackableValue

Int64Val returns an SuInt if it fits, else a SuDnum

func IntVal

func IntVal(n int) PackableValue

IntVal returns an SuInt if it fits, else a SuDnum

type Packed

type Packed string

Packed is a Packable wrapper for an already packed value

func (Packed) Pack

func (p Packed) Pack(_ *uint32, buf *pack.Encoder)

func (Packed) PackSize

func (p Packed) PackSize(*uint32) int

func (Packed) PackSize2

func (p Packed) PackSize2(*uint32, packStack) int

type ParamSpec

type ParamSpec struct {
	ValueBase[sufunction]

	// Lib is the library that the function came from
	Lib string

	// Name for library records will be the record name;
	// for class methods, the method name;
	// if assigned to a local variable, the variable name.
	// It is primarily for debugging, i.e. call stack traces.
	// See also: Name(value) builtin function
	Name string

	// Values contains any literals in the function
	// starting with parameter defaults
	Values []Value

	// Flags specifies "types" of params
	Flags []Flag

	// Names normally starts with the parameters, followed by local variables
	Names []string

	// Nparams is the number of arguments required on the stack
	Nparams uint8

	// NDefaults is the number of default values for parameters
	// They are in the start of Values
	Ndefaults uint8

	// Offset is the location of the parameter names within Names
	// and the arguments within Locals
	// It is used for closure blocks, for normal functions it is 0
	// Offset is only required for parameters (or arguments),
	// it is not needed for local variables
	Offset uint8

	// Signature is used for fast matching of simple Argspec to ParamSpec
	Signature byte
}

ParamSpec describes the parameters of a function See also ArgSpec which describes the arguments of a function call It also serves as the basis for callables like SuFunc

func (*ParamSpec) Compare

func (ps *ParamSpec) Compare(other Value) int

func (*ParamSpec) Equal

func (ps *ParamSpec) Equal(other any) bool

func (*ParamSpec) GetName

func (ps *ParamSpec) GetName() string

func (*ParamSpec) Lookup

func (*ParamSpec) Lookup(_ *Thread, method string) Callable

func (*ParamSpec) ParamName

func (ps *ParamSpec) ParamName(i int) string

func (*ParamSpec) Params

func (ps *ParamSpec) Params() string

func (ParamSpec) SetConcurrent

func (ParamSpec) SetConcurrent()

func (*ParamSpec) Show

func (ps *ParamSpec) Show() string

func (*ParamSpec) String

func (ps *ParamSpec) String() string

type Record

type Record string

Record is an immutable record stored in a string using the same format as cSuneido and jSuneido.

NOTE: This is the post 2019 format using a two byte header.

It is used for storing data records in the database and in dumps and for transferring data records across the client-server protocol.

An empty Record is a single zero byte.

First two bytes are the type and the count of values, high two bits are the type followed by the total length (uint8, uint16, or uint32) followed by the offsets of the fields (uint8, uint16, or uint32) followed by the contents of the fields integers are stored big endian (most significant first)

func (Record) Count

func (r Record) Count() int

Count returns the number of values in the record

func (Record) GetRaw

func (r Record) GetRaw(i int) string

GetRaw returns one of the (usually packed) values

func (Record) GetStr

func (r Record) GetStr(i int) string

GetStr is a more direct method to get a packed string

func (Record) GetVal

func (r Record) GetVal(i int) Value

GetVal is a convenience method to get and unpack

func (Record) Len

func (r Record) Len() int

func (Record) String

func (r Record) String() string

func (Record) Truncate

func (r Record) Truncate(n int) Record

Truncate shortens records to n fields and removes empty trailing fields. If the record has n or less fields it is returned unchanged.

type RecordBuilder

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

RecordBuilder is used to construct records. Zero value is ready to use.

func (*RecordBuilder) Add

Add appends a Packable

func (*RecordBuilder) AddRaw

func (b *RecordBuilder) AddRaw(s string) *RecordBuilder

AddRaw appends a string containing an already packed value

func (*RecordBuilder) Build

func (b *RecordBuilder) Build() Record

func (*RecordBuilder) Trim

func (b *RecordBuilder) Trim() *RecordBuilder

Trim removes trailing empty fields

type Row

type Row []DbRec

Row is the result of database queries. It is a list of DbRec so that operations e.g. join can avoid building new records.

func JoinRows

func JoinRows(row1, row2 Row) Row

func (Row) Derived

func (row Row) Derived() int

Derived returns the total size of the non-database records (with no offset)

func (Row) GetRaw

func (row Row) GetRaw(hdr *Header, fld string) string

GetRaw handles _lower! but does NOT handle rules. It is used by SuRecord Get.

func (Row) GetRawVal

func (row Row) GetRawVal(hdr *Header, fld string, th *Thread, tran *SuTran) string

GetRawVal is like GetVal (i.e. handles rules) but returns a raw/packed value.

func (Row) GetVal

func (row Row) GetVal(hdr *Header, fld string, th *Thread, tran *SuTran) Value

GetVal is used by query summarize and expr.

  • returns "" for fld not in hdr.Columns
  • returns stored value for Fields (rule ignored)
  • calls rule for Columns not in Fields

func (Row) SameAs

func (row Row) SameAs(row2 Row) bool

SameAs returns true if the db records have the same Off's and derived records (with Off == 0) are equal. WARNING: this is not general equality, for that see EqualRows.

type Showable

type Showable interface {
	Show() string
}

type Status

type Status byte
const (
	NEW Status = iota
	OLD
	DELETED
)

type SuBool

type SuBool bool

SuBool is a boolean Value

func OpMatch

func OpMatch(th *Thread, x Value, y Value) SuBool

func (SuBool) AsStr

func (b SuBool) AsStr() (string, bool)

func (SuBool) Call

func (SuBool) Call(*Thread, Value, *ArgSpec) Value

func (SuBool) Compare

func (b SuBool) Compare(other Value) int

func (SuBool) Equal

func (b SuBool) Equal(other any) bool

func (SuBool) Get

func (SuBool) Get(*Thread, Value) Value

func (SuBool) GetPut

func (SuBool) GetPut(*Thread, Value, Value, func(x, y Value) Value, bool) Value

func (SuBool) Hash

func (b SuBool) Hash() uint32

func (SuBool) Hash2

func (b SuBool) Hash2() uint32

func (SuBool) IfInt

func (b SuBool) IfInt() (int, bool)

func (SuBool) Lookup

func (SuBool) Lookup(*Thread, string) Callable

func (SuBool) Not

func (b SuBool) Not() SuBool

func (SuBool) Pack

func (b SuBool) Pack(_ *uint32, buf *pack.Encoder)

func (SuBool) PackSize

func (SuBool) PackSize(*uint32) int

func (SuBool) PackSize2

func (SuBool) PackSize2(*uint32, packStack) int

func (SuBool) Put

func (SuBool) Put(*Thread, Value, Value)

func (SuBool) RangeLen

func (SuBool) RangeLen(int, int) Value

func (SuBool) RangeTo

func (SuBool) RangeTo(int, int) Value

func (SuBool) SetConcurrent

func (SuBool) SetConcurrent()

func (SuBool) String

func (b SuBool) String() string

func (SuBool) ToContainer

func (SuBool) ToContainer() (Container, bool)

func (SuBool) ToDnum

func (b SuBool) ToDnum() (dnum.Dnum, bool)

func (SuBool) ToInt

func (b SuBool) ToInt() (int, bool)

func (SuBool) ToStr

func (b SuBool) ToStr() (string, bool)

func (SuBool) Type

func (SuBool) Type() types.Type

type SuBuiltin

type SuBuiltin struct {
	Fn func(th *Thread, args []Value) Value
	BuiltinParams
}

SuBuiltin is a Value for a built in function

func (*SuBuiltin) Call

func (b *SuBuiltin) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin0

type SuBuiltin0 struct {
	Fn func() Value
	BuiltinParams
}

SuBuiltin0 is a Value for a builtin function with no arguments

func (*SuBuiltin0) Call

func (b *SuBuiltin0) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin1

type SuBuiltin1 struct {
	Fn func(a1 Value) Value
	BuiltinParams
}

SuBuiltin1 is a Value for a builtin function with one argument

func (*SuBuiltin1) Call

func (b *SuBuiltin1) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin2

type SuBuiltin2 struct {
	Fn func(a1, a2 Value) Value
	BuiltinParams
}

SuBuiltin2 is a Value for a builtin function with two arguments

func (*SuBuiltin2) Call

func (b *SuBuiltin2) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin3

type SuBuiltin3 struct {
	Fn func(a1, a2, a3 Value) Value
	BuiltinParams
}

SuBuiltin3 is a Value for a builtin function with three arguments

func (*SuBuiltin3) Call

func (b *SuBuiltin3) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin4

type SuBuiltin4 struct {
	Fn func(a1, a2, a3, a4 Value) Value
	BuiltinParams
}

SuBuiltin4 is a Value for a builtin function with four arguments

func (*SuBuiltin4) Call

func (b *SuBuiltin4) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin5

type SuBuiltin5 struct {
	Fn func(a1, a2, a3, a4, a5 Value) Value
	BuiltinParams
}

SuBuiltin5 is a Value for a builtin function with five arguments

func (*SuBuiltin5) Call

func (b *SuBuiltin5) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin6

type SuBuiltin6 struct {
	Fn func(a1, a2, a3, a4, a5, a6 Value) Value
	BuiltinParams
}

SuBuiltin6 is a Value for a builtin function with six arguments

func (*SuBuiltin6) Call

func (b *SuBuiltin6) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltin7

type SuBuiltin7 struct {
	Fn func(a1, a2, a3, a4, a5, a6, a7 Value) Value
	BuiltinParams
}

func (*SuBuiltin7) Call

func (b *SuBuiltin7) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuBuiltinMethod

type SuBuiltinMethod struct {
	Fn func(th *Thread, this Value, args []Value) Value
	BuiltinParams
}

SuBuiltinMethod is a Callable for a builtin method

func (*SuBuiltinMethod) Call

func (b *SuBuiltinMethod) Call(th *Thread, this Value, as *ArgSpec) Value

type SuBuiltinMethod0

type SuBuiltinMethod0 struct {
	SuBuiltin1
}

SuBuiltinMethod0 is a Callable for a builtin method with no arguments

func (*SuBuiltinMethod0) Call

func (b *SuBuiltinMethod0) Call(th *Thread, this Value, as *ArgSpec) Value

type SuBuiltinMethod1

type SuBuiltinMethod1 struct {
	SuBuiltin2
}

SuBuiltinMethod1 is a Callable for a builtin method with one argument

func (*SuBuiltinMethod1) Call

func (b *SuBuiltinMethod1) Call(th *Thread, this Value, as *ArgSpec) Value

type SuBuiltinMethod2

type SuBuiltinMethod2 struct {
	SuBuiltin3
}

SuBuiltinMethod2 is a Callable for a builtin method with two arguments

func (*SuBuiltinMethod2) Call

func (b *SuBuiltinMethod2) Call(th *Thread, this Value, as *ArgSpec) Value

type SuBuiltinMethod3

type SuBuiltinMethod3 struct {
	SuBuiltin4
}

SuBuiltinMethod3 is a Callable for a builtin method with two arguments

func (*SuBuiltinMethod3) Call

func (b *SuBuiltinMethod3) Call(th *Thread, this Value, as *ArgSpec) Value

type SuBuiltinMethodRaw

type SuBuiltinMethodRaw struct {
	Fn func(th *Thread, as *ArgSpec, this Value, args []Value) Value
	ParamSpec
}

SuBuiltinMethodRaw is a Callable for a builtin function with no massage

func (*SuBuiltinMethodRaw) Call

func (b *SuBuiltinMethodRaw) Call(th *Thread, this Value, as *ArgSpec) Value

func (*SuBuiltinMethodRaw) Type

func (b *SuBuiltinMethodRaw) Type() types.Type

type SuBuiltinRaw

type SuBuiltinRaw struct {
	Fn func(th *Thread, as *ArgSpec, args []Value) Value
	BuiltinParams
}

SuBuiltinRaw is a Value for a builtin function with no massage

func (*SuBuiltinRaw) Call

func (b *SuBuiltinRaw) Call(th *Thread, _ Value, as *ArgSpec) Value

type SuClass

type SuClass struct {
	ValueBase[*SuClass]

	Lib  string
	Name string
	MemBase
	Base Gnum
	// contains filtered or unexported fields
}

SuClass is a user defined (Suneido language) class. Classes are read-only so there is no locking.

func (*SuClass) Call

func (c *SuClass) Call(th *Thread, this Value, as *ArgSpec) Value

func (*SuClass) Equal

func (c *SuClass) Equal(other any) bool

func (*SuClass) Finder

func (c *SuClass) Finder(th *Thread, fn func(v Value, mb *MemBase) Value) Value

Finder implements Findable

func (*SuClass) Get

func (c *SuClass) Get(th *Thread, m Value) Value

func (*SuClass) GetName

func (c *SuClass) GetName() string

func (*SuClass) GetParents

func (c *SuClass) GetParents() []*SuClass

func (*SuClass) IsConcurrent

func (*SuClass) IsConcurrent() Value

func (*SuClass) Lookup

func (c *SuClass) Lookup(th *Thread, method string) Callable

func (*SuClass) New

func (c *SuClass) New(th *Thread, as *ArgSpec) *SuInstance

func (*SuClass) Parent

func (c *SuClass) Parent(th *Thread) *SuClass

func (*SuClass) SetConcurrent

func (*SuClass) SetConcurrent()

func (*SuClass) SetParents

func (c *SuClass) SetParents(parents []*SuClass)

func (*SuClass) Show

func (c *SuClass) Show() string

func (*SuClass) StartCoverage

func (c *SuClass) StartCoverage(count bool)

func (*SuClass) StopCoverage

func (c *SuClass) StopCoverage() *SuObject

func (*SuClass) String

func (c *SuClass) String() string

func (*SuClass) Type

func (*SuClass) Type() types.Type

type SuClosure

type SuClosure struct {
	SuFunc
	// contains filtered or unexported fields
}

SuClosure is an instance of a closure block

func (*SuClosure) Call

func (b *SuClosure) Call(th *Thread, this Value, as *ArgSpec) Value

func (*SuClosure) IsConcurrent

func (b *SuClosure) IsConcurrent() Value

func (*SuClosure) SetConcurrent

func (b *SuClosure) SetConcurrent()

func (*SuClosure) String

func (b *SuClosure) String() string

func (*SuClosure) Type

func (*SuClosure) Type() types.Type

type SuConcat

type SuConcat struct {
	ValueBase[SuConcat]
	// contains filtered or unexported fields
}

SuConcat is a Value used to optimize string concatenation WARNING: zero value is not valid, use NewSuConcat

func NewSuConcat

func NewSuConcat() SuConcat

NewSuConcat returns an empty SuConcat

func (SuConcat) Add

func (c SuConcat) Add(s string) SuConcat

Add appends a string to an SuConcat

func (SuConcat) AsStr

func (c SuConcat) AsStr() (string, bool)

func (SuConcat) Call

func (c SuConcat) Call(th *Thread, this Value, as *ArgSpec) Value

func (SuConcat) Compare

func (c SuConcat) Compare(other Value) int

func (SuConcat) Equal

func (c SuConcat) Equal(other any) bool

func (SuConcat) Get

func (c SuConcat) Get(_ *Thread, key Value) Value

Get returns the character at a given index

func (SuConcat) Hash

func (c SuConcat) Hash() uint32

func (SuConcat) Hash2

func (c SuConcat) Hash2() uint32

func (SuConcat) IsConcurrent

func (c SuConcat) IsConcurrent() Value

func (SuConcat) Iter

func (c SuConcat) Iter() Iter

func (SuConcat) Len

func (c SuConcat) Len() int

Len returns the length of an SuConcat

func (SuConcat) Lookup

func (SuConcat) Lookup(th *Thread, method string) Callable

func (SuConcat) Pack

func (c SuConcat) Pack(_ *uint32, buf *pack.Encoder)

func (SuConcat) PackSize

func (c SuConcat) PackSize(*uint32) int

func (SuConcat) PackSize2

func (c SuConcat) PackSize2(*uint32, packStack) int

func (SuConcat) RangeLen

func (c SuConcat) RangeLen(from int, n int) Value

func (SuConcat) RangeTo

func (c SuConcat) RangeTo(from int, to int) Value

func (SuConcat) SetConcurrent

func (c SuConcat) SetConcurrent()

func (SuConcat) String

func (c SuConcat) String() string

String returns a quoted string

func (SuConcat) ToDnum

func (c SuConcat) ToDnum() (dnum.Dnum, bool)

func (SuConcat) ToInt

func (c SuConcat) ToInt() (int, bool)

func (SuConcat) ToStr

func (c SuConcat) ToStr() (string, bool)

func (SuConcat) Type

func (SuConcat) Type() types.Type

type SuCursor

type SuCursor struct {
	ValueBase[SuCursor]
	SuQueryCursor
}

func NewSuCursor

func NewSuCursor(th *Thread, query string, icursor ICursor) *SuCursor

func (*SuCursor) Equal

func (q *SuCursor) Equal(other any) bool

func (*SuCursor) GetRec

func (q *SuCursor) GetRec(th *Thread, tran *SuTran, dir Dir) Value

func (*SuCursor) Lookup

func (q *SuCursor) Lookup(_ *Thread, method string) Callable

func (*SuCursor) SetConcurrent

func (*SuCursor) SetConcurrent()

func (*SuCursor) String

func (q *SuCursor) String() string

func (*SuCursor) Type

func (*SuCursor) Type() types.Type

type SuDate

type SuDate struct {
	ValueBase[SuDate]
	// contains filtered or unexported fields
}

SuDate is a Suneido date/time Value

Represents a readable "local" date and time. Does not take into account time zones or daylight savings.

It is designed to be efficient to pack and unpack and to convert to human readable formats. (Calculations are less common.)

var NilDate SuDate

func DateTime

func DateTime(date uint32, time uint32) SuDate

func FromGoTime

func FromGoTime(t time.Time) SuDate

func NewDate

func NewDate(yr int, mon int, day int, hr int, min int, sec int, ms int) SuDate

NewDate returns a SuDate value, month is 1-12, day is 1-31

func NormalizeDate

func NormalizeDate(yr int, mon int, day int, hr int, min int, sec int, ms int) SuDate

func Now

func Now() SuDate

Now returns a SuDate for the current local date & time

func ParseDate

func ParseDate(s string, order string) SuDate

ParseDate converts a human readable date to a SuDate.

Returns NilDate if it fails.

func SuDateFromUnixMilli

func SuDateFromUnixMilli(t int64) SuDate

func (SuDate) AddMs

func (d SuDate) AddMs(ms int) SuDate

AddMs is used by Timestamp. It will usually be faster than Plus

func (SuDate) Compare

func (d SuDate) Compare(other Value) int

func (SuDate) Day

func (d SuDate) Day() int

func (SuDate) Equal

func (d SuDate) Equal(other any) bool

func (SuDate) Format

func (d SuDate) Format(fmt string) string

Format converts the date to a string in the specified format

func (SuDate) Hash

func (d SuDate) Hash() uint32

func (SuDate) Hash2

func (d SuDate) Hash2() uint32

func (SuDate) Hour

func (d SuDate) Hour() int

func (SuDate) Lookup

func (SuDate) Lookup(th *Thread, method string) Callable

func (SuDate) Millisecond

func (d SuDate) Millisecond() int

func (SuDate) MinusDays

func (d SuDate) MinusDays(other SuDate) int

MinusDays returns the difference between two Dates in days

func (SuDate) MinusMs

func (d SuDate) MinusMs(other SuDate) int64

MinusMs returns the difference between two Dates in milliseconds

WARNING: doing this around daylight savings changes may be problematic

func (SuDate) Minute

func (d SuDate) Minute() int

func (SuDate) Month

func (d SuDate) Month() int

func (SuDate) Pack

func (d SuDate) Pack(_ *uint32, buf *pack.Encoder)

Pack packs into the supplied byte slice (Packable interface)

func (SuDate) PackSize

func (SuDate) PackSize(*uint32) int

PackSize returns the packed size (Packable interface)

func (SuDate) PackSize2

func (SuDate) PackSize2(*uint32, packStack) int

func (SuDate) Plus

func (d SuDate) Plus(yr int, mon int, day int, hr int, min int, sec int, ms int) SuDate

func (SuDate) Second

func (d SuDate) Second() int

func (SuDate) SetConcurrent

func (SuDate) SetConcurrent()

func (SuDate) String

func (d SuDate) String() string

func (SuDate) ToGoTime

func (d SuDate) ToGoTime() time.Time

func (SuDate) Type

func (SuDate) Type() types.Type

func (SuDate) UnixMilli

func (d SuDate) UnixMilli() int64

UnixMilli returns the time in milliseconds since 1 Jan 1970

func (SuDate) WeekDay

func (d SuDate) WeekDay() int

WeekDay returns the day of the week - Sun is 0, Sat is 6

func (SuDate) WithoutMs

func (d SuDate) WithoutMs() SuDate

func (SuDate) Year

func (d SuDate) Year() int

type SuDnum

type SuDnum struct {
	ValueBase[SuDnum]
	dnum.Dnum
}

SuDnum wraps a Dnum and implements Value and Packable

func (SuDnum) AsStr

func (dn SuDnum) AsStr() (string, bool)

func (SuDnum) Compare

func (dn SuDnum) Compare(other Value) int

func (SuDnum) Equal

func (dn SuDnum) Equal(other any) bool

func (SuDnum) Hash

func (dn SuDnum) Hash() uint32

func (SuDnum) Hash2

func (dn SuDnum) Hash2() uint32

func (SuDnum) IfInt

func (dn SuDnum) IfInt() (int, bool)

func (SuDnum) Lookup

func (SuDnum) Lookup(th *Thread, method string) Callable

func (SuDnum) Pack

func (dn SuDnum) Pack(_ *uint32, buf *pack.Encoder)

func (SuDnum) PackSize

func (dn SuDnum) PackSize(*uint32) int

func (SuDnum) PackSize2

func (dn SuDnum) PackSize2(*uint32, packStack) int

func (SuDnum) SetConcurrent

func (SuDnum) SetConcurrent()

func (SuDnum) String

func (dn SuDnum) String() string

func (SuDnum) ToDnum

func (dn SuDnum) ToDnum() (dnum.Dnum, bool)

func (SuDnum) ToInt

func (dn SuDnum) ToInt() (int, bool)

func (SuDnum) Type

func (SuDnum) Type() types.Type

type SuExcept

type SuExcept struct {
	Callstack *SuObject
	SuStr
}

func BuiltinSuExcept

func BuiltinSuExcept(s string) *SuExcept

BuiltinSuExcept is for special values for block break, continue, return

func NewSuExcept

func NewSuExcept(th *Thread, s SuStr) *SuExcept

func OpCatch

func OpCatch(th *Thread, e any, catchPat string) *SuExcept

func ToSuExcept

func ToSuExcept(th *Thread, e any) *SuExcept

ToSuExcept converts to SuExcept, and also logs runtime and assert errors

func (*SuExcept) Lookup

func (*SuExcept) Lookup(th *Thread, method string) Callable

func (*SuExcept) SetConcurrent

func (e *SuExcept) SetConcurrent()

func (*SuExcept) Type

func (*SuExcept) Type() types.Type

type SuFunc

type SuFunc struct {

	// Code is the actual byte code
	Code string

	// ClassName is used to privatize dot params
	ClassName string

	// SrcPos contains pairs of source and code position deltas
	SrcPos string

	// ArgSpecs used by calls in the code
	ArgSpecs []ArgSpec

	ParamSpec

	// SrcBase is the starting point for the SrcPos source deltas
	SrcBase int

	// Nlocals is the number of parameters and local variables
	Nlocals uint8

	IsBlock bool
	// contains filtered or unexported fields
}

SuFunc is a compiled Suneido function, method, or block

func (*SuFunc) Call

func (f *SuFunc) Call(th *Thread, this Value, as *ArgSpec) Value

func (*SuFunc) CodeToSrcPos

func (f *SuFunc) CodeToSrcPos(ip int) int

func (*SuFunc) Lookup

func (*SuFunc) Lookup(_ *Thread, method string) Callable

func (*SuFunc) StartCoverage

func (f *SuFunc) StartCoverage(count bool)

func (*SuFunc) StopCoverage

func (f *SuFunc) StopCoverage() *SuObject

func (*SuFunc) String

func (f *SuFunc) String() string

func (*SuFunc) Type

func (f *SuFunc) Type() types.Type

type SuInstance

type SuInstance struct {
	ValueBase[*SuInstance]

	MemBase
	// contains filtered or unexported fields
}

SuInstance is an instance of an SuClass

func NewInstance

func NewInstance(th *Thread, class *SuClass) *SuInstance

func (*SuInstance) Base

func (ob *SuInstance) Base() *SuClass

func (*SuInstance) Call

func (ob *SuInstance) Call(th *Thread, _ Value, as *ArgSpec) Value

func (*SuInstance) Clear

func (ob *SuInstance) Clear()

func (*SuInstance) Copy

func (ob *SuInstance) Copy() *SuInstance

func (*SuInstance) Delete

func (ob *SuInstance) Delete(key Value)

func (*SuInstance) Equal

func (ob *SuInstance) Equal(other any) bool

Equal uses deepEqual if both instances have UseDeepEquals, otherwise it uses reference/pointer equality like Same?

func (*SuInstance) Finder

func (ob *SuInstance) Finder(_ *Thread, fn func(Value, *MemBase) Value) Value

Finder implements Findable

func (*SuInstance) Get

func (ob *SuInstance) Get(th *Thread, m Value) Value

func (*SuInstance) GetPut

func (ob *SuInstance) GetPut(th *Thread, m Value, v Value,
	op func(x, y Value) Value, retOrig bool) Value

func (*SuInstance) Lookup

func (ob *SuInstance) Lookup(th *Thread, method string) Callable

func (*SuInstance) Put

func (ob *SuInstance) Put(_ *Thread, m Value, v Value)

func (*SuInstance) SetConcurrent

func (ob *SuInstance) SetConcurrent()

func (*SuInstance) String

func (ob *SuInstance) String() string

func (*SuInstance) ToString

func (ob *SuInstance) ToString(th *Thread) string

ToString is used by Cat, Display, and Print to handle user defined ToString

func (*SuInstance) Type

func (*SuInstance) Type() types.Type

type SuIter

type SuIter struct {
	ValueBase[SuIter]
	Iter
}

SuIter is a Value that wraps a runtime.Iter and provides the Suneido interator interface (Next,Dup,Infinite) returning itself when it reaches the end

func OpIter

func OpIter(x Value) SuIter

func (SuIter) Equal

func (it SuIter) Equal(other any) bool

func (SuIter) IsConcurrent

func (it SuIter) IsConcurrent() Value

func (SuIter) Lookup

func (SuIter) Lookup(_ *Thread, method string) Callable

func (SuIter) SetConcurrent

func (it SuIter) SetConcurrent()

func (SuIter) Type

func (SuIter) Type() types.Type

type SuMethod

type SuMethod struct {
	ValueBase[SuMethod]
	// contains filtered or unexported fields
}

SuMethod is a bound method originating from an SuClass or SuInstance when called, it sets 'this' to the origin

func NewSuMethod

func NewSuMethod(this Value, fn Value) *SuMethod

func (*SuMethod) Call

func (m *SuMethod) Call(th *Thread, _ Value, as *ArgSpec) Value

func (*SuMethod) Equal

func (m *SuMethod) Equal(other any) bool

Equal returns true if two methods have the same fn and this

func (*SuMethod) GetFn

func (m *SuMethod) GetFn() Value

func (*SuMethod) GetName

func (m *SuMethod) GetName() string

func (*SuMethod) Lookup

func (m *SuMethod) Lookup(th *Thread, method string) Callable

Lookup is used for .Params or .Disasm

func (*SuMethod) SetConcurrent

func (m *SuMethod) SetConcurrent()

func (*SuMethod) String

func (m *SuMethod) String() string

func (*SuMethod) Type

func (*SuMethod) Type() types.Type

type SuObject

type SuObject struct {
	ValueBase[SuObject]
	// contains filtered or unexported fields
}

SuObject is a Suneido object i.e. a container with both list and named members. Zero value is a valid empty object.

func InstantiateIter

func InstantiateIter(iter Iter) *SuObject

func NewSuObject

func NewSuObject(args []Value) *SuObject

NewSuObject creates an SuObject from a slice of Value's

func SuObjectOf

func SuObjectOf(args ...Value) *SuObject

SuObjectOf returns an SuObject from its arguments

func SuObjectOfArgs

func SuObjectOfArgs(args []Value, as *ArgSpec) *SuObject

SuObjectOfArgs is used by massage and lrucache

func SuObjectOfStrs

func SuObjectOfStrs(strs []string) *SuObject

SuObjectOfStrs returns an SuObject from a slice of strings

func UnpackObject

func UnpackObject(s string) *SuObject

func (*SuObject) Add

func (ob *SuObject) Add(val Value)

Add appends a value to the list portion

func (*SuObject) ArgsIter

func (ob *SuObject) ArgsIter() func() (Value, Value)

ArgsIter is similar to Iter2 but it returns a nil key for list elements

func (*SuObject) BinarySearch

func (ob *SuObject) BinarySearch(value Value) int

BinarySearch does a binary search with default comparisons

func (*SuObject) BinarySearch2

func (ob *SuObject) BinarySearch2(th *Thread, value, lt Value) int

BinarySearch2 does a binary search with a user specified less than function

func (*SuObject) Call

func (*SuObject) Call(*Thread, Value, *ArgSpec) Value

func (*SuObject) Compare

func (ob *SuObject) Compare(other Value) int

Compare compares only list values (not named)

func (*SuObject) Copy

func (ob *SuObject) Copy() Container

func (*SuObject) Delete

func (ob *SuObject) Delete(_ *Thread, key Value) bool

Delete removes a key. If in the list, following list values are shifted over.

func (*SuObject) DeleteAll

func (ob *SuObject) DeleteAll()

DeleteAll removes all the contents of the object, making it empty (size 0)

func (*SuObject) Display

func (ob *SuObject) Display(th *Thread) string

func (*SuObject) Equal

func (ob *SuObject) Equal(other any) bool

func (*SuObject) Erase

func (ob *SuObject) Erase(_ *Thread, key Value) bool

Erase removes a key. If in the list, following list values are NOT shifted over.

func (*SuObject) Find

func (ob *SuObject) Find(val Value) Value

Find returns the key of the first occurrence of the value else False. Lock to avoid object-modified-during-iteration.

func (*SuObject) Get

func (ob *SuObject) Get(_ *Thread, key Value) Value

Get returns the value associated with a key, or defval if not found

func (*SuObject) GetIfPresent

func (ob *SuObject) GetIfPresent(_ *Thread, key Value) Value

func (*SuObject) GetPut

func (ob *SuObject) GetPut(_ *Thread, m, v Value,
	op func(x, y Value) Value, retOrig bool) Value

func (*SuObject) HasKey

func (ob *SuObject) HasKey(key Value) bool

HasKey returns true if the object contains the given key (not value)

func (*SuObject) Hash

func (ob *SuObject) Hash() uint32

func (*SuObject) Hash2

func (ob *SuObject) Hash2() uint32

Hash2 is shallow to prevents infinite recursion and deadlock

func (*SuObject) Insert

func (ob *SuObject) Insert(at int, val Value)

Insert inserts at the given position. If the position is within the list, following values are moved over.

func (*SuObject) IsConcurrent

func (ob *SuObject) IsConcurrent() Value

func (*SuObject) IsReadOnly

func (ob *SuObject) IsReadOnly() bool

func (*SuObject) Iter

func (ob *SuObject) Iter() Iter

func (*SuObject) Iter2

func (ob *SuObject) Iter2(list, named bool) func() (Value, Value)

Iter2 iterates through list and named elements. List elements are returned with their numeric key index.

func (*SuObject) ListGet

func (ob *SuObject) ListGet(i int) Value

ListGet returns a value from the list, panics if index out of range

func (*SuObject) ListSize

func (ob *SuObject) ListSize() int

func (*SuObject) Lock

func (x *SuObject) Lock() bool

func (*SuObject) Lookup

func (*SuObject) Lookup(th *Thread, method string) Callable

func (*SuObject) NamedSize

func (ob *SuObject) NamedSize() int

func (*SuObject) Pack

func (ob *SuObject) Pack(hash *uint32, buf *pack.Encoder)

func (*SuObject) PackSize

func (ob *SuObject) PackSize(hash *uint32) int

func (*SuObject) PackSize2

func (ob *SuObject) PackSize2(hash *uint32, stack packStack) int

func (*SuObject) PopFirst

func (ob *SuObject) PopFirst() Value

func (*SuObject) PopLast

func (ob *SuObject) PopLast() Value

func (*SuObject) Put

func (ob *SuObject) Put(_ *Thread, key, val Value)

Put adds or updates the given key and value The value will be added to the list if the key is the "next"

func (*SuObject) RLock

func (x *SuObject) RLock() bool

func (*SuObject) RUnlock

func (x *SuObject) RUnlock() bool

func (*SuObject) RangeLen

func (ob *SuObject) RangeLen(from int, n int) Value

func (*SuObject) RangeTo

func (ob *SuObject) RangeTo(from int, to int) Value

func (*SuObject) Reverse

func (ob *SuObject) Reverse()

func (*SuObject) Set

func (ob *SuObject) Set(key, val Value)

Set implements Put, doesn't require thread. The value will be added to the list if the key is the "next"

func (*SuObject) SetChildConc

func (ob *SuObject) SetChildConc()

func (*SuObject) SetConcurrent

func (ob *SuObject) SetConcurrent()

SetConcurrent when readonly does not need to set shouldLock. But it still needs to set its children to concurrent because they may be SuRecords that require locking when readonly or other objects that require copyCount initialization.

func (*SuObject) SetDefault

func (ob *SuObject) SetDefault(def Value)

func (*SuObject) SetReadOnly

func (ob *SuObject) SetReadOnly()

func (*SuObject) Show

func (ob *SuObject) Show() string

Show is like Display except that it sorts named members. It is used for tests.

func (*SuObject) Size

func (ob *SuObject) Size() int

Size returns the number of values in the object

func (*SuObject) Slice

func (ob *SuObject) Slice(n int) Container

Slice returns a copy of the object, omitting the first n list values

func (*SuObject) Sort

func (ob *SuObject) Sort(th *Thread, lt Value)

func (*SuObject) String

func (ob *SuObject) String() string

func (*SuObject) ToContainer

func (ob *SuObject) ToContainer() (Container, bool)

func (*SuObject) ToObject

func (ob *SuObject) ToObject() *SuObject

func (*SuObject) ToRecord

func (ob *SuObject) ToRecord(th *Thread, hdr *Header) Record

func (*SuObject) Type

func (*SuObject) Type() types.Type

func (*SuObject) Unique

func (ob *SuObject) Unique()

func (*SuObject) Unlock

func (x *SuObject) Unlock() bool

type SuQuery

type SuQuery struct {
	ValueBase[SuQuery]

	SuQueryCursor
	// contains filtered or unexported fields
}

func NewSuQuery

func NewSuQuery(th *Thread, tran *SuTran, query string, iquery IQuery) *SuQuery

func (*SuQuery) Equal

func (q *SuQuery) Equal(other any) bool

func (*SuQuery) GetRec

func (q *SuQuery) GetRec(th *Thread, dir Dir) Value

func (*SuQuery) Lookup

func (q *SuQuery) Lookup(_ *Thread, method string) Callable

func (*SuQuery) Output

func (q *SuQuery) Output(th *Thread, ob Container)

func (*SuQuery) SetConcurrent

func (*SuQuery) SetConcurrent()

func (*SuQuery) String

func (q *SuQuery) String() string

func (*SuQuery) Type

func (*SuQuery) Type() types.Type

type SuQueryCursor

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

SuQueryCursor is the common base for SuQuery and SuCursor

func (*SuQueryCursor) Close

func (qc *SuQueryCursor) Close()

func (*SuQueryCursor) Columns

func (qc *SuQueryCursor) Columns() Value

func (*SuQueryCursor) Keys

func (qc *SuQueryCursor) Keys() Value

func (*SuQueryCursor) Order

func (qc *SuQueryCursor) Order() Value

func (*SuQueryCursor) Rewind

func (qc *SuQueryCursor) Rewind()

func (*SuQueryCursor) RuleColumns

func (qc *SuQueryCursor) RuleColumns() Value

func (*SuQueryCursor) Strategy

func (qc *SuQueryCursor) Strategy(formatted bool) Value

type SuRecord

type SuRecord struct {
	ValueBase[SuRecord]
	// contains filtered or unexported fields
}

SuRecord is an SuObject with observers and rules and a default value of "". Uses the lock from SuObject. Use NewSuRecord since zero value doesn't set default.

func NewSuRecord

func NewSuRecord() *SuRecord

func SuRecordFromObject

func SuRecordFromObject(ob *SuObject) *SuRecord

SuRecordFromObject creates a record from an arguments object WARNING: it does not copy the data, the original object should be discarded

func SuRecordFromRow

func SuRecordFromRow(row Row, hdr *Header, table string, tran *SuTran) *SuRecord

func UnpackRecord

func UnpackRecord(s string) *SuRecord

func (*SuRecord) Add

func (r *SuRecord) Add(val Value)

func (*SuRecord) ArgsIter

func (r *SuRecord) ArgsIter() func() (Value, Value)

func (*SuRecord) AttachRule

func (r *SuRecord) AttachRule(key, callable Value)

func (*SuRecord) Clear

func (r *SuRecord) Clear()

func (*SuRecord) Compare

func (r *SuRecord) Compare(other Value) int

func (*SuRecord) Copy

func (r *SuRecord) Copy() Container

func (*SuRecord) DbDelete

func (r *SuRecord) DbDelete(th *Thread)

func (*SuRecord) DbUpdate

func (r *SuRecord) DbUpdate(th *Thread, ob Value)

func (*SuRecord) Delete

func (r *SuRecord) Delete(th *Thread, key Value) bool

func (*SuRecord) DeleteAll

func (r *SuRecord) DeleteAll()

func (*SuRecord) Display

func (r *SuRecord) Display(th *Thread) string

func (*SuRecord) Equal

func (r *SuRecord) Equal(other any) bool

func (*SuRecord) Erase

func (r *SuRecord) Erase(th *Thread, key Value) bool

func (*SuRecord) Get

func (r *SuRecord) Get(th *Thread, key Value) Value

Get returns the value associated with a key, or defval if not found

func (*SuRecord) GetDeps

func (r *SuRecord) GetDeps(key string) Value

func (*SuRecord) GetIfPresent

func (r *SuRecord) GetIfPresent(th *Thread, keyval Value) Value

GetIfPresent is the same as Get except it returns nil instead of defval for missing members

func (*SuRecord) GetPut

func (r *SuRecord) GetPut(th *Thread, m, v Value,
	op func(x, y Value) Value, retOrig bool) Value

func (*SuRecord) HasKey

func (r *SuRecord) HasKey(key Value) bool

func (*SuRecord) Hash

func (r *SuRecord) Hash() uint32

func (*SuRecord) Hash2

func (r *SuRecord) Hash2() uint32

func (*SuRecord) Insert

func (r *SuRecord) Insert(at int, val Value)

func (*SuRecord) Invalidate

func (r *SuRecord) Invalidate(th *Thread, key string)

func (*SuRecord) IsConcurrent

func (r *SuRecord) IsConcurrent() Value

func (*SuRecord) IsNew

func (r *SuRecord) IsNew() bool

func (*SuRecord) IsReadOnly

func (r *SuRecord) IsReadOnly() bool

func (*SuRecord) Iter

func (r *SuRecord) Iter() Iter

func (*SuRecord) Iter2

func (r *SuRecord) Iter2(list bool, named bool) func() (Value, Value)

func (*SuRecord) ListGet

func (r *SuRecord) ListGet(i int) Value

func (*SuRecord) ListSize

func (r *SuRecord) ListSize() int

func (*SuRecord) Lock

func (r *SuRecord) Lock() bool

func (*SuRecord) Lookup

func (*SuRecord) Lookup(th *Thread, method string) Callable

func (*SuRecord) NamedSize

func (r *SuRecord) NamedSize() int

func (*SuRecord) Observer

func (r *SuRecord) Observer(ofn Value)

func (*SuRecord) Pack

func (r *SuRecord) Pack(hash *uint32, buf *pack.Encoder)

func (*SuRecord) PackSize

func (r *SuRecord) PackSize(hash *uint32) int

func (*SuRecord) PackSize2

func (r *SuRecord) PackSize2(hash *uint32, stack packStack) int

func (*SuRecord) PreSet

func (r *SuRecord) PreSet(key, val Value)

func (*SuRecord) Put

func (r *SuRecord) Put(th *Thread, keyval, val Value)

func (*SuRecord) RangeLen

func (r *SuRecord) RangeLen(from int, n int) Value

func (*SuRecord) RangeTo

func (r *SuRecord) RangeTo(from int, to int) Value

func (*SuRecord) RemoveObserver

func (r *SuRecord) RemoveObserver(ofn Value) bool

func (*SuRecord) Set

func (r *SuRecord) Set(key, val Value)

func (*SuRecord) SetConcurrent

func (r *SuRecord) SetConcurrent()

SetConcurrent for SuRecord differs from SuObject. Unlike SuObject, SuRecord needs to lock when readonly because it modifies dependents and hdr's cache etc.

func (*SuRecord) SetDeps

func (r *SuRecord) SetDeps(key, deps string)

func (*SuRecord) SetReadOnly

func (r *SuRecord) SetReadOnly()

func (*SuRecord) Show

func (r *SuRecord) Show() string

func (*SuRecord) Slice

func (r *SuRecord) Slice(n int) Container

func (*SuRecord) String

func (r *SuRecord) String() string

func (*SuRecord) ToContainer

func (r *SuRecord) ToContainer() (Container, bool)

func (*SuRecord) ToObject

func (r *SuRecord) ToObject() *SuObject

func (*SuRecord) ToRecord

func (r *SuRecord) ToRecord(th *Thread, hdr *Header) Record

ToRecord converts this SuRecord to a Record to be stored in the database

func (*SuRecord) Transaction

func (r *SuRecord) Transaction() *SuTran

func (*SuRecord) Type

func (*SuRecord) Type() types.Type

func (*SuRecord) Unlock

func (r *SuRecord) Unlock() bool

type SuRegex

type SuRegex struct {
	ValueBase[SuRegex]
	Pat regex.Pattern
}

SuRegex is a compiled regular expression. It is not a general purpose Value and is internal, not exposed.

func (SuRegex) Equal

func (rx SuRegex) Equal(other any) bool

func (SuRegex) Lookup

func (SuRegex) Lookup(_ *Thread, method string) Callable

func (SuRegex) SetConcurrent

func (SuRegex) SetConcurrent()

type SuSequence

type SuSequence struct {
	ValueBase[SuSequence]

	MayLock
	// contains filtered or unexported fields
}

SuSequence wraps an Iter and instantiates it lazily the Iter is either built-in e.g. Seq or object.Members, or user defined via Sequence

func NewSuSequence

func NewSuSequence(it Iter) *SuSequence

func (*SuSequence) Compare

func (seq *SuSequence) Compare(other Value) int

func (*SuSequence) Copy

func (seq *SuSequence) Copy() Value

func (*SuSequence) Equal

func (seq *SuSequence) Equal(other any) bool

func (*SuSequence) Get

func (seq *SuSequence) Get(th *Thread, key Value) Value

func (*SuSequence) GetPut

func (seq *SuSequence) GetPut(th *Thread, key Value, val Value,
	op func(x, y Value) Value, retOrig bool) Value

func (*SuSequence) Hash

func (seq *SuSequence) Hash() uint32

func (*SuSequence) Hash2

func (seq *SuSequence) Hash2() uint32

func (*SuSequence) Infinite

func (seq *SuSequence) Infinite() bool

func (*SuSequence) Instantiated

func (seq *SuSequence) Instantiated() bool

func (*SuSequence) Iter

func (seq *SuSequence) Iter() Iter

func (*SuSequence) Lookup

func (seq *SuSequence) Lookup(th *Thread, method string) Callable

func (*SuSequence) Pack

func (seq *SuSequence) Pack(hash *uint32, buf *pack.Encoder)

func (*SuSequence) PackSize

func (seq *SuSequence) PackSize(hash *uint32) int

func (*SuSequence) PackSize2

func (seq *SuSequence) PackSize2(hash *uint32, stack packStack) int

func (*SuSequence) Put

func (seq *SuSequence) Put(th *Thread, key Value, val Value)

func (*SuSequence) RangeLen

func (seq *SuSequence) RangeLen(i int, n int) Value

func (*SuSequence) RangeTo

func (seq *SuSequence) RangeTo(i int, j int) Value

func (*SuSequence) SetConcurrent

func (seq *SuSequence) SetConcurrent()

func (*SuSequence) String

func (seq *SuSequence) String() string

func (*SuSequence) ToContainer

func (seq *SuSequence) ToContainer() (Container, bool)

func (*SuSequence) Type

func (*SuSequence) Type() types.Type

type SuStr

type SuStr string

SuStr is a string Value

func (SuStr) AsStr

func (ss SuStr) AsStr() (string, bool)

func (SuStr) Call

func (ss SuStr) Call(th *Thread, _ Value, as *ArgSpec) Value

Call implements s(ob, ...) being treated as ob[s](...)

func (SuStr) Compare

func (ss SuStr) Compare(other Value) int

func (SuStr) Display

func (ss SuStr) Display(th *Thread) string

func (SuStr) Equal

func (ss SuStr) Equal(other any) bool

func (SuStr) Get

func (ss SuStr) Get(_ *Thread, key Value) Value

func (SuStr) GetPut

func (SuStr) GetPut(*Thread, Value, Value, func(x, y Value) Value, bool) Value

func (SuStr) Hash

func (ss SuStr) Hash() uint32

func (SuStr) Hash2

func (ss SuStr) Hash2() uint32

func (SuStr) IfInt

func (ss SuStr) IfInt() (int, bool)

func (SuStr) Iter

func (ss SuStr) Iter() Iter

func (SuStr) Len

func (ss SuStr) Len() int

func (SuStr) Lookup

func (SuStr) Lookup(th *Thread, method string) Callable

func (SuStr) Pack

func (ss SuStr) Pack(_ *uint32, buf *pack.Encoder)

func (SuStr) PackSize

func (ss SuStr) PackSize(*uint32) int

func (SuStr) PackSize2

func (ss SuStr) PackSize2(*uint32, packStack) int

func (SuStr) Put

func (SuStr) Put(*Thread, Value, Value)

func (SuStr) RangeLen

func (ss SuStr) RangeLen(from int, n int) Value

func (SuStr) RangeTo

func (ss SuStr) RangeTo(from int, to int) Value

func (SuStr) SetConcurrent

func (SuStr) SetConcurrent()

func (SuStr) String

func (ss SuStr) String() string

String returns a human readable string with quotes and escaping

func (SuStr) ToContainer

func (SuStr) ToContainer() (Container, bool)

func (SuStr) ToDnum

func (ss SuStr) ToDnum() (dnum.Dnum, bool)

func (SuStr) ToInt

func (ss SuStr) ToInt() (int, bool)

func (SuStr) ToStr

func (ss SuStr) ToStr() (string, bool)

func (SuStr) Type

func (SuStr) Type() types.Type

type SuTimestamp

type SuTimestamp struct {
	SuDate
	// contains filtered or unexported fields
}

SuTimestamp is an extension of SuDate that adds an extra byte of precision for timestamps.

func UnpackTimestamp

func UnpackTimestamp(sd SuDate, d *pack.Decoder) SuTimestamp

func (SuTimestamp) Compare

func (d SuTimestamp) Compare(other Value) int

func (SuTimestamp) Equal

func (d SuTimestamp) Equal(other any) bool

func (SuTimestamp) Hash

func (d SuTimestamp) Hash() uint32

func (SuTimestamp) Pack

func (d SuTimestamp) Pack(h *uint32, buf *pack.Encoder)

func (SuTimestamp) PackSize

func (SuTimestamp) PackSize(*uint32) int

func (SuTimestamp) PackSize2

func (SuTimestamp) PackSize2(*uint32, packStack) int

func (SuTimestamp) String

func (d SuTimestamp) String() string

type SuTran

type SuTran struct {
	ValueBase[*suTransaction]
	// contains filtered or unexported fields
}

SuTran is a database transaction

func NewSuTran

func NewSuTran(itran ITran, updatable bool) *SuTran

func (*SuTran) Action

func (st *SuTran) Action(th *Thread, action string) int

func (*SuTran) Asof

func (st *SuTran) Asof(val Value) Value

func (*SuTran) Complete

func (st *SuTran) Complete()

func (*SuTran) Data

func (st *SuTran) Data() *SuObject

func (*SuTran) Delete

func (st *SuTran) Delete(th *Thread, table string, off uint64)

func (*SuTran) Ended

func (st *SuTran) Ended() bool

func (*SuTran) Equal

func (st *SuTran) Equal(other any) bool

func (*SuTran) GetRow

func (st *SuTran) GetRow(th *Thread, query string, dir Dir) (Row, *Header, string)

func (*SuTran) Lookup

func (st *SuTran) Lookup(th *Thread, method string) Callable

func (*SuTran) Query

func (st *SuTran) Query(th *Thread, query string) *SuQuery

func (*SuTran) ReadCount

func (st *SuTran) ReadCount() int

func (*SuTran) Rollback

func (st *SuTran) Rollback()

func (*SuTran) SetConcurrent

func (st *SuTran) SetConcurrent()

func (*SuTran) String

func (st *SuTran) String() string

func (*SuTran) Type

func (*SuTran) Type() types.Type

func (*SuTran) Updatable

func (st *SuTran) Updatable() bool

func (*SuTran) Update

func (st *SuTran) Update(th *Thread, table string, off uint64, rec Record) uint64

func (*SuTran) WriteCount

func (st *SuTran) WriteCount() int

type SuneidoObject

type SuneidoObject struct {
	SuObject
}

SuneidoObject is the global Suneido object. It is a separate type to allow Suneido.Parse and Suneido.Compile methods.

var Suneido *SuneidoObject

func (*SuneidoObject) Lock

func (x *SuneidoObject) Lock() bool

func (*SuneidoObject) Lookup

func (so *SuneidoObject) Lookup(th *Thread, method string) Callable

func (*SuneidoObject) RLock

func (x *SuneidoObject) RLock() bool

func (*SuneidoObject) RUnlock

func (x *SuneidoObject) RUnlock() bool

func (*SuneidoObject) Unlock

func (x *SuneidoObject) Unlock() bool

type Sviews

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

func (*Sviews) AddSview

func (sv *Sviews) AddSview(name, def string)

func (*Sviews) DropSview

func (sv *Sviews) DropSview(name string) bool

func (*Sviews) GetSview

func (sv *Sviews) GetSview(name string) string

type Thread

type Thread struct {
	// contains filtered or unexported fields
}
var MainThread *Thread

MainThread is injected by gsuneido.go to use for debugging

func NewThread

func NewThread(parent *Thread) *Thread

NewThread creates a new thread. It is primarily used for user initiated threads. Internal threads can just use a zero Thread.

func (*Thread) Args

func (th *Thread) Args(ps *ParamSpec, as *ArgSpec) []Value

func (*Thread) Call

func (th *Thread) Call(fn Callable, args ...Value) Value

Call pushes the arguments onto the stack and calls the function

func (*Thread) CallEach

func (th *Thread) CallEach(fn Callable, arg Value) Value

func (*Thread) CallEach1

func (th *Thread) CallEach1(fn Callable, arg Value) Value

func (*Thread) CallLookup

func (th *Thread) CallLookup(this Value, method string, args ...Value) Value

CallLookup calls a *named* method.

func (*Thread) CallLookupEach1

func (th *Thread) CallLookupEach1(this Value, method string, arg Value) Value

func (*Thread) CallThis

func (th *Thread) CallThis(fn Callable, this Value, args ...Value) Value

func (*Thread) Callstack

func (th *Thread) Callstack() *SuObject

Callstack captures the call stack

func (*Thread) Cat

func (th *Thread) Cat(x, y Value) Value

func (*Thread) Close

func (th *Thread) Close()

Close closes the thread's dbms connection (if it has one)

func (*Thread) Dbms

func (th *Thread) Dbms() IDbms

func (*Thread) GetState

func (th *Thread) GetState() ThreadState

func (*Thread) Invalidate

func (th *Thread) Invalidate()

Invalidate is used by workers to help detect use of thread after request

func (*Thread) Locals

func (th *Thread) Locals(i int) *SuObject

func (*Thread) Lookup

func (th *Thread) Lookup(this Value, method string) Callable

func (*Thread) Pop

func (th *Thread) Pop() Value

Pop pops a value off the value stack

func (*Thread) PrintStack

func (th *Thread) PrintStack()

PrintStack outputs the thread's call stack to stderr

func (*Thread) Push

func (th *Thread) Push(x Value)

Push pushes a value onto the value stack

func (*Thread) PushCall

func (th *Thread) PushCall(fn Callable, this Value, as *ArgSpec, args ...Value) Value

PushCall pushes the arguments onto the stack and calls the function

func (*Thread) Regex

func (th *Thread) Regex(x Value) regex.Pattern

func (*Thread) Reset

func (th *Thread) Reset()

Reset clears the thread except for Num, Name, session, and dbms. It is used by the repl and by dbms server workers.

func (*Thread) RestoreState

func (th *Thread) RestoreState(st ThreadState)

func (*Thread) RunWithMainSuneido

func (th *Thread) RunWithMainSuneido(fn func() Value) Value

func (*Thread) Session

func (th *Thread) Session() string

func (*Thread) SessionId

func (th *Thread) SessionId(id string) string

func (*Thread) SetDbms

func (th *Thread) SetDbms(dbms IDbms)

SetDbms is used to set up the main thread initially

func (*Thread) SetSession

func (th *Thread) SetSession(s string)

func (*Thread) SetSviews

func (th *Thread) SetSviews(sv *Sviews)

func (*Thread) StartProfile

func (th *Thread) StartProfile()

func (*Thread) StopProfile

func (th *Thread) StopProfile() (total, self, ops, calls map[string]int32)

func (*Thread) SubThread

func (th *Thread) SubThread() *Thread

SubThread is a NewThread with the same dbms as this thread. This is used for SuneidoAPP threads. We want a new thread for isolation e.g. for exceptions or dynamic variables but we don't need the overhead of another dbms connection. WARNING: This should only be used where it is guaranteed that the Threads will NOT be used concurrently.

func (*Thread) Sviews

func (th *Thread) Sviews() *Sviews

func (*Thread) Swap

func (th *Thread) Swap()

Swap exchanges the top two values on the stack

func (*Thread) Timestamp

func (th *Thread) Timestamp() PackableValue

Timestamp is a Thread method for convenience, so it has access to the dbms. It is not "per thread". This is the "client" version of Timestamp.

func (*Thread) Top

func (th *Thread) Top() Value

Top returns the top of the value stack (without modifying the stack)

func (*Thread) TrSet

func (th *Thread) TrSet(x Value) tr.Set

func (*Thread) TraceCaller

func (th *Thread) TraceCaller()

func (*Thread) TraceStack

func (th *Thread) TraceStack()

TraceStack outputs the thread's call stack to trace

type ThreadState

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

type ToStringable

type ToStringable interface {
	ToString(*Thread) string
}

type Value

type Value interface {
	// String returns a human readable string i.e. Suneido Display
	// Note: strings will have quotes and be escaped
	String() string

	// AsStr converts SuBool, SuInt, SuDnum, SuStr, SuConcat, SuExcept to string
	AsStr() (string, bool)

	// ToStr converts SuStr, SuConcat, SuExcept to string
	ToStr() (string, bool)

	// ToInt converts false (SuBool), "" (SuStr), SuInt, SuDnum to int
	ToInt() (int, bool)

	// IfInt converts SuInt, SuDnum to int
	IfInt() (int, bool)

	// ToDnum converts false (SuBool), "" (SuStr), SuInt, SuDnum to Dnum
	ToDnum() (dnum.Dnum, bool)

	// ToContainer converts object,record,sequence to a Container
	ToContainer() (Container, bool)

	// Get returns a member of an object/instance/class or a character of a string
	// returns nil if the member does not exist
	// The thread is necessary to call getters
	Get(th *Thread, key Value) Value

	// Put sets its key member to val.
	// Implemented by SuObject, SuRecord, and SuInstance.
	// t is required by SuRecord to call observers.
	Put(th *Thread, key Value, val Value)

	// GetPut is used for update operations like += and ++ atomically
	GetPut(th *Thread, key Value, val Value,
		op func(x, y Value) Value, retOrig bool) Value

	RangeTo(i int, j int) Value
	RangeLen(i int, n int) Value

	Equal(other any) bool

	Hash() uint32

	// Hash2 is used by object to shallow hash contents
	Hash2() uint32

	// Type returns the Suneido name for the type
	Type() types.Type

	// Compare returns -1 for less, 0 for equal, +1 for greater
	Compare(other Value) int

	Callable

	// Lookup returns a Callable or nil if the method isn't found
	Lookup(th *Thread, method string) Callable

	// SetConcurrent is called when a Value is
	// about to become reachable by multiple threads.
	// At the point where SetConcurrent is called it is still thread contained.
	// SetConcurrent should be called on any other Value's reachable from this.
	// Additional calls to SetConcurrent should be ignored.
	// NOTE: SetConcurrent cannot call abitrary code
	// because it is called when holding a lock.
	SetConcurrent()
}

Value is a value visible to Suneido programmers The naming convention is to use a prefix of "Su" - SuBoolean - SuInt, SuDnum - numbers - SuStr, SuConcat, SuExcept - strings - SuDate - SuObject, SuRecord, SuSequence - objects - SuBuiltin*, SuBuiltinMethod* - SuFunc - SuClosure - SuClass - SuInstance - SuMethod - not directly accessible, but returned for bound methods - SuIter - not directly accessible, but returned from e.g. object.Iter

var (
	Zero     Value = SuInt(0)
	One      Value = SuInt(1)
	MinusOne Value = SuInt(-1)
	MaxInt   Value = SuDnum{Dnum: dnum.FromInt(math.MaxInt32)}
	Inf      Value = SuDnum{Dnum: dnum.PosInf}
	NegInf   Value = SuDnum{Dnum: dnum.NegInf}
	True     Value = SuBool(true)
	False    Value = SuBool(false)
)
var EmptyStr Value = SuStr("")
var NilVal Value

func GetBuiltinNames

func GetBuiltinNames() []Value

func InfoStr

func InfoStr(name string) Value

func IsConcurrent

func IsConcurrent(x any) Value

func NumFromString

func NumFromString(s string) Value

NumFromString converts a string to an SuInt or SuDnum. It will panic for invalid input.

func OpAdd

func OpAdd(x Value, y Value) Value

func OpBitAnd

func OpBitAnd(x Value, y Value) Value

func OpBitNot

func OpBitNot(x Value) Value

func OpBitOr

func OpBitOr(x Value, y Value) Value

func OpBitXor

func OpBitXor(x Value, y Value) Value

func OpCat

func OpCat(th *Thread, x, y Value) Value

func OpDiv

func OpDiv(x Value, y Value) Value

func OpGt

func OpGt(x Value, y Value) Value

func OpGte

func OpGte(x Value, y Value) Value

func OpInRange

func OpInRange(x Value, orgOp tok.Token, org Value, endOp tok.Token, end Value) Value

func OpIs

func OpIs(x Value, y Value) Value

func OpIsnt

func OpIsnt(x Value, y Value) Value

func OpLeftShift

func OpLeftShift(x Value, y Value) Value

func OpLt

func OpLt(x Value, y Value) Value

func OpLte

func OpLte(x Value, y Value) Value

func OpMod

func OpMod(x Value, y Value) Value

func OpMul

func OpMul(x Value, y Value) Value

func OpNot

func OpNot(x Value) Value

func OpRightShift

func OpRightShift(x Value, y Value) Value

func OpSub

func OpSub(x Value, y Value) Value

func OpUnaryMinus

func OpUnaryMinus(x Value) Value

func OpUnaryPlus

func OpUnaryPlus(x Value) Value

func Unpack

func Unpack(s string) Value

Unpack returns the decoded value

func UnpackDate

func UnpackDate(s string) Value

UnpackDate unpacks a date from the supplied byte slice

func UnpackNumber

func UnpackNumber(s string) Value

type ValueBase

type ValueBase[E any] struct{}

ValueBase is embedded in Value types to supply default methods. The parameter type is only used to get a type name for errors.

func (ValueBase[E]) AsStr

func (ValueBase[E]) AsStr() (string, bool)

func (ValueBase[E]) Call

func (ValueBase[E]) Call(*Thread, Value, *ArgSpec) Value

func (ValueBase[E]) Compare

func (ValueBase[E]) Compare(Value) int

func (ValueBase[E]) Get

func (ValueBase[E]) Get(*Thread, Value) Value

func (ValueBase[E]) GetPut

func (ValueBase[E]) GetPut(*Thread, Value, Value, func(x, y Value) Value, bool) Value

func (ValueBase[E]) Hash

func (ValueBase[E]) Hash() uint32

func (ValueBase[E]) Hash2

func (ValueBase[E]) Hash2() uint32

func (ValueBase[E]) IfInt

func (ValueBase[E]) IfInt() (int, bool)

func (ValueBase[E]) Lookup

func (ValueBase[E]) Lookup(*Thread, string) Callable

func (ValueBase[E]) Put

func (ValueBase[E]) Put(*Thread, Value, Value)

func (ValueBase[E]) RangeLen

func (ValueBase[E]) RangeLen(int, int) Value

func (ValueBase[E]) RangeTo

func (ValueBase[E]) RangeTo(int, int) Value

func (ValueBase[E]) SetConcurrent

func (ValueBase[E]) SetConcurrent()

func (ValueBase[E]) String

func (ValueBase[E]) String() string

func (ValueBase[E]) ToContainer

func (ValueBase[E]) ToContainer() (Container, bool)

func (ValueBase[E]) ToDnum

func (ValueBase[E]) ToDnum() (dnum.Dnum, bool)

func (ValueBase[E]) ToInt

func (ValueBase[E]) ToInt() (int, bool)

func (ValueBase[E]) ToStr

func (ValueBase[E]) ToStr() (string, bool)

func (ValueBase[E]) Type

func (ValueBase[E]) Type() types.Type

func (ValueBase[E]) TypeName

func (ValueBase[E]) TypeName() string

type ValueList

type ValueList = list.List[Value]

Directories

Path Synopsis
Package opcodes defines the bytecode instructions generated by compiler and executed by runtime
Package opcodes defines the bytecode instructions generated by compiler and executed by runtime

Jump to

Keyboard shortcuts

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