Documentation ¶
Overview ¶
GopherLua: VM and compiler for Lua in Go
This file was generated by go-inline.DO NOT EDIT.
This file was generated by go-inline.DO NOT EDIT.
Index ¶
- Constants
- Variables
- func LVAsBool(v LValue) bool
- func LVAsString(v LValue) string
- func LVCanConvToString(v LValue) bool
- func LVIsFalse(v LValue) bool
- func UpvalueIndex(i int) int
- type ApiError
- type ApiErrorType
- type CompileError
- type DbgCall
- type DbgLocalInfo
- type Debug
- type FunctionProto
- type Global
- type LBool
- type LChannel
- type LFunction
- type LGFunction
- type LNilType
- type LNumber
- type LState
- func (ls *LState) ArgError(n int, message string)
- func (ls *LState) Call(nargs, nret int)
- func (ls *LState) CallByParam(cp P, args ...LValue) error
- func (ls *LState) CallMeta(obj LValue, event string) LValue
- func (ls *LState) CheckAny(n int) LValue
- func (ls *LState) CheckBool(n int) bool
- func (ls *LState) CheckChannel(n int) chan LValue
- func (ls *LState) CheckFunction(n int) *LFunction
- func (ls *LState) CheckInt(n int) int
- func (ls *LState) CheckInt64(n int) int64
- func (ls *LState) CheckNumber(n int) LNumber
- func (ls *LState) CheckOption(n int, options []string) int
- func (ls *LState) CheckString(n int) string
- func (ls *LState) CheckTable(n int) *LTable
- func (ls *LState) CheckThread(n int) *LState
- func (ls *LState) CheckType(n int, typ LValueType)
- func (ls *LState) CheckTypes(n int, typs ...LValueType)
- func (ls *LState) CheckUserData(n int) *LUserData
- func (ls *LState) Close()
- func (ls *LState) Concat(values ...LValue) string
- func (ls *LState) CreateTable(acap, hcap int) *LTable
- func (ls *LState) DoFile(path string) error
- func (ls *LState) DoString(source string) error
- func (ls *LState) Equal(lhs, rhs LValue) bool
- func (ls *LState) Error(lv LValue, level int)
- func (ls *LState) FindTable(obj *LTable, n string, size int) LValue
- func (ls *LState) ForEach(tb *LTable, cb func(LValue, LValue))
- func (ls *LState) GPCall(fn LGFunction, data LValue) error
- func (ls *LState) Get(idx int) LValue
- func (ls *LState) GetFEnv(obj LValue) LValue
- func (ls *LState) GetField(obj LValue, skey string) LValue
- func (ls *LState) GetGlobal(name string) LValue
- func (ls *LState) GetInfo(what string, dbg *Debug, fn LValue) (LValue, error)
- func (ls *LState) GetLocal(dbg *Debug, no int) (string, LValue)
- func (ls *LState) GetMetaField(obj LValue, event string) LValue
- func (ls *LState) GetMetatable(obj LValue) LValue
- func (ls *LState) GetStack(level int) (*Debug, bool)
- func (ls *LState) GetTable(obj LValue, key LValue) LValue
- func (ls *LState) GetTop() int
- func (ls *LState) GetTypeMetatable(typ string) LValue
- func (ls *LState) GetUpvalue(fn *LFunction, no int) (string, LValue)
- func (ls *LState) Insert(value LValue, index int)
- func (ls *LState) LessThan(lhs, rhs LValue) bool
- func (ls *LState) Load(reader io.Reader, name string) (*LFunction, error)
- func (ls *LState) LoadFile(path string) (*LFunction, error)
- func (ls *LState) LoadString(source string) (*LFunction, error)
- func (ls *LState) NewClosure(fn LGFunction, upvalues ...LValue) *LFunction
- func (ls *LState) NewFunction(fn LGFunction) *LFunction
- func (ls *LState) NewTable() *LTable
- func (ls *LState) NewThread() *LState
- func (ls *LState) NewTypeMetatable(typ string) *LTable
- func (ls *LState) NewUserData() *LUserData
- func (ls *LState) Next(tb *LTable, key LValue) (LValue, LValue)
- func (ls *LState) ObjLen(v1 LValue) int
- func (ls *LState) OpenLibs()
- func (ls *LState) OptBool(n int, d bool) bool
- func (ls *LState) OptChannel(n int, ch chan LValue) chan LValue
- func (ls *LState) OptFunction(n int, d *LFunction) *LFunction
- func (ls *LState) OptInt(n int, d int) int
- func (ls *LState) OptInt64(n int, d int64) int64
- func (ls *LState) OptNumber(n int, d LNumber) LNumber
- func (ls *LState) OptString(n int, d string) string
- func (ls *LState) OptTable(n int, d *LTable) *LTable
- func (ls *LState) OptUserData(n int, d *LUserData) *LUserData
- func (ls *LState) PCall(nargs, nret int, errfunc *LFunction) (err error)
- func (ls *LState) Pop(n int)
- func (ls *LState) PreloadModule(name string, loader LGFunction)
- func (ls *LState) Push(value LValue)
- func (ls *LState) RaiseError(format string, args ...interface{})
- func (ls *LState) RawEqual(lhs, rhs LValue) bool
- func (ls *LState) RawGet(tb *LTable, key LValue) LValue
- func (ls *LState) RawGetInt(tb *LTable, key int) LValue
- func (ls *LState) RawSet(tb *LTable, key LValue, value LValue)
- func (ls *LState) RawSetInt(tb *LTable, key int, value LValue)
- func (ls *LState) Register(name string, fn LGFunction)
- func (ls *LState) RegisterModule(name string, funcs map[string]LGFunction) LValue
- func (ls *LState) Remove(index int)
- func (ls *LState) Replace(idx int, value LValue)
- func (ls *LState) Resume(th *LState, fn *LFunction, args ...LValue) (ResumeState, error, []LValue)
- func (ls *LState) SetFEnv(obj LValue, env LValue)
- func (ls *LState) SetField(obj LValue, key string, value LValue)
- func (ls *LState) SetFuncs(tb *LTable, funcs map[string]LGFunction, upvalues ...LValue) *LTable
- func (ls *LState) SetGlobal(name string, value LValue)
- func (ls *LState) SetLocal(dbg *Debug, no int, lv LValue) string
- func (ls *LState) SetMetatable(obj LValue, mt LValue)
- func (ls *LState) SetMx(mx int)
- func (ls *LState) SetTable(obj LValue, key LValue, value LValue)
- func (ls *LState) SetTop(idx int)
- func (ls *LState) SetUpvalue(fn *LFunction, no int, lv LValue) string
- func (ls *LState) Status(th *LState) string
- func (ls *LState) String() string
- func (ls *LState) ToBool(n int) bool
- func (ls *LState) ToChannel(n int) chan LValue
- func (ls *LState) ToFunction(n int) *LFunction
- func (ls *LState) ToInt(n int) int
- func (ls *LState) ToInt64(n int) int64
- func (ls *LState) ToNumber(n int) LNumber
- func (ls *LState) ToString(n int) string
- func (ls *LState) ToTable(n int) *LTable
- func (ls *LState) ToThread(n int) *LState
- func (ls *LState) ToUserData(n int) *LUserData
- func (ls *LState) Type() LValueType
- func (ls *LState) TypeError(n int, typ LValueType)
- func (ls *LState) Where(level int) string
- func (ls *LState) XMoveTo(other *LState, n int)
- func (ls *LState) Yield(values ...LValue) int
- type LString
- type LTable
- func (tb *LTable) Append(value LValue)
- func (tb *LTable) ForEach(cb func(LValue, LValue))
- func (tb *LTable) Insert(i int, value LValue)
- func (tb *LTable) Len() int
- func (tb *LTable) MaxN() int
- func (tb *LTable) Next(key LValue) (LValue, LValue)
- func (tb *LTable) RawGet(key LValue) LValue
- func (tb *LTable) RawGetH(key LValue) LValue
- func (tb *LTable) RawGetInt(key int) LValue
- func (tb *LTable) RawGetString(key string) LValue
- func (tb *LTable) RawSet(key LValue, value LValue)
- func (tb *LTable) RawSetH(key LValue, value LValue)
- func (tb *LTable) RawSetInt(key int, value LValue)
- func (tb *LTable) RawSetString(key string, value LValue)
- func (tb *LTable) Remove(pos int) LValue
- func (tb *LTable) String() string
- func (tb *LTable) Type() LValueType
- type LUserData
- type LValue
- type LValueType
- type Options
- type P
- type ResumeState
- type Upvalue
Constants ¶
const ( VarArgHasArg uint8 = 1 VarArgIsVarArg uint8 = 2 VarArgNeedsArg uint8 = 4 )
const ( OP_MOVE int = iota /* A B R(A) := R(B) */ OP_MOVEN /* A B R(A) := R(B); followed by R(C) MOVE ops */ OP_LOADK /* A Bx R(A) := Kst(Bx) */ OP_LOADBOOL /* A B C R(A) := (Bool)B; if (C) pc++ */ OP_LOADNIL /* A B R(A) := ... := R(B) := nil */ OP_GETUPVAL /* A B R(A) := UpValue[B] */ OP_GETGLOBAL /* A Bx R(A) := Gbl[Kst(Bx)] */ OP_GETTABLE /* A B C R(A) := R(B)[RK(C)] */ OP_GETTABLEKS /* A B C R(A) := R(B)[RK(C)] ; RK(C) is constant string */ OP_SETGLOBAL /* A Bx Gbl[Kst(Bx)] := R(A) */ OP_SETUPVAL /* A B UpValue[B] := R(A) */ OP_SETTABLE /* A B C R(A)[RK(B)] := RK(C) */ OP_SETTABLEKS /* A B C R(A)[RK(B)] := RK(C) ; RK(B) is constant string */ OP_NEWTABLE /* A B C R(A) := {} (size = BC) */ OP_SELF /* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */ OP_ADD /* A B C R(A) := RK(B) + RK(C) */ OP_SUB /* A B C R(A) := RK(B) - RK(C) */ OP_MUL /* A B C R(A) := RK(B) * RK(C) */ OP_DIV /* A B C R(A) := RK(B) / RK(C) */ OP_MOD /* A B C R(A) := RK(B) % RK(C) */ OP_POW /* A B C R(A) := RK(B) ^ RK(C) */ OP_UNM /* A B R(A) := -R(B) */ OP_NOT /* A B R(A) := not R(B) */ OP_LEN /* A B R(A) := length of R(B) */ OP_CONCAT /* A B C R(A) := R(B).. ... ..R(C) */ OP_JMP /* sBx pc+=sBx */ OP_EQ /* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ OP_LT /* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ OP_LE /* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ OP_TEST /* A C if not (R(A) <=> C) then pc++ */ OP_TESTSET /* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ OP_CALL /* A B C R(A) ... R(A+C-2) := R(A)(R(A+1) ... R(A+B-1)) */ OP_TAILCALL /* A B C return R(A)(R(A+1) ... R(A+B-1)) */ OP_RETURN /* A B return R(A) ... R(A+B-2) (see note) */ OP_FORLOOP /* A sBx R(A)+=R(A+2); if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/ OP_FORPREP /* A sBx R(A)-=R(A+2); pc+=sBx */ OP_TFORLOOP /* A C R(A+3) ... R(A+3+C) := R(A)(R(A+1) R(A+2)); if R(A+3) ~= nil then { pc++; R(A+2)=R(A+3); } */ OP_SETLIST /* A B C R(A)[(C-1)*FPF+i] := R(A+i) 1 <= i <= B */ OP_CLOSE /* A close all variables in the stack up to (>=) R(A)*/ OP_CLOSURE /* A Bx R(A) := closure(KPROTO[Bx] R(A) ... R(A+n)) */ OP_VARARG /* A B R(A) R(A+1) ... R(A+B-1) = vararg */ OP_NOP /* NOP */ )
const EnvironIndex = -10001
const GlobalsIndex = -10002
const LNumberBit = 64
const LNumberScanFormat = "%f"
const MultRet = -1
const PackageAuthors = "Yusuke Inuzuka"
const PackageCopyRight = PackageName + " " + PackageVersion + " Copyright (C) 2015 " + PackageAuthors
const PackageName = "GopherLua"
const PackageVersion = "0.1"
const RegistryIndex = -10000
Variables ¶
var CallStackSize = 256
var CompatVarArg = true
var FieldsPerFlush = 50
var LFalse = LBool(false)
var LNil = LValue(&LNilType{})
var LTrue = LBool(true)
var LuaLDir string
var LuaOS string
var LuaPath = "LUA_PATH"
var LuaPathDefault string
var MaxArrayIndex = 67108864
var MaxTableGetLoop = 100
var RegistrySize = 256 * 20
Functions ¶
func LVAsString ¶
func LVCanConvToString ¶
func UpvalueIndex ¶
Types ¶
type ApiError ¶
type ApiError struct { Type ApiErrorType Object LValue StackTrace string // Underlying error. This attribute is set only if the Type is ApiErrorFile or ApiErrorSyntax Cause error }
type ApiErrorType ¶
type ApiErrorType int
const ( ApiErrorSyntax ApiErrorType = iota ApiErrorFile ApiErrorRun ApiErrorError ApiErrorPanic )
type CompileError ¶
func (*CompileError) Error ¶
func (e *CompileError) Error() string
type DbgLocalInfo ¶
type FunctionProto ¶
type FunctionProto struct { SourceName string LineDefined int LastLineDefined int NumUpvalues uint8 NumParameters uint8 IsVarArg uint8 NumUsedRegisters uint8 Code []uint32 Constants []LValue FunctionPrototypes []*FunctionProto DbgSourcePositions []int DbgLocals []*DbgLocalInfo DbgCalls []DbgCall DbgUpvalues []string // contains filtered or unexported fields }
func (*FunctionProto) String ¶
func (fp *FunctionProto) String() string
type LChannel ¶
type LChannel chan LValue
func (LChannel) Type ¶
func (ch LChannel) Type() LValueType
type LFunction ¶
type LFunction struct { IsG bool Env *LTable Proto *FunctionProto GFunction LGFunction Upvalues []*Upvalue }
func (*LFunction) Type ¶
func (fn *LFunction) Type() LValueType
type LGFunction ¶
type LNilType ¶
type LNilType struct{}
func (*LNilType) Type ¶
func (nl *LNilType) Type() LValueType
type LNumber ¶
type LNumber float64
func LVAsNumber ¶
func (LNumber) Type ¶
func (nm LNumber) Type() LValueType
type LState ¶
type LState struct { G *Global Parent *LState Env *LTable Panic func(*LState) Dead bool Options Options // contains filtered or unexported fields }
func (*LState) CheckChannel ¶
Checks whether the given index is an LChannel and returns this channel.
func (*LState) CheckFunction ¶
func (*LState) CheckInt64 ¶
func (*LState) CheckNumber ¶
func (*LState) CheckString ¶
func (*LState) CheckTable ¶
func (*LState) CheckThread ¶
func (*LState) CheckType ¶
func (ls *LState) CheckType(n int, typ LValueType)
func (*LState) CheckTypes ¶
func (ls *LState) CheckTypes(n int, typs ...LValueType)
func (*LState) CheckUserData ¶
func (*LState) CreateTable ¶
func (*LState) Error ¶
This function is equivalent to lua_error( http://www.lua.org/manual/5.1/manual.html#lua_error ).
func (*LState) GetMetatable ¶
func (*LState) GetTypeMetatable ¶
func (*LState) NewClosure ¶
func (ls *LState) NewClosure(fn LGFunction, upvalues ...LValue) *LFunction
func (*LState) NewFunction ¶
func (ls *LState) NewFunction(fn LGFunction) *LFunction
func (*LState) NewTypeMetatable ¶
func (*LState) NewUserData ¶
func (*LState) OptChannel ¶
If the given index is a LChannel, returns this channel. If this argument is absent or is nil, returns ch. Otherwise, raises an error.
func (*LState) PreloadModule ¶
func (ls *LState) PreloadModule(name string, loader LGFunction)
Set a module loader to the package.preload table.
func (*LState) RaiseError ¶
This function is equivalent to luaL_error( http://www.lua.org/manual/5.1/manual.html#luaL_error ).
func (*LState) Register ¶
func (ls *LState) Register(name string, fn LGFunction)
func (*LState) RegisterModule ¶
func (ls *LState) RegisterModule(name string, funcs map[string]LGFunction) LValue
func (*LState) SetMetatable ¶
func (*LState) SetMx ¶
Set maximum memory size. This function can only be called from the main thread.
func (*LState) ToFunction ¶
func (*LState) ToUserData ¶
func (*LState) Type ¶
func (ls *LState) Type() LValueType
func (*LState) TypeError ¶
func (ls *LState) TypeError(n int, typ LValueType)
type LTable ¶
type LTable struct { Metatable LValue // contains filtered or unexported fields }
func (*LTable) RawGetString ¶
func (*LTable) RawSetString ¶
func (*LTable) Type ¶
func (tb *LTable) Type() LValueType
type LValue ¶
type LValue interface { String() string Type() LValueType // contains filtered or unexported methods }
type LValueType ¶
type LValueType int
const ( LTNil LValueType = iota LTBool LTNumber LTString LTFunction LTUserData LTThread LTTable LTChannel )
func (LValueType) String ¶
func (vt LValueType) String() string
type Options ¶
type Options struct { // Call stack size. This defaults to `lua.CallStackSize`. CallStackSize int // Data stack size. This defaults to `lua.RegistrySize`. RegistrySize int // Controls whether or not libraries are opened by default SkipOpenLibs bool // Tells whether a Go stacktrace should be included in a Lua stacktrace when panics occur. IncludeGoStackTrace bool }
Options is a configuration that is used to create a new LState.
type ResumeState ¶
type ResumeState int
const ( ResumeOK ResumeState = iota ResumeYield ResumeError )