summaryrefslogtreecommitdiff
path: root/lstate.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-11-19 15:31:19 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-11-19 15:31:19 -0200
commitb79ffdc4cef96ababe0cc068a6c11afdc71782eb (patch)
tree3900162dc96b809924852bcb5105109bc77eac6c /lstate.c
parent592a3f289b428e3ee5cc595a266607ad7f5d94ff (diff)
downloadlua-github-b79ffdc4cef96ababe0cc068a6c11afdc71782eb.tar.gz
global state for Lua interpreter
Diffstat (limited to 'lstate.c')
-rw-r--r--lstate.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/lstate.c b/lstate.c
new file mode 100644
index 00000000..653c4ba3
--- /dev/null
+++ b/lstate.c
@@ -0,0 +1,52 @@
+/*
+** $Id: $
+** Global State
+** See Copyright Notice in lua.h
+*/
+
+
+#include "lbuiltin.h"
+#include "ldo.h"
+#include "llex.h"
+#include "lmem.h"
+#include "lstate.h"
+#include "lstring.h"
+#include "ltable.h"
+#include "ltm.h"
+
+
+LState *lua_state = NULL;
+
+
+void lua_open (void)
+{
+ if (lua_state) return;
+ lua_state = luaM_new(LState);
+ L->numCblocks = 0;
+ L->Cstack.base = 0;
+ L->Cstack.lua2C = 0;
+ L->Cstack.num = 0;
+ L->errorJmp = NULL;
+ L->rootproto.next = NULL;
+ L->rootproto.marked = 0;
+ L->rootcl.next = NULL;
+ L->rootcl.marked = 0;
+ L->rootglobal.next = NULL;
+ L->rootglobal.marked = 0;
+ L->roottable.next = NULL;
+ L->roottable.marked = 0;
+ L->refArray = NULL;
+ L->refSize = 0;
+ L->Mbuffsize = 0;
+ L->Mbuffer = NULL;
+ L->GCthreshold = GARBAGE_BLOCK;
+ L->nblocks = 0;
+ luaD_init();
+ luaS_init();
+ luaX_init();
+ luaT_init();
+ L->globalbag.ttype = LUA_T_ARRAY;
+ L->globalbag.value.a = luaH_new(0);
+ luaB_predefine();
+}
+