World model is now operational

This commit is contained in:
2021-01-16 01:24:33 -05:00
parent d7d633bd96
commit 313e78067a
11 changed files with 313 additions and 188 deletions

View File

@@ -14,7 +14,7 @@
#include <string>
#include "luastack.hpp"
#include "util.hpp"
#include "source.hpp"
#include "world.hpp"
#include "traceback.hpp"
@@ -174,43 +174,10 @@ static void dotty(lua_State *L)
fflush(stdout);
}
static int pmain(lua_State *L)
{
globalL = L;
LUAJIT_VERSION_SYM(); /* Linker-enforced version check. */
LuaStack::register_all_userdata(L);
// Initialize the builtins, then copy a snapshot of the
// builtins to the registry. The snapshot will allow us to restore
// the builtins during source_rebuild operations.
source_install_and_snapshot_builtins(L);
// Load the lua source.
source_update(L);
// Rebuild the global environment.
source_rebuild(L);
// Run unit tests.
source_run_unittests(L);
dotty(L);
return 0;
}
int main(int argc, char **argv)
{
int status;
lua_State *L = lua_open();
if (L == NULL)
{
l_message("cannot create state: not enough memory");
return -1;
}
status = lua_cpcall(L, pmain, NULL);
report(L, status);
lua_close(L);
return status ? -1 : 0;
LUAJIT_VERSION_SYM(); // Linker-enforced version check.
World w;
dotty(w.get_lua_state());
return 0;
}