2007-06-08 05:11:37 +00:00
|
|
|
package lua;
|
|
|
|
|
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
|
|
|
|
|
import lua.value.LTable;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
** `global state', shared by all threads of this state
|
|
|
|
|
*/
|
|
|
|
|
public class GlobalState {
|
|
|
|
|
|
|
|
|
|
// typedef struct global_State {
|
|
|
|
|
Hashtable strt; /* hash table for strings */
|
|
|
|
|
StringBuffer buff; /* temporary buffer for string concatentation */
|
|
|
|
|
// lu_mem totalbytes; /* number of bytes currently allocated */
|
|
|
|
|
// lu_mem estimate; /* an estimate of number of bytes actually in use */
|
|
|
|
|
// lua_CFunction panic; /* to be called in unprotected errors */
|
|
|
|
|
// TValue l_registry;
|
|
|
|
|
// struct lua_State *mainthread;
|
|
|
|
|
StackState mainthread;
|
|
|
|
|
// UpVal uvhead; /* head of double-linked list of all open upvalues */
|
|
|
|
|
// struct Table *mt[NUM_TAGS]; /* metatables for basic types */
|
|
|
|
|
// TString *tmname[TM_N]; /* array with tag-method names */
|
|
|
|
|
// } global_State;
|
|
|
|
|
//
|
2007-06-24 15:04:19 +00:00
|
|
|
private static LTable _G;
|
|
|
|
|
|
|
|
|
|
static {
|
2007-07-21 04:44:22 +00:00
|
|
|
resetGlobals();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void resetGlobals() {
|
2007-06-24 15:04:19 +00:00
|
|
|
_G = new LTable();
|
2007-06-27 06:43:33 +00:00
|
|
|
_G .put( "_G", _G );
|
2007-06-24 15:04:19 +00:00
|
|
|
Builtin.addBuiltins( _G );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static LTable getGlobalsTable() {
|
|
|
|
|
return _G;
|
2007-06-08 05:11:37 +00:00
|
|
|
}
|
|
|
|
|
}
|