runtime

package
v0.0.0-...-f4c0d56 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LuaNil   = NewLuaNil()
	LuaTrue  = LuaBoolean(true)
	LuaFalse = LuaBoolean(false)
)

Functions

func LoadCheck

func LoadCheck(lvm *lua.LState) int

func LuaAssign

func LuaAssign(obj LuaObject) string

func LuaAssignLR

func LuaAssignLR(left, right LuaObject) string

func LuaDoFunc

func LuaDoFunc(lvm *lua.LState, fun *lua.LFunction) error

func LuaLabel

func LuaLabel(name string) string

func LuaLocalVar

func LuaLocalVar(obj LuaObject) string

func LuaModuleLoader

func LuaModuleLoader(lvm *lua.LState, funcs LuaFuncs) int

func NewLuaMCB

func NewLuaMCB(fun lua.LGFunction) *luaMCB

func SafePanic

func SafePanic() int

Types

type ArkExport

type ArkExport interface {
	Raw() []string
	Format() []string
	Set(raw string, format string)
}

func GetExport

func GetExport() ArkExport

type Handles

type Handles = LuaFuncs

type LuaBooleanObject

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

func LuaBoolean

func LuaBoolean(value bool) *LuaBooleanObject

func NewLuaBooleanObject

func NewLuaBooleanObject(ident string, value bool) *LuaBooleanObject

func (*LuaBooleanObject) Ident

func (obj *LuaBooleanObject) Ident() string

func (*LuaBooleanObject) Value

func (obj *LuaBooleanObject) Value() string

type LuaExport

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

func (*LuaExport) Format

func (luaExport *LuaExport) Format() []string

func (*LuaExport) Raw

func (luaExport *LuaExport) Raw() []string

func (*LuaExport) Set

func (luaExport *LuaExport) Set(k, v string)

type LuaForObject

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

func LuaIRange

func LuaIRange() *LuaForObject

func LuaKRange

func LuaKRange() *LuaForObject

func (LuaForObject) Ident

func (LuaForObject) Ident() string

func (*LuaForObject) Value

func (obj *LuaForObject) Value() string

type LuaFuncObject

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

func LuaFunc

func LuaFunc() *LuaFuncObject

func NewLuaFuncObject

func NewLuaFuncObject(ident string) *LuaFuncObject

func (*LuaFuncObject) Bind

func (obj *LuaFuncObject) Bind(argv ...LuaObject) *LuaFuncObject

func (*LuaFuncObject) Ident

func (obj *LuaFuncObject) Ident() string

func (*LuaFuncObject) Lambda

func (obj *LuaFuncObject) Lambda() *LuaFuncObject

func (*LuaFuncObject) PCall

func (obj *LuaFuncObject) PCall(argv ...LuaObject) string

func (*LuaFuncObject) SetArgc

func (obj *LuaFuncObject) SetArgc(n int) *LuaFuncObject

func (*LuaFuncObject) SetArgs

func (obj *LuaFuncObject) SetArgs(args []string) *LuaFuncObject

func (*LuaFuncObject) SetBlock

func (obj *LuaFuncObject) SetBlock(block ...LuaObject)

func (*LuaFuncObject) Value

func (obj *LuaFuncObject) Value() string

type LuaFuncs

type LuaFuncs map[string]lua.LGFunction

type LuaGotoObject

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

func LuaGoto

func LuaGoto(label string) *LuaGotoObject

func (LuaGotoObject) Ident

func (LuaGotoObject) Ident() string

func (*LuaGotoObject) Value

func (obj *LuaGotoObject) Value() string

type LuaIfObject

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

func LuaIf

func LuaIf(conds []string, block ...LuaObject) *LuaIfObject

func (*LuaIfObject) AppendCond

func (obj *LuaIfObject) AppendCond()

func (LuaIfObject) Ident

func (LuaIfObject) Ident() string

func (*LuaIfObject) SetCond

func (obj *LuaIfObject) SetCond()

func (*LuaIfObject) Value

func (obj *LuaIfObject) Value() string

type LuaInterp

type LuaInterp = lua.LState

lua interpreter

type LuaListObejct

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

func LuaList

func LuaList(values ...LuaObject) *LuaListObejct

func NewLuaListObject

func NewLuaListObject(ident string, values ...LuaObject) *LuaListObejct

func (*LuaListObejct) Ident

func (obj *LuaListObejct) Ident() string

func (*LuaListObejct) Insert

func (obj *LuaListObejct) Insert(value ...LuaObject)

func (*LuaListObejct) Unpack

func (obj *LuaListObejct) Unpack() string

func (*LuaListObejct) Value

func (obj *LuaListObejct) Value() string

type LuaMAT

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

MAT is abbreviation for module allocate table, which is used to load module into virtual machine with lazy.

func (*LuaMAT) Collect

func (mat *LuaMAT) Collect(cluster string, mids []string) MAT

Collect to converge specify mcb according to cluster.

func (*LuaMAT) MCB

func (mat *LuaMAT) MCB(mid string) map[string]*luaMCB

MCB returns specify mcb according to mid

func (*LuaMAT) Mount

func (mat *LuaMAT) Mount(funcs LuaFuncs) MAT

Mount to add MCB to MAT

func (*LuaMAT) Unmount

func (mat *LuaMAT) Unmount(mid string) MAT

Unmount to remove MCB from MAT

type LuaMapObject

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

func LuaMap

func LuaMap(values Luamap) *LuaMapObject

func LuaStringMap

func LuaStringMap(values map[string]string) *LuaMapObject

func NewLuaMapObject

func NewLuaMapObject(ident string, values Luamap) *LuaMapObject

func (*LuaMapObject) Ident

func (obj *LuaMapObject) Ident() string

func (*LuaMapObject) Insert

func (obj *LuaMapObject) Insert(k string, v LuaObject) *LuaMapObject

func (*LuaMapObject) Unpack

func (obj *LuaMapObject) Unpack() string

func (*LuaMapObject) Value

func (obj *LuaMapObject) Value() string

type LuaNilObject

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

func NewLuaNil

func NewLuaNil() *LuaNilObject

func (*LuaNilObject) Ident

func (obj *LuaNilObject) Ident() string

func (LuaNilObject) Value

func (LuaNilObject) Value() string

type LuaNumberObject

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

func LuaNumber

func LuaNumber(value string) *LuaNumberObject

func NewLuaNumberObject

func NewLuaNumberObject(ident, value string) *LuaNumberObject

func (*LuaNumberObject) Ident

func (obj *LuaNumberObject) Ident() string

func (*LuaNumberObject) Value

func (obj *LuaNumberObject) Value() string

type LuaObject

type LuaObject interface {
	Ident() string
	Value() string
}

LuaObject is an interface to abstract object of lua type

func LuaComment

func LuaComment(comment string) LuaObject

func LuaDisableFileUndefinedGlobal

func LuaDisableFileUndefinedGlobal() LuaObject

func LuaDisableNextLineUndefinedGlobal

func LuaDisableNextLineUndefinedGlobal() LuaObject

func LuaGlobalVar

func LuaGlobalVar(v string) LuaObject

func LuaIdent

func LuaIdent(ident string) LuaObject

func LuaImport

func LuaImport(mods ...string) LuaObject

func LuaPackagePath

func LuaPackagePath(paths ...string) LuaObject

func LuaRequire

func LuaRequire(modename string) LuaObject

func LuaSpaceLine

func LuaSpaceLine() LuaObject

type LuaProgramObject

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

func LuaProgram

func LuaProgram(codes ...LuaObject) *LuaProgramObject

func NewLuaProgramObject

func NewLuaProgramObject(ident string, codes ...LuaObject) *LuaProgramObject

func (*LuaProgramObject) Ident

func (obj *LuaProgramObject) Ident() string

func (*LuaProgramObject) Value

func (obj *LuaProgramObject) Value() string

type LuaStringObject

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

func LuaString

func LuaString(value string) *LuaStringObject

func NewLuaStringObject

func NewLuaStringObject(ident, value string) *LuaStringObject

func (*LuaStringObject) Ident

func (obj *LuaStringObject) Ident() string

func (*LuaStringObject) Value

func (obj *LuaStringObject) Value() string

type LuaTableObject

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

func LuaTable

func LuaTable() *LuaTableObject

func NewLuaTabelObject

func NewLuaTabelObject(ident string) *LuaTableObject

func (*LuaTableObject) Ident

func (obj *LuaTableObject) Ident() string

func (*LuaTableObject) Insert

func (obj *LuaTableObject) Insert(values ...LuaObject) *LuaTableObject

func (*LuaTableObject) InsertKV

func (obj *LuaTableObject) InsertKV(k string, v LuaObject) *LuaTableObject

func (*LuaTableObject) SetList

func (obj *LuaTableObject) SetList(list ...LuaObject) *LuaTableObject

func (*LuaTableObject) SetMap

func (obj *LuaTableObject) SetMap(kvs Luamap) *LuaTableObject

func (*LuaTableObject) Unpack

func (obj *LuaTableObject) Unpack() string

func (*LuaTableObject) Value

func (obj *LuaTableObject) Value() string

type LuaVM

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

func (*LuaVM) Call

func (vm *LuaVM) Call(fun string) ([]any, error)

Call to call specify function without arguments

func (*LuaVM) CallByParam

func (vm *LuaVM) CallByParam(fn string, args []lua.LValue) ([]any, error)

Call to call specify function with arguments

func (*LuaVM) Default

func (vm *LuaVM) Default() VirtualMachine

Default to build vm with standard

func (*LuaVM) Eval

func (vm *LuaVM) Eval(script string) error

Eval to execute string of script

func (*LuaVM) EvalFile

func (vm *LuaVM) EvalFile(fullpath string) error

EvalFile to execute file of script

func (*LuaVM) EvalFunc

func (vm *LuaVM) EvalFunc(fn lua.LValue, args []lua.LValue) ([]any, error)

EvalFunc to execute function

func (*LuaVM) FastCall

func (vm *LuaVM) FastCall(fun string) error

FastCall to call specify function without arguments and not return value

func (*LuaVM) FastCallByParam

func (vm *LuaVM) FastCallByParam(fn string, args []lua.LValue) error

FastCallByParam to call specify function with arguments and not return value

func (*LuaVM) FastEvalFunc

func (vm *LuaVM) FastEvalFunc(fn lua.LValue, args []lua.LValue) error

FastEvalFunc to execute function and not return value

func (*LuaVM) GetGlobalVar

func (vm *LuaVM) GetGlobalVar(name string) lua.LValue

GetGlobalVar returns global variable

func (*LuaVM) Interp

func (vm *LuaVM) Interp() *LuaInterp

Interp returns interpreter

func (*LuaVM) LoadModule

func (vm *LuaVM) LoadModule(name string, loader lua.LGFunction)

LoadModule to immediately load module to be specified

func (*LuaVM) RegisterModule

func (vm *LuaVM) RegisterModule(fns LuaFuncs)

RegisterModule to register modules

func (*LuaVM) SafeSetGlobalFn

func (vm *LuaVM) SafeSetGlobalFn(loaders LuaFuncs)

SafeSetGlobalFn to set global function when it isn't exist

func (*LuaVM) SafeSetGlobalVar

func (vm *LuaVM) SafeSetGlobalVar(name string, v lua.LValue)

SafeSetGlobalVar to set global variable when variable isn't exist

func (*LuaVM) SetGlobalFn

func (vm *LuaVM) SetGlobalFn(loaders LuaFuncs)

SetGlobalFn to set global function

func (*LuaVM) SetGlobalVar

func (vm *LuaVM) SetGlobalVar(name string, v lua.LValue)

SetGlobalVar to set global variable

func (*LuaVM) UnregisterModule

func (vm *LuaVM) UnregisterModule(mid string)

UnregisterModule to unregister specify module

type Luamap

type Luamap map[string]LuaObject

type MAT

type MAT interface {
	// Mount to add MCB to MAT
	Mount(LuaFuncs) MAT
	// Unmount to remove MCB from MAT
	Unmount(string) MAT
	// Collect to converge specify mcb according to cluster.
	Collect(string, []string) MAT
	// MCB returns mcb list
	MCB(string) map[string]*luaMCB
}

MAT is abbreviation for module allocate table, which is used to load module into virtual machine with lazy.

func NewLuaMAT

func NewLuaMAT() MAT

type MCB

type MCB interface {
	// Mark to set module used state
	Mark()
	// Used returns whether mcb is used
	Used() bool
}

MCB is abbreviation for module control block, which store and control module meta.

type VirtualMachine

type VirtualMachine interface {
	// Default to build vm with standard
	Default() VirtualMachine
	// Call to call specify function without arguments
	Call(string) ([]any, error)
	// FastCall to call specify function without arguments and not return value
	FastCall(string) error
	// Call to call specify function with arguments
	CallByParam(string, []lua.LValue) ([]any, error)
	// FastCallByParam to call specify function with arguments and not return value
	FastCallByParam(string, []lua.LValue) error
	// Eval to execute string of script
	Eval(string) error
	// EvalFile to execute file of script
	EvalFile(string) error
	// EvalFunc to execute function
	EvalFunc(lua.LValue, []lua.LValue) ([]any, error)
	// FastEvalFunc to execute function and not return value
	FastEvalFunc(lua.LValue, []lua.LValue) error
	// SetGlobalFn to set global function
	SetGlobalFn(Handles)
	// SafeSetGlobalFn to set global function when it isn't exist
	SafeSetGlobalFn(Handles)
	// GetGlobalVar returns global variable
	GetGlobalVar(string) lua.LValue
	// SetGlobalVar to set global variable
	SetGlobalVar(string, lua.LValue)
	// SafeSetGlobalVar to set global variable when variable isn't exist
	SafeSetGlobalVar(string, lua.LValue)
	// RegisterModule to register modules
	RegisterModule(Handles)
	// UnregisterModule to unregister specify module
	UnregisterModule(string)
	// LoadModule to immediately load module to be specified
	LoadModule(string, lua.LGFunction)
	// Interp returns interpreter
	Interp() *LuaInterp
}

VirtualMachine is an interface to abstract different interpreter

func NewVirtualMachine

func NewVirtualMachine() VirtualMachine

Jump to

Keyboard shortcuts

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