vm

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 36 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 (
	AESKey  = 32
	SaltLen = 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
	// ErrObjValue is returned when obj has wrong type
	ErrObjValue
	// 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
	// ErrMainThread is returned when the function is called in go thread
	ErrMainThread
	// ErrThread is returned when the function is called in main thread
	ErrThread
	// ErrObjNil is returned when the object value is undefined
	ErrObjNil
	// ErrObjArr is returned when the object must contains array
	ErrObjArr
	// ErrObjMap is returned when the object must contains map
	ErrObjMap
	// ErrObjType is returned when the value has incompatible type
	ErrObjType
	// ErrTerminated is returned when the script has been terminated by owner
	ErrTerminated
	// ErrExit is returned when exit function has been called
	ErrExit
	// ErrPlayCycle is returned when maximum cycle count has been reached in Playground mode
	ErrPlayCycle
	// ErrPlayRun is returned on starting any processes in Playground mode
	ErrPlayRun
	// ErrPlayEnv is returned on setting environment in Playground mode
	ErrPlayEnv
	// ErrPlayAccess is returned on access denied error in Playground mode
	ErrPlayAccess
	// ErrPlayCount is returned when files count limit is exceeded in Playground mode
	ErrPlayCount
	// ErrPlaySize is returned when the file size limit reached in Playground mode
	ErrPlaySize
	// ErrPlayAllSize is returned when the summary files size limit reached in Playground mode
	ErrPlayAllSize
	// ErrPlayDepth is returned when maximum depth of recursion has been reached om Playground mode
	ErrPlayDepth
	// ErrPlayFunc is returned on calling disabled function in Playground mode
	ErrPlayFunc
	// ErrDecode is returned if decoding error occurs
	ErrDecode

	// ErrEmbedded means golang error in embedded functions
	ErrEmbedded = 254
	// ErrRuntime error. It means bug
	ErrRuntime = 255
)
View Source
const (
	Recursive = 0x01
	OnlyFiles = 0x02
	RegExp    = 0x04
	OnlyDirs  = 0x08

	FileCreate   = 0x01
	FileTrunc    = 0x02
	FileReadonly = 0x04
)
View Source
const (
	NoLimit       = -1
	ClearSize     = -2
	DeleteSize    = -3
	DeleteAllSize = -4
)
View Source
const (
	ProgressCopy = iota
	ProgressDownload
	ProgressCompress
	ProgressDecompress

	ProgressCompressCounter   = 200
	ProgressDecompressCounter = 201

	ProgStatusStart  = 0
	ProgStatusActive = 1
	ProgStatusEnd    = 2
)
View Source
const (
	TRACESTRUCT = iota
	TIMESTRUCT
	FINFOSTRUCT
	HINFOSTRUCT
)
View Source
const (
	BININT = binary.MaxVarintLen64 + iota
	BINCHAR
	BINSTR
	BINFLOAT
	BINBUF
)
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 (
	SysSuspend
	SysResume
	SysTerminate
)
View Source
const (
	// SleepStep is a tick in sleep
	SleepStep = int64(100)
)
View Source
const StdLibCount = 365

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{}/* 365 elements not displayed */

Functions

func AESDecrypt added in v1.18.0

func AESDecrypt(passphrase, data []byte) ([]byte, error)

func AESDecryptBuf added in v1.18.0

func AESDecryptBuf(passphrase string, buf *core.Buffer) (bufout *core.Buffer, err error)

AESDecrypt(str, buf) buf

func AESEncrypt added in v1.18.0

func AESEncrypt(passphrase, data []byte) ([]byte, error)

func AESEncryptBuf added in v1.18.0

func AESEncryptBuf(passphrase string, buf *core.Buffer) (bufout *core.Buffer, err error)

AESEncrypt(str, buf) buf

func AbsPath added in v1.7.0

func AbsPath(rt *Runtime, 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(rt *Runtime, 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(rt *Runtime, filename, s string) error

AppendFileºStrStr appends a string to a file

func ArchiveName added in v1.20.0

func ArchiveName(finfo *Struct, root string) string

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ºObj added in v1.16.0

func AssignAddºObj(obj interface{}, value interface{}) (interface{}, error)

AssignAddºObj appends an item to object array

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ºObjAny added in v1.8.0

func AssignºObjAny(ptr interface{}, value interface{}) (interface{}, error)

AssignºObjAny assigns integer, float, str, arr, map to obj

func AssignºObjBool added in v1.8.0

func AssignºObjBool(ptr interface{}, value interface{}) (interface{}, error)

AssignºObjBool assigns bool to obj

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(rt *Runtime, dirname string) error

ChDirºStr change the current directory

func ChModeºStr added in v1.9.0

func ChModeºStr(rt *Runtime, name string, mode int64) error

ChModeºStr change the file mode.

func CheckPlaygroundLimits added in v1.14.0

func CheckPlaygroundLimits(vm *VM, fname string, size int64) error

func ClearCarriage added in v1.9.0

func ClearCarriage(input string) string

ClearCarriage deletes output before carriage return character

func CloseFile added in v1.19.0

func CloseFile(file *core.File) error

func CloseTarGz added in v1.20.0

func CloseTarGz(gzfile *GzFile) (err error)

CloseTarGz closes the created tar.gz file

func CloseZip added in v1.20.0

func CloseZip(zfile *ZipFile) (err error)

CloseZip closes the created zip file

func Command added in v1.7.0

func Command(rt *Runtime, cmdLine string) error

Command executes the command line

func CommandOutput added in v1.7.0

func CommandOutput(rt *Runtime, cmdLine string) (string, error)

CommandOutput executes the command line and returns the standard output

func CompressFile added in v1.20.0

func CompressFile(rt *Runtime, pack Pack, filename, packname string) error

func CopyFileºStrStr added in v1.7.0

func CopyFileºStrStr(rt *Runtime, 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(rt *Runtime, dirname string) error

CreateDirºStr creates the directory(s)

func CreateFileºStrBool added in v1.12.0

func CreateFileºStrBool(rt *Runtime, filename string, always int64) error

CreateFileºStrBool creates an empty file

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 DecodeºBufInt added in v1.19.0

func DecodeºBufInt(buf *core.Buffer, offset int64) (int64, error)

DecodeºBufInt decodes int from buf

func DeinitPlayground added in v1.14.0

func DeinitPlayground(vm *VM)

DeinitPlayground removes playground files

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 DerivePassphrase added in v1.18.0

func DerivePassphrase(passphrase, salt []byte, keyLen int) ([]byte, []byte, error)

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(rt *Runtime, url, filename string) (written int64, err error)

Download downloads and saves the file by url.

func EncodeºBufInt added in v1.19.0

func EncodeºBufInt(buf *core.Buffer, i int64) *core.Buffer

EncodeºBufInt encodes int to buf

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 ExistFile added in v1.12.0

func ExistFile(rt *Runtime, filename string) (int64, error)

ExistFile returns true if the file or directory exists

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 ExpStrºObj added in v1.8.0

func ExpStrºObj(left string, right *core.Obj) string

ExpStrºObj adds string and obj 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 FileInfoToPath added in v1.20.0

func FileInfoToPath(finfo *Struct) string

FileInfoToPath return the full name of the file from finfo

func FileModeºStr added in v1.9.0

func FileModeºStr(rt *Runtime, name string) (int64, error)

FileModeºStr returns the file mode.

func FindFirstRegExpºStrStr added in v1.17.0

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

FindFirstRegExpºStrStr returns an array of the first successive matches of the expression

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(rt *Runtime, url string) (buf *core.Buffer, err error)

HTTPGet issues a GET to the specified URL.

func HTTPPage added in v1.7.0

func HTTPPage(rt *Runtime, url string) (string, error)

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

func HTTPRequest added in v1.13.0

func HTTPRequest(rt *Runtime, urlPath string, method string, params *core.Map, headers *core.Map) (ret string,
	err error)

HTTPRequest send HTTP request 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 IfaceToObj added in v1.21.0

func IfaceToObj(val interface{}) (*core.Obj, error)

func IncDecºInt added in v1.7.0

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

IncDecºInt incriment and decriment

func InitPlayground added in v1.14.0

func InitPlayground(settings *Settings) (err error)

InitPlayground inits playground settings

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 IsArrayºObj added in v1.16.0

func IsArrayºObj(obj *core.Obj) int64

IsArrayºObj returns true if the object is an array

func IsEmptyDir added in v1.17.0

func IsEmptyDir(rt *Runtime, path string) (ret int64, err error)

IsEmptyDir returns true if the specified folder is empty

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 IsMapºObj added in v1.16.0

func IsMapºObj(obj *core.Obj) int64

IsMapºObj returns true if the object is a map

func IsNil added in v1.8.0

func IsNil(val *core.Obj) int64

IsNil returns true if the object is undefined

func IsSet added in v1.7.0

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

IsSet returns the value of set[index]

func ItemºObjInt added in v1.16.0

func ItemºObjInt(val *core.Obj, ind int64) (ret *core.Obj, err error)

ItemºObjInt returns an item from array object

func ItemºObjStr added in v1.16.0

func ItemºObjStr(val *core.Obj, key string) (ret *core.Obj, err error)

ItemºObjStr returns an item from map object

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 Json added in v1.8.0

func Json(obj *core.Obj) (ret string, err error)

Json converts object to json

func JsonToObj added in v1.8.0

func JsonToObj(input string) (ret *core.Obj, err error)

JsonToObj converts json to object

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 Lock added in v1.8.0

func Lock(rt *Runtime)

Lock locks vm mutex

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(rt *Runtime, 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 ObjºFinfo added in v1.16.0

func ObjºFinfo(finfo *Struct) *core.Obj

ObjºFinfo converts finfo structure to object.

func OpenFileºStr added in v1.19.0

func OpenFileºStr(rt *Runtime, fname string, flags int64) (ret *core.File, err error)

func OpenWithºStr added in v1.6.0

func OpenWithºStr(rt *Runtime, app, fname string) error

OpenWithºStr runs the application with the specified file.

func OpenºStr added in v1.6.0

func OpenºStr(rt *Runtime, fname string) error

OpenºStr runs corresponding application with the specified file.

func PlaygroundAbsPath added in v1.14.0

func PlaygroundAbsPath(vm *VM, fname string) (ret string, err error)

func PlaygroundSize added in v1.14.0

func PlaygroundSize(vm *VM, fname string) (int64, error)

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 ProgressEnd added in v1.15.0

func ProgressEnd(rt *Runtime, id int64)

func ProgressInc added in v1.15.0

func ProgressInc(rt *Runtime, id, inc int64)

func ProgressStart added in v1.15.0

func ProgressStart(rt *Runtime, total int64, ptype int64, src, dest string) int64

func Random added in v1.9.0

func Random(limit int64) int64

Random returns a random number from 0 to parameter's value [0, limit)

func RandomBuf added in v1.18.0

func RandomBuf(size int64) (buf *core.Buffer, err error)

Random(int size) buf

func RandomBytes added in v1.18.0

func RandomBytes(size int) (ret []byte, err error)

func ReadDirºStr added in v1.6.0

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

ReadDirºStr reads a directory

func ReadDirºStrArr added in v1.17.0

func ReadDirºStrArr(rt *Runtime, dirname string, flags int64, patterns *core.Array,
	ignore *core.Array) (*core.Array, error)

ReadDirºStrArr reads a directory with additional settings

func ReadDirºStrIntStr added in v1.11.0

func ReadDirºStrIntStr(rt *Runtime, dirname string, flags int64, pattern string) (*core.Array, error)

ReadDirºStrIntStr reads a directory with additional settings

func ReadFileºStr added in v1.7.0

func ReadFileºStr(rt *Runtime, filename string) (string, error)

ReadFileºStr reads a file

func ReadFileºStrBuf added in v1.7.0

func ReadFileºStrBuf(rt *Runtime, 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(rt *Runtime, 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 ReadTarGz added in v1.20.0

func ReadTarGz(rt *Runtime, filename string) (*core.Array, error)

ReadTarGz gets the list of files in the .tar.gz file

func ReadZip added in v1.20.0

func ReadZip(rt *Runtime, zipfile string) (*core.Array, error)

ReadZip returns the file list of zip

func ReadºFileInt added in v1.19.0

func ReadºFileInt(file *core.File, size int64) (*core.Buffer, error)

func RegExpºStrStr added in v1.8.0

func RegExpºStrStr(src, rePattern string) (ret string, err error)

RegExpºStrStr returns the first found match of the expression

func RemoveDirºStr added in v1.7.0

func RemoveDirºStr(rt *Runtime, dirname string) error

RemoveDirºStr removes a directory

func RemoveºStr added in v1.7.0

func RemoveºStr(rt *Runtime, filename string) error

RemoveºStr removes a file or an empty directory

func RenameºStrStr added in v1.7.0

func RenameºStrStr(rt *Runtime, 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 RightºStrInt added in v1.8.0

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

RightºStrInt returns the right substring of the string.

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(rt *Runtime, name string, value interface{}) (string, error)

SetEnv assign the value to the environment variable

func SetEnvBool added in v1.7.0

func SetEnvBool(rt *Runtime, 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(rt *Runtime, name string, ftime *Struct) error

SetFileTimeºStrTime changes the modification time of the named file

func SetLenºBuf added in v1.19.0

func SetLenºBuf(buf *core.Buffer, size int64) (*core.Buffer, error)

SetLenºBuf sets the length of the buffer

func SetPosºFileIntInt added in v1.19.0

func SetPosºFileIntInt(file *core.File, off int64, whence int64) (int64, error)

SetPosºFileIntInt sets the postion in the file

func SetThreadData added in v1.22.0

func SetThreadData(rt *Runtime, obj *core.Obj)

SetThreadData sets Data parameter of the thread

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(rt *Runtime, 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 SizeToStr added in v1.15.0

func SizeToStr(size int64, format string) string

SizeToStr function returns the short string value of the size

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 SplitCmdLine added in v1.10.0

func SplitCmdLine(cmdline string) (ret *core.Array)

SplitCmdLine splits the command line parameters to the 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 StructDecode added in v1.18.0

func StructDecode(input *core.Buffer, pstruct *Struct) (err error)

StructDecode decodes buffer to struct variable

func StructEncode added in v1.18.0

func StructEncode(pstruct *Struct) (ret *core.Buffer, err error)

StructEncode encodes struct variable to buffer

func StrºTime added in v1.16.0

func StrºTime(it *Struct) string

StrºTime converts time to string

func Subbuf added in v1.20.0

func Subbuf(buf *core.Buffer, off int64, size int64) (*core.Buffer, error)

Subbuf return subbuffer

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 TarGz added in v1.20.0

func TarGz(rt *Runtime, targzfile string, path string) error

TarGz packs a file or directory to tar.gz

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(rt *Runtime, dir, prefix string) (string, error)

TempDirºStrStr creates a directory in the temporary directory

func ThreadData added in v1.22.0

func ThreadData(rt *Runtime) (*core.Obj, error)

ThreadData returns Data parameter of the thread

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 TrimLeftºStr added in v1.8.0

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

TrimLeftºStr returns a substring of the string with all leading characters in set removed.

func TrimRightºStr added in v1.7.0

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

TrimRightºStr returns a substring of the string with all trailing characters in set removed.

func TrimSpaceºStr added in v1.7.0

func TrimSpaceºStr(in string) string

TrimSpaceºStr trims white space in a string

func TrimºStr added in v1.8.0

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

TrimºStr returns a substring of the string with all leading and trailing characters in set removed.

func Type added in v1.8.0

func Type(val *core.Obj) string

Type returns the type of the object's value

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 Unlock added in v1.8.0

func Unlock(rt *Runtime)

Unlock unlocks vm mutex

func UnpackTarGz added in v1.20.0

func UnpackTarGz(rt *Runtime, filename string, dir string) error

UnpackTarGz unpacks a .tar.gz file to the specified folder

func UnpackTarGzºStr added in v1.20.0

func UnpackTarGzºStr(rt *Runtime, filename string, dir string, patterns *core.Array,
	ignore *core.Array) error

UnpackTarGzºStr unpacks a .tar.gz file to the specified folder

func UnpackZip added in v1.20.0

func UnpackZip(rt *Runtime, zipfile string, dir string) error

UnpackZip unpacks a zip file to the specified folder

func UnpackZipºStr added in v1.20.0

func UnpackZipºStr(rt *Runtime, zipfile string, dir string, patterns *core.Array,
	ignore *core.Array) error

UnpackZipºStr unpacks a zip file to the specified folder

func UnsetEnv added in v1.15.0

func UnsetEnv(rt *Runtime, name string) error

UnsetEnv unsets the environment variable

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 WaitAll added in v1.8.0

func WaitAll(rt *Runtime) error

WaitAll blocks until the WaitGroup counter is zero

func WaitDone added in v1.8.0

func WaitDone(rt *Runtime) error

WaitDone decrements the WaitGroup counter by one

func WaitGroup added in v1.8.0

func WaitGroup(rt *Runtime, count int64) error

WaitGroup changes WaitGroup counter

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ºFileBuf added in v1.19.0

func WriteFileºFileBuf(rt *Runtime, file *core.File, buf *core.Buffer) (*core.File, error)

WriteFileºFileBuf writes a buffer to a file

func WriteFileºStrBuf added in v1.7.0

func WriteFileºStrBuf(rt *Runtime, 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(rt *Runtime, filename, in string) error

WriteFileºStrStr writes a string to a file

func WriteºBuf added in v1.19.0

func WriteºBuf(buf *core.Buffer, offset int64, input *core.Buffer) (*core.Buffer, error)

WriteºBuf writes one buffer to another

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.

func ZipºStr added in v1.20.0

func ZipºStr(rt *Runtime, zipfile string, path string) error

ZipºStr packs a file or directory

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 GzFile added in v1.20.0

type GzFile struct {
	Name      string
	File      *os.File
	GzWriter  *gzip.Writer
	TarWriter *tar.Writer
}

func CreateTarGz added in v1.20.0

func CreateTarGz(rt *Runtime, filename string) (*GzFile, error)

CreateTarGz creates tar.gz file and returns its handle

func (*GzFile) FileName added in v1.20.0

func (gzf *GzFile) FileName() string

func (*GzFile) Header added in v1.20.0

func (gzf *GzFile) Header(finfo os.FileInfo, packname string) (io.Writer, error)

type OptValue added in v1.6.0

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

type Pack added in v1.20.0

type Pack interface {
	FileName() string
	Header(finfo os.FileInfo, packname string) (io.Writer, error)
}

type Playground added in v1.14.0

type Playground struct {
	Path         string // path to the temporary folder if it's empty then TempDir is used.
	AllSizeLimit int64  // all files size limit. By default, 10MB
	FilesLimit   int    // count of files limit. By default, 100
	SizeLimit    int64  // file size limit. By default, 5MB
}

type PlaygroundFS added in v1.14.0

type PlaygroundFS struct {
	Size  int64 // summary of files size
	Files map[string]int64
}

type Progress added in v1.15.0

type Progress struct {
	ID      uint32
	Type    int32
	Status  int32
	Total   int64
	Current int64
	Source  string
	Dest    string
	Ratio   float64
	Custom  interface{}
	// contains filtered or unexported fields
}

func NewProgress added in v1.15.0

func NewProgress(rt *Runtime, total int64, ptype int64) *Progress

func (*Progress) Complete added in v1.15.0

func (progress *Progress) Complete()

func (*Progress) Increment added in v1.15.0

func (progress *Progress) Increment(inc int64)

func (*Progress) Start added in v1.15.0

func (progress *Progress) Start(source, dest string)

type ProgressFunc added in v1.15.0

type ProgressFunc func(*Progress) bool

type ProgressReader added in v1.15.0

type ProgressReader struct {
	*Progress
	// contains filtered or unexported fields
}

func NewProgressReader added in v1.15.0

func NewProgressReader(reader io.Reader, progress *Progress) *ProgressReader

func (*ProgressReader) Read added in v1.15.0

func (progress *ProgressReader) Read(data []byte) (n int, err error)

type ProgressWriter added in v1.20.0

type ProgressWriter struct {
	*Progress
	// contains filtered or unexported fields
}

func NewProgressWriter added in v1.20.0

func NewProgressWriter(writer io.Writer, progress *Progress) *ProgressWriter

func (*ProgressWriter) Write added in v1.20.0

func (progress *ProgressWriter) Write(data []byte) (n int, err error)

type Runtime

type Runtime struct {
	Owner    *VM
	ParCount int32
	Calls    []Call
	Thread   Thread
	ThreadID int64
	Optional *[]OptValue
	Data     *core.Obj   // gentee embedded object
	Custom   interface{} // embedded structure
	// 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
	Stdin          *os.File
	Stdout         *os.File
	Stderr         *os.File
	Input          []byte   // stdin
	Cycle          uint64   // limit of loops
	Depth          uint32   // limit of blocks stack
	SysChan        chan int // system chan
	IsPlayground   bool
	Playground     Playground
	ProgressHandle ProgressFunc
}

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ºFile added in v1.19.0

func FileInfoºFile(rt *Runtime, file *core.File) (*Struct, error)

FileInfoºFile sets returns the finfo of the file

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 HeadInfo added in v1.14.0

func HeadInfo(rt *Runtime, url string) (*Struct, error)

HeadInfo function read the header of url

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 UntargzFile added in v1.20.0

type UntargzFile struct {
	Name      string
	File      *os.File
	GzReader  *gzip.Reader
	TarReader *tar.Reader
}

type UnzipFile added in v1.20.0

type UnzipFile struct {
	Name   string
	Reader *zip.ReadCloser
}

type VM

type VM struct {
	Settings    Settings
	Exec        *core.Exec
	Consts      map[int32]Const
	Runtimes    []*Runtime
	CtxMutex    sync.RWMutex
	ThreadMutex sync.RWMutex
	LockMutex   sync.Mutex
	WaitGroup   sync.WaitGroup
	Unique      *sync.Map // now for progress
	Context     map[string]string
	Count       int64 // count of active threads
	WaitCount   int64
	Stopped     bool
	ChCount     chan int64
	ChError     chan error
	ChWait      chan int64
	Playground  PlaygroundFS
}

VM is the main structure of the virtual machine

type ZipFile added in v1.20.0

type ZipFile struct {
	Name   string
	File   *os.File
	Writer *zip.Writer
}

func CreateZip added in v1.20.0

func CreateZip(rt *Runtime, filename string) (*ZipFile, error)

CreateZip creates zip file and returns its handle

func (*ZipFile) FileName added in v1.20.0

func (zf *ZipFile) FileName() string

func (*ZipFile) Header added in v1.20.0

func (zf *ZipFile) Header(finfo os.FileInfo, packname string) (io.Writer, error)

Jump to

Keyboard shortcuts

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