Documentation ¶
Index ¶
- Constants
- Variables
- func ArgCount(rt *Runtime) int64
- func Args(rt *Runtime) *core.Array
- func ArgsTail(rt *Runtime) *core.Array
- func ArgsºStr(rt *Runtime, flag string) *core.Array
- func ArgºStr(rt *Runtime, flag string) string
- func ArgºStrInt(rt *Runtime, flag string, def int64) (int64, error)
- func ArgºStrStr(rt *Runtime, flag, def string) string
- func CopyVar(rt *Runtime, ptr *interface{}, value interface{})
- func CtxGetºStr(rt *Runtime, key string) (string, error)
- func CtxIsºStr(rt *Runtime, key string) int64
- func CtxSetºStrBool(rt *Runtime, key string, value int64) (string, error)
- func CtxSetºStrFloat(rt *Runtime, key string, value float64) (string, error)
- func CtxSetºStrInt(rt *Runtime, key string, value int64) (string, error)
- func CtxSetºStrStr(rt *Runtime, key, value string) (string, error)
- func CtxValueºStr(rt *Runtime, key string) string
- func CtxºStr(rt *Runtime, input string) (string, error)
- func DaysºTime(it *Struct) int64
- func EqualºTimeTime(left, right *Struct) int64
- func ErrFormat(path string, line, pos int64, message string) string
- func ErrID(err *RuntimeError) int64
- func ErrText(err *RuntimeError) string
- func ErrTrace(rt *Runtime, err *RuntimeError) *core.Array
- func ErrorText(id int) string
- func FormatºTimeStr(layout string, t *Struct) string
- func GreaterºTimeTime(left, right *Struct) int64
- func IsArgºStr(rt *Runtime, flag string) int64
- func LessºTimeTime(left, right *Struct) int64
- func OpenWithºStr(app, fname string) error
- func OpenºStr(fname string) error
- func ReadDirºStr(rt *Runtime, dirname string) (*core.Array, error)
- func Run(exec *core.Exec, settings Settings) (interface{}, error)
- func SetFileTimeºStrTime(name string, ftime *Struct) error
- func Trace(rt *Runtime) *core.Array
- func WeekdayºTime(rt *Runtime, t *Struct) int64
- func YearDayºTime(t *Struct) int64
- type Call
- type Const
- type Fn
- type OptValue
- type Runtime
- type RuntimeError
- type Settings
- type Struct
- func AddHoursºTimeInt(rt *Runtime, it *Struct, hours int64) *Struct
- func DateTimeºInts(rt *Runtime, year, month, day, hour, minute, second int64) *Struct
- func DateºInts(rt *Runtime, year, month, day int64) *Struct
- func FileInfoºStr(rt *Runtime, name string) (*Struct, error)
- func NewStruct(rt *Runtime, sInfo *core.StructInfo) *Struct
- func Now(rt *Runtime) *Struct
- func ParseTimeºStrStr(rt *Runtime, layout, value string) (*Struct, error)
- func UTCºTime(rt *Runtime, local *Struct) *Struct
- type Thread
- type TraceInfo
- type VM
Constants ¶
const ( // CtxChar is a context boundery character CtxChar = '#' // CtxLength is the max length of the context key CtxLength = 64 // CtxDeep is the max deep in replace function CtxDeep = 16 )
const ( // ErrRunIndex is returned when Run has been executed with wrong index ErrRunIndex = iota + 1 // ErrDepth is returned when maximum depth of recursion has been reached ErrDepth // ErrDivZero is returned when there is division by zero ErrDivZero // ErrCycle is returned when maximum cycle count has been reached ErrCycle // ErrShift is returned when << or >> are used with the negative right operand ErrShift // ErrStrToInt is returned when the conversion string to integer is invalid ErrStrToInt // ErrStrToFloat is returned when the conversion string to float is invalid ErrStrToFloat // ErrEmptyCommand is returned if empty command is specified in $ ErrEmptyCommand // ErrQuoteCommand is returned if there is an unclosed quotation mark in $ command ErrQuoteCommand // ErrIndexOut means that int index is out of the length of the array ErrIndexOut // ErrMapIndex is returned when there is not the key in the map ErrMapIndex // ErrAssignment is returned when there is a recursive assignment ErrAssignment // ErrUndefined means that the value of the variable is undefined ErrUndefined // ErrByteOut is returned when value for buf is greater 255 ErrByteOut // ErrInvalidParam is returned when the function gets invalid parameter(s) ErrInvalidParam // ErrNotRun is returned when the executing unit doesn't have run function ErrNotRun // ErrFnEmpty is returned in case of calling undefined fn variable ErrFnEmpty // ErrThreadIndex is returned when the index of the thread is out of range ErrThreadIndex // ErrThreadClosed is generated when the thread has been closed ErrThreadClosed // ErrPlatform is generated when the function is not supported on the current platform ErrPlatform // ErrEmbedded means golang error in embedded functions ErrEmbedded = 254 // ErrRuntime error. It means bug ErrRuntime = 255 )
const ( TRACESTRUCT = iota TIMESTRUCT FINFOSTRUCT )
const ( // ThQueue means that the thread is in the queue to start ThQueue = iota // ThWork means that the thread is running ThWork // ThPaused means that the thread has been suspended ThPaused // ThWait means that the thread is waiting for the end of another thread ThWait // ThFinished means that the thread finished ThFinished // ThError means that the thread has been closed with an error ThError // ThClosed means that the thread has been closed ThClosed )
const ( // ThCmdClose closes the thread ThCmdClose = iota // ThCmdResume resumes the thread ThCmdResume // ThCmdContinue continues the thread after waiting ThCmdContinue )
const ( STACKSIZE = 256 // CYCLE is the limit of loops CYCLE = uint64(16000000) // DEPTH is the maximum size of blocks stack DEPTH = uint32(1000) )
const ( // SleepStep is a tick in sleep SleepStep = int64(100) )
Variables ¶
var ( // ErrCtxLength is returned when the key is too long ErrCtxLength = `key length is longer than %d characters` // ErrCtxLoop is returned when there is a loop in values of context ErrCtxLoop = `%s key refers to itself` // ErrCtxDeep is returned if the maximum depth reached ErrCtxDeep = `maximum depth reached` )
var Embedded = []core.Embed{ {Func: CtxSetºStrStr, Return: core.TYPESTR, Params: []uint16{core.TYPESTR, core.TYPESTR}, Runtime: true, CanError: true}, {Func: CtxSetºStrBool, Return: core.TYPESTR, Params: []uint16{core.TYPESTR, core.TYPEBOOL}, Runtime: true, CanError: true}, {Func: CtxSetºStrFloat, Return: core.TYPESTR, Params: []uint16{core.TYPESTR, core.TYPEFLOAT}, Runtime: true, CanError: true}, {Func: CtxSetºStrInt, Return: core.TYPESTR, Params: []uint16{core.TYPESTR, core.TYPEINT}, Runtime: true, CanError: true}, {Func: CtxValueºStr, Return: core.TYPESTR, Params: []uint16{core.TYPESTR}, Runtime: true}, {Func: CtxIsºStr, Return: core.TYPEBOOL, Params: []uint16{core.TYPESTR}, Runtime: true}, {Func: CtxºStr, Return: core.TYPESTR, Params: []uint16{core.TYPESTR}, Runtime: true, CanError: true}, {Func: CtxGetºStr, Return: core.TYPESTR, Params: []uint16{core.TYPESTR}, Runtime: true, CanError: true}, {Func: sleepºInt, Params: []uint16{core.TYPEINT}, Runtime: true}, {Func: errorºIntStr, Params: []uint16{core.TYPEINT, core.TYPESTR}, CanError: true, Variadic: true}, {Func: terminateºThread, Params: []uint16{core.TYPEINT}, Runtime: true, CanError: true}, {Func: waitºThread, Params: []uint16{core.TYPEINT}, Runtime: true, CanError: true}, {Func: ErrID, Return: core.TYPEINT, Params: []uint16{core.TYPEERROR}}, {Func: ErrText, Return: core.TYPESTR, Params: []uint16{core.TYPEERROR}}, {Func: ErrTrace, Return: core.TYPEARR, Params: []uint16{core.TYPEERROR}, Runtime: true}, {Func: ParseTimeºStrStr, Return: core.TYPESTRUCT, Params: []uint16{core.TYPESTR, core.TYPESTR}, Runtime: true, CanError: true}, {Func: FileInfoºStr, Return: core.TYPESTRUCT, Params: []uint16{core.TYPESTR}, Runtime: true, CanError: true}, {Func: ReadDirºStr, Return: core.TYPEARR, Params: []uint16{core.TYPESTR}, Runtime: true, CanError: true}, {Func: SetFileTimeºStrTime, Params: []uint16{core.TYPESTR, core.TYPESTRUCT}, CanError: true}, {Func: EqualºTimeTime, Return: core.TYPEBOOL, Params: []uint16{core.TYPESTRUCT, core.TYPESTRUCT}}, {Func: FormatºTimeStr, Return: core.TYPESTR, Params: []uint16{core.TYPESTR, core.TYPESTRUCT}}, {Func: GreaterºTimeTime, Return: core.TYPEBOOL, Params: []uint16{core.TYPESTRUCT, core.TYPESTRUCT}}, {Func: LessºTimeTime, Return: core.TYPEBOOL, Params: []uint16{core.TYPESTRUCT, core.TYPESTRUCT}}, {Func: ArgCount, Return: core.TYPEINT, Runtime: true}, {Func: ArgºStr, Return: core.TYPESTR, Params: []uint16{core.TYPESTR}, Runtime: true}, {Func: ArgºStrStr, Return: core.TYPESTR, Params: []uint16{core.TYPESTR, core.TYPESTR}, Runtime: true}, {Func: ArgºStrInt, Return: core.TYPEINT, Params: []uint16{core.TYPESTR, core.TYPEINT}, Runtime: true, CanError: true}, {Func: Args, Return: core.TYPEARR, Runtime: true}, {Func: ArgsºStr, Return: core.TYPEARR, Params: []uint16{core.TYPESTR}, Runtime: true}, {Func: ArgsTail, Return: core.TYPEARR, Runtime: true}, {Func: IsArgºStr, Return: core.TYPEBOOL, Params: []uint16{core.TYPESTR}, Runtime: true}, {Func: OpenºStr, Params: []uint16{core.TYPESTR}, CanError: true}, {Func: OpenWithºStr, Params: []uint16{core.TYPESTR, core.TYPESTR}, CanError: true}, {Func: sysRun, Params: []uint16{core.TYPESTR, core.TYPEBOOL, core.TYPEBUF, core.TYPEBUF, core.TYPEBUF, core.TYPEARR}, CanError: true}, {Func: Trace, Return: core.TYPEARR, Runtime: true}, {Func: resumeºThread, Params: []uint16{core.TYPEINT}, Runtime: true, CanError: true}, {Func: suspendºThread, Params: []uint16{core.TYPEINT}, Runtime: true, CanError: true}, {Func: Now, Return: core.TYPESTRUCT, Runtime: true}, {Func: UTCºTime, Return: core.TYPESTRUCT, Params: []uint16{core.TYPESTRUCT}, Runtime: true}, {Func: WeekdayºTime, Return: core.TYPEINT, Params: []uint16{core.TYPESTRUCT}, Runtime: true}, {Func: YearDayºTime, Return: core.TYPEINT, Params: []uint16{core.TYPESTRUCT}}, {Func: intºTime, Return: core.TYPEINT, Params: []uint16{core.TYPESTRUCT}}, {Func: timeºInt, Return: core.TYPESTRUCT, Params: []uint16{core.TYPEINT}, Runtime: true}, {Func: AddHoursºTimeInt, Return: core.TYPESTRUCT, Params: []uint16{core.TYPESTRUCT, core.TYPEINT}, Runtime: true}, {Func: DateºInts, Return: core.TYPESTRUCT, Params: []uint16{core.TYPEINT, core.TYPEINT, core.TYPEINT}, Runtime: true}, {Func: DateTimeºInts, Return: core.TYPESTRUCT, Params: []uint16{core.TYPEINT, core.TYPEINT, core.TYPEINT, core.TYPEINT, core.TYPEINT, core.TYPEINT}, Runtime: true}, {Func: DaysºTime, Return: core.TYPEINT, Params: []uint16{core.TYPESTRUCT}}, }
Functions ¶
func ArgºStrInt ¶ added in v1.6.0
ArgºStrInt returns the number value of the command-line option or the default value
func ArgºStrStr ¶ added in v1.6.0
ArgºStrStr returns the value of the command-line option or the default value
func CopyVar ¶ added in v1.6.0
func CopyVar(rt *Runtime, ptr *interface{}, value interface{})
CopyVar copies one object to another one
func CtxGetºStr ¶ added in v1.6.0
CtxGetºStr replaces context values in the value of the key
func CtxSetºStrBool ¶ added in v1.6.0
CtxSetºStrBool assign a bool to a context key
func CtxSetºStrFloat ¶ added in v1.6.0
CtxSetºStrFloat assign a float to a context key
func CtxSetºStrInt ¶ added in v1.6.0
CtxSetºStrInt assign an integer to a context key
func CtxSetºStrStr ¶ added in v1.6.0
CtxSetºStrStr sets a context value
func CtxValueºStr ¶ added in v1.6.0
CtxValueºStr returns a context value
func EqualºTimeTime ¶ added in v1.6.0
EqualºTimeTime returns true if time structures are equal
func ErrText ¶ added in v1.6.0
func ErrText(err *RuntimeError) string
ErrText returns the text of the error
func ErrTrace ¶ added in v1.6.0
func ErrTrace(rt *Runtime, err *RuntimeError) *core.Array
ErrTrace returns the trace of the error
func FormatºTimeStr ¶ added in v1.6.0
FormatºTimeStr formats the time
func GreaterºTimeTime ¶ added in v1.6.0
GreaterºTimeTime returns true if left time structures are greater than right
func LessºTimeTime ¶ added in v1.6.0
LessºTimeTime returns true if left time structures are less than right
func OpenWithºStr ¶ added in v1.6.0
OpenWithºStr runs the application with the specified file.
func ReadDirºStr ¶ added in v1.6.0
ReadDirºStr reads a directory
func SetFileTimeºStrTime ¶ added in v1.6.0
SetFileTimeºStrTime changes the modification time of the named file
func WeekdayºTime ¶ added in v1.6.0
WeekdayºTime returns the day of the week specified by t.
func YearDayºTime ¶ added in v1.6.0
YearDayºTime returns the day of the year specified by t.
Types ¶
type Call ¶
type Call struct { IsFunc bool IsLocal bool Cycle uint64 Offset int32 Int int32 Float int32 Str int32 Any int32 Optional *[]OptValue // for loop blocks Flags int16 Start int32 Continue int32 // shift for continue Break int32 // shift for break Try int32 // shift for try Recover int32 // shift for recover Retry int32 // shift for retry }
Call stores stack of blocks
type Fn ¶ added in v1.6.0
type Fn struct {
Func int32 // id of function
}
Fn is used for custom func types
type Runtime ¶
type Runtime struct { Owner *VM ParCount int32 Calls []Call Thread Thread ThreadID int64 Optional *[]OptValue // These are stacks for different types SInt [STACKSIZE]int64 // int, char, bool SFloat [STACKSIZE]float64 // float SStr [STACKSIZE]string // str SAny [STACKSIZE]interface{} // all other types }
Runtime is the one thread structure
type RuntimeError ¶ added in v1.6.0
RuntimeError is a runtime error type
func (*RuntimeError) Error ¶ added in v1.6.0
func (re *RuntimeError) Error() string
type Struct ¶ added in v1.6.0
type Struct struct { Type *core.StructInfo Values []interface{} // Values of fields }
Struct is used for custom struct types
func AddHoursºTimeInt ¶ added in v1.6.0
AddHoursºTimeInt adds/subtract hours
func DateTimeºInts ¶ added in v1.6.0
DateTimeºInts returns time
func FileInfoºStr ¶ added in v1.6.0
FileInfoºStr returns the finfo describing the named file.
func NewStruct ¶ added in v1.6.0
func NewStruct(rt *Runtime, sInfo *core.StructInfo) *Struct
NewStruct creates a new struct object
func ParseTimeºStrStr ¶ added in v1.6.0
ParseTimeºStrStr parses a formatted string and returns the time value it represents
type TraceInfo ¶ added in v1.6.0
type TraceInfo struct { Path string // the full path name of the source Entry string // the entry function name Func string // the called function Line int64 // line position in the source Pos int64 // column position in the line }
TraceInfo is a structure for stack func info
type VM ¶
type VM struct { Settings Settings Exec *core.Exec Consts map[int32]Const Runtimes []*Runtime CtxMutex sync.RWMutex ThreadMutex sync.RWMutex Context map[string]string Count int64 // count of active threads ChCount chan int64 ChError chan error }
VM is the main structure of the virtual machine