Documentation
¶
Overview ¶
Package litecode is a deterministic Luau virtual machine and standard library toolkit.
Index ¶
- func ToString(a any) string
- type Args
- func (a *Args) CheckNextArg()
- func (a *Args) GetAny(optV ...any) (arg any)
- func (a *Args) GetBool(optV ...bool) bool
- func (a *Args) GetBuffer(optV ...*Buffer) *Buffer
- func (a *Args) GetCoroutine(optV ...*Coroutine) *Coroutine
- func (a *Args) GetFunction(optV ...Function) Function
- func (a *Args) GetNumber(optV ...float64) float64
- func (a *Args) GetString(optV ...string) string
- func (a *Args) GetTable(optV ...*Table) *Table
- func (a *Args) GetVector(optV ...Vector) Vector
- type Buffer
- type Compiler
- type Coroutine
- type Env
- type Function
- type Rets
- type Status
- type Table
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Args ¶
type Args struct {
// Co is the coroutine that the function is running.
Co *Coroutine
// List is the list of all arguments passed to the function.
List []any
// contains filtered or unexported fields
}
Args represents the arguments passed to a user-defined native function.
A number of helper functions are provided to extract arguments from the list. If these functions fail to extract the argument, the coroutine yields an invalid/missing argument error.
func (*Args) CheckNextArg ¶
func (a *Args) CheckNextArg()
CheckNextArg ensures that there is at least one more argument to be read. If there isn't, the coroutine yields a missing argument error.
func (*Args) GetBool ¶
GetBool returns the next argument as a boolean value. An optional value can be passed if the argument is not required.
func (*Args) GetBuffer ¶
GetBuffer returns the next argument as a buffer value. An optional value can be passed if the argument is not required.
func (*Args) GetCoroutine ¶
GetCoroutine returns the next argument as a coroutine value. An optional value can be passed if the argument is not required.
func (*Args) GetFunction ¶
GetFunction returns the next argument as a function value. An optional value can be passed if the argument is not required.
func (*Args) GetNumber ¶
GetNumber returns the next argument as a float64 number value. An optional value can be passed if the argument is not required.
func (*Args) GetString ¶
GetString returns the next argument as a string value. An optional value can be passed if the argument is not required.
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler allows programs to be compiled and deserialised with a cache and given optimisation level.
func NewCompiler ¶
NewCompiler creates a new compiler with the given optimisation level.
type Coroutine ¶
type Coroutine struct {
// contains filtered or unexported fields
}
Coroutine represents a Luau coroutine, including the main coroutine. Luau type `thread`
type Function ¶
type Function struct {
// Run is the native body of the function. Its coroutine argument is used to run the function in a coroutine.
Run *func(co *Coroutine, args ...any) (r Rets, err error)
// contains filtered or unexported fields
}
Function represents a native or wrapped Luau function. Luau type `function`
type Table ¶
Table represents a Luau table, with resizeable array and hash parts. Luau type `table`
func NewLib ¶
NewLib creates a new library with a given table of functions and other values, such as constants. Functions can be created using MakeFn.
func (*Table) ForceSet ¶
ForceSet sets a table value at a key, regardless of whether the table is readonly.
func (*Table) GetHash ¶
GetHash returns a value at a key, only searching the hash part of the table.
func (*Table) Iter ¶
Iter returns an iterator over the table, yielding key-value pairs in a deterministic order.
func (*Table) Len ¶
Len returns the length of the array part of the table (the length of the array up until the first nil).