vm

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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
	// ErrCustom is generated when there is an invalid custom declaration
	ErrCustom
	// ErrCRC is returned when Exec was compiled with different stdlib or custom functions
	ErrCRC

	// ErrEmbedded means golang error in embedded functions
	ErrEmbedded = 254
	// ErrRuntime error. It means bug
	ErrRuntime = 255
)
View Source
const (
	TRACESTRUCT = iota
	TIMESTRUCT
	FINFOSTRUCT
)
View Source
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
)
View Source
const (
	// ThCmdClose closes the thread
	ThCmdClose = iota
	// ThCmdResume resumes the thread
	ThCmdResume
	// ThCmdContinue continues the thread after waiting
	ThCmdContinue
)
View Source
const (
	STACKSIZE = 256
	// CYCLE is the limit of loops
	CYCLE = uint64(16000000)
	// DEPTH is the maximum size of blocks stack
	DEPTH = uint32(1000)
)
View Source
const (
	// SleepStep is a tick in sleep
	SleepStep = int64(100)
)
View Source
const StdLibCount = 260

Variables

View Source
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`
)
View Source
var CRCCustom uint64
View Source
var CRCStdlib uint64
View Source
var EmbedFuncs = []core.Embed{}/* 260 elements not displayed */

Functions

func AbsPath added in v1.7.0

func AbsPath(fname string) (string, error)

AbsPath returns an absolute representation of path.

func AbsºInt added in v1.7.0

func AbsºInt(x int64) int64

AbsºInt the absolute value of x.

func AddºBufBuf added in v1.7.0

func AddºBufBuf(left *core.Buffer, right *core.Buffer) (out *core.Buffer)

AddºBufBuf adds two buffers

func AddºCharChar added in v1.7.0

func AddºCharChar(left, right int64) string

AddºCharChar adds two rune values

func AddºCharStr added in v1.7.0

func AddºCharStr(left int64, right string) string

AddºCharStr appends rune to string

func AddºFloatInt added in v1.7.0

func AddºFloatInt(left float64, right int64) float64

AddºFloatInt adds float and int

func AddºIntFloat added in v1.7.0

func AddºIntFloat(left int64, right float64) float64

AddºIntFloat adds int and float

func AddºStrChar added in v1.7.0

func AddºStrChar(left string, right int64) string

AddºStrChar appends rune to string

func AppendFileºStrBuf added in v1.7.0

func AppendFileºStrBuf(filename string, buf *core.Buffer) error

AppendFileºStrBuf appends a buffer to a file

func AppendFileºStrStr added in v1.7.0

func AppendFileºStrStr(filename, s string) error

AppendFileºStrStr appends a string to a file

func ArgCount added in v1.6.0

func ArgCount(rt *Runtime) int64

ArgCount returns the count of command-line parameters

func Args added in v1.6.0

func Args(rt *Runtime) *core.Array

Args returns the command-line parameters

func ArgsTail added in v1.6.0

func ArgsTail(rt *Runtime) *core.Array

ArgsTail returns the list of command-line parameters

func ArgsºStr added in v1.6.0

func ArgsºStr(rt *Runtime, flag string) *core.Array

ArgsºStr returns the value list of command-line option

func ArgºStr added in v1.6.0

func ArgºStr(rt *Runtime, flag string) string

ArgºStr returns the value of the command-line option

func ArgºStrInt added in v1.6.0

func ArgºStrInt(rt *Runtime, flag string, def int64) (int64, error)

ArgºStrInt returns the number value of the command-line option or the default value

func ArgºStrStr added in v1.6.0

func ArgºStrStr(rt *Runtime, flag, def string) string

ArgºStrStr returns the value of the command-line option or the default value

func AssignAddºArr added in v1.7.0

func AssignAddºArr(dest interface{}, src interface{}) (interface{}, error)

AssignAddºArr appends one array to another one

func AssignAddºArrAny added in v1.7.0

func AssignAddºArrAny(arr interface{}, value interface{}) (interface{}, error)

AssignAddºArrAny appends an item to array

func AssignAddºBufBuf added in v1.7.0

func AssignAddºBufBuf(buf interface{}, value interface{}) (interface{}, error)

AssignAddºBufBuf appends buffer to buffer

func AssignAddºBufChar added in v1.7.0

func AssignAddºBufChar(buf interface{}, value interface{}) (interface{}, error)

AssignAddºBufChar appends rune to buffer

func AssignAddºBufInt added in v1.7.0

func AssignAddºBufInt(buf interface{}, value interface{}) (interface{}, error)

AssignAddºBufInt appends one byte to buffer

func AssignAddºBufStr added in v1.7.0

func AssignAddºBufStr(buf interface{}, value interface{}) (interface{}, error)

AssignAddºBufStr appends string to buffer

func AssignAddºFloatFloat added in v1.7.0

func AssignAddºFloatFloat(ptr *float64, value float64) (float64, error)

AssignAddºFloatFloat adds one float to another

func AssignAddºIntInt added in v1.7.0

func AssignAddºIntInt(ptr *int64, value int64) (int64, error)

AssignAddºIntInt adds one integer to another

func AssignAddºSetSet added in v1.7.0

func AssignAddºSetSet(set interface{}, value interface{}) (interface{}, error)

AssignAddºSetSet appends set to set

func AssignAddºStrChar added in v1.7.0

func AssignAddºStrChar(ptr *string, value interface{}) (string, error)

AssignAddºStrChar appends one rune to string

func AssignAddºStrStr added in v1.7.0

func AssignAddºStrStr(ptr *string, value interface{}) (string, error)

AssignAddºStrStr appends one string to another

func AssignBitAndºIntInt added in v1.7.0

func AssignBitAndºIntInt(ptr *int64, value int64) (int64, error)

AssignBitAndºIntInt equals int &= int

func AssignBitOrºIntInt added in v1.7.0

func AssignBitOrºIntInt(ptr *int64, value int64) (int64, error)

AssignBitOrºIntInt equals int |= int

func AssignBitXorºIntInt added in v1.7.0

func AssignBitXorºIntInt(ptr *int64, value int64) (int64, error)

AssignBitXorºIntInt equals int ^= int

func AssignDivºFloatFloat added in v1.7.0

func AssignDivºFloatFloat(ptr *float64, value float64) (float64, error)

AssignDivºFloatFloat does float /= float

func AssignDivºIntInt added in v1.7.0

func AssignDivºIntInt(ptr *int64, value int64) (int64, error)

AssignDivºIntInt does int /= int

func AssignLShiftºIntInt added in v1.7.0

func AssignLShiftºIntInt(ptr *int64, value int64) (int64, error)

AssignLShiftºIntInt does int <<= int

func AssignModºIntInt added in v1.7.0

func AssignModºIntInt(ptr *int64, value int64) (int64, error)

AssignModºIntInt equals int %= int

func AssignMulºFloatFloat added in v1.7.0

func AssignMulºFloatFloat(ptr *float64, value float64) (float64, error)

AssignMulºFloatFloat equals float *= float

func AssignMulºIntInt added in v1.7.0

func AssignMulºIntInt(ptr *int64, value int64) (int64, error)

AssignMulºIntInt equals int *= int

func AssignRShiftºIntInt added in v1.7.0

func AssignRShiftºIntInt(ptr *int64, value int64) (int64, error)

AssignRShiftºIntInt does int >>= int

func AssignSubºFloatFloat added in v1.7.0

func AssignSubºFloatFloat(ptr *float64, value float64) (float64, error)

AssignSubºFloatFloat equals float *= float

func AssignSubºIntInt added in v1.7.0

func AssignSubºIntInt(ptr *int64, value int64) (int64, error)

AssignSubºIntInt equals int *= int

func AssignºStrBool added in v1.7.0

func AssignºStrBool(ptr *string, value interface{}) (string, error)

AssignºStrBool assigns boolean to string

func AssignºStrInt added in v1.7.0

func AssignºStrInt(ptr *string, value interface{}) (string, error)

AssignºStrInt assigns integer to string

func Base64ºBuf added in v1.7.0

func Base64ºBuf(buf *core.Buffer) string

Base64ºBuf encodes buf to base64 string

func BaseName added in v1.7.0

func BaseName(fname string) string

BaseName returns the last element of path.

func BitAndºSetSet added in v1.7.0

func BitAndºSetSet(left *core.Set, right *core.Set) *core.Set

BitAndºSetSet equals set & set

func BitNotºSet added in v1.7.0

func BitNotºSet(set *core.Set) *core.Set

BitNotºSet changes boolean value of set

func BitOrºSetSet added in v1.7.0

func BitOrºSetSet(left *core.Set, right *core.Set) *core.Set

BitOrºSetSet equals set & set

func CeilºFloat added in v1.7.0

func CeilºFloat(val float64) int64

CeilºFloat returns the least integer value greater than or equal to val.

func ChDirºStr added in v1.7.0

func ChDirºStr(dirname string) error

ChDirºStr change the current directory

func Command added in v1.7.0

func Command(cmdLine string) error

Command executes the command line

func CommandOutput added in v1.7.0

func CommandOutput(cmdLine string) (string, error)

CommandOutput executes the command line and returns the standard output

func CopyFileºStrStr added in v1.7.0

func CopyFileºStrStr(src, dest string) (int64, error)

CopyFileºStrStr copies a file

func CopyVar added in v1.6.0

func CopyVar(rt *Runtime, ptr *interface{}, value interface{})

CopyVar copies one object to another one

func CreateDirºStr added in v1.7.0

func CreateDirºStr(dirname string) error

CreateDirºStr creates the directory(s)

func CtxGetºStr added in v1.6.0

func CtxGetºStr(rt *Runtime, key string) (string, error)

CtxGetºStr replaces context values in the value of the key

func CtxIsºStr added in v1.6.0

func CtxIsºStr(rt *Runtime, key string) int64

CtxIsºStr returns true if a context key exists

func CtxSetºStrBool added in v1.6.0

func CtxSetºStrBool(rt *Runtime, key string, value int64) (string, error)

CtxSetºStrBool assign a bool to a context key

func CtxSetºStrFloat added in v1.6.0

func CtxSetºStrFloat(rt *Runtime, key string, value float64) (string, error)

CtxSetºStrFloat assign a float to a context key

func CtxSetºStrInt added in v1.6.0

func CtxSetºStrInt(rt *Runtime, key string, value int64) (string, error)

CtxSetºStrInt assign an integer to a context key

func CtxSetºStrStr added in v1.6.0

func CtxSetºStrStr(rt *Runtime, key, value string) (string, error)

CtxSetºStrStr sets a context value

func CtxValueºStr added in v1.6.0

func CtxValueºStr(rt *Runtime, key string) string

CtxValueºStr returns a context value

func CtxºStr added in v1.6.0

func CtxºStr(rt *Runtime, input string) (string, error)

CtxºStr replaces context values in a string

func DaysºTime added in v1.6.0

func DaysºTime(it *Struct) int64

DaysºTime returns the days of the month

func DelºBufIntInt added in v1.7.0

func DelºBufIntInt(buf *core.Buffer, off, length int64) (*core.Buffer, error)

DelºBufIntInt deletes part of the buffer

func DelºMapStr added in v1.7.0

func DelºMapStr(pmap *core.Map, key string) *core.Map

DelºMapStr deletes key and value from the map

func Dir added in v1.7.0

func Dir(fname string) string

Dir returns all but the last element of path.

func DivºFloatInt added in v1.7.0

func DivºFloatInt(left float64, right int64) (float64, error)

DivºFloatInt divides one float by int

func DivºIntFloat added in v1.7.0

func DivºIntFloat(left int64, right float64) (float64, error)

DivºIntFloat divides one int by float

func Download added in v1.7.0

func Download(url, filename string) (int64, error)

Download downloads and saves the file by url.

func EqualºFloatInt added in v1.7.0

func EqualºFloatInt(left float64, right int64) int64

EqualºFloatInt returns true if left == right

func EqualºTimeTime added in v1.6.0

func EqualºTimeTime(left, right *Struct) int64

EqualºTimeTime returns true if time structures are equal

func ErrFormat added in v1.6.0

func ErrFormat(path string, line, pos int64, message string) string

ErrFormat is a function for formating error message

func ErrID added in v1.6.0

func ErrID(err *RuntimeError) int64

ErrID returns the id of the error

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 ErrorText added in v1.6.0

func ErrorText(id int) string

ErrorText returns the text of the error message

func ExpStrºBool added in v1.7.0

func ExpStrºBool(left string, right int64) string

ExpStrºBool adds string and boolean in string expression

func ExpStrºChar added in v1.7.0

func ExpStrºChar(left string, right int64) string

ExpStrºChar adds string and char in string expression

func ExpStrºFloat added in v1.7.0

func ExpStrºFloat(left string, right float64) string

ExpStrºFloat adds string and float in string expression

func ExpStrºInt added in v1.7.0

func ExpStrºInt(left string, right int64) string

ExpStrºInt adds string and integer in string expression

func Ext added in v1.7.0

func Ext(fname string) string

Ext returns the file name extension used by path.

func FindRegExpºStrStr added in v1.7.0

func FindRegExpºStrStr(src, rePattern string) (*core.Array, error)

FindRegExpºStrStr returns an array of all successive matches of the expression

func FindºStrStr added in v1.7.0

func FindºStrStr(s, substr string) (off int64)

FindºStrStr returns the index of the first instance of substr

func FloorºFloat added in v1.7.0

func FloorºFloat(val float64) int64

FloorºFloat returns the greatest integer value less than or equal to val.

func FormatºStr added in v1.7.0

func FormatºStr(pattern string, pars ...interface{}) string

FormatºStr formats according to a format specifier and returns the resulting string

func FormatºTimeStr added in v1.6.0

func FormatºTimeStr(layout string, t *Struct) string

FormatºTimeStr formats the time

func GetCurDir added in v1.7.0

func GetCurDir() (string, error)

GetCurDir returns the current directory

func GetEnv added in v1.7.0

func GetEnv(name string) string

GetEnv return the value of the environment variable

func GreaterºCharChar added in v1.7.0

func GreaterºCharChar(left, right int64) int64

GreaterºCharChar returns true if left > right

func GreaterºFloatInt added in v1.7.0

func GreaterºFloatInt(left float64, right int64) int64

GreaterºFloatInt returns true if left > right

func GreaterºTimeTime added in v1.6.0

func GreaterºTimeTime(left, right *Struct) int64

GreaterºTimeTime returns true if left time structures are greater than right

func HTTPGet added in v1.7.0

func HTTPGet(url string) (buf *core.Buffer, err error)

HTTPGet issues a GET to the specified URL.

func HTTPPage added in v1.7.0

func HTTPPage(url string) (string, error)

HTTPPage issues a GET to the specified URL and returns a string result.

func HasPrefixºStrStr added in v1.7.0

func HasPrefixºStrStr(s, prefix string) int64

HasPrefixºStrStr returns true if the string s begins with prefix

func HasSuffixºStrStr added in v1.7.0

func HasSuffixºStrStr(s, suffix string) int64

HasSuffixºStrStr returns true if the string s ends with suffix

func HexºBuf added in v1.7.0

func HexºBuf(buf *core.Buffer) string

HexºBuf encodes buf to hex string

func IncDecºInt added in v1.7.0

func IncDecºInt(ptr *int64, shift int64) (int64, error)

IncDecºInt incriment and decriment

func InsertºBufIntBuf added in v1.7.0

func InsertºBufIntBuf(buf *core.Buffer, off int64, b *core.Buffer) (*core.Buffer, error)

InsertºBufIntBuf inserts one buf object into another one

func IsArgºStr added in v1.6.0

func IsArgºStr(rt *Runtime, flag string) int64

IsArgºStr returns true if the options is present

func IsKeyºMapStr added in v1.7.0

func IsKeyºMapStr(pmap *core.Map, key string) int64

IsKeyºMapStr returns true if there is the key in the map

func IsSet added in v1.7.0

func IsSet(set *core.Set, index int64) int64

IsSet returns the value of set[index]

func JoinPath added in v1.7.0

func JoinPath(pars ...interface{}) string

JoinPath joins any number of path elements into a single path.

func JoinºArrStr added in v1.7.0

func JoinºArrStr(value *core.Array, sep string) string

JoinºArrStr concatenates the elements of a to create a single string.

func KeyºMapInt added in v1.7.0

func KeyºMapInt(pmap *core.Map, index int64) (string, error)

KeyºMapInt returns the key by the index

func LeftºStrInt added in v1.7.0

func LeftºStrInt(s string, count int64) string

LeftºStrInt cuts the string.

func LessºCharChar added in v1.7.0

func LessºCharChar(left, right int64) int64

LessºCharChar returns true if left < right

func LessºFloatInt added in v1.7.0

func LessºFloatInt(left float64, right int64) int64

LessºFloatInt returns true if left < right

func LessºTimeTime added in v1.6.0

func LessºTimeTime(left, right *Struct) int64

LessºTimeTime returns true if left time structures are less than right

func LinesºStr added in v1.7.0

func LinesºStr(in string) *core.Array

LinesºStr splits a string to a array of strings

func LowerºStr added in v1.7.0

func LowerºStr(s string) string

LowerºStr converts a copy of the string to their lower case and returns it.

func MatchPath added in v1.7.0

func MatchPath(pattern, fname string) (int64, error)

MatchPath reports whether name matches the specified file name pattern.

func MatchºStrStr added in v1.7.0

func MatchºStrStr(s string, rePattern string) (int64, error)

MatchºStrStr reports whether the string s contains any match of the regular expression

func MaxºFloatFloat added in v1.7.0

func MaxºFloatFloat(left, right float64) float64

MaxºFloatFloat returns the maximum of two float numbers

func MaxºIntInt added in v1.7.0

func MaxºIntInt(left, right int64) int64

MaxºIntInt returns the maximum of two integers

func Md5FileºStr added in v1.7.0

func Md5FileºStr(filename string) (string, error)

Md5FileºStr returns md5 hash of the file as a hex string

func Md5ºBuf added in v1.7.0

func Md5ºBuf(in *core.Buffer) (out *core.Buffer)

Md5ºBuf returns md5 hash of the buffer

func Md5ºStr added in v1.7.0

func Md5ºStr(in string) (out *core.Buffer)

Md5ºStr returns md5 hash of the string as hex string

func MinºFloatFloat added in v1.7.0

func MinºFloatFloat(left, right float64) float64

MinºFloatFloat returns the minimum of two float numbers

func MinºIntInt added in v1.7.0

func MinºIntInt(left, right int64) int64

MinºIntInt returns the minimum of two integers

func MulºFloatInt added in v1.7.0

func MulºFloatInt(left float64, right int64) float64

MulºFloatInt multiplies float and int

func MulºIntFloat added in v1.7.0

func MulºIntFloat(left int64, right float64) float64

MulºIntFloat multiplies int and float

func OpenWithºStr added in v1.6.0

func OpenWithºStr(app, fname string) error

OpenWithºStr runs the application with the specified file.

func OpenºStr added in v1.6.0

func OpenºStr(fname string) error

OpenºStr runs corresponding application with the specified file.

func Print added in v1.7.0

func Print(pars ...interface{}) (int64, error)

Print writes to standard output.

func PrintShiftºStr added in v1.7.0

func PrintShiftºStr(par string) (int64, error)

PrintShiftºStr writes to standard output with trim spaces characters in the each line.

func Println added in v1.7.0

func Println(pars ...interface{}) (int64, error)

Println writes to standard output.

func ReadDirºStr added in v1.6.0

func ReadDirºStr(rt *Runtime, dirname string) (*core.Array, error)

ReadDirºStr reads a directory

func ReadFileºStr added in v1.7.0

func ReadFileºStr(filename string) (string, error)

ReadFileºStr reads a file

func ReadFileºStrBuf added in v1.7.0

func ReadFileºStrBuf(filename string, buf *core.Buffer) (*core.Buffer, error)

ReadFileºStrBuf reads a file to buffer

func ReadFileºStrIntInt added in v1.7.0

func ReadFileºStrIntInt(filename string, off int64, length int64) (buf *core.Buffer, err error)

ReadFileºStrIntInt reads a part of the file to the buffer

func ReadString added in v1.7.0

func ReadString(rt *Runtime, text string) (string, error)

ReadString reads a string from standard input.

func RemoveDirºStr added in v1.7.0

func RemoveDirºStr(dirname string) error

RemoveDirºStr removes a directory

func RemoveºStr added in v1.7.0

func RemoveºStr(filename string) error

RemoveºStr removes a file or an empty directory

func RenameºStrStr added in v1.7.0

func RenameºStrStr(oldname, newname string) error

RenameºStrStr renames a file or a directory

func RepeatºStrInt added in v1.7.0

func RepeatºStrInt(input string, count int64) string

RepeatºStrInt returns a new string consisting of count copies of the specified string.

func ReplaceRegExpºStrStr added in v1.7.0

func ReplaceRegExpºStrStr(src, rePattern, repl string) (string, error)

ReplaceRegExpºStrStr returns a copy of src, replacing matches of the Regexp with the replacement string

func ReplaceºStrStrStr added in v1.7.0

func ReplaceºStrStrStr(in, old, new string) string

ReplaceºStrStrStr replaces strings in a string

func ReverseºArr added in v1.7.0

func ReverseºArr(arr *core.Array) *core.Array

ReverseºArr reverses an array

func RoundºFloat added in v1.7.0

func RoundºFloat(val float64) int64

RoundºFloat returns the nearest integer, rounding half away from zero.

func RoundºFloatInt added in v1.7.0

func RoundºFloatInt(val float64, digits int64) float64

RoundºFloatInt returns a number with the specified number of decimal places.

func Run

func Run(exec *core.Exec, settings Settings) (interface{}, error)

func SetEnv added in v1.7.0

func SetEnv(name string, value interface{}) (string, error)

SetEnv assign the value to the environment variable

func SetEnvBool added in v1.7.0

func SetEnvBool(name string, value int64) (string, error)

SetEnvBool assign the value to the environment variable

func SetFileTimeºStrTime added in v1.6.0

func SetFileTimeºStrTime(name string, ftime *Struct) error

SetFileTimeºStrTime changes the modification time of the named file

func SetºSet added in v1.7.0

func SetºSet(set *core.Set, index int64) (*core.Set, error)

SetºSet sets the item in the set

func Sha256FileºStr added in v1.7.0

func Sha256FileºStr(filename string) (string, error)

Sha256FileºStr returns sha256 hash of the file as a hex string

func Sha256ºBuf added in v1.7.0

func Sha256ºBuf(in *core.Buffer) (out *core.Buffer)

Sha256ºBuf returns md5 hash of the buffer

func Sha256ºStr added in v1.7.0

func Sha256ºStr(in string) (out *core.Buffer)

Sha256ºStr returns md5 hash of the string as hex string

func ShiftºStr added in v1.7.0

func ShiftºStr(par string) string

ShiftºStr trims white spaces characters in the each line of the string.

func SliceºArr added in v1.7.0

func SliceºArr(rt *Runtime, arr *core.Array, start, end int64) (*core.Array, error)

SliceºArr extracts some consecutive elements from within an array.

func SortºArr added in v1.7.0

func SortºArr(value *core.Array) *core.Array

SortºArr sorts an array of strings

func SplitºStrStr added in v1.7.0

func SplitºStrStr(in, sep string) *core.Array

SplitºStrStr splits a string to a array of strings

func SubstrºStrIntInt added in v1.7.0

func SubstrºStrIntInt(in string, off, length int64) (string, error)

SubstrºStrIntInt returns a substring with the specified offset and length

func SubºFloatInt added in v1.7.0

func SubºFloatInt(left float64, right int64) float64

SubºFloatInt subtracts float and int

func SubºIntFloat added in v1.7.0

func SubºIntFloat(left int64, right float64) float64

SubºIntFloat subtracts int and float

func TempDir added in v1.7.0

func TempDir() string

TempDir returns the temporary directory

func TempDirºStrStr added in v1.7.0

func TempDirºStrStr(dir, prefix string) (string, error)

TempDirºStrStr creates a directory in the temporary directory

func ToggleºSetInt added in v1.7.0

func ToggleºSetInt(set *core.Set, index int64) (prev int64, err error)

ToggleºSetInt changes the value of the set

func Trace added in v1.6.0

func Trace(rt *Runtime) *core.Array

Trace gets trace information

func TrimRightºStr added in v1.7.0

func TrimRightºStr(in string, set string) string

TrimRightºStr trims white space in a string

func TrimSpaceºStr added in v1.7.0

func TrimSpaceºStr(in string) string

TrimSpaceºStr trims white space in a string

func UnBase64ºStr added in v1.7.0

func UnBase64ºStr(value string) (buf *core.Buffer, err error)

UnBase64ºStr decodes base64 string to buf

func UnHexºStr added in v1.7.0

func UnHexºStr(value string) (*core.Buffer, error)

UnHexºStr decodes hex string to the buffer

func UnSetºSet added in v1.7.0

func UnSetºSet(set *core.Set, index int64) (*core.Set, error)

UnSetºSet sets the item in the set

func UpperºStr added in v1.7.0

func UpperºStr(s string) string

UpperºStr converts a copy of the string to their upper case and returns it.

func WeekdayºTime added in v1.6.0

func WeekdayºTime(rt *Runtime, t *Struct) int64

WeekdayºTime returns the day of the week specified by t.

func WriteFileºStrBuf added in v1.7.0

func WriteFileºStrBuf(filename string, buf *core.Buffer) error

WriteFileºStrBuf writes a buffer to a file

func WriteFileºStrStr added in v1.7.0

func WriteFileºStrStr(filename, in string) error

WriteFileºStrStr writes a string to a file

func YearDayºTime added in v1.6.0

func YearDayºTime(t *Struct) int64

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 Const added in v1.6.0

type Const struct {
	Type  uint16
	Value interface{}
}

type Fn added in v1.6.0

type Fn struct {
	Func int32 // id of function
}

Fn is used for custom func types

type OptValue added in v1.6.0

type OptValue struct {
	Var   int32       // id of variable
	Type  int         // type of variable
	Value interface{} // value
}

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

func (*Runtime) GoThread added in v1.6.0

func (rt *Runtime) GoThread(offset int64, pars []int32, top *Call) int64

GoThread executes a new thread

func (*Runtime) Run

func (rt *Runtime) Run(i int64) (result interface{}, err error)

type RuntimeError added in v1.6.0

type RuntimeError struct {
	ID      int
	Message string
	Trace   []TraceInfo
}

RuntimeError is a runtime error type

func (*RuntimeError) Error added in v1.6.0

func (re *RuntimeError) Error() string

type Settings

type Settings struct {
	CmdLine []string
	Input   []byte // stdin
	Cycle   uint64 // limit of loops
	Depth   uint32 // limit of blocks stack
}

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

func AddHoursºTimeInt(rt *Runtime, it *Struct, hours int64) *Struct

AddHoursºTimeInt adds/subtract hours

func DateTimeºInts added in v1.6.0

func DateTimeºInts(rt *Runtime, year, month, day, hour, minute, second int64) *Struct

DateTimeºInts returns time

func DateºInts added in v1.6.0

func DateºInts(rt *Runtime, year, month, day int64) *Struct

DateºInts returns time

func FileInfoºStr added in v1.6.0

func FileInfoºStr(rt *Runtime, name string) (*Struct, error)

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 Now added in v1.6.0

func Now(rt *Runtime) *Struct

Now returns the current time

func ParseTimeºStrStr added in v1.6.0

func ParseTimeºStrStr(rt *Runtime, layout, value string) (*Struct, error)

ParseTimeºStrStr parses a formatted string and returns the time value it represents

func UTCºTime added in v1.6.0

func UTCºTime(rt *Runtime, local *Struct) *Struct

UTCºTime converts time to UTC time.

func (*Struct) GetIndex added in v1.6.0

func (pstruct *Struct) GetIndex(index interface{}) (interface{}, bool)

GetIndex is part of Indexer interface.

func (*Struct) Len added in v1.6.0

func (pstruct *Struct) Len() int

Len is part of Indexer interface.

func (*Struct) SetIndex added in v1.6.0

func (pstruct *Struct) SetIndex(index, value interface{}) int

SetIndex is part of Indexer interface.

func (Struct) String added in v1.6.0

func (pstruct Struct) String() string

String interface for Struct

type Thread added in v1.6.0

type Thread struct {
	Status byte
	Sleep  int64
	Chan   chan int
	Notify []int64 // who waits the end
}

Thread contains information about a thread

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

func GetTrace added in v1.6.0

func GetTrace(rt *Runtime, pos int64) []TraceInfo

GetTrace returns information about called functions

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

Jump to

Keyboard shortcuts

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