public class Globals extends LuaTable
JsePlatform.standardGlobals() or
and then used to load lua scripts for execution as in the following example.
Globals globals = JsePlatform.standardGlobals();
globals.load( new StringReader("print 'hello'"), "main.lua" ).call();
The creates a complete global environment with the standard libraries loaded.
For specialized circumstances, the Globals may be constructed directly and loaded with only those libraries that are needed, for example.
Globals globals = new Globals();
globals.load( new BaseLib() );
globals.load( new StringReader("print 'hello'"), "main.lua" ).call();
ResourceFinder
Compiler
Prototype using Globals.Undumper
LuaClosure from Prototype with Globals using Globals.Loader
There are alternate flows when the direct lua-to-Java bytecode compiling LuaJC is used.
Compiler or load precompiled code using Globals.Undumper
LuaJC that implements Globals.Loader directly
STDIN Current value for standard input in the laaded IoLib, if any.
STDOUT Current value for standard output in the loaded IoLib, if any.
STDERR Current value for standard error in the loaded IoLib, if any.
finder Current loaded ResourceFinder, if any.
compiler Current loaded Compiler, if any.
undumper Current loaded Globals.Undumper, if any.
loader Current loaded Globals.Loader, if any.
JsePlatform,
LuaValue,
Compiler,
Globals.Loader,
Globals.Undumper,
ResourceFinder,
LuaC,
LuaJC| 限定符和类型 | 类和说明 |
|---|---|
static interface |
Globals.Compiler
Interface for module that converts lua source text into a prototype.
|
static interface |
Globals.Loader
Interface for module that converts a Prototype into a LuaFunction with an environment.
|
static interface |
Globals.Undumper
Interface for module that loads lua binary chunk into a prototype.
|
| 限定符和类型 | 字段和说明 |
|---|---|
BaseLib |
baselib
The BaseLib instance loaded into this Globals
|
Globals.Compiler |
compiler
The installed compiler.
|
DebugLib |
debuglib
The DebugLib instance loaded into this Globals, or null if debugging is not enabled
|
ResourceFinder |
finder
The installed ResourceFinder for looking files by name.
|
Globals.Loader |
loader
The installed loader.
|
PackageLib |
package_
The PackageLib instance loaded into this Globals
|
LuaThread |
running
The currently running thread.
|
PrintStream |
STDERR
The current default error stream.
|
InputStream |
STDIN
The current default input stream.
|
PrintStream |
STDOUT
The current default output stream.
|
Globals.Undumper |
undumper
The installed undumper.
|
array, hash, hashEntries, m_metatable, mConstADD, BAND, BNOT, BOR, BXOR, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, IDIV, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SHL, SHR, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, uservalue, ZERO| 构造器和说明 |
|---|
Globals() |
| 限定符和类型 | 方法和说明 |
|---|---|
Globals |
checkglobals()
Check that this object is a Globals object, and return it, otherwise throw an error.
|
Prototype |
compilePrototype(InputStream stream,
String chunkname)
Compile lua source from an InputStream into a Prototype.
|
Prototype |
compilePrototype(Reader reader,
String chunkname)
Compile lua source from a Reader into a Prototype.
|
LuaValue |
load(byte[] script,
String chunkname) |
LuaValue |
load(InputStream is,
String chunkname,
String mode,
LuaValue environment)
Load the content form an input stream as a binary chunk or text file.
|
LuaValue |
load(Reader reader,
String chunkname)
Load the content form a reader as a text file.
|
LuaValue |
load(Reader reader,
String chunkname,
LuaTable environment)
Load the content form a reader as a text file, supplying a custom environment.
|
LuaValue |
load(String script)
Convenience function to load a string value as a script.
|
LuaValue |
load(String script,
String chunkname)
Convenience function to load a string value as a script.
|
LuaValue |
load(String script,
String chunkname,
LuaTable environment)
Convenience function to load a string value as a script with a custom environment.
|
LuaValue |
loadfile(String filename)
Convenience function for loading a file that is either binary lua or lua source.
|
LuaValue |
loadfile(String filename,
LuaValue env) |
Prototype |
loadPrototype(InputStream is,
String chunkname,
String mode)
Load lua source or lua binary from an input stream into a Prototype.
|
Varargs |
yield(Varargs args)
Function which yields the current thread.
|
_const, arrayget, checktable, clear, clone, concat, defaultEntry, entry, eq_b, eq, find, get, get, getArrayLength, getHashLength, getmetatable, hashget, hashmod, hashpow2, hashset, hashSlot, inext, insert, isLargeKey, istable, keyCount, keys, len, length, next, opttable, presize, presize, rawget, rawget, rawlen, rawset, rawset, remove, set, set, setmetatable, size, sort, toLuaValue, type, typename, unpack, unpack, unpack, useWeakKeys, useWeakValues, wrapadd, add, add, and, arg, arg1, argerror, argerror, aritherror, aritherror, arithmt, arithmtwith, assert_, band, band, bnot, bor, bor, buffer, bxor, bxor, call, call, call, call, call, callmt, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checkmetatag, checknotnil, checknumber, checknumber, checkstring, checkthread, checkuserdata, checkuserdata, compareerror, compareerror, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, div, div, div, divInto, eqmtcall, equals, error, get, getfenv, gettable, getuservalue, gt_b, gt_b, gt_b, gt, gt, gt, gteq_b, gteq_b, gteq_b, gteq, gteq, gteq, idiv, idiv, illegal, initupvalue1, invoke, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isfunction, isint, isinttype, islong, isnil, isnumber, isstring, isthread, isuserdata, isuserdata, isvalidkey, jcall, jget, jset, lenerror, listOf, listOf, load, lt_b, lt_b, lt_b, lt, lt, lt, lteq_b, lteq_b, lteq_b, lteq, lteq, lteq, metatableOf, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq_b, neq, not, onInvoke, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, optthread, optuserdata, optuserdata, optvalue, or, pow, pow, pow, powWith, powWith, raweq, raweq, raweq, raweq, raweq, rawget, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, setfenv, settable, setuservalue, shl, shl, shr, shr, strcmp, strcmp, strongvalue, strvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, tonumber, toshort, tostring, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOfargcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, typepublic InputStream STDIN
public PrintStream STDOUT
public PrintStream STDERR
public ResourceFinder finder
public LuaThread running
public BaseLib baselib
public PackageLib package_
public DebugLib debuglib
public Globals.Loader loader
Globals.Loaderpublic Globals.Compiler compiler
Compilerpublic Globals.Undumper undumper
Globals.Undumperpublic Globals checkglobals()
checkglobals 在类中 LuaValuethis if if an instance fof Globalspublic LuaValue loadfile(String filename)
filename - Name of the file to load.LuaError - if the file could not be loaded.public LuaValue load(String script, String chunkname)
script - Contents of a lua script, such as "print 'hello, world.'"chunkname - Name that will be used within the chunk as the source.LuaError - if the script could not be compiled.public LuaValue load(String script)
script - Contents of a lua script, such as "print 'hello, world.'"LuaError - if the script could not be compiled.public LuaValue load(String script, String chunkname, LuaTable environment)
script - Contents of a lua script, such as "print 'hello, world.'"chunkname - Name that will be used within the chunk as the source.environment - LuaTable to be used as the environment for the loaded function.LuaError - if the script could not be compiled.public LuaValue load(Reader reader, String chunkname)
reader - Reader containing text of a lua script, such as "print 'hello, world.'"chunkname - Name that will be used within the chunk as the source.LuaError - if the script could not be compiled.public LuaValue load(Reader reader, String chunkname, LuaTable environment)
reader - Reader containing text of a lua script, such as "print 'hello, world.'"chunkname - Name that will be used within the chunk as the source.environment - LuaTable to be used as the environment for the loaded function.LuaError - if the script could not be compiled.public LuaValue load(InputStream is, String chunkname, String mode, LuaValue environment)
is - InputStream containing a lua script or compiled lua"chunkname - Name that will be used within the chunk as the source.mode - String containing 'b' or 't' or both to control loading as binary or text or either.environment - LuaTable to be used as the environment for the loaded function.public Prototype loadPrototype(InputStream is, String chunkname, String mode) throws IOException
is - Input stream containing a lua script or compiled lua"chunkname - Name that will be used within the chunk as the source.mode - String containing 'b' or 't' or both to control loading as binary or text or either.IOExceptionpublic Prototype compilePrototype(Reader reader, String chunkname) throws IOException
IOExceptionpublic Prototype compilePrototype(InputStream stream, String chunkname) throws IOException
IOExceptionCopyright © 2020. All rights reserved.